From 507920738585e8c8e88aeb47fdf782074c481d65 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 21 Aug 2023 15:11:12 +0100 Subject: [PATCH] Add admin toolbox section to public body list It's still too easy to use the mass tag manipulation form as a search box. We do now have a confirmation alert, but it's still annoying. This commit adds a "toolbox" section so that infrequently used tools can be hidden away until needed. I did look at using the Bootstrap collapse [1] element, but it wasn't quite right as I only wanted one heading that collapses the whole section. The Bootstrap component added lots of extra markup, so went with a simple `` tag for an initial implementation. We can tweak it further if other tools get added. [1] https://getbootstrap.com/2.2.0/javascript.html#collapse --- app/assets/stylesheets/admin.scss | 11 +++++ .../admin_public_body/_one_list.html.erb | 42 +++++++++++-------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index 71379d7ca0..5ce1bb4c09 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -282,6 +282,17 @@ body.admin { padding: 2em; } +/* Toolbox */ +.toolbox { + summary { + margin-bottom: 1em; + } + + .toolbox-tool { + margin-bottom: 1em; + } +} + /* Bootstrap Extensions */ /* These must come last because we @import bootstrap in .admin */ diff --git a/app/views/admin_public_body/_one_list.html.erb b/app/views/admin_public_body/_one_list.html.erb index 0ea13195ae..dfd2057d26 100644 --- a/app/views/admin_public_body/_one_list.html.erb +++ b/app/views/admin_public_body/_one_list.html.erb @@ -4,24 +4,30 @@
-
- <%= form_tag(mass_tag_admin_bodies_path, method: "post", class: "form form-inline" ) do %> - <%= text_field_tag 'tag', params[:tag], { size: 15, id: "mass_tag_tag_" + table_name } %> - <%= hidden_field_tag(:query, params[:query], { id: "mass_tag_query_" + table_name } ) %> - <%= hidden_field_tag(:page, params[:page], { id: "mass_page_" + table_name } ) %> - <%= hidden_field_tag(:table_name, table_name, { id: "mass_tag_table_name_" + table_name } ) %> - <%= submit_tag 'Add tag to all', class: 'btn btn-warning', data: { confirm: 'Are you sure you want to add the new tag to these authorities?' } %> - <% end %> +
+
+ 🧰 Extra tools… - <% if table_name == 'exact' %> - <%= form_tag(mass_tag_admin_bodies_path, method: "delete", class: "form form-inline" ) do %> - <%= hidden_field_tag 'tag', params[:query], { id: "mass_tag_tag_" + table_name } %> - <%= hidden_field_tag(:query, params[:query], { id: "mass_tag_query_" + table_name } ) %> - <%= hidden_field_tag(:page, params[:page], { id: "mass_page_" + table_name } ) %> - <%= hidden_field_tag(:table_name, table_name, { id: "mass_tag_table_name_" + table_name } ) %> - <%= submit_tag "Remove '#{params[:query].html_safe}' tag from all", class: 'btn btn-warning', data: { confirm: 'Are you sure you want to remove the tag from these authorities?' } %> - <% end %> - <% end %> +
+ <%= form_tag(mass_tag_admin_bodies_path, method: "post", class: "form form-inline" ) do %> + <%= text_field_tag 'tag', params[:tag], { size: 15, id: "mass_tag_tag_" + table_name } %> + <%= hidden_field_tag(:query, params[:query], { id: "mass_tag_query_" + table_name } ) %> + <%= hidden_field_tag(:page, params[:page], { id: "mass_page_" + table_name } ) %> + <%= hidden_field_tag(:table_name, table_name, { id: "mass_tag_table_name_" + table_name } ) %> + <%= submit_tag 'Add tag to all', class: 'btn btn-warning', data: { confirm: 'Are you sure you want to add the new tag to these authorities?' } %> + <% end %> - (in table just above) + <% if table_name == 'exact' %> + <%= form_tag(mass_tag_admin_bodies_path, method: "delete", class: "form form-inline" ) do %> + <%= hidden_field_tag 'tag', params[:query], { id: "mass_tag_tag_" + table_name } %> + <%= hidden_field_tag(:query, params[:query], { id: "mass_tag_query_" + table_name } ) %> + <%= hidden_field_tag(:page, params[:page], { id: "mass_page_" + table_name } ) %> + <%= hidden_field_tag(:table_name, table_name, { id: "mass_tag_table_name_" + table_name } ) %> + <%= submit_tag "Remove '#{params[:query].html_safe}' tag from all", class: 'btn btn-warning', data: { confirm: 'Are you sure you want to remove the tag from these authorities?' } %> + <% end %> + <% end %> + + (in table just above) +
+