aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/general/frontpage.rhtml
blob: 07997a12fd4eab212ac85c3cba111ebfaec8dd84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<div id="make_requests">
    <h1>Make requests in public for UK government information</h1>

    <% if @public_bodies.size == 0 and @query_made %>
        <div id="error">
            Sorry! We couldn't find any public authorities with that in their names.
            Either <a href="/body/list/department">browse them all</a> or
            <a href="/help/about#missing_body">help us add it</a>.
        </div>
    <% end %>

    <% form_tag({:action => :frontpage}, :method => 'get', :id => 'public_body_form', :class => 'plaque' ) do %>
        <p>
            <label for="public_body_query">Find the public authority you would like information from:</label>
        </p>

        <!-- Autocomplete field, which submits form when user picks entry -->
        <div>
            <%= text_field_with_auto_complete 'public_body', 'query', {}, { :skip_style => true, :frequency => 0.1, 
                :after_update_element => 
                  "function(element,value) {
                      parent.window.location = '/?public_body[query]=' + element.value 
                  }"
                } %>
        </div>
        <div class="public_body_search_note">
            Type to search e.g. Health, Business, Scotland
        </div>

        <!-- Show search button if javascript isn't there -->
        <p id="public_body_query_button">
            <%= submit_tag "Search" %>
        </p>
        <script type="text/javascript">
            Element.toggle('public_body_query_button')
        </script>

        <% if @public_bodies.size > 0 %>
            <div id="public_body_search">
                <ul>
                    <strong>Public authorities found</strong>
                <% for public_body in @public_bodies %>
                    <li>
                        <%= link_to h(public_body.name), new_request_to_body_url(:public_body_id => public_body.id.to_s) %>
                    </li>
                <% end %>
                </ul>
            </div>
        <% end %>

        <p>
            Can't find it? <a href="/body/list/department">Browse all</a> or <a href="/help/about#missing_body">ask us to add it</a>.
        </p>
    <% end %>
</div>

<div id="find_information">
    <h1>Explore government information that others received</h1>
    <% if @xapian_object.results.empty? %>
        <p>None yet.</p>
    <% else %>
        <% for result in @xapian_object.results %>
            <% if result[:model].class.to_s == 'InfoRequestEvent' %>
                <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
            <% else %>
                <p><strong>Unexpected search result type <%=result[:model].class.to_s%></strong></p>
            <% end %>
        <% end %>
    <% end %>

    <p><%=link_to "More recent successful responses", request_list_url(:view => 'successful') %></p>
    <% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
       <p>
           <%= text_field_tag 'query', params[:query], { :size => 20 } %>
           <%= submit_tag "Search" %>
       </p>
    <% end %>
</div>