Sha256: 068e6af8eb96d901804b1ad5dab240f0f6c44048480460a1130c05a28e339ae1
Contents?: true
Size: 1.81 KB
Versions: 60
Compression:
Stored size: 1.81 KB
Contents
class CountUpdateForms @beginListening: (isReceiving) -> # Edit $('body').on 'click', '#listing_transfer_items .fa-edit', (ev) => ev.preventDefault() transferItemId = $(ev.currentTarget).data('id') Spree.NumberFieldUpdater.hideReadOnly(transferItemId) Spree.NumberFieldUpdater.showForm(transferItemId) # Cancel $('body').on 'click', '#listing_transfer_items .fa-void', (ev) => ev.preventDefault() transferItemId = $(ev.currentTarget).data('id') Spree.NumberFieldUpdater.hideForm(transferItemId) Spree.NumberFieldUpdater.showReadOnly(transferItemId) # Submit $('body').on 'click', '#listing_transfer_items .fa-check', (ev) => ev.preventDefault() transferItemId = $(ev.currentTarget).data('id') stockTransferNumber = $("#stock_transfer_number").val() quantity = parseInt($("#number-update-#{transferItemId} input[type='number']").val(), 10) itemAttributes = id: transferItemId stockTransferNumber: stockTransferNumber quantityKey = if isReceiving then 'receivedQuantity' else 'expectedQuantity' itemAttributes[quantityKey] = quantity transferItem = new Spree.TransferItem(itemAttributes) transferItem.update(successHandler, errorHandler) successHandler = (transferItem) => if $('#received-transfer-items').length > 0 Spree.NumberFieldUpdater.successHandler(transferItem.id, transferItem.received_quantity) Spree.StockTransfers.ReceivedCounter.updateTotal() else Spree.NumberFieldUpdater.successHandler(transferItem.id, transferItem.expected_quantity) show_flash("success", Spree.translations.updated_successfully) errorHandler = (errorData) => show_flash("error", errorData.responseText) Spree.StockTransfers ?= {} Spree.StockTransfers.CountUpdateForms = CountUpdateForms
Version data entries
60 entries across 60 versions & 1 rubygems