cirandas.net

commit 4b5b0c6d5c6db8f5b2100fb36df436ba5da3289b

Author: Hugo Melo <hugo@riseup.net>

Warn users about changing group product name creating divergence with
supplier name

%!v(PANIC=String method: strings: negative Repeat count)


diff --git a/plugins/suppliers/locales/en-US.yml b/plugins/suppliers/locales/en-US.yml
index 3d0b88aa9d30e326bb040eb8cdf7cab109cc968b..ff1a9f70de96f664bbadd2dc298c46e800391a07 100644
--- a/plugins/suppliers/locales/en-US.yml
+++ b/plugins/suppliers/locales/en-US.yml
@@ -225,6 +225,8 @@         validation_error_supplier_id: "Validation error: Please, fill the field Supplier"
         validation_error_name: "Validation error: Please, fill the field Name"
         validation_error_supplier_price: "Validation error: Please, fill the field Supplier Price"
         validation_error_margin_percentage: "Validation error: Please, fill the field Margin"
+        supplier_product_name: "Product name to the supplier: "
+        name_change_warning: "WARNING: Changing the product name doesn't change the supplier product name. To avoid issues with orders history and name divergences between ordered and delived, prefer to create another product with the right name and disable this."
         import:
           action: "Import spreadsheet"
           help: "Format your spreadsheet to have exactly the fields bellow with header. Then, save it choosing the CSV file type (.csv extension)."




diff --git a/plugins/suppliers/locales/pt-BR.yml b/plugins/suppliers/locales/pt-BR.yml
index 6011f80e53add5dd209be85071eb5156de39bc52..a8b15602ebee8efcb57e1edc3fefd23fb35500f9 100644
--- a/plugins/suppliers/locales/pt-BR.yml
+++ b/plugins/suppliers/locales/pt-BR.yml
@@ -231,6 +231,8 @@         validation_error_supplier_id: "Erro de validação: Por favor preencher o campo Fornecedor"
         validation_error_name: "Erro de validação: Por favor preencher o campo Nome"
         validation_error_supplier_price: "Erro de validação: Por favor preencher o campo preço do fornecedor"
         validation_error_margin_percentage: "Erro de validação: Por favor preencher o campo margem"
+        supplier_product_name: "Nome do produto para o fornecedor: "
+        name_change_warning: "CUIDADO: Ao mudar o nome do produto, ele continua igual para o fornecedor. Para não estragar o histórico de pedidos e criar divergências entre o produto pedido e o entregue, prefira criar um novo produto com o nome correto e desabilitar esse."
         import:
           action: "Importar planilha"
           help: "Formate sua planilha para que tenha exatamente os campos abaixo com cabeçalho. Depois, salve-a escolhendo o tipo de arquivo CSV (extensão .csv)."




diff --git a/plugins/suppliers/public/javascripts/views/product-item.tag.slim b/plugins/suppliers/public/javascripts/views/product-item.tag.slim
index 1b598696fe28901a9be46196164a3600d318e9f9..bd2eb840f8e3994abcf445ea2f50dff4d26bb162 100644
--- a/plugins/suppliers/public/javascripts/views/product-item.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/product-item.tag.slim
@@ -11,9 +11,8 @@     .switch show="{product.edition}"
       input.cmn-toggle.cmn-toggle-round type="checkbox" name='available' checked="{product.available}" id="{'available-'+product.id}"
       label for="{'available-'+product.id}"
   .name
-    span show="{!product.edition}"
+    span
       |{product.name}
-    input type="text" value="{product.name}" show="{product.edition}" name='name'
   .supplier
     .overflow
       |{supplier}




diff --git a/plugins/suppliers/public/javascripts/views/product-modal.tag.slim b/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
index 424b2e658e7bc4223f05097a8df0146dda4b59d2..fab4833563d1bb028e1a020df56485580e474f1b 100644
--- a/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
@@ -29,8 +29,13 @@
               .form-group
                 label for="p-name"
                   |{t("views.product.product_name")}
+                small.title if="{product.id}"
+                  |{t("views.product.name_change_warning")}
                 input type="text" value="{product.name}" id="p-name"
-
+                small.supplier_product_name show="{product.supplier_product_name != product.name}"
+                  strong
+                    |{t("views.product.supplier_product_name")}
+                  |{this.product.supplier_product_name}
               .form-group
                 select name="supplier_id" id="p-supplier_id" if="{!product.id}"
                   option each="{id,name in parent.active_suppliers}" value="{id}"




diff --git a/plugins/suppliers/public/stylesheets/product.scss b/plugins/suppliers/public/stylesheets/product.scss
index 42b12fbeedea859f36f57720fd504d68850fd480..5f6871269502ba0a02044c818c30c87c7e135557 100644
--- a/plugins/suppliers/public/stylesheets/product.scss
+++ b/plugins/suppliers/public/stylesheets/product.scss
@@ -394,6 +394,12 @@           width: 100%;
           min-height: 100px;
         }
       }
+      small.title {
+        color: orange;
+      }
+      small.supplier_product_name {
+        color: red;
+      }
       .change_image {
         position: relative;
         top: -30px;




diff --git a/plugins/suppliers/serializers/suppliers_plugin/product_serializer.rb b/plugins/suppliers/serializers/suppliers_plugin/product_serializer.rb
index 22e7093787ee612b1e6971dae0e11ce46bfa8eba..76210bdea4fc1b5716391c79ba8d9323db5e7f4e 100644
--- a/plugins/suppliers/serializers/suppliers_plugin/product_serializer.rb
+++ b/plugins/suppliers/serializers/suppliers_plugin/product_serializer.rb
@@ -10,6 +10,7 @@
     attribute :unit_id
     attribute :price
     attribute :supplier_price
+    attribute :supplier_product_name
     attribute :margin_percentage
 
     attribute :stored
@@ -32,6 +33,10 @@       product[:unit_id] || product[:from_product_unit_id]
     end
     def supplier_price
       product[:from_product_price] || product.supplier_price
+    end
+
+    def supplier_product_name
+      product[:from_product_name] || product.supplier_product_name
     end
 
     def available