openaustralia/planningalerts

View on GitHub
app/views/atdis/test.html.haml

Summary

Maintainability
Test Coverage
- content_for :page_title, "Application Tracking Data Interchange Specification (ATDIS)"

%h2= yield :page_title

- if @page.nil?
  %p
    The
    = link_to "Application Tracking Data Interchange Specification", atdis_specification_path
    (ATDIS) is a modern, straightforward specification for publishing development
    applications online in a consistent machine readable format. It has been developed by the
    #{link_to "NSW Department of Planning & Environment", "https://www.planning.nsw.gov.au/"},
    = link_to "Carpadium Pty Ltd", "http://www.carpadium.com/"
    and the
    #{link_to "OpenAustralia Foundation", "https://www.oaf.org.au"}.
  %p
    This page allows software vendors and planning authorities to automatically check that their ATDIS feed is compliant with the specification. It currently validates against version 1.0.2 of the specification.
%p
  = link_to "Read the ATDIS Specification", atdis_specification_path

%h3 Example feeds to test

%ul
  %li
    = link_to "Example with 2 pages", atdis_test_path(url: atdis_feed_url(number: 1))
    (<strong>#{link_to "view source", atdis_feed_url(number: 1)}</strong>)
  %li
    = link_to "Example with errors", atdis_test_path(url: atdis_feed_url(number: 2))
    (<strong>#{link_to "view source", atdis_feed_url(number: 2)}</strong>)
  %li
    = link_to "Example with optional extended block", atdis_test_path(url: atdis_feed_url(number: 3))
    (<strong>#{link_to "view source", atdis_feed_url(number: 3)}</strong>)
  %li
    = link_to "Example with invalid json", atdis_test_path(url: atdis_feed_url(number: 4))
    (<strong>#{link_to "view source", atdis_feed_url(number: 4)}</strong>)
  %li
    = link_to "Example with a single application", atdis_test_path(url: atdis_feed_url(number: 5))
    (<strong>#{link_to "view source", atdis_feed_url(number: 5)}</strong>)

%p (Note that the filters won't do anything with the example feeds)

- if @error
  %p.error= @error

= semantic_form_for @feed, url: atdis_test_path do |f|
  = f.inputs do
    = f.input :base_url, label: "ATDIS Base URL", placeholder: "https://www.council.nsw.gov.au/atdis/1.0"
  = f.inputs do
    = f.input :page, label: "Page Number", as: :number, min: 1
  %div{ "x-data": "{show: #{@feed.filters_set?}}" }
    %h2= link_to "Filters", "#", "@click.prevent": "show = !show"
    %div{ "x-show": "show", "x-cloak": true }
      = render "date_range_fields", f:, description: "Lodgement Date", start_name: :lodgement_date_start, end_name: :lodgement_date_end
      = render "date_range_fields", f:, description: "Last Modified Date", start_name: :last_modified_date_start, end_name: :last_modified_date_end
      = f.input :street, placeholder: "Military,Cardinal", required: false, hint: "Restrict results to those applications in the given streets"
      = f.input :suburb, placeholder: "Mosman,Manly", required: false, hint: "Restrict results to those applications in the given suburbs"
      = f.input :postcode, placeholder: "2000,2780", required: false, hint: "Restrict results to those applications in the given postcodes"
  = f.actions do
    = f.action :submit, label: "Test", button_html: { class: "button button-rounded" }

- if @page
  %h3 Test Results
  %p
    URL for this page:
    = link_to @page.url, @page.url

  - if @page.valid?
    %p
      %strong Success!
      We've not found any errors on this page. It's worth looking through the information below to see how the data is actually loaded to double check that everything is as expected.
    %p
      Also, to check that the whole feed is working you need to check that the other pages are working. Use the buttons below to test other pages.
    %p
      - if @page.previous_url
        = link_to "Test previous page", { url: @page.previous_url }, class: "button button-rounded"
      - else
        %span.button.button-rounded.disabled Test previous page
      - if @page.next_url
        = link_to "Test next page", { url: @page.next_url }, class: "button button-rounded"
      - else
        %span.button.button-rounded.disabled Test next page

    %h3 How the applications get loaded
    %p
      Note that this is showing all parameters, irrespective of whether they are optional or mandatory and used or not.
    = attribute_value(@page.response)
  - else
    %p
      %strong Errors found.
      = link_to "This page", @page.url
      does not validate. See the errors below.
    %h3 Errors
    = render partial: "attribute_error_table", locals: { model: @page }

= javascript_include_tag "flatpickr"