Skip to content

Commit

Permalink
AO3-5865 Reorganise 'Edit multiple works' form (#4655)
Browse files Browse the repository at this point in the history
* AO3-5865 Reorganize edit multiple works form

* AO3-5865 Update capitalization on related labels

* ERBLint autocorrect to resolve style issues

* Update relevant tests to match new case format

* Correct additional linter errors

* Convert related text lines to i18n

* Fix unexpected (s)

* Appease linter

* Update app/views/works/_work_form_associations_language.html.erb

Co-authored-by: Brian Austin <13002992+brianjaustin@users.noreply.github.com>

* Fix work skin test to reflect updated capitalisation

* Prefer single-quoted strings inside interpolations

---------

Co-authored-by: Brian Austin <13002992+brianjaustin@users.noreply.github.com>
  • Loading branch information
denerose and brianjaustin authored Apr 5, 2024
1 parent 139b76b commit bed484d
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 48 deletions.
2 changes: 1 addition & 1 deletion app/views/collectibles/_collectible_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</dd>
<% end %>
<dt><%= form.label :collections_to_add, ts("Add To Collections") %> <%= link_to_help "add-collectible-to-collection" %></dt>
<dt><%= form.label :collections_to_add, ts("Add to collections") %> <%= link_to_help "add-collectible-to-collection" %></dt>
<dd title="add to collection">
<%= form.text_field :collections_to_add, autocomplete_options("open_collection_names") %>
</dd>
4 changes: 2 additions & 2 deletions app/views/pseuds/_byline.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
<% end %>

<dt class="byline coauthors">
<%= label_tag "co-authors-options-show", ts("Add co-creators?") %>
<%= label_tag "co-authors-options-show", t("works.byline.show_co-creator_options") %>
</dt>
<dd class="byline coauthors">
<%= check_box_tag "co-authors-options-show", "1", object.creatorships.any?(&:ambiguous?), class: "toggle_formfield" %>
<fieldset id="co-authors-options" title="<%= ts("Add co-creators") %>">
<fieldset id="co-authors-options" title="<%= t("works.byline.add_co-creators") %>">
<%= creator_form.text_field :byline, autocomplete_options("pseud", size: 50).merge(id: "pseud_byline") %>
<% object.creatorships.each do |creatorship| %>
<% next unless creatorship.ambiguous? %>
Expand Down
10 changes: 5 additions & 5 deletions app/views/works/_standard_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<%= render "work_form_tags", include_blank: false %>

<fieldset class="preface" role="article">
<legend><%= ts("Preface") %></legend>
<h3 class="landmark heading"><%= ts("Preface") %></h3>
<legend><%= t("works.preface.title") %></legend>
<h3 class="landmark heading"><%= ts("work.preface.title") %></h3>
<dl>
<dt class="title required">
<%= f.label :title, ts("Work Title") + "*" %>
Expand Down Expand Up @@ -43,8 +43,8 @@
</fieldset>

<fieldset id="associations" role="article">
<legend><%= ts("Associations") %></legend>
<h3 class="landmark heading"><%= ts("Associations") %></h3>
<legend><%= t("works.associations.title") %></legend>
<h3 class="landmark heading"><%= t("works.associations.title") %></h3>
<dl>
<% @assignments = get_open_assignments(current_user) %>
<% if @assignments.any? || @work.challenge_assignments.any? %>
Expand Down Expand Up @@ -243,7 +243,7 @@
<%= render "work_form_associations_language", f: f %>

<dt class="skin">
<%= f.label :work_skin_id, ts("Select Work Skin") %>
<%= f.label :work_skin_id, t("works.skin.select") %>
<%= link_to_help "work-skins" %>
</dt>
<dd class="skin">
Expand Down
2 changes: 1 addition & 1 deletion app/views/works/_work_form_associations_language.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% # expects local variable f %>
<dt class="language required">
<%= f.label :language_id, ts("Choose a language") + "*" %>
<%= f.label :language_id, "#{t('works.associations.language.choose')} *" %>
<%= link_to_help "languages-help" %>
</dt>
<dd class="language required">
Expand Down
4 changes: 2 additions & 2 deletions app/views/works/_work_form_pseuds.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<% if has_cocreators %>
<%= label_tag :remove_me, class: "action" do %>
<%= check_box_tag :remove_me, "1", false %>
<%= ts("Remove Me As Co-Creator") %>
<%= ts("Remove me as co-creator") %>
<% end %>
<% end %>
</dd>
<% end %>
<dt><%= form.label :pseuds_to_add, ts("Add Co-Creators") %></dt>
<dt><%= form.label :pseuds_to_add, t("works.byline.add_co-creators") %></dt>
<dd><%= form.text_field :pseuds_to_add, autocomplete_options("pseud", data: { autocomplete_min_chars: 0 }) %></dd>
58 changes: 30 additions & 28 deletions app/views/works/edit_multiple.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,52 @@
<%= ts("Your edits will be applied to") %> <strong><%= ts("all") %></strong> <%= ts("of the following works:") %>
</p>

<%= render "works/work_abbreviated_list", :works => @works %>
<%= render "works/work_abbreviated_list", works: @works %>

<%= form_for :work, :url => update_multiple_user_works_path(@user), method: :patch, :html => { :class => "post" } do |form| %>
<%= form_for :work, url: update_multiple_user_works_path(@user), method: :patch, html: { class: "verbose post" } do |form| %>
<p class="required notice">
<%= ts("* Required information") %>
<% @works.each do |work| %>
<%= hidden_field_tag "work_ids[]", work.id %>
<% end %>
</p>

<%= render 'work_form_tags', :include_blank => true %>

<fieldset>
<legend><%= ts("Associations") %></legend>
<h3 class="landmark heading"><%= ts("Associations") %></h3>
<%= render "work_form_tags", include_blank: true %>
<fieldset class="preface" role="article">
<legend><%= t("works.preface.title") %></legend>
<h3 class="landmark heading"><%= t("works.preface.title") %></h3>
<dl>
<%= render "works/work_form_pseuds", :form => form, :works => @works %>
<%= render "collectibles/collectible_form", :form => form, :collectibles => @works %>
<%= render "works/work_form_pseuds", form: form, works: @works %>
</dl>
</fieldset>

<fieldset>
<legend><%= ts("Settings") %></legend>
<h3 class="landmark heading"><%= ts("Settings") %></h3>
<fieldset id="associations" role="article">
<legend><%= t("works.associations.title") %></legend>
<h3 class="landmark heading"><%= t("works.associations.title") %></h3>
<dl>
<dt><%= form.label :language_id, ts("Language") %> <%= link_to_help "languages-help" %></dt>
<%= render "collectibles/collectible_form", form: form, collectibles: @works %>
<dt><%= form.label :language_id, t("works.associations.language.choose") %> <%= link_to_help "languages-help" %></dt>
<dd>
<%= form.select :language_id, language_options_for_select(sorted_languages, "id"), { include_blank: true } %>
</dd>

<dt><%= form.label :work_skin_id, ts("Select Work Skin") %> <%= link_to_help "work-skins" %></dt>
<dt><%= form.label :work_skin_id, t("works.skin.select") %> <%= link_to_help "work-skins" %></dt>
<dd>
<%= form.collection_select :work_skin_id, WorkSkin.approved_or_owned_by(current_user).order(:title), :id, :title,
{:include_blank => true} %>
{ include_blank: true } %>
</dd>
</dl>
</fieldset>

<fieldset class="privacy" role="article">
<legend><%= t("works.permissions.privacy") %></legend>
<h3 class="landmark heading"><%= t("works.permissions.privacy") %></h3>
<dl>

<dt><%= t("works.permissions.visibility.label") %> <%= link_to_help "registered-users" %></dt>
<dd>
<fieldset>
<%=
radio_button_list(form, :restricted, [
<%= radio_button_list(form, :restricted, [
["", t("works.permissions.visibility.keep_current")],
["1", t("works.permissions.visibility.multiple_works_restricted")],
["0", t("works.permissions.visibility.unrestricted")]
Expand All @@ -63,8 +68,7 @@
<dt><%= t("comments.commentable.permissions.moderated_commenting.label") %><%= link_to_help "comments-moderated" %></dt>
<dd>
<fieldset>
<%=
radio_button_list(form, :moderated_commenting_enabled, [
<%= radio_button_list(form, :moderated_commenting_enabled, [
["", t("comments.commentable.permissions.moderated_commenting.keep_current")],
["1", t("comments.commentable.permissions.moderated_commenting.enable")],
["0", t("comments.commentable.permissions.moderated_commenting.disable")]
Expand All @@ -79,14 +83,12 @@
</dt>
<dd>
<fieldset>
<%=
radio_button_list(form, :comment_permissions, [
["", t("comments.commentable.permissions.options.keep_current")],
[:enable_all, t("comments.commentable.permissions.options.enable_all")],
[:disable_anon, t("comments.commentable.permissions.options.disable_anon")],
[:disable_all, t("comments.commentable.permissions.options.disable_all")]
])
%>
<%= radio_button_list(form, :comment_permissions, [
["", t("comments.commentable.permissions.options.keep_current")],
[:enable_all, t("comments.commentable.permissions.options.enable_all")],
[:disable_anon, t("comments.commentable.permissions.options.disable_anon")],
[:disable_all, t("comments.commentable.permissions.options.disable_all")]
]) %>
</fieldset>
</dd>
</dl>
Expand All @@ -97,7 +99,7 @@
(If you leave a field blank it will remain unchanged.)") %>
</p>

<p class="submit actions"><%= submit_tag ts("Update All Works"), data: {confirm: ts("Are you sure? Remember this will replace all existing values!")} %></p>
<p class="submit actions"><%= submit_tag ts("Update All Works"), data: { confirm: ts("Are you sure? Remember this will replace all existing values!") } %></p>

<% end %>
<!--/content-->
4 changes: 2 additions & 2 deletions app/views/works/edit_tags.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

<% if logged_in_as_admin? %>
<fieldset role="article">
<legend><%= ts('Associations') %></legend>
<h3 class="landmark heading"><%= ts('Associations') %></h3>
<legend><%= t("works.associations.title") %></legend>
<h3 class="landmark heading"><%= t("works.associations.title") %></h3>
<dl>
<%= render 'work_form_associations_language', f: f %>
</dl>
Expand Down
13 changes: 12 additions & 1 deletion config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ en:
disable: Disable comment moderation
enable: Enable comment moderation
keep_current: Keep current comment moderation settings
label: Comment Moderation
label: Comment moderation
options:
disable_all: No one can comment
disable_anon: Only registered users can comment
Expand Down Expand Up @@ -901,6 +901,13 @@ en:
continue: Yes, Continue
preferences: Set your preferences now
page_title: Adult Content Warning
associations:
language:
choose: Choose a language
title: Associations
byline:
add_co-creators: Add co-creators
show_co-creator_options: Add co-creators?
meta:
original_creators:
one: 'Original Creator ID:'
Expand All @@ -914,13 +921,17 @@ en:
multiple_works_restricted: Only show to registered users
restricted: Only show your work to registered users
unrestricted: Show to all
preface:
title: Preface
search_box:
a11y_label: Work
label: Work Search
submit: Search
tooltip_label: 'tip:'
show:
unposted_deletion_notice_html: This work is a draft and has not been posted. The draft will be <strong>scheduled for deletion</strong> on %{deletion_date}.
skin:
select: Select work skin
work_approved_children:
inspired_by:
restricted_html: "[Restricted Work] by %{creator_link} (Log in to access.)"
Expand Down
2 changes: 1 addition & 1 deletion features/works/work_edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Feature: Edit Works
Then I should see "Lead Author's Work Skin" within "#work_work_skin_id"
And I should see "Coauthor's Work Skin" within "#work_work_skin_id"
And I should not see "Random User's Work Skin" within "#work_work_skin_id"
When I select "Coauthor's Work Skin" from "Select Work Skin"
When I select "Coauthor's Work Skin" from "Select work skin"
And I press "Post"
Then I should see "Work was successfully updated"

Expand Down
10 changes: 5 additions & 5 deletions features/works/work_edit_multiple.feature
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Feature: Edit Multiple Works
And the user "coauthor" allows co-creators
And I am logged in as "lead_author"
And I edit the multiple works "First Shared" and "Second Shared"
When I fill in "Add Co-Creators" with "coauthor"
When I fill in "Add co-creators" with "coauthor"
And I press "Update All Works"
Then I should see "Your edits were put through"
And 2 emails should be delivered to "coauthor"
Expand All @@ -200,7 +200,7 @@ Feature: Edit Multiple Works
And the user "coauthor" allows co-creators
And I am logged in as "lead_author"
And I edit multiple works coauthored as "lead_author" with "coauthor"
When I check "Remove Me As Co-Creator"
When I check "Remove me as co-creator"
And I press "Update All Works"
Then I should see "Your edits were put through"
When I view the work "Shared Work 1"
Expand All @@ -218,7 +218,7 @@ Feature: Edit Multiple Works
And I select "Solo" for editing
And I select "Shared" for editing
And I press "Edit"
And I check "Remove Me As Co-Creator"
And I check "Remove me as co-creator"
And I press "Update All Works"
Then I should see "You cannot remove yourself as co-creator of the work Solo because you are the only listed creator."
When I view the work "Solo"
Expand All @@ -236,15 +236,15 @@ Feature: Edit Multiple Works
And I edit multiple works coauthored as "lead_author" with "coauthor"
Then I should see "Lead Author's Work Skin" within "#work_work_skin_id"
And I should not see "Coauthor's Work Skin" within "#work_work_skin_id"
When I select "Lead Author's Work Skin" from "Select Work Skin"
When I select "Lead Author's Work Skin" from "Select work skin"
And I press "Update All Works"
Then I should see "Your edits were put through"

Scenario: I can add several works to a collection at once
Given I am logged in as "author"
And I create the collection "MyCollection"
And I edit the multiple works "Glorious" and "Excellent"
When I fill in "Add To Collections" with "MyCollection"
When I fill in "Add to collections" with "MyCollection"
And I press "Update All Works"
Then I should see "Your edits were put through"
When I view the work "Glorious"
Expand Down

0 comments on commit bed484d

Please sign in to comment.