From 39db271419e09e17c8706ea24d845fd83f14845b Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Wed, 10 Nov 2021 09:03:29 -0800 Subject: [PATCH] Extract a Spotlight::TabPanelComponent for building bootstrap tab panels --- .../spotlight/tab_component.html.erb | 3 + app/components/spotlight/tab_component.rb | 20 ++ .../spotlight/tab_panel_component.html.erb | 19 ++ .../spotlight/tab_panel_component.rb | 9 + app/views/spotlight/appearances/edit.html.erb | 79 ++---- .../spotlight/bulk_updates/edit.html.erb | 36 +-- app/views/spotlight/exhibits/_delete.html.erb | 14 +- app/views/spotlight/exhibits/_export.html.erb | 10 +- app/views/spotlight/exhibits/_import.html.erb | 26 +- .../spotlight/exhibits/_languages.html.erb | 100 ++++--- .../exhibits/_public_exhibits.html.erb | 11 + app/views/spotlight/exhibits/edit.html.erb | 68 +++-- app/views/spotlight/exhibits/index.html.erb | 59 ++-- app/views/spotlight/filters/_form.html.erb | 22 +- app/views/spotlight/pages/_form.html.erb | 53 ++-- .../_external_resources_form.html.erb | 29 +- app/views/spotlight/resources/new.html.erb | 31 +-- .../search_configurations/edit.html.erb | 46 ++-- app/views/spotlight/searches/_form.html.erb | 108 ++++---- app/views/spotlight/searches/index.html.erb | 104 ++++---- app/views/spotlight/sites/edit.html.erb | 30 +-- .../translations/_browse_categories.html.erb | 160 ++++++----- .../spotlight/translations/_general.html.erb | 252 +++++++++--------- .../spotlight/translations/_groups.html.erb | 56 ++-- .../spotlight/translations/_metadata.html.erb | 118 ++++---- .../spotlight/translations/_pages.html.erb | 56 ++-- .../translations/_search_fields.html.erb | 176 ++++++------ .../spotlight/translations/edit.html.erb | 50 +--- blacklight-spotlight.gemspec | 1 + lib/spotlight/engine.rb | 1 + .../exhibits/translation_editing_spec.rb | 7 +- 31 files changed, 803 insertions(+), 951 deletions(-) create mode 100644 app/components/spotlight/tab_component.html.erb create mode 100644 app/components/spotlight/tab_component.rb create mode 100644 app/components/spotlight/tab_panel_component.html.erb create mode 100644 app/components/spotlight/tab_panel_component.rb create mode 100644 app/views/spotlight/exhibits/_public_exhibits.html.erb diff --git a/app/components/spotlight/tab_component.html.erb b/app/components/spotlight/tab_component.html.erb new file mode 100644 index 0000000000..2d441fd953 --- /dev/null +++ b/app/components/spotlight/tab_component.html.erb @@ -0,0 +1,3 @@ +<%= tag.div role: 'tabpanel', class: @classes.join(' '), id: @id, data: @data do %> + <%= content %> +<% end %> diff --git a/app/components/spotlight/tab_component.rb b/app/components/spotlight/tab_component.rb new file mode 100644 index 0000000000..7fc36a4852 --- /dev/null +++ b/app/components/spotlight/tab_component.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# Component for a single tab panel pane +class Spotlight::TabComponent < ViewComponent::Base + def initialize(id:, label:, active: false, label_data: {}) + super + + @id = id + @label = label + @active = active + @classes = ['tab-pane', ('active' if active)].compact + @label_data = label_data + end + + def render_label + tag.li role: 'presentation', class: 'nav-item' do + link_to @label, "##{@id}", aria: { controls: @id }, role: 'tab', data: { toggle: 'tab' }.merge(@label_data), class: ['nav-link', ('active' if @active)].compact.join(' ') + end + end +end diff --git a/app/components/spotlight/tab_panel_component.html.erb b/app/components/spotlight/tab_panel_component.html.erb new file mode 100644 index 0000000000..edc8f6813d --- /dev/null +++ b/app/components/spotlight/tab_panel_component.html.erb @@ -0,0 +1,19 @@ +<% tabs_content = capture do %> + +<% end %> + +<%= tabs_content if @tab_position == :outside %> + +
+ <%= tabs_content if @tab_position == :inside %> + +
+ <% tabs.each do |tab| %> + <%= tab %> + <% end %> +
+
diff --git a/app/components/spotlight/tab_panel_component.rb b/app/components/spotlight/tab_panel_component.rb new file mode 100644 index 0000000000..6c3147b767 --- /dev/null +++ b/app/components/spotlight/tab_panel_component.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Spotlight::TabPanelComponent < ViewComponent::Base + renders_many :tabs, Spotlight::TabComponent + + def initialize(tab_position: :inside) + @tab_position = tab_position + end +end diff --git a/app/views/spotlight/appearances/edit.html.erb b/app/views/spotlight/appearances/edit.html.erb index aad9acf33c..dfb53994fb 100644 --- a/app/views/spotlight/appearances/edit.html.erb +++ b/app/views/spotlight/appearances/edit.html.erb @@ -16,29 +16,9 @@ <% end %> -
- -
- <% if current_exhibit.themes.many? %> -
+ <%= render Spotlight::TabPanelComponent.new do |component| %> + <% if current_exhibit.themes.many? %> + <% component.tab(id: 'site-theme', active: true, label: t(:'.site_theme.heading')) do %>

<%= t(:'.site_theme.help') %>

<%= f.form_group :theme, label: { text: t(:'.site_theme.label') } do %> <% current_exhibit.themes.each do |theme| %> @@ -48,37 +28,36 @@
<% end %> <% end %> -
<% end %> + <% end %> -
-

<%= t(:'.site_masthead.help') %>

- <%= f.fields_for(:masthead, current_exhibit.masthead || current_exhibit.build_masthead) do |m| %> - <%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.masthead_initial_crop_selection, crop_type: :masthead %> - <% end %> -
+ <% component.tab(id: 'site-masthead', active: !current_exhibit.themes.many?, label: t(:'.site_masthead.heading')) do %> +

<%= t(:'.site_masthead.help') %>

+ <%= f.fields_for(:masthead, current_exhibit.masthead || current_exhibit.build_masthead) do |m| %> + <%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.masthead_initial_crop_selection, crop_type: :masthead %> + <% end %>`` + <% end %> -
-

<%= t(:'.site_thumbnail.help') %>

- <%= f.fields_for(:thumbnail, current_exhibit.thumbnail || current_exhibit.build_thumbnail) do |m| %> - <%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.thumbnail_initial_crop_selection, crop_type: :thumbnail %> - <% end %> -
+ <% component.tab(id: 'site-thumbnail', label: t(:'.site_thumbnail.heading')) do %> +

<%= t(:'.site_thumbnail.help') %>

+ <%= f.fields_for(:thumbnail, current_exhibit.thumbnail || current_exhibit.build_thumbnail) do |m| %> + <%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.thumbnail_initial_crop_selection, crop_type: :thumbnail %> + <% end %> + <% end %> - -
- + <% component.tab(id: 'main-menu', label: t(:'.main_navigation.menu')) do %> + <%= field_set_tag do %> +

<%= t(:'.main_navigation.help') %>

+ + <% end %> + <% end %> + <% end %>
diff --git a/app/views/spotlight/bulk_updates/edit.html.erb b/app/views/spotlight/bulk_updates/edit.html.erb index 25d5513383..2552b45ef5 100644 --- a/app/views/spotlight/bulk_updates/edit.html.erb +++ b/app/views/spotlight/bulk_updates/edit.html.erb @@ -8,30 +8,16 @@ <%= render 'progress_panel' %>
-
- +<%= render Spotlight::TabPanelComponent.new do |component| %> + <% component.tab(id: 'overview', label: t(:'.overview.heading'), active: true) do %> + <%= render 'overview' %> + <% end %> -
-
- <%= render 'overview' %> -
+ <% component.tab(id: 'download', label: t(:'.download.heading')) do %> + <%= render 'download' %> + <% end %> -
- <%= render 'download' %> -
- -
- <%= render 'upload' %> -
-
-
+ <% component.tab(id: 'upload', label: t(:'.upload.heading')) do %> + <%= render 'upload' %> + <% end %> +<% end %> diff --git a/app/views/spotlight/exhibits/_delete.html.erb b/app/views/spotlight/exhibits/_delete.html.erb index c2702fc332..bd874ee0d0 100644 --- a/app/views/spotlight/exhibits/_delete.html.erb +++ b/app/views/spotlight/exhibits/_delete.html.erb @@ -1,11 +1,9 @@ -
-
-

<%= t(:".heading") %>

-
-

<%= t(:".warning_html", export_link: link_to(t(:'spotlight.exhibits.export.download'), spotlight.edit_exhibit_path(current_exhibit, anchor: 'export'))) %>

-
- <%= delete_link current_exhibit, class: 'btn btn-secondary' %> -
+
+

<%= t(:".heading") %>

+
+

<%= t(:".warning_html", export_link: link_to(t(:'spotlight.exhibits.export.download'), spotlight.edit_exhibit_path(current_exhibit, anchor: 'export'))) %>

+
+ <%= delete_link current_exhibit, class: 'btn btn-secondary' %>
diff --git a/app/views/spotlight/exhibits/_export.html.erb b/app/views/spotlight/exhibits/_export.html.erb index 8ed1097bad..32e43b78f1 100644 --- a/app/views/spotlight/exhibits/_export.html.erb +++ b/app/views/spotlight/exhibits/_export.html.erb @@ -1,8 +1,6 @@ -
-
-

<%= t :'.instructions' %>

-
- <%= link_to t(:'.download'), get_exhibit_path(current_exhibit, format: 'json'), class: 'btn btn-primary' %> -
+
+

<%= t :'.instructions' %>

+
+ <%= link_to t(:'.download'), get_exhibit_path(current_exhibit, format: 'json'), class: 'btn btn-primary' %>
diff --git a/app/views/spotlight/exhibits/_import.html.erb b/app/views/spotlight/exhibits/_import.html.erb index c1771e0493..1263f50564 100644 --- a/app/views/spotlight/exhibits/_import.html.erb +++ b/app/views/spotlight/exhibits/_import.html.erb @@ -1,16 +1,14 @@ -
- <%= bootstrap_form_for [:import, current_exhibit], html: { class: 'clearfix', multipart: true } do |f| %> -
-

<%= t :'.instructions' %>

-
- <%= file_field_tag :file, class: 'form-control' %> - <%= hidden_field_tag :tab, 'import' %> -
-
-
- <%= f.submit t(:'.button'), class: 'btn btn-primary' %> -
+<%= bootstrap_form_for [:import, current_exhibit], html: { class: 'clearfix', multipart: true } do |f| %> +
+

<%= t :'.instructions' %>

+
+ <%= file_field_tag :file, class: 'form-control' %> + <%= hidden_field_tag :tab, 'import' %> +
+
+
+ <%= f.submit t(:'.button'), class: 'btn btn-primary' %>
- <% end %> -
+
+<% end %> diff --git a/app/views/spotlight/exhibits/_languages.html.erb b/app/views/spotlight/exhibits/_languages.html.erb index 6bc8b0e9bf..62c592d445 100644 --- a/app/views/spotlight/exhibits/_languages.html.erb +++ b/app/views/spotlight/exhibits/_languages.html.erb @@ -1,59 +1,57 @@ -
-

<%= t :'spotlight.exhibits.languages.selection_instructions' %>

+

<%= t :'spotlight.exhibits.languages.selection_instructions' %>

- <%= bootstrap_form_for [current_exhibit, Spotlight::Language.new], layout: :horizontal, html: { class: 'row' }, label_col: "col-sm-3", control_col: "col-sm-9" do |f| %> -
- <%= f.select('locale', add_exhibit_language_dropdown_options, prompt: t('.selection_prompt')) %> - <%= hidden_field_tag :tab, 'language' %> -
-
- <%= f.submit nil, class: 'btn btn-primary' %> -
- <% end %> +<%= bootstrap_form_for [current_exhibit, Spotlight::Language.new], layout: :horizontal, html: { class: 'row' }, label_col: "col-sm-3", control_col: "col-sm-9" do |f| %> +
+ <%= f.select('locale', add_exhibit_language_dropdown_options, prompt: t('.selection_prompt')) %> + <%= hidden_field_tag :tab, 'language' %> +
+
+ <%= f.submit nil, class: 'btn btn-primary' %> +
+<% end %> -

<%= t :'spotlight.exhibits.languages.current_header' %>

+

<%= t :'spotlight.exhibits.languages.current_header' %>

- <% if current_exhibit.languages.any? && current_exhibit.languages.last.persisted? %> -

<%= t :'spotlight.exhibits.languages.current_instructions' %>

+<% if current_exhibit.languages.any? && current_exhibit.languages.last.persisted? %> +

<%= t :'spotlight.exhibits.languages.current_instructions' %>

- <%= bootstrap_form_for current_exhibit, layout: :horizontal do |f| %> -
-
- - - - - - - - - - <% current_exhibit.languages.each do |language| %> - <%= f.fields_for :languages, language do |languages| %> - - - - - - <% end %> + <%= bootstrap_form_for current_exhibit, layout: :horizontal do |f| %> +
+
+
<%= t('.table_heading.language') %><%= t('.table_heading.public') %><%= t('.table_heading.action') %>
<%= t("locales.#{language.locale}") %> -
- <%= languages.label :public, class: 'sr-only' %> - <%= languages.check_box_without_bootstrap :public %> -
-
<%= link_to t('.remove'), exhibit_language_path(current_exhibit, language), method: :delete, data: { confirm: t('.modal.confirm') }, class: 'btn btn-sm btn-danger' %>
+ + + + + + + + + <% current_exhibit.languages.each do |language| %> + <%= f.fields_for :languages, language do |languages| %> + + + + + <% end %> - -
<%= t('.table_heading.language') %><%= t('.table_heading.public') %><%= t('.table_heading.action') %>
<%= t("locales.#{language.locale}") %> +
+ <%= languages.label :public, class: 'sr-only' %> + <%= languages.check_box_without_bootstrap :public %> +
+
<%= link_to t('.remove'), exhibit_language_path(current_exhibit, language), method: :delete, data: { confirm: t('.modal.confirm') }, class: 'btn btn-sm btn-danger' %>
-
+ <% end %> + +
-
-
- <%= hidden_field_tag :tab, 'language' %> - <%= f.submit nil, class: 'btn btn-primary' %> -
+
+
+
+ <%= hidden_field_tag :tab, 'language' %> + <%= f.submit nil, class: 'btn btn-primary' %>
- <% end %> - <% else %> -

<%= t('.no_languages_help_text') %>

+
<% end %> -
+<% else %> +

<%= t('.no_languages_help_text') %>

+<% end %> diff --git a/app/views/spotlight/exhibits/_public_exhibits.html.erb b/app/views/spotlight/exhibits/_public_exhibits.html.erb new file mode 100644 index 0000000000..7e8ddce80d --- /dev/null +++ b/app/views/spotlight/exhibits/_public_exhibits.html.erb @@ -0,0 +1,11 @@ +<%= render 'tags', tags: @exhibits.published.all_tags %> +<%= render 'exhibits', exhibits: @published_exhibits %> + +<% if @published_exhibits.total_count > @published_exhibits.size %> + +<% end %> diff --git a/app/views/spotlight/exhibits/edit.html.erb b/app/views/spotlight/exhibits/edit.html.erb index 0a7efa15fd..1aa437c41b 100644 --- a/app/views/spotlight/exhibits/edit.html.erb +++ b/app/views/spotlight/exhibits/edit.html.erb @@ -3,45 +3,39 @@ <% end %> <%= configuration_page_title %> -
- -
-
- <%= render 'form' %> -
- <%= render 'languages' if can? :manage, current_exhibit.languages.first_or_initialize %> - <%= render 'spotlight/filters/form' if can? :edit, current_exhibit.filters.first_or_initialize %> - <%= render 'import' if can? :import, current_exhibit %> - <%= render 'export' if can? :export, current_exhibit %> - <%= render 'delete' if can? :destroy, current_exhibit %> -
-
+ <% end %> +<% end %> diff --git a/app/views/spotlight/exhibits/index.html.erb b/app/views/spotlight/exhibits/index.html.erb index b350621db4..573e25f47e 100644 --- a/app/views/spotlight/exhibits/index.html.erb +++ b/app/views/spotlight/exhibits/index.html.erb @@ -1,47 +1,32 @@ -<% if (current_user && current_user.exhibits.any?) || can?(:manage, Spotlight::Exhibit) %> - +<% public_content = capture do %> + <% if @exhibits.published.none? %> + <%= render 'missing_exhibits' %> + <% else %> + <%= render 'public_exhibits' %> + <% end %> <% end %> -
-
- <% if @exhibits.published.none? %> - <%= render 'missing_exhibits' %> - <% else %> - <%= render 'tags', tags: @exhibits.published.all_tags %> - <%= render 'exhibits', exhibits: @published_exhibits %> +<% if (current_user && current_user.exhibits.any?) || can?(:manage, Spotlight::Exhibit) %> + <%= render Spotlight::TabPanelComponent.new(tab_position: :outside) do |component| %> + <% component.tab(id: 'published', label: t('.published'), active: true) do %> + <%= public_content %> + <% end %> - <% if @published_exhibits.total_count > @published_exhibits.size %> - + <% if can?(:manage, Spotlight::Exhibit) && @exhibits.unpublished.accessible_by(current_ability).any? %> + <% component.tab(id: 'unpublished', label: t('.unpublished')) do %> + <%= render 'exhibits', exhibits: @exhibits.unpublished.ordered_by_weight.accessible_by(current_ability) %> <% end %> <% end %> -
- - <% if @exhibits.unpublished.accessible_by(current_ability).any? %> -
- <%= render 'exhibits', exhibits: @exhibits.unpublished.ordered_by_weight.accessible_by(current_ability) %> -
- <% end %> - - <% if current_user && current_user.exhibits.any? %> -
- <%= render 'exhibits', exhibits: current_user.exhibits %> -
+ <% if current_user && current_user.exhibits.any? %> + <% component.tab(id: 'user', label: t('.user')) do %> + <%= render 'exhibits', exhibits: current_user.exhibits %> + <% end %> + <% end %> <% end %> -
+<% else %> + <%= public_content %> +<% end %> <% content_for(:sidebar_position) { 'order-last' } %> <% content_for(:sidebar) do %> diff --git a/app/views/spotlight/filters/_form.html.erb b/app/views/spotlight/filters/_form.html.erb index b142762ccc..b74456d364 100644 --- a/app/views/spotlight/filters/_form.html.erb +++ b/app/views/spotlight/filters/_form.html.erb @@ -1,15 +1,13 @@ -
- <%= bootstrap_form_for [@exhibit, @exhibit.filters.first_or_initialize], layout: :horizontal, label_col: 'col-md-2', control_col: 'col-md-10' do |f| %> -

<%= t :'spotlight.exhibits.filter.instructions' %>

+<%= bootstrap_form_for [@exhibit, @exhibit.filters.first_or_initialize], layout: :horizontal, label_col: 'col-md-2', control_col: 'col-md-10' do |f| %> +

<%= t :'spotlight.exhibits.filter.instructions' %>

- <%= f.text_field :field %> - <%= f.text_field :value %> - <%= hidden_field_tag :tab, 'filter' %> + <%= f.text_field :field %> + <%= f.text_field :value %> + <%= hidden_field_tag :tab, 'filter' %> -
-
- <%= f.submit nil, class: 'btn btn-primary' %> -
+
+
+ <%= f.submit nil, class: 'btn btn-primary' %>
- <% end %> -
+
+<% end %> diff --git a/app/views/spotlight/pages/_form.html.erb b/app/views/spotlight/pages/_form.html.erb index 6e12edb5e1..65d064e219 100644 --- a/app/views/spotlight/pages/_form.html.erb +++ b/app/views/spotlight/pages/_form.html.erb @@ -16,49 +16,32 @@
<% end %> -
- - -
-
-
- <%= f.label :title, class: 'sr-only' %> - <%= f.text_field_without_bootstrap :title, class: 'form-control form-control-lg', placeholder: t(:'.title_placeholder') %> -
-
- <%= f.label :content, class: 'sr-only' %> - <%= f.text_area_without_bootstrap :content, value: { data: f.object.content.as_json }.to_json, class: content_editor_class(f.object), data: { 'block-types': SirTrevorRails::Block.custom_block_types } %> -
+ <%= render Spotlight::TabPanelComponent.new do |component| %> + <% component.tab(id: 'page-content', label: t(:'.page_content'), active: true) do %> +
+ <%= f.label :title, class: 'sr-only' %> + <%= f.text_field_without_bootstrap :title, class: 'form-control form-control-lg', placeholder: t(:'.title_placeholder') %>
- -
- <%= render "page_options", f: f %> +
+ <%= f.label :content, class: 'sr-only' %> + <%= f.text_area_without_bootstrap :content, value: { data: f.object.content.as_json }.to_json, class: content_editor_class(f.object), data: { 'block-types': SirTrevorRails::Block.custom_block_types } %>
+ <% end %> + + <% component.tab(id: 'page-options', label: t(:'.page_options')) do %> + <%= render "page_options", f: f %> + <% end %> - <% if @page.respond_to? :thumbnail %> -
+ <% if @page.respond_to? :thumbnail %> + <% component.tab(id: 'page-thumbnail', label: t(:'.page_thumbnail')) do %> <%= f.fields_for :thumbnail, (@page.thumbnail || @page.build_thumbnail), include_id: false do |m| %>

<%= t(:'.thumbnail.help') %>

<%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.featured_image_thumb_size, crop_type: :thumbnail %> <% end %> -
<% end %> -
-
- + <% end %> + <% end %> +
<%= link_to(t('cancel'), :back, data: (@page.lock && @page.lock.current_session? ? { lock: url_for([spotlight, @page.exhibit, @page.lock]) } : {}), class: 'btn-sizing') %> diff --git a/app/views/spotlight/resources/_external_resources_form.html.erb b/app/views/spotlight/resources/_external_resources_form.html.erb index 87f7b4b446..cf16e5dcbb 100644 --- a/app/views/spotlight/resources/_external_resources_form.html.erb +++ b/app/views/spotlight/resources/_external_resources_form.html.erb @@ -2,27 +2,10 @@ <%= render 'missing_external_resources_partials' %> <% end %> -
- -
- <% Spotlight::Engine.config.external_resources_partials.each_with_index do |p, i| %> - <%= content_tag :div, id: "external_resource_tab_#{i}", role: 'tabpanel', class: "tab-pane #{"active" if i == 0}" do %> - <%= render p %> - <% end %> - <% end %> -
-
+ <% end %> +<% end %> diff --git a/app/views/spotlight/resources/new.html.erb b/app/views/spotlight/resources/new.html.erb index d27929a891..85b283aebe 100644 --- a/app/views/spotlight/resources/new.html.erb +++ b/app/views/spotlight/resources/new.html.erb @@ -3,26 +3,13 @@ <% end %> <%= curation_page_title %> -
- -
- <% Spotlight::Engine.config.resource_partials.each_with_index do |p, i| %> - <% tab_name = p.split('/')[2] %> - <%= content_tag :div, id: "#{tab_name}", role: 'tabpanel', class: "tab-pane #{"active" if @tab == tab_name}" do %> - <%= render p %> - <% end %> + +<%= render Spotlight::TabPanelComponent.new do |component| %> + <% Spotlight::Engine.config.resource_partials.each_with_index do |p, i| %> + <% tab_name = p.split('/')[2] %> + + <% component.tab(id: tab_name, label: t("#{p.gsub('/', '.')}.title"), active: @tab == tab_name) do %> + <%= render p %> <% end %> -
-
+ <% end %> +<% end %> diff --git a/app/views/spotlight/search_configurations/edit.html.erb b/app/views/spotlight/search_configurations/edit.html.erb index ad2f3b12b2..20b9825728 100644 --- a/app/views/spotlight/search_configurations/edit.html.erb +++ b/app/views/spotlight/search_configurations/edit.html.erb @@ -4,44 +4,28 @@ <%= configuration_page_title %> <%= bootstrap_form_for @blacklight_configuration, url: spotlight.exhibit_search_configuration_path(@exhibit), layout: :horizontal, label_col: 'col-md-3 col-sm-3', control_col: 'col-md-5 col-sm-5' do |f| %> + <%= render Spotlight::TabPanelComponent.new do |component| %> + <% component.tab(id: 'options', label: t(:'.tab.options'), active: true) do %> + <%= render 'search_fields', f: f %> + <% end %> -
- -
-
- <%= render 'search_fields', f: f %> -
+ <% component.tab(id: 'facets', label: t(:'.tab.facets')) do %> + <%= render 'facets', f: f %> + <% end %> -
- <%= render 'facets', f: f %> -
+ <% component.tab(id: 'results', label: t(:'.tab.results')) do %> + <%= field_set_tag do %> + <%= render 'document_index_view_types', f: f %> + <%= render 'default_per_page', f: f %> + <% end %> -
- <%= field_set_tag do %> - <%= render 'document_index_view_types', f: f %> - <%= render 'default_per_page', f: f %> - <% end %> - - <%= render 'sort', f: f %> -
- -
-
+ <%= render 'sort', f: f %> + <% end %> + <% end %>
<%= f.submit nil, class: 'btn btn-primary' %>
- <% end %> diff --git a/app/views/spotlight/searches/_form.html.erb b/app/views/spotlight/searches/_form.html.erb index bebde0a1fe..ac5b31e8d1 100644 --- a/app/views/spotlight/searches/_form.html.erb +++ b/app/views/spotlight/searches/_form.html.erb @@ -10,74 +10,56 @@
<% end %> -
- - - -
-
- <%= f.text_field :title, control_col: "col-sm-5" %> - <%= f.text_field :subtitle, control_col: "col-sm-5" %> - <%= f.text_area :long_description, rows: 5 %> - <%= f.form_group :search_box, label: { text: t(:'.search_box.label'), class: 'pt-0' }, help: t(:'.search_box.help_block') do %> - <%= f.check_box :search_box, label: t(:'.search_box.checkbox_label') %> - <% end %> - <%= f.form_group label: { text: t(:".default_index_view_type"), class: 'pt-0' } do %> - <% available_document_index_views.each do |key, view| %> - <%= f.radio_button :default_index_view_type, key, label: view.display_label(key) %> - <% end %> + <%= render Spotlight::TabPanelComponent.new do |component| %> + <% component.tab(id: 'search-description', label: t(:'.search_description'), active: true) do %> + <%= f.text_field :title, control_col: "col-sm-5" %> + <%= f.text_field :subtitle, control_col: "col-sm-5" %> + <%= f.text_area :long_description, rows: 5 %> + <%= f.form_group :search_box, label: { text: t(:'.search_box.label'), class: 'pt-0' }, help: t(:'.search_box.help_block') do %> + <%= f.check_box :search_box, label: t(:'.search_box.checkbox_label') %> + <% end %> + <%= f.form_group label: { text: t(:".default_index_view_type"), class: 'pt-0' } do %> + <% available_document_index_views.each do |key, view| %> + <%= f.radio_button :default_index_view_type, key, label: view.display_label(key) %> <% end %> - <% unless @search.query_params.blank? %> -
- -
-
- <%= render_constraints(@search.query_params) %> -
+ <% end %> + <% unless @search.query_params.blank? %> +
+ +
+
+ <%= render_constraints(@search.query_params) %>
- <% end %> -
-
- <% if @groups.present? %> -

<%= t(:'.group.help') %>

- <%= f.collection_check_boxes(:group_ids, @groups, :id, :title, hide_label: true) %> - <% else %> -

<%= t(:'.group.help_no_groups') %>

- <% end %> -
-
- <%= f.fields_for :masthead, (@search.masthead || @search.build_masthead) do |m| %> -

<%= t(:'.masthead.help') %>

-

<%= t(:'.masthead.help_secondary') %>

- <%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.masthead_initial_crop_selection, crop_type: :masthead %> - <% end %> -
-
- <%= f.fields_for :thumbnail, (@search.thumbnail || @search.build_thumbnail) do |m| %> -

<%= t(:'.thumbnail.help') %>

- <%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.featured_image_thumb_size, crop_type: :thumbnail %> - <% end %> -
+
+ <% end %> + <% end %> -
-
+ <% component.tab(id: 'search-group', label: t(:'.search_group')) do %> + <% if @groups.present? %> +

<%= t(:'.group.help') %>

+ <%= f.collection_check_boxes(:group_ids, @groups, :id, :title, hide_label: true) %> + <% else %> +

<%= t(:'.group.help_no_groups') %>

+ <% end %> + <% end %> + + <% component.tab(id: 'search-masthead', label: t(:'.search_masthead')) do %> + <%= f.fields_for :masthead, (@search.masthead || @search.build_masthead) do |m| %> +

<%= t(:'.masthead.help') %>

+

<%= t(:'.masthead.help_secondary') %>

+ <%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.masthead_initial_crop_selection, crop_type: :masthead %> + <% end %> + <% end %> + + <% component.tab(id: 'search-thumbnail', label: t(:'.search_thumbnail')) do %> + <%= f.fields_for :thumbnail, (@search.thumbnail || @search.build_thumbnail) do |m| %> +

<%= t(:'.thumbnail.help') %>

+ <%= render '/spotlight/featured_images/form', f: m, initial_crop_selection: Spotlight::Engine.config.featured_image_thumb_size, crop_type: :thumbnail %> + <% end %> + <% end %> + <% end %>
diff --git a/app/views/spotlight/searches/index.html.erb b/app/views/spotlight/searches/index.html.erb index ff18495983..9e9d2757d8 100644 --- a/app/views/spotlight/searches/index.html.erb +++ b/app/views/spotlight/searches/index.html.erb @@ -12,66 +12,56 @@

<% end %> <% else %> -
- -
-
-

<%= t(:'.categories_instructions') %>

- <% unless @exhibit.searchable? %> -

- <%= t(:'.not_searchable_html', href: link_to(t(:'spotlight.configuration.sidebar.search_configuration'), spotlight.edit_exhibit_search_configuration_path(@exhibit))) %> -

- <% end %> - <%= bootstrap_form_for @exhibit, url: update_all_exhibit_searches_path(@exhibit), layout: :horizontal, control_col: 'col-sm-10' do |f| %> +
+
    + <%= f.fields_for :searches do |p| %> + <%= render partial: 'search', locals: { f: p} %> + <% end %> +
+
-
-
    - <%= f.fields_for :searches do |p| %> - <%= render partial: 'search', locals: { f: p} %> - <% end %> -
-
+
+ <%= submit_tag t(:'helpers.action.update_all'), class: "btn btn-primary" %> +
+ <% end %> + <% end %> -
- <%= submit_tag t(:'helpers.action.update_all'), class: "btn btn-primary" %> -
- <% end %> -
-
-
<%= t(:'.groups_instructions_html') %>
- <%= bootstrap_form_for @exhibit, url: update_all_exhibit_groups_path(@exhibit), layout: :horizontal, control_col: 'col-sm-10' do |f| %> + <% component.tab(id: 'browse-groups', label: t(:'.groups_header')) do %> +
<%= t(:'.groups_instructions_html') %>
+ <%= bootstrap_form_for @exhibit, url: update_all_exhibit_groups_path(@exhibit), layout: :horizontal, control_col: 'col-sm-10' do |f| %> -
-
    - <%= f.fields_for :groups do |p| %> - <%= render partial: 'group', locals: { f: p} %> - <% end %> -
-
+
+
    + <%= f.fields_for :groups do |p| %> + <%= render partial: 'group', locals: { f: p} %> + <% end %> +
+
-
- <%= submit_tag t(:'helpers.action.update_all'), class: "btn btn-primary" %> -
- <% end %> - <%= form_for :group, url: spotlight.exhibit_groups_path(current_exhibit), html: {class: "expanded-add-button"} do |f|%> - - <%= t(:'.add_new_group') %> <%= blacklight_icon('chevron_right') %> - - <%= f.text_field(:title) %> - <%= f.submit t(:'.save'), data: {behavior: "save"} %> - <%= f.submit t(:'.cancel'), data: {behavior: "cancel"} %> - - - <%- end -%> -
-
-
+
+ <%= submit_tag t(:'helpers.action.update_all'), class: "btn btn-primary" %> +
+ <% end %> + <%= form_for :group, url: spotlight.exhibit_groups_path(current_exhibit), html: {class: "expanded-add-button"} do |f|%> + + <%= t(:'.add_new_group') %> <%= blacklight_icon('chevron_right') %> + + <%= f.text_field(:title) %> + <%= f.submit t(:'.save'), data: {behavior: "save"} %> + <%= f.submit t(:'.cancel'), data: {behavior: "cancel"} %> + + + <%- end -%> + <% end %> + <% end %> <% end %> diff --git a/app/views/spotlight/sites/edit.html.erb b/app/views/spotlight/sites/edit.html.erb index 06ea5e27b3..23f9be79be 100644 --- a/app/views/spotlight/sites/edit.html.erb +++ b/app/views/spotlight/sites/edit.html.erb @@ -1,34 +1,24 @@ <%= page_title(t('.page_title')) %> -
<%= bootstrap_form_for @site, url: spotlight.site_path, layout: :horizontal, label_col: 'col-md-2', control_col: 'col-md-10' do |f| %> - -
-
+ <%= render Spotlight::TabPanelComponent.new do |component| %> + <% component.tab(id: 'basic', label: t(:'.basic_settings.heading'), active: true) do %> <%= f.text_field :title %> <%= f.text_field :subtitle %> -
+ <% end %> -
-

<%= t(:'.site_masthead.help') %>

- <%= f.fields_for(:masthead, @site.masthead || @site.build_masthead) do |m| %> - <%= render '/spotlight/featured_images/upload_form', f: m, initial_crop_selection: Spotlight::Engine.config.masthead_initial_crop_selection, crop_type: :masthead %> - <% end %> -
-
+ <% component.tab(id: 'site-masthead', label: t(:'.site_masthead.heading')) do %> +

<%= t(:'.site_masthead.help') %>

+ <%= f.fields_for(:masthead, @site.masthead || @site.build_masthead) do |m| %> + <%= render '/spotlight/featured_images/upload_form', f: m, initial_crop_selection: Spotlight::Engine.config.masthead_initial_crop_selection, crop_type: :masthead %> + <% end %> + <% end %> + <% end %>
<%= f.submit nil, class: 'btn btn-primary' %>
-
<% end %> <% content_for(:sidebar_position) { 'order-last' } %> diff --git a/app/views/spotlight/translations/_browse_categories.html.erb b/app/views/spotlight/translations/_browse_categories.html.erb index d1b177ad85..d12037df4a 100644 --- a/app/views/spotlight/translations/_browse_categories.html.erb +++ b/app/views/spotlight/translations/_browse_categories.html.erb @@ -1,98 +1,96 @@ -
- <%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> - <% # Add hidden fields for the language and tab so the redirect knows how to come back here %> - <%= hidden_field_tag :language, @language %> - <%= hidden_field_tag :tab, 'browse' %> -
-
- - <%= t :'.default_language_column_label' %> - -
-
- - <%= t :'.translation_column_label', language: t("locales.#{@language}") %> - -
+<%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> + <% # Add hidden fields for the language and tab so the redirect knows how to come back here %> + <%= hidden_field_tag :language, @language %> + <%= hidden_field_tag :tab, 'browse_categories' %> +
+
+ + <%= t :'.default_language_column_label' %> +
+
+ + <%= t :'.translation_column_label', language: t("locales.#{@language}") %> + +
+
- <% current_exhibit.searches.each do |search| %> - <% title_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{search.slug}.title", locale: @language) %> - <%= f.fields_for :translations, title_translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, search[:title], class: 'col-form-label col-4' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> -
-
- <% if title_translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
-
- <% end %> - - <% subtitle_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{search.slug}.subtitle", locale: @language) %> -
-
- <%= f.fields_for :translations, subtitle_translation do |translation_fields| %> - <%= button_tag 'type' => 'button', class: 'btn btn-text collapse-toggle collapsed translation-subtitle-toggle', 'data-toggle': 'collapse', 'data-target': "#browse_category_subtitle_#{search.id}", 'aria-expanded': 'false', 'aria-controls': "#browse_category_subtitle_#{search.id}" do %> - <%= translation_fields.label :value, t(:'.subtitle_label') %> - <% end %> - - - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - <%= search[:subtitle] %> -
- <% end %> + <% current_exhibit.searches.each do |search| %> + <% title_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{search.slug}.title", locale: @language) %> + <%= f.fields_for :translations, title_translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, search[:title], class: 'col-form-label col-4' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %>
- <% if subtitle_translation.value.present? %> + <% if title_translation.value.present? %> <%= blacklight_icon('check', classes: 'translation-complete') %> <% end %>
+ <% end %> - <% description_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{search.slug}.long_description", locale: @language) %> -
-
- <%= f.fields_for :translations, description_translation do |translation_fields| %> - <%= button_tag 'type' => 'button', class: 'btn btn-text collapse-toggle collapsed translation-description-toggle', 'data-toggle': 'collapse', 'data-target': "#browse_category_description_#{search.id}", 'aria-expanded': 'false', 'aria-controls': "#browse_category_description_#{search.id}" do %> - <%= translation_fields.label :value, t(:'.description_label') %> - <% end %> - - - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.text_area_without_bootstrap :value, class: 'form-control' %> - <%= search[:long_description] %> -
+ <% subtitle_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{search.slug}.subtitle", locale: @language) %> +
+
+ <%= f.fields_for :translations, subtitle_translation do |translation_fields| %> + <%= button_tag 'type' => 'button', class: 'btn btn-text collapse-toggle collapsed translation-subtitle-toggle', 'data-toggle': 'collapse', 'data-target': "#browse_category_subtitle_#{search.id}", 'aria-expanded': 'false', 'aria-controls': "#browse_category_subtitle_#{search.id}" do %> + <%= translation_fields.label :value, t(:'.subtitle_label') %> <% end %> -
-
- <% if description_translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+ + + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + <%= search[:subtitle] %> +
+ <% end %>
- <% end %> +
+ <% if subtitle_translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %> +
+
+ + <% description_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{search.slug}.long_description", locale: @language) %> +
+
+ <%= f.fields_for :translations, description_translation do |translation_fields| %> + <%= button_tag 'type' => 'button', class: 'btn btn-text collapse-toggle collapsed translation-description-toggle', 'data-toggle': 'collapse', 'data-target': "#browse_category_description_#{search.id}", 'aria-expanded': 'false', 'aria-controls': "#browse_category_description_#{search.id}" do %> + <%= translation_fields.label :value, t(:'.description_label') %> + <% end %> + -
-
- <%= f.submit nil, class: 'btn btn-primary' %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.text_area_without_bootstrap :value, class: 'form-control' %> + <%= search[:long_description] %> +
+ <% end %> +
+
+ <% if description_translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %>
<% end %> -
+ +
+
+ <%= f.submit nil, class: 'btn btn-primary' %> +
+
+<% end %> diff --git a/app/views/spotlight/translations/_general.html.erb b/app/views/spotlight/translations/_general.html.erb index 6dfcabee59..288fde8eb8 100644 --- a/app/views/spotlight/translations/_general.html.erb +++ b/app/views/spotlight/translations/_general.html.erb @@ -1,138 +1,114 @@ -
- <%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> - <% # Add a hidden field for the language so the redirect knows how to come back here %> - <%= hidden_field_tag :language, @language %> +<%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> + <% # Add a hidden field for the language so the redirect knows how to come back here %> + <%= hidden_field_tag :language, @language %> -
-

- <%= t('.basic_settings.label') %> -

+
+

+ <%= t('.basic_settings.label') %> +

- <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{current_exhibit.slug}.title", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t('.basic_settings.title'), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - - <%= current_exhibit[:title] %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+ <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{current_exhibit.slug}.title", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, t('.basic_settings.title'), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= current_exhibit[:title] %> +
- <% end %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{current_exhibit.slug}.subtitle", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t('.basic_settings.subtitle'), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - - <%= current_exhibit[:subtitle] %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %>
- <% end %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{current_exhibit.slug}.description", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t('.basic_settings.description'), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_area_without_bootstrap :value, class: 'form-control' %> - - <%= current_exhibit.description %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+
+ <% end %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{current_exhibit.slug}.subtitle", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, t('.basic_settings.subtitle'), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= current_exhibit[:subtitle] %> +
- <% end %> -
-
-

- <%= t('.main_menu.label') %> -

- - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "spotlight.curation.nav.home", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t('.main_menu.home'), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - - <%= t(:'spotlight.curation.nav.home', locale: I18n.default_locale) %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %>
- <% end %> +
+ <% end %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{current_exhibit.slug}.description", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, t('.basic_settings.description'), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_area_without_bootstrap :value, class: 'form-control' %> + + <%= current_exhibit.description %> + +
+
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %> +
+
+ <% end %> +
+
+

+ <%= t('.main_menu.label') %> +

- <% current_exhibit.main_navigations.each do |navigation| %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "main_navigation.#{navigation.nav_type}.label", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> - - <% end %> - <% end %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "spotlight.curation.nav.home", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, t('.main_menu.home'), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= t(:'spotlight.curation.nav.home', locale: I18n.default_locale) %> + +
+
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %> +
+
+ <% end %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: 'spotlight.catalog.breadcrumb.index', locale: @language) %> + <% current_exhibit.main_navigations.each do |navigation| %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "main_navigation.#{navigation.nav_type}.label", locale: @language) %> <%= f.fields_for :translations, translation do |translation_fields| %> <%= translation_fields.hidden_field :key %> <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t('spotlight.catalog.breadcrumb.index'), class: 'col-form-label col-12 col-sm-2' %> + <% end %> -
-
-
- <%= f.submit nil, class: 'btn btn-primary' %> + <% end %> + + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: 'spotlight.catalog.breadcrumb.index', locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, t('spotlight.catalog.breadcrumb.index'), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= t(:'spotlight.catalog.breadcrumb.index', locale: I18n.default_locale) %> + +
+
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %> +
+ <% end %> +
+
+
+ <%= f.submit nil, class: 'btn btn-primary' %>
- <% end %> -
+
+<% end %> diff --git a/app/views/spotlight/translations/_groups.html.erb b/app/views/spotlight/translations/_groups.html.erb index c20cf69d97..9a819e9bc7 100644 --- a/app/views/spotlight/translations/_groups.html.erb +++ b/app/views/spotlight/translations/_groups.html.erb @@ -1,34 +1,32 @@ -
- <%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> - <% # Add hidden fields for the language and tab so the redirect knows how to come back here %> - <%= hidden_field_tag :language, @language %> - <%= hidden_field_tag :tab, 'groups' %> +<%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> + <% # Add hidden fields for the language and tab so the redirect knows how to come back here %> + <%= hidden_field_tag :language, @language %> + <%= hidden_field_tag :tab, 'groups' %> - <% current_exhibit.groups.each do |group| %> - <% title_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{group.slug}.title", locale: @language) %> - <%= f.fields_for :translations, title_translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, group[:title], class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> -
-
- <% if title_translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+ <% current_exhibit.groups.each do |group| %> + <% title_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{group.slug}.title", locale: @language) %> + <%= f.fields_for :translations, title_translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, group[:title], class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %>
- <% end %> +
+ <% if title_translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %> +
+
<% end %> + <% end %> -
-
- <%= f.submit nil, class: 'btn btn-primary' %> -
+
+
+ <%= f.submit nil, class: 'btn btn-primary' %>
- <% end %> -
+
+<% end %> diff --git a/app/views/spotlight/translations/_metadata.html.erb b/app/views/spotlight/translations/_metadata.html.erb index efc60698e8..1a1a7417d5 100644 --- a/app/views/spotlight/translations/_metadata.html.erb +++ b/app/views/spotlight/translations/_metadata.html.erb @@ -1,71 +1,69 @@ -
- <%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> - <% # Add a hidden field for the language so the redirect knows how to come back here %> - <%= hidden_field_tag :language, @language %> - <%= hidden_field_tag :tab, 'metadata' %> +<%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> + <% # Add a hidden field for the language so the redirect knows how to come back here %> + <%= hidden_field_tag :language, @language %> + <%= hidden_field_tag :tab, 'metadata' %> - <% non_custom_metadata_fields.each do |key, field_config| %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.#{key}", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> + <% non_custom_metadata_fields.each do |key, field_config| %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.#{key}", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t("spotlight.search.fields.#{key}", default: field_config.label, locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - - <%= field_config.label %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+
+ <%= translation_fields.label :value, t("spotlight.search.fields.#{key}", default: field_config.label, locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= field_config.label %> +
- <% end %> +
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %> +
+
<% end %> + <% end %> - <% if current_exhibit.custom_fields.any? %> -
-

- <%= t('.exhibit_specific_fields.label') %> -

+ <% if current_exhibit.custom_fields.any? %> +
+

+ <%= t('.exhibit_specific_fields.label') %> +

- <% current_exhibit.custom_fields.each do |custom_field| %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.#{custom_field.field}", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> + <% current_exhibit.custom_fields.each do |custom_field| %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.#{custom_field.field}", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t("spotlight.search.fields.#{custom_field.field}", default: custom_field.configuration['label'], locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - - <%= custom_field.configuration['label'] %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+
+ <%= translation_fields.label :value, t("spotlight.search.fields.#{custom_field.field}", default: custom_field.configuration['label'], locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= custom_field.configuration['label'] %> +
- <% end %> +
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %> +
+
<% end %> -
- <% end %> - -
-
- <%= f.submit nil, class: 'btn btn-primary' %> -
+ <% end %>
<% end %> -
+ +
+
+ <%= f.submit nil, class: 'btn btn-primary' %> +
+
+<% end %> diff --git a/app/views/spotlight/translations/_pages.html.erb b/app/views/spotlight/translations/_pages.html.erb index e3adcc3383..9aad11df07 100644 --- a/app/views/spotlight/translations/_pages.html.erb +++ b/app/views/spotlight/translations/_pages.html.erb @@ -1,37 +1,35 @@ -
-

<%= t('.help_html') %>

+

<%= t('.help_html') %>

- <%= bootstrap_form_for @exhibit, url: polymorphic_path([:update_all, @exhibit, :pages]), layout: :horizontal, control_col: 'col-sm-10', html: {:'data-form-observer' => true} do |f| %> -
+<%= bootstrap_form_for @exhibit, url: polymorphic_path([:update_all, @exhibit, :pages]), layout: :horizontal, control_col: 'col-sm-10', html: {:'data-form-observer' => true} do |f| %> +
+

+ <%= t('.home_page.label') %> +

+ <%= render 'pages_table', pages: [current_exhibit.home_page], f: f %> +
+ + <% if current_exhibit.feature_pages.any? %> +

- <%= t('.home_page.label') %> + <%= t('.feature_pages.label') %>

- <%= render 'pages_table', pages: [current_exhibit.home_page], f: f %> -
- <% if current_exhibit.feature_pages.any? %> -
-

- <%= t('.feature_pages.label') %> -

- - <%= render 'pages_table', pages: current_exhibit.feature_pages.for_default_locale, f: f %> -
- <% end %> + <%= render 'pages_table', pages: current_exhibit.feature_pages.for_default_locale, f: f %> +
+ <% end %> - <% if current_exhibit.about_pages.any? %> -
-

- <%= t('.about_pages.label') %> -

+ <% if current_exhibit.about_pages.any? %> +
+

+ <%= t('.about_pages.label') %> +

- <%= render 'pages_table', pages: current_exhibit.about_pages.for_default_locale, f: f %> -
- <% end %> -
-
- <%= f.submit nil, class: 'btn btn-primary' %> -
+ <%= render 'pages_table', pages: current_exhibit.about_pages.for_default_locale, f: f %>
<% end %> -
+
+
+ <%= f.submit nil, class: 'btn btn-primary' %> +
+
+<% end %> diff --git a/app/views/spotlight/translations/_search_fields.html.erb b/app/views/spotlight/translations/_search_fields.html.erb index 3464add0fa..c42dd4b262 100644 --- a/app/views/spotlight/translations/_search_fields.html.erb +++ b/app/views/spotlight/translations/_search_fields.html.erb @@ -1,103 +1,101 @@ -
- <%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> - <% # Add hidden fields for the language and tab so the redirect knows how to come back here %> - <%= hidden_field_tag :language, @language %> - <%= hidden_field_tag :tab, 'search_fields' %> +<%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %> + <% # Add hidden fields for the language and tab so the redirect knows how to come back here %> + <%= hidden_field_tag :language, @language %> + <%= hidden_field_tag :tab, 'search_fields' %> -
-

- <%= t('.field_based_search_fields.label') %> -

+
+

+ <%= t('.field_based_search_fields.label') %> +

- <% current_exhibit.blacklight_config.search_fields.select { |_, config| config.if }.each do |key, search_config| %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.search.#{key}", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t("spotlight.search.fields.search.#{key}", locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - - <%= search_config.label %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+ <% current_exhibit.blacklight_config.search_fields.select { |_, config| config.if }.each do |key, search_config| %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.search.#{key}", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, t("spotlight.search.fields.search.#{key}", locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= search_config.label %> +
- <% end %> +
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %> +
+
<% end %> -
+ <% end %> +
-
-

- <%= t('.facet_fields.label') %> -

+
+

+ <%= t('.facet_fields.label') %> +

- <% current_exhibit.blacklight_config.facet_fields.each do |key, facet_config| %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.facet.#{key}", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t("spotlight.search.fields.facet.#{key}", locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - - <%= facet_config.label %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+ <% current_exhibit.blacklight_config.facet_fields.each do |key, facet_config| %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.facet.#{key}", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, t("spotlight.search.fields.facet.#{key}", locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= facet_config.label %> + +
+
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %>
- <% end %> +
<% end %> -
+ <% end %> +
-
-

- <%= t('.sort_fields.label') %> -

+
+

+ <%= t('.sort_fields.label') %> +

- <% current_exhibit.blacklight_config.sort_fields.each do |key, sort_config| %> - <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.sort.#{key}", locale: @language) %> - <%= f.fields_for :translations, translation do |translation_fields| %> - <%= translation_fields.hidden_field :key %> - <%= translation_fields.hidden_field :locale %> -
- <%= translation_fields.label :value, t("spotlight.search.fields.sort.#{key}", locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> -
- <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> - - <%= sort_config.label %> - -
-
- <% if translation.value.present? %> - - <%= blacklight_icon('check', classes: 'translation-complete') %> - - <% end %> -
+ <% current_exhibit.blacklight_config.sort_fields.each do |key, sort_config| %> + <% translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "blacklight.search.fields.sort.#{key}", locale: @language) %> + <%= f.fields_for :translations, translation do |translation_fields| %> + <%= translation_fields.hidden_field :key %> + <%= translation_fields.hidden_field :locale %> +
+ <%= translation_fields.label :value, t("spotlight.search.fields.sort.#{key}", locale: I18n.default_locale), class: 'col-form-label col-12 col-sm-2' %> +
+ <%= translation_fields.text_field_without_bootstrap :value, class: 'form-control' %> + + <%= sort_config.label %> + +
+
+ <% if translation.value.present? %> + + <%= blacklight_icon('check', classes: 'translation-complete') %> + + <% end %>
- <% end %> +
<% end %> -
+ <% end %> +
-
-
- <%= f.submit nil, class: 'btn btn-primary' %> -
+
+
+ <%= f.submit nil, class: 'btn btn-primary' %>
- <% end %> -
+
+<% end %> diff --git a/app/views/spotlight/translations/edit.html.erb b/app/views/spotlight/translations/edit.html.erb index 315ac4ae17..3161f37249 100644 --- a/app/views/spotlight/translations/edit.html.erb +++ b/app/views/spotlight/translations/edit.html.erb @@ -19,47 +19,13 @@ <%= render partial: 'import' %> -
- + <%= render Spotlight::TabPanelComponent.new do |component| %> + <% badge = tag.span(class: 'badge') %> -
- <%= render 'general' %> - <%= render 'metadata' %> - <%= render 'search_fields' %> - <%= render 'browse_categories' %> - <%= render 'pages' %> - <%= render 'groups' %> -
-
+ <% %w[general metadata search_fields browse_categories groups pages].each do |section| %> + <% component.tab(id: section, label: safe_join([t("spotlight.translations.#{section}.label"), badge], ' '), active: @tab == section || (section == 'general' && @tab.blank?), label_data: { behavior: 'translation-progress' }) do %> + <%= render section %> + <% end %> + <% end %> + <% end %>
diff --git a/blacklight-spotlight.gemspec b/blacklight-spotlight.gemspec index 2590ac84c4..39a60c8301 100644 --- a/blacklight-spotlight.gemspec +++ b/blacklight-spotlight.gemspec @@ -60,6 +60,7 @@ these collections.) s.add_dependency 'thor' s.add_dependency 'tophat' s.add_dependency 'underscore-rails', '~> 1.6' + s.add_dependency 'view_component', '~> 2.42' s.add_development_dependency 'capybara', '~> 3.31' s.add_development_dependency 'engine_cart', '~> 2.0' diff --git a/lib/spotlight/engine.rb b/lib/spotlight/engine.rb index 61d096fe5c..7df8e58540 100644 --- a/lib/spotlight/engine.rb +++ b/lib/spotlight/engine.rb @@ -19,6 +19,7 @@ require 'riiif' require 'faraday' require 'faraday_middleware' +require 'view_component/engine' module Spotlight ## diff --git a/spec/features/exhibits/translation_editing_spec.rb b/spec/features/exhibits/translation_editing_spec.rb index db11808ded..3923badd2e 100644 --- a/spec/features/exhibits/translation_editing_spec.rb +++ b/spec/features/exhibits/translation_editing_spec.rb @@ -329,7 +329,7 @@ end it 'has a title and description for every browse category' do - within '#browse' do + within '#browse_categories' do expect(page).to have_css('input[type="text"]', count: 4) expect(page).to have_css('textarea', count: 2) @@ -341,7 +341,7 @@ it 'redirects to the same form tab' do click_link 'Browse categories' - within('#browse', visible: true) do + within('#browse_categories', visible: true) do fill_in 'All exhibit items', with: "Tous les objets d'exposition" click_button 'Save changes' end @@ -353,7 +353,7 @@ it 'persists changes', js: true do click_link 'Browse categories' - within('#browse', visible: true) do + within('#browse_categories', visible: true) do fill_in 'All exhibit items', with: "Tous les objets d'exposition" first('.translation-description-toggle').click @@ -454,6 +454,7 @@ it 'counts existing and total available translations' do visit spotlight.edit_exhibit_translations_path(exhibit, language: 'fr') + expect(page).to have_link('General 1/8') expect(page).to have_link('Search field labels 0/16') expect(page).to have_link('Browse categories 0/3')