From 7b578f735b8a84ddbb2ee8621b2951d6708cd9e5 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Wed, 3 Apr 2024 16:37:52 -0400 Subject: [PATCH 1/3] Add machine generated option to captions This commit moves the 'Treat as Transcript' and 'Machine Generated' checkboxes to their own row within the edit supplemental file form. --- app/assets/stylesheets/avalon.scss | 4 + app/assets/stylesheets/avalon/_form.scss | 5 + .../_supplemental_files_list.html.erb | 155 +++++++++--------- .../supplemental_files_controller_examples.rb | 2 +- 4 files changed, 91 insertions(+), 75 deletions(-) diff --git a/app/assets/stylesheets/avalon.scss b/app/assets/stylesheets/avalon.scss index 46d3ece523..1ca1a49888 100644 --- a/app/assets/stylesheets/avalon.scss +++ b/app/assets/stylesheets/avalon.scss @@ -949,6 +949,10 @@ h5.card-title { } } + div.supplemental-file-data.is-editing:not(.edit-item) + div.supplemental-file-data { + margin-top: 2.6rem; + } + .supplemental-file-form { float: left; width: 100%; diff --git a/app/assets/stylesheets/avalon/_form.scss b/app/assets/stylesheets/avalon/_form.scss index 28bf7dfda1..378c3299ba 100644 --- a/app/assets/stylesheets/avalon/_form.scss +++ b/app/assets/stylesheets/avalon/_form.scss @@ -80,6 +80,11 @@ $border-radius-base: 4px !default; margin-bottom: 2px; } +.form-group label.checkbox { + margin-left: 0.5rem !important; + padding-right: 1rem !important; +} + /* * Fix that shouldn't be needed to make sure that the text behaves like a regular * link diff --git a/app/views/media_objects/_supplemental_files_list.html.erb b/app/views/media_objects/_supplemental_files_list.html.erb index 76f74af561..9a464379cd 100644 --- a/app/views/media_objects/_supplemental_files_list.html.erb +++ b/app/views/media_objects/_supplemental_files_list.html.erb @@ -13,81 +13,88 @@ Unless required by applicable law or agreed to in writing, software distributed specific language governing permissions and limitations under the License. --- END LICENSE_HEADER BLOCK --- %> - <% if section.supplemental_files_json.present? %> - <% files=tag.empty? ? section.supplemental_files(tag: nil) : section.supplemental_files(tag: tag) %> -
captions<% end %>"> - <% if tag == "caption" %> -
-
-
- -
-
- -
-
+<% if section.supplemental_files_json.present? %> + <% files=tag.empty? ? section.supplemental_files(tag: nil) : section.supplemental_files(tag: tag) %> +
captions<% end %>"> + <% if tag == "caption" %> +
+
+
+ +
+
+ +
+
+
+ <% end %> + <% files.each do |file| %> + <% next if tag == 'transcript' and file.tags.include?('caption') %> +
+ " class="display-item"><%= file.label %> + <%= form_for :supplemental_file, url: object_supplemental_file_path(section, file), remote: true, + html: { method: "put", class: "supplemental-file-form edit-item", id: "form-#{file.id}" }, + data: { file_id: file.id, masterfile_id: section.id } do |form| %> +
+
+ <%= form.text_field :label, id: "supplemental_file_input_#{section.id}_#{file.id}", value: file.label %> +
+ <% if tag == 'transcript' %> + + <%= label_tag "machine_generated_#{file.id}", class: "ml-3" do %> + <%= check_box_tag "machine_generated_#{file.id}", '1', file.machine_generated? %> + Machine Generated + <% end %> + + <% end %> + <% if tag == 'caption' %> +
+ <%= form.text_field :language, id: "supplemental_file_language_#{section.id}_#{file.id}", value: LanguageTerm.find(file.language).text, + class: "typeahead from-model form-control", + data: { model: 'languageTerm', validate: false } %> +
+
+
+ <%= label_tag "treat_as_transcript_#{file.id}", class: "checkbox", style: "white-space: nowrap; padding-left: 0.45rem;" do %> + <%= check_box_tag "treat_as_transcript_#{file.id}", '1', file.caption_transcript? %> + Treat as Transcript + <% end %>
- <% end %> - <% files.each do |file| %> - <% next if tag == 'transcript' and file.tags.include?('caption') %> -
- " class="display-item"><%= file.label %> - <%= form_for :supplemental_file, url: object_supplemental_file_path(section, file), remote: true, - html: { method: "put", class: "supplemental-file-form edit-item", id: "form-#{file.id}" }, - data: { file_id: file.id, masterfile_id: section.id } do |form| %> -
- <% col = tag == 'caption' ? 4 : 6 %> -
- <%= form.text_field :label, id: "supplemental_file_input_#{section.id}_#{file.id}", value: file.label %> -
- <% if tag == 'transcript' %> - - <%= label_tag "machine_generated_#{file.id}", class: "ml-3" do %> - <%= check_box_tag "machine_generated_#{file.id}", '1', file.machine_generated? %> - Machine Generated - <% end %> - - <% end %> - <% if tag == 'caption' %> -
- <%= form.text_field :language, id: "supplemental_file_language_#{section.id}_#{file.id}", value: LanguageTerm.find(file.language).text, - class: "typeahead from-model form-control", - data: { model: 'languageTerm', validate: false } %> -
- - <%= label_tag "treat_as_transcript_#{file.id}", class: "ml-3" do %> - <%= check_box_tag "treat_as_transcript_#{file.id}", '1', file.caption_transcript? %> - Treat as transcript - <% end %> - - <% end %> -
-
-
- <%= button_tag name: 'save_label', :class => "btn btn-outline btn-sm edit-item" do %> - Save - <% end %> - <%= button_tag name: 'cancel_edit_label', class:'btn btn-danger btn-sm edit-item', type: 'button' do%> - Cancel - <% end %> -
-
- <% end %> - - - - - -
- <%# Update button %> - <%= button_tag name: 'edit_label', class:'btn btn-outline btn-sm edit_label display-item', type: 'button' do %> - Edit - <% end %> - <%= link_to(object_supplemental_file_path(section, file), title: 'Remove', method: :delete, class: "btn btn-danger btn-sm file-remove btn-confirmation") do %> - Delete - <% end %> -
+
+ <%= label_tag "machine_generated_#{file.id}", class: "ml-3 checkbox", style: "white-space: nowrap; padding-left: 2.6rem;" do %> + <%= check_box_tag "machine_generated_#{file.id}", '1', file.machine_generated? %> + Machine Generated + <% end %>
+
+ <% end %> +
+
+
+ <%= button_tag name: 'save_label', :class => "btn btn-outline btn-sm edit-item" do %> + Save + <% end %> + <%= button_tag name: 'cancel_edit_label', class:'btn btn-danger btn-sm edit-item', type: 'button' do%> + Cancel <% end %>
- <% end %> +
+ <% end %> + + + + + +
+ <%# Update button %> + <%= button_tag name: 'edit_label', class:'btn btn-outline btn-sm edit_label display-item', type: 'button' do %> + Edit + <% end %> + <%= link_to(object_supplemental_file_path(section, file), title: 'Remove', method: :delete, class: "btn btn-danger btn-sm file-remove btn-confirmation") do %> + Delete + <% end %> +
+
+ <% end %> +
+<% end %> diff --git a/spec/support/supplemental_files_controller_examples.rb b/spec/support/supplemental_files_controller_examples.rb index cb1a5ac2f4..51612f0b81 100644 --- a/spec/support/supplemental_files_controller_examples.rb +++ b/spec/support/supplemental_files_controller_examples.rb @@ -264,7 +264,7 @@ end end - context "machine generated transcript" do + context "machine generated file" do let(:machine_param) { "machine_generated_#{supplemental_file.id}".to_sym } context "missing machine_generated tag" do let(:supplemental_file) { FactoryBot.create(:supplemental_file, :with_transcript_file, :with_transcript_tag, label: 'label') } From f8aa7e9ff8db958664b5cd4c55c512dbc1080d1f Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Thu, 4 Apr 2024 09:50:52 -0400 Subject: [PATCH 2/3] Increase gap between checkboxes and input fields --- app/assets/stylesheets/avalon.scss | 3 +++ app/views/media_objects/_supplemental_files_list.html.erb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/avalon.scss b/app/assets/stylesheets/avalon.scss index 1ca1a49888..9b5f4a5fec 100644 --- a/app/assets/stylesheets/avalon.scss +++ b/app/assets/stylesheets/avalon.scss @@ -932,6 +932,9 @@ h5.card-title { .file-remove { display: none; } + .form-group { + margin-bottom: 0.2rem; + } display: flex; } margin-top: 0.75rem; diff --git a/app/views/media_objects/_supplemental_files_list.html.erb b/app/views/media_objects/_supplemental_files_list.html.erb index 9a464379cd..a6b6389ac4 100644 --- a/app/views/media_objects/_supplemental_files_list.html.erb +++ b/app/views/media_objects/_supplemental_files_list.html.erb @@ -36,7 +36,7 @@ Unless required by applicable law or agreed to in writing, software distributed html: { method: "put", class: "supplemental-file-form edit-item", id: "form-#{file.id}" }, data: { file_id: file.id, masterfile_id: section.id } do |form| %>
-
+
<%= form.text_field :label, id: "supplemental_file_input_#{section.id}_#{file.id}", value: file.label %>
<% if tag == 'transcript' %> @@ -48,7 +48,7 @@ Unless required by applicable law or agreed to in writing, software distributed <% end %> <% if tag == 'caption' %> -
+
<%= form.text_field :language, id: "supplemental_file_language_#{section.id}_#{file.id}", value: LanguageTerm.find(file.language).text, class: "typeahead from-model form-control", data: { model: 'languageTerm', validate: false } %> From 2fb563b075ca96aa9cc8bbd06af4adfa9d156a81 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Fri, 5 Apr 2024 15:20:43 -0400 Subject: [PATCH 3/3] Adjust spacing between edit fields --- app/assets/stylesheets/avalon.scss | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/avalon.scss b/app/assets/stylesheets/avalon.scss index 9b5f4a5fec..c22e44685b 100644 --- a/app/assets/stylesheets/avalon.scss +++ b/app/assets/stylesheets/avalon.scss @@ -953,7 +953,7 @@ h5.card-title { } div.supplemental-file-data.is-editing:not(.edit-item) + div.supplemental-file-data { - margin-top: 2.6rem; + margin-top: 2.5rem; } .supplemental-file-form { @@ -977,6 +977,12 @@ h5.card-title { .form-control { height: 25px; } + + &.captions { + div.supplemental-file-data.is-editing:last-child { + margin-bottom: 1.75rem; + } + } } }