From d08665be5f21565263fc4cfbf4167ff3fbe0ae4e Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 25 Apr 2024 11:06:29 -0400 Subject: [PATCH] Use shared form partial for `admin/rules` views --- app/views/admin/rules/_form.html.haml | 7 +++++++ app/views/admin/rules/edit.html.haml | 10 +++------- app/views/admin/rules/index.html.haml | 10 +++------- 3 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 app/views/admin/rules/_form.html.haml diff --git a/app/views/admin/rules/_form.html.haml b/app/views/admin/rules/_form.html.haml new file mode 100644 index 0000000000..9fc54e2887 --- /dev/null +++ b/app/views/admin/rules/_form.html.haml @@ -0,0 +1,7 @@ +.fields-group + = form.input :text, + wrapper: :with_block_label + +.fields-group + = form.input :hint, + wrapper: :with_block_label diff --git a/app/views/admin/rules/edit.html.haml b/app/views/admin/rules/edit.html.haml index 77815588d2..9e3c915812 100644 --- a/app/views/admin/rules/edit.html.haml +++ b/app/views/admin/rules/edit.html.haml @@ -1,14 +1,10 @@ - content_for :page_title do = t('admin.rules.edit') -= simple_form_for @rule, url: admin_rule_path(@rule) do |f| += simple_form_for @rule, url: admin_rule_path(@rule) do |form| = render 'shared/error_messages', object: @rule - .fields-group - = f.input :text, wrapper: :with_block_label - - .fields-group - = f.input :hint, wrapper: :with_block_label + = render form .actions - = f.button :button, t('generic.save_changes'), type: :submit + = form.button :button, t('generic.save_changes'), type: :submit diff --git a/app/views/admin/rules/index.html.haml b/app/views/admin/rules/index.html.haml index dd15ce03c0..5a2789edcf 100644 --- a/app/views/admin/rules/index.html.haml +++ b/app/views/admin/rules/index.html.haml @@ -6,17 +6,13 @@ %hr.spacer/ - if can? :create, :rule - = simple_form_for @rule, url: admin_rules_path do |f| + = simple_form_for @rule, url: admin_rules_path do |form| = render 'shared/error_messages', object: @rule - .fields-group - = f.input :text, wrapper: :with_block_label - - .fields-group - = f.input :hint, wrapper: :with_block_label + = render form .actions - = f.button :button, t('admin.rules.add_new'), type: :submit + = form.button :button, t('admin.rules.add_new'), type: :submit %hr.spacer/