diff options
author | Matt Jankowski <matt@jankowski.online> | 2023-09-28 10:36:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-28 16:36:24 +0200 |
commit | 89a17878ef7c6e1b5fae847ee293a7dcfc43c305 (patch) | |
tree | 0edf129cfa73ac100697402bd157de7661ccf99c /app/views/admin | |
parent | f9eefb27855d0b6d73aec430f8cf6ece7f99bf88 (diff) |
Fix haml-lint `InstanceVariables` rule for admin/roles/_form (#26063)
Diffstat (limited to 'app/views/admin')
-rw-r--r-- | app/views/admin/roles/_form.html.haml | 52 | ||||
-rw-r--r-- | app/views/admin/roles/edit.html.haml | 5 | ||||
-rw-r--r-- | app/views/admin/roles/new.html.haml | 5 |
3 files changed, 32 insertions, 30 deletions
diff --git a/app/views/admin/roles/_form.html.haml b/app/views/admin/roles/_form.html.haml index 3cbec0d0b57..2400332145b 100644 --- a/app/views/admin/roles/_form.html.haml +++ b/app/views/admin/roles/_form.html.haml @@ -1,40 +1,36 @@ -= simple_form_for @role, url: @role.new_record? ? admin_roles_path : admin_role_path(@role) do |f| - = render 'shared/error_messages', object: @role += render 'shared/error_messages', object: form.object - - if @role.everyone? - .flash-message.info - = t('admin.roles.everyone_full_description_html') - - else - .fields-group - = f.input :name, wrapper: :with_label - - - unless current_user.role.id == @role.id - .fields-group - = f.input :position, wrapper: :with_label, input_html: { max: current_user.role.position - 1 } +- if form.object.everyone? + .flash-message.info + = t('admin.roles.everyone_full_description_html') +- else + .fields-group + = form.input :name, wrapper: :with_label + - unless current_user.role == form.object .fields-group - = f.input :color, wrapper: :with_label, input_html: { placeholder: '#000000', type: 'color' } + = form.input :position, wrapper: :with_label, input_html: { max: current_user.role.position - 1 } - %hr.spacer/ + .fields-group + = form.input :color, wrapper: :with_label, input_html: { placeholder: '#000000', type: 'color' } - .fields-group - = f.input :highlighted, wrapper: :with_label + %hr.spacer/ - %hr.spacer/ + .fields-group + = form.input :highlighted, wrapper: :with_label - - unless current_user.role.id == @role.id + %hr.spacer/ - .field-group - .input.with_block_label - %label= t('simple_form.labels.user_role.permissions_as_keys') - %span.hint= t('simple_form.hints.user_role.permissions_as_keys') +- unless current_user.role == form.object - - (@role.everyone? ? UserRole::Flags::CATEGORIES.slice(:invites) : UserRole::Flags::CATEGORIES).each do |category, permissions| - %h4= t(category, scope: 'admin.roles.categories') + .field-group + .input.with_block_label + %label= t('simple_form.labels.user_role.permissions_as_keys') + %span.hint= t('simple_form.hints.user_role.permissions_as_keys') - = f.input :permissions_as_keys, collection: permissions, wrapper: :with_block_label, include_blank: false, label_method: ->(privilege) { safe_join([t("admin.roles.privileges.#{privilege}"), content_tag(:span, t("admin.roles.privileges.#{privilege}_description"), class: 'hint')]) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', label: false, hint: false, disabled: permissions.filter { |privilege| UserRole::FLAGS[privilege] & current_user.role.computed_permissions == 0 } + - (form.object.everyone? ? UserRole::Flags::CATEGORIES.slice(:invites) : UserRole::Flags::CATEGORIES).each do |category, permissions| + %h4= t(category, scope: 'admin.roles.categories') - %hr.spacer/ + = form.input :permissions_as_keys, collection: permissions, wrapper: :with_block_label, include_blank: false, label_method: ->(privilege) { safe_join([t("admin.roles.privileges.#{privilege}"), content_tag(:span, t("admin.roles.privileges.#{privilege}_description"), class: 'hint')]) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', label: false, hint: false, disabled: permissions.filter { |privilege| UserRole::FLAGS[privilege] & current_user.role.computed_permissions == 0 } - .actions - = f.button :button, @role.new_record? ? t('admin.roles.add_new') : t('generic.save_changes'), type: :submit + %hr.spacer/ diff --git a/app/views/admin/roles/edit.html.haml b/app/views/admin/roles/edit.html.haml index 5688b69b1fd..ec3f5b6fbe6 100644 --- a/app/views/admin/roles/edit.html.haml +++ b/app/views/admin/roles/edit.html.haml @@ -4,4 +4,7 @@ - content_for :heading_actions do = link_to t('admin.roles.delete'), admin_role_path(@role), method: :delete, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button button--destructive' if can?(:destroy, @role) -= render partial: 'form' += simple_form_for @role, url: admin_role_path(@role) do |form| + = render partial: 'form', object: form + .actions + = form.button :button, t('generic.save_changes'), type: :submit diff --git a/app/views/admin/roles/new.html.haml b/app/views/admin/roles/new.html.haml index 82107927185..6ca0c2137b1 100644 --- a/app/views/admin/roles/new.html.haml +++ b/app/views/admin/roles/new.html.haml @@ -1,4 +1,7 @@ - content_for :page_title do = t('admin.roles.add_new') -= render partial: 'form' += simple_form_for @role, url: admin_roles_path do |form| + = render partial: 'form', object: form + .actions + = form.button :button, t('admin.roles.add_new'), type: :submit |