-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2547 from jhawthorn/store_credit_js
Simplify store_credit memo edit JS
- Loading branch information
Showing
4 changed files
with
52 additions
and
64 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
backend/app/assets/javascripts/spree/backend/store_credits.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Spree.ready(function() { | ||
$('.store-credit-memo-row').each(function() { | ||
var row = this; | ||
var field = row.querySelector('[name="store_credit[memo]"]') | ||
var textDisplay = row.querySelector('.store-credit-memo-text') | ||
|
||
$(row).on('ajax:success', function(event, data) { | ||
row.classList.remove('editing'); | ||
field.defaultValue = field.value; | ||
textDisplay.textContent = field.value; | ||
|
||
show_flash('success', data.message); | ||
}).on('ajax:error', function(event, xhr, status, error) { | ||
show_flash('error', xhr.responseJSON.message); | ||
}); | ||
|
||
row.querySelector('.edit-memo').addEventListener('click', function() { | ||
row.classList.add('editing'); | ||
}); | ||
|
||
row.querySelector('.cancel-memo').addEventListener('click', function() { | ||
row.classList.remove('editing'); | ||
}); | ||
}); | ||
}); |
40 changes: 0 additions & 40 deletions
40
backend/app/assets/javascripts/spree/backend/store_credits.js.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters