Sha256: 42e791af706f232bfd7642f4b236dd5fdd47ca4b6af1484b8711d42e424d95fa

Contents?: true

Size: 1.25 KB

Versions: 64

Compression:

Stored size: 1.25 KB

Contents

$(document).ready ->
  return unless $('#sc_memo_edit_form').length > 0

  $('.js-edit-memo').on('click', (ev) =>
    ev.preventDefault()
    originalValue = $('#memo-edit-row').data('original-value')
    $('#sc_memo_edit_form').find("[name='store_credit[memo]']").val(originalValue)
    $('#memo-display-row').addClass('hidden')
    $('#memo-edit-row').removeClass('hidden')
  )

  $('.js-save-memo').on('click', (ev) ->
    ev.preventDefault()
    Spree.ajax(
      $('#sc_memo_edit_form').attr('url'), {
        data: $('#sc_memo_edit_form').serialize(),
        dataType: 'json',
        method: 'put',
        success: ( (response) =>
          newValue = $('#sc_memo_edit_form').find("[name='store_credit[memo]']").val()
          $('#memo-edit-row').data('original-value', newValue)
          $('#memo-display-row').find('.js-memo-text').text(newValue)
          hideEditMemoForm()
          show_flash('success', response.message)
        ),
        error: ( (xhr, status) =>
          show_flash('error', xhr.responseJSON.message)
        )
      }
    )
  )

  $('.js-cancel-memo').on('click', (ev) =>
    ev.preventDefault()
    hideEditMemoForm()
  )

  hideEditMemoForm = ->
    $('#memo-edit-row').addClass('hidden')
    $('#memo-display-row').removeClass('hidden')

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
solidus_backend-1.0.6 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.2.2 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.2.1 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.1.3 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.0.5 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.2.0 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.2.0.rc2 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.0.4 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.1.2 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.2.0.rc1 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.2.0.beta1 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.0.3 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.1.1 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.1.0 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.1.0.pre2 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.1.0.pre1 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.1.0.beta1 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.0.2 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.0.1 app/assets/javascripts/spree/backend/store_credits.js.coffee
solidus_backend-1.0.0 app/assets/javascripts/spree/backend/store_credits.js.coffee