diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c1487289a78..10d6b126d3a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -362,8 +362,8 @@ module ApplicationHelper back_url end - def check_all_links(form_id = nil) - render(OpenProject::Common::CheckAllComponent.new(checkable_id: form_id)) + def check_all_links(form_id = nil, &) + render(OpenProject::Common::CheckAllComponent.new(checkable_id: form_id), &) end def current_layout diff --git a/app/views/roles/_permissions.html.erb b/app/views/roles/_permissions.html.erb index b94b8ce1997..e66f3ec9982 100644 --- a/app/views/roles/_permissions.html.erb +++ b/app/views/roles/_permissions.html.erb @@ -27,17 +27,13 @@ See COPYRIGHT and LICENSE files for more details. ++#%> <% permissions.each do |mod, mod_permissions| %> - <% global_prefix = show_global_role ? "fieldset--global--" : "fieldset--" %> - <% module_name = mod.blank? ? "fieldset--global--#{Project.model_name.human.downcase.tr(' ', '_')}" : "#{global_prefix}#{l_or_humanize(mod, prefix: 'project_module_').downcase.tr(' ', '_')}" %> - <% module_id = module_name.parameterize %> + <% module_name = mod.blank? ? Project.model_name.param_key : l_or_humanize(mod, prefix: "project_module_").downcase.tr(" ", "_") %> + <% module_title = show_global_role && mod.blank? ? t(:label_global) : permission_header_for_project_module(mod) %> + <% section_id = "#{'global-' if show_global_role}#{module_name.parameterize}-section" %> - <%= render Primer::OpenProject::CollapsibleSection.new(id: module_id, display: :block, mb: 3) do |section| %> + <%= render Primer::OpenProject::CollapsibleSection.new(id: section_id, display: :block, mb: 3) do |section| %> <% section.with_title(tag: :h3) do %> - <% if show_global_role && mod.blank? %> - <%= t(:label_global) %> - <% else %> - <%= permission_header_for_project_module(mod) %> - <% end %> + <%= module_title %> <% end %> <% if I18n.exists?("permission_header_explanation", scope: mod) %> @@ -47,7 +43,12 @@ See COPYRIGHT and LICENSE files for more details. <% end %> <% section.with_additional_information do %> - <%= check_all_links module_id %> + <%= + check_all_links section_id do |links| + links.with_check_all_button.with_tooltip(text: t(".section_check_all_label", module: module_title)) + links.with_uncheck_all_button.with_tooltip(text: t(".section_uncheck_all_label", module: module_title)) + end + %> <% end %> <% section.with_collapsible_content(classes: "-columns-2", data: { controller: "checkable" }) do %> diff --git a/app/views/roles/report.html.erb b/app/views/roles/report.html.erb index ee7414a38b0..8d26da0aeed 100644 --- a/app/views/roles/report.html.erb +++ b/app/views/roles/report.html.erb @@ -48,16 +48,22 @@ See COPYRIGHT and LICENSE files for more details. <%= hidden_field_tag "permissions[0]", "", id: nil %> <% group_permissions_by_module(@permissions).each do |mod, mod_permissions| %> - <% module_name = mod.blank? ? "form--#{I18n.t('attributes.project')}" : "form--#{l_or_humanize(mod, prefix: 'project_module_').tr(' ', '_')}" %> - <% escaped_name = module_name.parameterize %> + <% module_name = mod.blank? ? Project.model_name.param_key : l_or_humanize(mod, prefix: "project_module_").tr(" ", "_") %> + <% module_title = permission_header_for_project_module(mod) %> + <% section_id = "#{module_name.parameterize}-section" %> - <%= render Primer::OpenProject::CollapsibleSection.new(id: escaped_name, display: :block, mb: 3) do |section| %> + <%= render Primer::OpenProject::CollapsibleSection.new(id: section_id, display: :block, mb: 3) do |section| %> <% section.with_title do %> - <%= permission_header_for_project_module(mod) %> + <%= module_title %> <% end %> <% section.with_additional_information do %> - <%= check_all_links escaped_name %> + <%= + check_all_links section_id do |links| + links.with_check_all_button.with_tooltip(text: t(".matrix_check_all_label", module: module_title)) + links.with_uncheck_all_button.with_tooltip(text: t(".matrix_uncheck_all_label", module: module_title)) + end + %> <% end %> <% section.with_collapsible_content do %> @@ -66,8 +72,11 @@ See COPYRIGHT and LICENSE files for more details.
|
-
+
- <%= render(Primer::BaseComponent.new(tag: :div, display: :inline_flex, align_items: :center)) do %>
- <%= render(Primer::Beta::Text.new(mr: 1)) do %>
- <%= role.name %>
- <%= render(Primer::Beta::Label.new(scheme: :secondary)) { t(:label_builtin) } if role.builtin? %>
- <% end %>
+ <%=
+ render(
+ Primer::BaseComponent.new(
+ tag: :div,
+ display: :flex,
+ align_items: :center,
+ classes: "gap-1",
+ ml: 1,
+ mr: 2
+ )
+ ) do
+ %>
<%=
render(
Primer::Beta::IconButton.new(
scheme: :invisible,
size: :small,
icon: :check,
- tooltip_direction: :se,
+ tooltip_direction: :sw,
aria: {
- label: t(:label_check_uncheck_all_in_column)
+ label: t(".matrix_check_uncheck_all_in_col_label_html", module: module_title, role: role.name)
},
data: {
action: "checkable#toggleSelection",
@@ -112,6 +128,10 @@ See COPYRIGHT and LICENSE files for more details.
)
)
%>
+ <%= render(Primer::Beta::Truncate.new(flex: 1)) do %>
+ <%= role.name %>
+ <%= render(Primer::Beta::Label.new(scheme: :secondary)) { t(:label_builtin) } if role.builtin? %>
+ <% end %>
<% end %>
- <%= render(Primer::BaseComponent.new(tag: :div, display: :inline_flex, align_items: :center)) do %>
+ |
+ <%=
+ render(
+ Primer::BaseComponent.new(
+ tag: :div,
+ display: :flex,
+ align_items: :center,
+ data: { controller: "truncation" },
+ classes: "gap-1",
+ ml: 1,
+ mr: 3
+ )
+ ) do
+ %>
<%=
render(
Primer::Beta::IconButton.new(
@@ -132,7 +165,7 @@ See COPYRIGHT and LICENSE files for more details.
icon: :check,
tooltip_direction: :sw,
aria: {
- label: t(:label_check_uncheck_all_in_row)
+ label: t(".matrix_check_uncheck_all_in_row_label_html", permission: humanized_permission_name)
},
data: {
action: "checkable#toggleSelection",
@@ -142,26 +175,49 @@ See COPYRIGHT and LICENSE files for more details.
)
)
%>
- <%= render(Primer::Beta::Text.new(ml: 1)) do %>
- <%= l_or_humanize(permission.name, prefix: "permission_") %>
- <% end %>
+ <%=
+ render(
+ Primer::Beta::Truncate.new(
+ data: { truncation_target: "truncate" },
+ flex: 1
+ )
+ ) do
+ humanized_permission_name
+ end
+ %>
+ <%=
+ render(
+ Primer::Alpha::HiddenTextExpander.new(
+ hidden: true,
+ aria: { label: t(:"js.label_expand_text") },
+ data: { truncation_target: "expander" }
+ )
+ )
+ %>
<% end %>
-
- <% @roles.each do |role| %>
+ |
+ <% @roles.each.with_index do |role, i| %>
<% if setable_permissions(role).include?(permission) %>
<%=
- check_box_tag(
- "permissions[#{role.id}][]",
- permission.name,
- role.permissions.include?(permission.name),
- id: nil,
- data: {
- checkable_target: "checkbox",
- role: role.id,
- permission: permission.name
- }
- )
+ render(Primer::BaseComponent.new(tag: :div, display: :flex, align_items: :center, mx: 1)) do
+ render(
+ Primer::Alpha::CheckBox.new(
+ scheme: :array,
+ name: "permissions[#{role.id}]",
+ id: "permissions_#{role.id}_#{permission.name}", # See BUG https://github.com/primer/view_components/issues/3811
+ value: permission.name,
+ checked: role.permissions.include?(permission.name),
+ label: t(".matrix_checkbox_label", permission: humanized_permission_name, role: role.name),
+ visually_hide_label: true,
+ data: {
+ checkable_target: "checkbox",
+ role: role.id,
+ permission: permission.name
+ }
+ )
+ )
+ end
%>
<% end %>
|
diff --git a/app/views/workflows/_form.html.erb b/app/views/workflows/_form.html.erb
index b60d1afe6cc..c79e45a907d 100644
--- a/app/views/workflows/_form.html.erb
+++ b/app/views/workflows/_form.html.erb
@@ -43,6 +43,9 @@ See COPYRIGHT and LICENSE files for more details.
|
|---|