<commit_before>order-item-quantity-price

  .quantity-price-row class="{status_id} {flagClasses}"

    .box-field.quantity title='{statusWithUnit()}'
      span.value if='{status.flags.removed}'
        '{t('views.item._edit.removed')}
      span.value if='{!status.flags.removed}'
        '{quantityNumber}

      span if='{parent.parent.order.may_edit && status.flags.editable}'
        input.form-control.inline-input name='quantity_{status.field}' type='number' value='{status.quantity}' min='0' step='any' onkeyup='{quantityChange}' oninput='{quantityChange}' onchange='{quantityChange}'
      span.unit if='{!parent.parent.order.may_edit || !status.flags.editable}'
        '&nbsp;{item.unit_name}

    .box-field.price-total
      span class='{outdated: status.new_price}'
        '{status.price}
      span.new-price if='{status.new_price}'
        '{status.new_price}

    .box-field.status if='{parent.parent.order.admin}'
      '{t('models.order.statuses.'+status_id)}

  javascript:
    this.item      = opts.item
    this.status    = opts.status
    this.status_id = opts.status_id

    statusWithUnit() {
      if (!status.flags.removed)
        return quantityNumber+' '+item.unit_name
    }

    quantityChange(event) {
      var input = event.target
      // avoid recalling save when there's no change
      if (!input.value && parseInt(this.status.quantity).toFixed(2) == parseInt(input.value).toFixed(2)) {
        return
      }
      this.run_at = new Date()
      this.event_type = event.type
      var self = this

      setTimeout(function(run_at, type) {
        if (self.run_at == run_at && type == self.event_type)
          self.quantityUpdate(input)
      }, 2000, this.run_at, event.type);
    }

    quantityUpdate(input) {
      var value = input.value
      var data = {item: {}}
      data.item['quantity_'+this.status.field] = value

      $.post(this.item.update_url, data, function (order) {<commit_msg>Improve the order quantity input update<commit_after>order-item-quantity-price

  .quantity-price-row class="{status_id} {flagClasses}"

    .box-field.quantity title='{statusWithUnit()}'
      span.value if='{status.flags.removed}'
        '{t('views.item._edit.removed')}
      span.value if='{!status.flags.removed}'
        '{quantityNumber}

      span if='{parent.parent.order.may_edit && status.flags.editable}'
        input.form-control.inline-input name='quantity_{status.field}' type='number' value='{status.quantity}' min='0' step='any' onkeyup='{quantityChange}' oninput='{quantityChange}' onchange='{quantityChange}'
      span.unit if='{!parent.parent.order.may_edit || !status.flags.editable}'
        '&nbsp;{item.unit_name}

    .box-field.price-total
      span class='{outdated: status.new_price}'
        '{status.price}
      span.new-price if='{status.new_price}'
        '{status.new_price}

    .box-field.status if='{parent.parent.order.admin}'
      '{t('models.order.statuses.'+status_id)}

  javascript:
    this.item      = opts.item
    this.status    = opts.status
    this.status_id = opts.status_id

    statusWithUnit() {
      if (!status.flags.removed)
        return quantityNumber+' '+item.unit_name
    }

    quantityChange(event) {
      var input = event.target

      // avoid recalling save when there's no change
      if (!input.value.trim() || parseInt(this.status.quantity).toFixed(2) == parseInt(input.value).toFixed(2)) {
        return
      }
      this.run_at = new Date().getTime()
      var self = this

      setTimeout(function(run_at) {
        if (self.run_at == run_at && input.value != "") {
          self.quantityUpdate(input)
        }
      }, 2000, this.run_at);
    }

    quantityUpdate(input) {
      var value = input.value
      var data = {item: {}}
      data.item['quantity_'+this.status.field] = value

      $.post(this.item.update_url, data, function (order) {
{'fraction_non_alphanumeric': 0.15467904098994587, 'fraction_numerical': 0.003609177623098737, 'mean_word_length': 2.9311043566362716, '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': '5326179', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1228, 'n_words': 200}