mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Simplify email confirmation directive
Making better use of Angular features. Adding a spec for this functionality.
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
angular.module("admin.users").directive "resendUserEmailConfirmation", ($http) ->
|
||||
template: "{{ 'js.admin.resend_user_email_confirmation.' + status | t }}"
|
||||
scope:
|
||||
email: "@resendUserEmailConfirmation"
|
||||
link: (scope, element, attrs) ->
|
||||
sent = false
|
||||
text = element.text()
|
||||
sending = " " + t "js.admin.resend_user_email_confirmation.sending"
|
||||
done = " " + t "js.admin.resend_user_email_confirmation.done"
|
||||
failed = " " + t "js.admin.resend_user_email_confirmation.failed"
|
||||
scope.status = "resend"
|
||||
|
||||
element.bind "click", ->
|
||||
return if sent
|
||||
element.text(text + sending)
|
||||
scope.status = "sending"
|
||||
$http.post("/user/spree_user/confirmation", {spree_user: {email: scope.email}}).success (data) ->
|
||||
sent = true
|
||||
element.addClass "action--disabled"
|
||||
element.text text + done
|
||||
scope.status = "done"
|
||||
.error (data) ->
|
||||
element.text text + failed
|
||||
scope.status = "failed"
|
||||
|
||||
Reference in New Issue
Block a user