From 2e2ff25ef731e4d53ce7285323046a46ce9f4c0a Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 28 Sep 2022 16:46:23 +1000 Subject: [PATCH] DRY up code Slightly. If we upgrade to Ruby 3.1 with hash value omission, this would be neater. If we could set a scope in the controller (https://stackoverflow.com/questions/6137960/rails-i18n-default-scope) it would be even neater. --- .../admin/enterprises/_new_form.html.haml | 32 +++++++++---------- app/views/admin/enterprises/new.html.haml | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/views/admin/enterprises/_new_form.html.haml b/app/views/admin/enterprises/_new_form.html.haml index f3526fd1f7..47746fa6ea 100644 --- a/app/views/admin/enterprises/_new_form.html.haml +++ b/app/views/admin/enterprises/_new_form.html.haml @@ -1,9 +1,9 @@ .row .three.columns.alpha - = f.label :name, t('admin.enterprises.form.primary_details.name') + = f.label :name, t('primary_details.name', scope: scope) %span.required * .nine.columns.omega - = f.text_field :name, { placeholder: t('admin.enterprises.form.primary_details.name_placeholder'), class: "fullwidth" } + = f.text_field :name, { placeholder: t('primary_details.name_placeholder', scope: scope), class: "fullwidth" } - if spree_current_user.admin? .row @@ -17,8 +17,8 @@ = f.hidden_field :owner_id, class: "select2 fullwidth", 'user-select' => 'Enterprise.owner' .row .three.columns.alpha - %label= t('admin.enterprises.form.primary_details.primary_producer') - %div{'ofn-with-tip' => t('admin.enterprises.form.primary_details.primary_producer_tip')} + %label= t('primary_details.primary_producer', scope: scope) + %div{'ofn-with-tip' => t('primary_details.primary_producer_tip', scope: scope)} %a= t('admin.whats_this') .five.columns.omega = f.check_box :is_primary_producer, 'ng-model' => 'Enterprise.is_primary_producer' @@ -28,42 +28,42 @@ .row .alpha.eleven.columns .three.columns.alpha - = f.label :sells, t('admin.enterprises.form.primary_details.sells') - %div{'ofn-with-tip' => t('admin.enterprises.form.primary_details.sells_tip')} + = f.label :sells, t('primary_details.sells', scope: scope) + %div{'ofn-with-tip' => t('primary_details.sells_tip', scope: scope)} %a What's this? .two.columns = f.radio_button :sells, "none", 'ng-model' => 'Enterprise.sells'   - = f.label :sells, t('admin.enterprises.form.primary_details.none'), value: "none" + = f.label :sells, t('primary_details.none', scope: scope), value: "none" .two.columns = f.radio_button :sells, "own", 'ng-model' => 'Enterprise.sells'   - = f.label :sells, t('admin.enterprises.form.primary_details.own'), value: "own" + = f.label :sells, t('primary_details.own', scope: scope), value: "own" .four.columns.omega = f.radio_button :sells, "any", 'ng-model' => 'Enterprise.sells'   - = f.label :sells, t('admin.enterprises.form.primary_details.any'), value: "any" + = f.label :sells, t('primary_details.any', scope: scope), value: "any" .row .alpha.three.columns = f.label :contact_name, t('.contact_name') .omega.nine.columns - = f.text_field :contact_name, { placeholder: t('admin.enterprises.form.contact.name_placeholder')} + = f.text_field :contact_name, { placeholder: t('contact.name_placeholder', scope: scope)} .row .alpha.three.columns - = f.label :email_address, t('admin.enterprises.form.contact.email_address') + = f.label :email_address, t('contact.email_address', scope: scope) .omega.nine.columns - = f.text_field :email_address, { placeholder: t('admin.enterprises.form.contact.email_address_placeholder'), "ng-model" => "Enterprise.email_address" } + = f.text_field :email_address, { placeholder: t('contact.email_address_placeholder', scope: scope), "ng-model" => "Enterprise.email_address" } .row .alpha.three.columns - = f.label :phone, t('admin.enterprises.form.contact.phone') + = f.label :phone, t('contact.phone', scope: scope) .omega.nine.columns - = f.text_field :phone, { placeholder: t('admin.enterprises.form.contact.phone_placeholder')} + = f.text_field :phone, { placeholder: t('contact.phone_placeholder', scope: scope)} .row .alpha.three.columns - = f.label :website, t('admin.enterprises.form.contact.website') + = f.label :website, t('contact.website', scope: scope) .omega.nine.columns - = f.text_field :website, { placeholder: t('admin.enterprises.form.contact.website_placeholder')} + = f.text_field :website, { placeholder: t('contact.website_placeholder', scope: scope)} = f.fields_for :address do |af| .row diff --git a/app/views/admin/enterprises/new.html.haml b/app/views/admin/enterprises/new.html.haml index 4cd0297362..26a34ad45f 100644 --- a/app/views/admin/enterprises/new.html.haml +++ b/app/views/admin/enterprises/new.html.haml @@ -17,4 +17,4 @@ = form_for [main_app, :admin, @enterprise], html: { "nav-check" => '', "nav-callback" => '' } do |f| .row .twelve.columns.fullwidth_inputs{ ng: { controller: "NewEnterpriseController" } } - = render 'new_form', f: f + = render 'new_form', f: f, scope: 'admin.enterprises.form'