Fix: prevent users from changing the author when a post is part of a post series (#20259)
* disable authors and co-authors selectors for series posts * add translations * fix constrant issues * add alternative text for icon --------- Co-authored-by: Mac Siri <mac@forem.com>
This commit is contained in:
parent
3bc1b242ce
commit
212ddf0265
6 changed files with 47 additions and 13 deletions
|
|
@ -150,6 +150,13 @@
|
|||
&::-ms-clear {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
background-color: #f2f2f2;
|
||||
color: #888888;
|
||||
pointer-events: none;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -46,3 +46,18 @@
|
|||
line-height: var(--lh-tight);
|
||||
}
|
||||
}
|
||||
|
||||
.disabled-info-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.disabled-info-icon {
|
||||
color: #666666;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.disabled-info-text {
|
||||
color: #666666;
|
||||
text-align: left;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,22 +122,30 @@
|
|||
|
||||
<div class="crayons-field mb-4">
|
||||
<label for="user_id" class="crayons-field__label"><%= t("views.dashboard.article.author") %></label>
|
||||
<%= f.select :user_id, options_for_select(organization.users.pluck(:name, :id), article.user_id), {}, { class: "crayons-select" } %>
|
||||
<%= f.select :user_id, options_for_select(organization.users.pluck(:name, :id), article.user_id), {}, { class: "crayons-select #{article_series ? 'disabled': ''}", disabled: article_series } %>
|
||||
<%= f.hidden_field :from_dashboard, value: 1 %>
|
||||
<% if article_series %>
|
||||
<div class="disabled-info-container">
|
||||
<%= crayons_icon_tag("info", class: "disabled-info-icon", title: t("views.dashboard.article.icon")) %>
|
||||
<p class="disabled-info-text"><%= t("views.dashboard.article.series_author_change_warning") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-field mb-4">
|
||||
<label for="co_author_ids" class="crayons-field__label"><%= t("views.dashboard.article.co_authors") %></label>
|
||||
<div class="crayons-field">
|
||||
<%= f.text_field :co_author_ids_list,
|
||||
id: "article_#{article.id}_co_author_ids_list",
|
||||
class: "article_org_co_author_ids_list",
|
||||
data: {
|
||||
fetch_users: organization_members_path(organization.username, format: "json")
|
||||
} %>
|
||||
<% unless article_series %>
|
||||
<div class="crayons-field mb-4">
|
||||
<label for="co_author_ids" class="crayons-field__label"><%= t("views.dashboard.article.co_authors") %></label>
|
||||
<div class="crayons-field">
|
||||
<%= f.text_field :co_author_ids_list,
|
||||
id: "article_#{article.id}_co_author_ids_list",
|
||||
class: "article_org_co_author_ids_list",
|
||||
data: {
|
||||
fetch_users: organization_members_path(organization.username, format: "json")
|
||||
} %>
|
||||
</div>
|
||||
<%= f.hidden_field :from_dashboard, value: 1 %>
|
||||
</div>
|
||||
<%= f.hidden_field :from_dashboard, value: 1 %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<button type="submit" class="crayons-btn"><%= t("views.dashboard.article.save") %></button>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<div class="crayons-card mb-6 mt-3">
|
||||
<% @articles.each do |article| %>
|
||||
<% if params[:which] == "organization" %>
|
||||
<%= render "dashboard_article_row", article: article, organization: article.organization, org_admin: true, manage_view: false %>
|
||||
<%= render "dashboard_article_row", article: article, organization: article.organization, org_admin: true, manage_view: false, article_series: article.collection.present? %>
|
||||
<% else %>
|
||||
<%= render "dashboard_article_row", article: article, organization: nil, org_admin: false, manage_view: false %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ en:
|
|||
unarchive: Unarchive post
|
||||
author: Author
|
||||
co_authors: Co-authors
|
||||
series_author_change_warning: No author changes allowed for series posts.
|
||||
icon: Details
|
||||
author_is: 'AUTHOR: '
|
||||
save: Save
|
||||
submit: Submit author change
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ fr:
|
|||
unarchive: Unarchive post
|
||||
author: Author
|
||||
co_authors: Co-authors
|
||||
series_author_change_warning: No author changes allowed for series posts.
|
||||
icon: Details
|
||||
author_is: 'AUTHOR: '
|
||||
save: Save
|
||||
submit: Submit author change
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue