Add ability to translate server rules (#34494)
This commit is contained in:
parent
977164decc
commit
8c51a8ba94
17 changed files with 149 additions and 20 deletions
27
app/views/admin/rules/_translation_fields.html.haml
Normal file
27
app/views/admin/rules/_translation_fields.html.haml
Normal file
|
@ -0,0 +1,27 @@
|
|||
%tr.nested-fields
|
||||
%td
|
||||
.fields-row
|
||||
.fields-row__column.fields-group
|
||||
= f.input :language,
|
||||
collection: ui_languages,
|
||||
include_blank: false,
|
||||
label_method: ->(locale) { native_locale_name(locale) }
|
||||
|
||||
.fields-row__column.fields-group
|
||||
= f.hidden_field :id if f.object&.persisted? # Required so Rails doesn't put the field outside of the <tr/>
|
||||
= link_to_remove_association(f, class: 'table-action-link') do
|
||||
= safe_join([material_symbol('close'), t('filters.index.delete')])
|
||||
|
||||
.fields-group
|
||||
= f.input :text,
|
||||
label: I18n.t('simple_form.labels.rule.text'),
|
||||
hint: I18n.t('simple_form.hints.rule.text'),
|
||||
input_html: { lang: f.object&.language },
|
||||
wrapper: :with_block_label
|
||||
|
||||
.fields-group
|
||||
= f.input :hint,
|
||||
label: I18n.t('simple_form.labels.rule.hint'),
|
||||
hint: I18n.t('simple_form.hints.rule.hint'),
|
||||
input_html: { lang: f.object&.language },
|
||||
wrapper: :with_block_label
|
|
@ -6,5 +6,26 @@
|
|||
|
||||
= render form
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%h4= t('admin.rules.translations')
|
||||
|
||||
%p.hint= t('admin.rules.translations_explanation')
|
||||
|
||||
.table-wrapper
|
||||
%table.table.keywords-table
|
||||
%thead
|
||||
%tr
|
||||
%th= t('admin.rules.translation')
|
||||
%th
|
||||
%tbody
|
||||
= form.simple_fields_for :translations do |translation|
|
||||
= render 'translation_fields', f: translation
|
||||
%tfoot
|
||||
%tr
|
||||
%td{ colspan: 3 }
|
||||
= link_to_add_association form, :translations, class: 'table-action-link', partial: 'translation_fields', 'data-association-insertion-node': '.keywords-table tbody', 'data-association-insertion-method': 'append' do
|
||||
= safe_join([material_symbol('add'), t('admin.rules.add_translation')])
|
||||
|
||||
.actions
|
||||
= form.button :button, t('generic.save_changes'), type: :submit
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
|
||||
%ol.rules-list
|
||||
- @rules.each do |rule|
|
||||
- translation = rule.translation_for(I18n.locale.to_s)
|
||||
%li
|
||||
%button{ type: 'button', aria: { expanded: 'false' } }
|
||||
.rules-list__text= rule.text
|
||||
.rules-list__hint= rule.hint
|
||||
.rules-list__text= translation.text
|
||||
.rules-list__hint= translation.hint
|
||||
|
||||
.stacked-actions
|
||||
- accept_path = @invite_code.present? ? public_invite_url(invite_code: @invite_code, accept: @accept_token) : new_user_registration_path(accept: @accept_token)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue