aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/new-request.js14
-rw-r--r--app/assets/javascripts/select-authorities.js67
-rw-r--r--app/assets/stylesheets/main.scss47
3 files changed, 127 insertions, 1 deletions
diff --git a/app/assets/javascripts/new-request.js b/app/assets/javascripts/new-request.js
new file mode 100644
index 000000000..f8f2a0665
--- /dev/null
+++ b/app/assets/javascripts/new-request.js
@@ -0,0 +1,14 @@
+$(document).ready(function() {
+ $('.batch_public_body_list').hide();
+ var showtext = $('.batch_public_body_toggle').attr('data-showtext');
+ var hidetext = $('.batch_public_body_toggle').attr('data-hidetext');
+ $('.toggle-message').text(showtext);
+ $('.batch_public_body_toggle').click(function(){
+ $('.batch_public_body_list').toggle();
+ if ($('.toggle-message').text() == showtext){
+ $('.toggle-message').text(hidetext);
+ }else{
+ $('.toggle-message').text(showtext);
+ }
+ })
+})
diff --git a/app/assets/javascripts/select-authorities.js b/app/assets/javascripts/select-authorities.js
new file mode 100644
index 000000000..843f5c0ad
--- /dev/null
+++ b/app/assets/javascripts/select-authorities.js
@@ -0,0 +1,67 @@
+$(document).ready(function() {
+
+ function add_option(selector, value, text) {
+ var optionExists = ($(selector + ' option[value=' + value + ']').length > 0);
+ if(!optionExists){
+ $(selector).append("<option value=" + value + ">" + text + "</option>");
+ }
+ }
+ // Transfer a set of select options defined by 'from_selector' to another select,
+ // defined by 'to_selector'
+ function transfer_options(from_selector, to_selector){
+ $(from_selector).each(function()
+ {
+ add_option(to_selector, $(this).val(), $(this).text());
+ $(this).remove();
+ })
+ $('#public_body_query').val('');
+ return false;
+ }
+
+ // Submit the search form once the text reaches a certain length
+ $("#public_body_query").keypress($.debounce( 300, function() {
+ if ($('#public_body_query').val().length >= 3) {
+ $('#body_search_form').submit();
+ }
+ }));
+
+ // Populate the candidate list with json search results
+ $('#body_search_form').on('ajax:success', function(event, data, status, xhr) {
+ $('#select_body_candidates').empty();
+ $.each(data, function(key, value)
+ {
+ add_option('#select_body_candidates', value['id'], value['name']);
+ });
+ });
+
+ // Add a hidden element to the submit form for every option in the selected list
+ $('#body_submit_button').click(function(){
+ $('#select_body_selections option').each(function()
+ {
+ $('#body_submit_form').append('<input type="hidden" value="' + $(this).val() + '" name="public_body_ids[]">' );
+ })
+ })
+
+ // Transfer selected candidates to selected list
+ $('#body_select_button').click(function(){
+ return transfer_options('#select_body_candidates option:selected', '#select_body_selections');
+ })
+
+ // Transfer selected selected options back to candidate list
+ $('#body_deselect_button').click(function(){
+ return transfer_options('#select_body_selections option:selected', '#select_body_candidates');
+ })
+
+ // Transfer all candidates to selected list
+ $('#body_select_all_button').click(function(){
+ return transfer_options('#select_body_candidates option', '#select_body_selections');
+ })
+
+ // Transfer all selected back to candidate list
+ $('#body_deselect_all_button').click(function(){
+ return transfer_options('#select_body_selections option', '#select_body_candidates');
+ })
+
+ // Show the buttons for selecting and deselecting all
+ $('.select_all_button').show();
+})
diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss
index 6405d1dc3..3118eab3d 100644
--- a/app/assets/stylesheets/main.scss
+++ b/app/assets/stylesheets/main.scss
@@ -1722,7 +1722,7 @@ padding-right:50px;
margin-bottom:10px;
}
-div.ff-icon-printfix,.comment_in_request_text img.comment_quote,body.front #other-country-notice,#other-country-notice,#authority_preview .public-body-name-prefix,#authority_preview #list-filter,#authority_preview h2.foi_results,div#show_response_view p.event_actions {
+div.ff-icon-printfix,.comment_in_request_text img.comment_quote,body.front #other-country-notice,#other-country-notice,#authority_preview .public-body-name-prefix,#authority_preview #list-filter,#authority_preview h2.foi_results,div#show_response_view p.event_actions, div.batch_public_body_toggle {
display:none;
}
@@ -1777,3 +1777,48 @@ text-decoration:none;
the axes black rather than transparent grey for the moment: */
color: #000 !important;
}
+
+
+#body_selection .body_list {
+ width: 45%;
+}
+
+#body_selection .body_list input[type='submit'] {
+ margin: 10px 0;
+ width: 45%;
+}
+
+#body_selection .body_list #body_select_all_button,
+#body_selection .body_list #body_deselect_button{
+ float: right;
+}
+
+#body_selection #body_candidates {
+ float: left;
+}
+
+#body_selection #body_selections {
+ float: right;
+}
+
+#body_selection #body_submission input[type='submit'] {
+ margin: 10px 0;
+ width:100%;
+}
+
+#body_selection .select_all_button {
+ display: none;
+}
+
+#body_selection .body_select {
+ width: 100%;
+}
+
+.batch_public_body_list {
+ margin-left: 110px;
+}
+
+.batch_public_body_toggle {
+ color: #0000EE;
+ font-size: 0.9em;
+}