<NME> display_as.js.coffee
<BEF> angular.module("ofn.admin").directive "ofnDisplayAs", (OptionValueNamer) ->
  link: (scope, element, attrs) ->

    scope.$watchCollection ->
      return [
        scope.$eval(attrs.ofnDisplayAs).unit_value_with_description
        scope.product.variant_unit_name
        scope.product.variant_unit_with_scale
      ]
    , ->
      [variant_unit, variant_unit_scale] = productUnitProperties()
      [unit_value, unit_description] = variantUnitProperties(variant_unit_scale)
      variant_object = 
        unit_value: unit_value
        unit_description: unit_description
        product:
          variant_unit_scale: variant_unit_scale
          variant_unit: variant_unit
          variant_unit_name: scope.product.variant_unit_name

      scope.placeholder_text = new OptionValueNamer(variant_object).name()

    productUnitProperties = ->
      # get relevant product properties
      if scope.product.variant_unit_with_scale?
        match = scope.product.variant_unit_with_scale.match(/^([^_]+)_([\d\.]+)$/)
        if match
          variant_unit = match[1]
          variant_unit_scale = parseFloat(match[2])
        else
          variant_unit = scope.product.variant_unit_with_scale
          variant_unit_scale = null
      else
        variant_unit = variant_unit_scale = null

      [variant_unit, variant_unit_scale]

    variantUnitProperties = (variant_unit_scale)->
      # get relevant variant properties
      variant = scope.$eval(attrs.ofnDisplayAs) # Like this so we can switch between 'master' and 'variant'
      if variant.unit_value_with_description?
        match = variant.unit_value_with_description.match(/^([\d\.]+(?= |$)|)( |)(.*)$/)
        if match
          unit_value  = parseFloat(match[1])
          unit_value  = null if isNaN(unit_value)
          unit_value *= variant_unit_scale if unit_value && variant_unit_scale
          unit_description = match[3]
      [unit_value, unit_description]
<MSG> Allow to change unit value for numbers with a comma separator

<DFF> @@ -39,9 +39,9 @@ angular.module("ofn.admin").directive "ofnDisplayAs", (OptionValueNamer) ->
       # get relevant variant properties
       variant = scope.$eval(attrs.ofnDisplayAs) # Like this so we can switch between 'master' and 'variant'
       if variant.unit_value_with_description?
-        match = variant.unit_value_with_description.match(/^([\d\.]+(?= |$)|)( |)(.*)$/)
+        match = variant.unit_value_with_description.match(/^([\d\.\,]+(?= |$)|)( |)(.*)$/)
         if match
-          unit_value  = parseFloat(match[1])
+          unit_value  = parseFloat(match[1].replace(",", "."))
           unit_value  = null if isNaN(unit_value)
           unit_value *= variant_unit_scale if unit_value && variant_unit_scale
           unit_description = match[3]

{'commit': 'diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee\nindex 9ee52b745..711db5b93 100644\n--- a/app/assets/javascripts/admin/bulk_product_update.js.coffee\n+++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee\n@@ -256,10 +256,10 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout\n \n   $scope.packVariant = (product, variant) ->\n     if variant.hasOwnProperty("unit_value_with_description")\n-      match = variant.unit_value_with_description.match(/^([\\d\\.]+(?= |$)|)( |)(.*)$/)\n+      match = variant.unit_value_with_description.match(/^([\\d\\.\\,]+(?= |$)|)( |)(.*)$/)\n       if match\n         product = BulkProducts.find product.id\n-        variant.unit_value  = parseFloat(match[1])\n+        variant.unit_value  = parseFloat(match[1].replace(",", "."))\n         variant.unit_value  = null if isNaN(variant.unit_value)\n         variant.unit_value *= product.variant_unit_scale if variant.unit_value && product.variant_unit_scale\n         variant.unit_description = match[3]\ndiff --git a/app/assets/javascripts/admin/directives/display_as.js.coffee b/app/assets/javascripts/admin/directives/display_as.js.coffee\nindex 5e4c5f741..375f1795e 100644\n--- a/app/assets/javascripts/admin/directives/display_as.js.coffee\n+++ b/app/assets/javascripts/admin/directives/display_as.js.coffee\n@@ -39,9 +39,9 @@ angular.module("ofn.admin").directive "ofnDisplayAs", (OptionValueNamer) ->\n       # get relevant variant properties\n       variant = scope.$eval(attrs.ofnDisplayAs) # Like this so we can switch between \'master\' and \'variant\'\n       if variant.unit_value_with_description?\n-        match = variant.unit_value_with_description.match(/^([\\d\\.]+(?= |$)|)( |)(.*)$/)\n+        match = variant.unit_value_with_description.match(/^([\\d\\.\\,]+(?= |$)|)( |)(.*)$/)\n         if match\n-          unit_value  = parseFloat(match[1])\n+          unit_value  = parseFloat(match[1].replace(",", "."))\n           unit_value  = null if isNaN(unit_value)\n           unit_value *= variant_unit_scale if unit_value && variant_unit_scale\n           unit_description = match[3]\n', 'commit_subject': 'Allow to change unit value for numbers with a comma separator', 'repo_name': 'openfoodfoundation/openfoodnetwork', 'committer': {'name': 'saunmanoj888', 'email': 'e5bed78df35c9a68cd0ebc89592def76df34c305@kiprosh.com', 'time_sec': '1662978303', 'tz_offset': '330', 'date': {'seconds': '1662978303'}}, 'commit_tree': '80d5477d559d3e86c58009d7b0b0b756c0c5ca8f', 'commit_message': 'Allow to change unit value for numbers with a comma separator\n', 'language_name': 'JavaScript', 'license': 'agpl-3.0', 'hunks': '@@ -39,9 +39,9 @@ angular.module("ofn.admin").directive "ofnDisplayAs", (OptionValueNamer) ->\n       # get relevant variant properties\n       variant = scope.$eval(attrs.ofnDisplayAs) # Like this so we can switch between \'master\' and \'variant\'\n       if variant.unit_value_with_description?\n-        match = variant.unit_value_with_description.match(/^([\\d\\.]+(?= |$)|)( |)(.*)$/)\n+        match = variant.unit_value_with_description.match(/^([\\d\\.\\,]+(?= |$)|)( |)(.*)$/)\n         if match\n-          unit_value  = parseFloat(match[1])\n+          unit_value  = parseFloat(match[1].replace(",", "."))\n           unit_value  = null if isNaN(unit_value)\n           unit_value *= variant_unit_scale if unit_value && variant_unit_scale\n           unit_description = match[3]\n', 'addition_count': 2, 'deletion_count': 2, 'src_file': 'a/app/assets/javascripts/admin/directives/display_as.js.coffee', 'tgt_file': 'b/app/assets/javascripts/admin/directives/display_as.js.coffee', 'file_extension': '.coffee', 'before_file': 'angular.module("ofn.admin").directive "ofnDisplayAs", (OptionValueNamer) ->\n  link: (scope, element, attrs) ->\n\n    scope.$watchCollection ->\n      return [\n        scope.$eval(attrs.ofnDisplayAs).unit_value_with_description\n        scope.product.variant_unit_name\n        scope.product.variant_unit_with_scale\n      ]\n    , ->\n      [variant_unit, variant_unit_scale] = productUnitProperties()\n      [unit_value, unit_description] = variantUnitProperties(variant_unit_scale)\n      variant_object = \n        unit_value: unit_value\n        unit_description: unit_description\n        product:\n          variant_unit_scale: variant_unit_scale\n          variant_unit: variant_unit\n          variant_unit_name: scope.product.variant_unit_name\n\n      scope.placeholder_text = new OptionValueNamer(variant_object).name()\n\n    productUnitProperties = ->\n      # get relevant product properties\n      if scope.product.variant_unit_with_scale?\n        match = scope.product.variant_unit_with_scale.match(/^([^_]+)_([\\d\\.]+)$/)\n        if match\n          variant_unit = match[1]\n          variant_unit_scale = parseFloat(match[2])\n        else\n          variant_unit = scope.product.variant_unit_with_scale\n          variant_unit_scale = null\n      else\n        variant_unit = variant_unit_scale = null\n\n      [variant_unit, variant_unit_scale]\n\n    variantUnitProperties = (variant_unit_scale)->\n      # get relevant variant properties\n      variant = scope.$eval(attrs.ofnDisplayAs) # Like this so we can switch between \'master\' and \'variant\'\n      if variant.unit_value_with_description?\n        match = variant.unit_value_with_description.match(/^([\\d\\.]+(?= |$)|)( |)(.*)$/)\n        if match\n          unit_value  = parseFloat(match[1])\n          unit_value  = null if isNaN(unit_value)\n          unit_value *= variant_unit_scale if unit_value && variant_unit_scale\n          unit_description = match[3]\n      [unit_value, unit_description]', 'message': 'Allow to change unit value for numbers with a comma separator\n', 'author_name': 'saunmanoj888', 'lang': 'js'}