From bddbb36813ec4f2feb99f366259139f1cafa65e6 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Thu, 13 Oct 2022 09:19:03 +0100 Subject: [PATCH 1/7] remove red star from supplier --- app/views/spree/admin/products/new.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/spree/admin/products/new.html.haml b/app/views/spree/admin/products/new.html.haml index beec70cc5a..e7b212dfba 100644 --- a/app/views/spree/admin/products/new.html.haml +++ b/app/views/spree/admin/products/new.html.haml @@ -10,7 +10,6 @@ .eight.columns.alpha = f.field_container :supplier do = f.label :supplier_id, t(".supplier") - %span.required * = f.select :supplier_id, options_from_collection_for_select(@producers, :id, :name, @product.supplier_id), {}, { "data-controller": "tom-select", class: "primary" } = f.error_message_on :supplier .eight.columns.omega From f8af84d9d4921849cde77ac6c5c32e28f3924962 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Thu, 13 Oct 2022 09:21:59 +0100 Subject: [PATCH 2/7] remove red start from tax category form --- app/views/spree/admin/products/_tax_category_form.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/spree/admin/products/_tax_category_form.html.haml b/app/views/spree/admin/products/_tax_category_form.html.haml index 250ba8c832..5c8080ca3b 100644 --- a/app/views/spree/admin/products/_tax_category_form.html.haml +++ b/app/views/spree/admin/products/_tax_category_form.html.haml @@ -1,6 +1,5 @@ = f.field_container :tax_category_id do = f.label :tax_category_id, t(:tax_category) - %span.required * %br = f.collection_select(:tax_category_id, Spree::TaxCategory.all, :id, :name, {:include_blank => Spree::Config.products_require_tax_category ? false : t(:none)}, {:class => "select2 fullwidth"}) = f.error_message_on :tax_category_id From e3f157ebdd0c68bbdc8835d9b89b1c3764fb18d5 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Thu, 13 Oct 2022 10:47:33 +0100 Subject: [PATCH 3/7] remove empty option from unit size --- app/views/spree/admin/products/new.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/admin/products/new.html.haml b/app/views/spree/admin/products/new.html.haml index e7b212dfba..efdbb993e5 100644 --- a/app/views/spree/admin/products/new.html.haml +++ b/app/views/spree/admin/products/new.html.haml @@ -24,7 +24,7 @@ = f.field_container :units do = f.label :variant_unit_with_scale, t(".units") %span.required * - %select{id: 'product_variant_unit_with_scale', 'ng-model' => 'product.variant_unit_with_scale', 'ng-options' => 'unit[1] as unit[0] for unit in variant_unit_options',"data-controller": "tom-select", class: "primary"} + %select{id: 'product_variant_unit_with_scale', 'ng-model' => 'product.variant_unit_with_scale', 'ng-options' => 'unit[1] as unit[0] for unit in variant_unit_options', "data-controller": "tom-select","data-tom-select-options-value": '{"allowEmptyOption":false}', class: "primary"} %option{'value' => '', 'ng-hide' => "hasUnit(product)"} %input{ type: 'hidden', 'ng-value': 'product.variant_unit', "ng-init": "product.variant_unit='#{@product.variant_unit}'", name: 'product[variant_unit]' } %input{ type: 'hidden', 'ng-value': 'product.variant_unit_scale', "ng-init": "product.variant_unit_scale='#{@product.variant_unit_scale}'", name: 'product[variant_unit_scale]' } From 0000faab913fad315a6b6b9d825febac71931ab8 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Thu, 13 Oct 2022 11:40:27 +0100 Subject: [PATCH 4/7] render the error message when the unit value is not set --- app/views/spree/admin/products/new.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/spree/admin/products/new.html.haml b/app/views/spree/admin/products/new.html.haml index efdbb993e5..a19ed1bb35 100644 --- a/app/views/spree/admin/products/new.html.haml +++ b/app/views/spree/admin/products/new.html.haml @@ -35,6 +35,7 @@ %input.fullwidth{ id: 'product_unit_value_with_description', 'ng-model' => 'product.master.unit_value_with_description', :type => 'text', placeholder: "eg. 2", 'ng-disabled' => "!hasUnit(product)" } %input{ type: 'hidden', 'ng-value': 'product.master.unit_value', "ng-init": "product.master.unit_value='#{@product.master.unit_value}'", name: 'product[unit_value]' } %input{ type: 'hidden', 'ng-value': 'product.master.unit_description', "ng-init": "product.master.unit_description='#{@product.master.unit_description}'", name: 'product[unit_description]' } + = f.error_message_on :unit_value = render 'display_as', f: f .six.columns.omega{ 'ng-show' => "product.variant_unit_with_scale == 'items'" } = f.field_container :unit_name do From 955492bfddfe2dcba02fe635e47d560aa5a22be0 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Thu, 13 Oct 2022 11:42:23 +0100 Subject: [PATCH 5/7] show the error message when the variant unit is not selected --- app/views/spree/admin/products/new.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/spree/admin/products/new.html.haml b/app/views/spree/admin/products/new.html.haml index a19ed1bb35..97c5e0dbf3 100644 --- a/app/views/spree/admin/products/new.html.haml +++ b/app/views/spree/admin/products/new.html.haml @@ -21,13 +21,14 @@ = f.error_message_on :name .sixteen.columns.alpha .eight.columns.alpha - = f.field_container :units do + = f.field_container :variant_unit do = f.label :variant_unit_with_scale, t(".units") %span.required * %select{id: 'product_variant_unit_with_scale', 'ng-model' => 'product.variant_unit_with_scale', 'ng-options' => 'unit[1] as unit[0] for unit in variant_unit_options', "data-controller": "tom-select","data-tom-select-options-value": '{"allowEmptyOption":false}', class: "primary"} %option{'value' => '', 'ng-hide' => "hasUnit(product)"} %input{ type: 'hidden', 'ng-value': 'product.variant_unit', "ng-init": "product.variant_unit='#{@product.variant_unit}'", name: 'product[variant_unit]' } %input{ type: 'hidden', 'ng-value': 'product.variant_unit_scale', "ng-init": "product.variant_unit_scale='#{@product.variant_unit_scale}'", name: 'product[variant_unit_scale]' } + = f.error_message_on :variant_unit .two.columns = f.field_container :unit_value do = f.label :unit_value_with_description, t(".value"), 'ng-disabled' => "!hasUnit(product)" From 6a8c7b15dc5a65aa3bacb2cb30cbe67bd9f91d1e Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Thu, 13 Oct 2022 12:20:54 +0100 Subject: [PATCH 6/7] fix product category errors message in the form --- app/views/spree/admin/products/_primary_taxon_form.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/spree/admin/products/_primary_taxon_form.html.haml b/app/views/spree/admin/products/_primary_taxon_form.html.haml index d8a6b1715e..b5b8369866 100644 --- a/app/views/spree/admin/products/_primary_taxon_form.html.haml +++ b/app/views/spree/admin/products/_primary_taxon_form.html.haml @@ -1,6 +1,6 @@ -= f.field_container :primary_taxon_id do += f.field_container :primary_taxon do = f.label :primary_taxon_id, t('.product_category') %span.required * %br = f.collection_select(:primary_taxon_id, Spree::Taxon.order(:name), :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"}) - = f.error_message_on :primary_taxon_id + = f.error_message_on :primary_taxon From 96c6f58ba2726ea8baf5868331b830b58c76fda5 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Fri, 14 Oct 2022 03:23:18 +0100 Subject: [PATCH 7/7] fix test @/spec/system/admin/products_spec.rb:32 --- spec/system/admin/products_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index 0595ec2259..7918d52983 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -59,7 +59,7 @@ describe ' expect(page).to have_field 'product_on_demand', checked: true expect(page).to have_field 'product_tax_category_id', with: tax_category.id expect(page.find("div[id^='taTextElement']")).to have_content 'A description...' - expect(page.find("#product_units_field")).to have_content 'Weight (kg)' + expect(page.find("#product_variant_unit_field")).to have_content 'Weight (kg)' expect(page).to have_content "Name can't be blank" end