<commit_before>= render_dialog_error_messages 'product' if errors

= form_for @product, as: :product, remote: true,
  loading: "small_loading('product-info-form')",
  url: {controller: 'manage_products', action: 'edit', id: @product, field: 'info'},
  html: {id: 'product-info-form', method: 'post', class: 'form-horizontal', data: {type: 'html', update: '#product-info'}} do |f|

  - if defined? SuppliersPlugin and @product.is_a? SuppliersPlugin::DistributedProduct
    .form-group
      = f.label :price, _('Price sold'), class: 'col-lg-4 col-md-4 col-sm-5'
      .col-lg-8.col-md-8.col-sm-7
        = input_group_addon environment.currency_unit
          = f.number_field :price, step: 'any', class: 'form-control', onkeyup: 'suppliers.product.pmsync(false)', oninput: 'this.onkeyup()'
    .form-group
      = f.label :margin_percentage, _('Margin'), class: 'col-lg-4 col-md-4 col-sm-5'
      .col-lg-8.col-md-8.col-sm-7
        = input_group_addon '%'
          = f.number_field :margin_percentage, step: 'any', class: 'form-control', onkeyup: 'suppliers.product.pmsync(true)', oninput: 'this.onkeyup()'
    .form-group
      = f.fields_for :supplier_product, @product.supplier_product do |ff|
        = ff.label :price, _("Supplier's price"), class: 'col-lg-4 col-md-4 col-sm-5'
        .col-lg-8.col-md-8.col-sm-7
          = input_group_addon environment.currency_unit
            = ff.number_field :price, step: 'any', class: 'form-control', onkeyup: 'suppliers.product.updateBasePrice()', oninput: 'this.onkeyup()'
  - else
    .form-group
      = f.label :price, _('Price'), class: 'control-label col-lg-3 col-md-3 col-sm-4'
      .col-lg-9.col-md-9.col-sm-8
        = input_group_addon environment.currency_unit
          = f.number_field :price, step: 'any', class: 'form-control'

    .form-group
      = f.label :discount, _('Discount'), class: 'control-label col-lg-3 col-md-3 col-sm-4'
      .col-lg-9.col-md-9.col-sm-8
        = input_group_addon environment.currency_unit
          = f.number_field :discount, step: 'any', class: 'form-control', title: _('If your product is on sale, fill this field with the discount value')

  .form-group
    = f.label :available, _('Available'), class: 'control-label col-lg-3 col-md-3 col-sm-4'
    .col-lg-9.col-md-9.col-sm-8
      = labelled_radio_button  _('Yes'), 'product[available]', true, @product.available, id: 'product_available') + labelled_radio_button( _('No'), 'product[available]', false, !@product.available<commit_msg>products: cover the case the price is nil<commit_after>= render_dialog_error_messages 'product' if errors

= form_for @product, as: :product, remote: true,
  loading: "small_loading('product-info-form')",
  url: {controller: 'manage_products', action: 'edit', id: @product, field: 'info'},
  html: {id: 'product-info-form', method: 'post', class: 'form-horizontal', data: {type: 'html', update: '#product-info'}} do |f|

  - if defined? SuppliersPlugin and @product.is_a? SuppliersPlugin::DistributedProduct
    .form-group
      = f.label :price, _('Price sold'), class: 'col-lg-4 col-md-4 col-sm-5'
      .col-lg-8.col-md-8.col-sm-7
        = input_group_addon environment.currency_unit
          = f.number_field :price, step: 'any', class: 'form-control', onkeyup: 'suppliers.product.pmsync(false)', oninput: 'this.onkeyup()'
    .form-group
      = f.label :margin_percentage, _('Margin'), class: 'col-lg-4 col-md-4 col-sm-5'
      .col-lg-8.col-md-8.col-sm-7
        = input_group_addon '%'
          = f.number_field :margin_percentage, step: 'any', class: 'form-control', onkeyup: 'suppliers.product.pmsync(true)', oninput: 'this.onkeyup()'
    .form-group
      = f.fields_for :supplier_product, @product.supplier_product do |ff|
        = ff.label :price, _("Supplier's price"), class: 'col-lg-4 col-md-4 col-sm-5'
        .col-lg-8.col-md-8.col-sm-7
          = input_group_addon environment.currency_unit
            = ff.number_field :price, step: 'any', class: 'form-control', onkeyup: 'suppliers.product.updateBasePrice()', oninput: 'this.onkeyup()'
    javascript:
      // cover the case the price is nil, i.e., the same as the supplier
      suppliers.product.pmsync(true)
  - else
    .form-group
      = f.label :price, _('Price'), class: 'control-label col-lg-3 col-md-3 col-sm-4'
      .col-lg-9.col-md-9.col-sm-8
        = input_group_addon environment.currency_unit
          = f.number_field :price, step: 'any', class: 'form-control'

    .form-group
      = f.label :discount, _('Discount'), class: 'control-label col-lg-3 col-md-3 col-sm-4'
      .col-lg-9.col-md-9.col-sm-8
        = input_group_addon environment.currency_unit
          = f.number_field :discount, step: 'any', class: 'form-control', title: _('If your product is on sale, fill this field with the discount value')

  .form-group
    = f.label :available, _('Available'), class: 'control-label col-lg-3 col-md-3 col-sm-4'
    .col-lg-9.col-md-9.col-sm-8
      = labelled_radio_button  _('Yes'), 'product[available]', true, @product.available, id: 'product_available') + labelled_radio_button( _('No'), 'product[available]', false, !@product.available
{'fraction_non_alphanumeric': 0.16854807318022577, 'fraction_numerical': 0.014013234721681589, 'mean_word_length': 3.3477157360406093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6262787', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1823, 'n_words': 389}