2018-10-25 16:51:20 +02:00
|
|
|
/* eslint-disable
|
|
|
|
no-undef,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2018-10-25 16:50:16 +02:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
|
|
|
Application.Directives.directive('confirmationNeeded', [() =>
|
|
|
|
({
|
|
|
|
priority: 1,
|
|
|
|
terminal: true,
|
2018-10-25 16:51:20 +02:00
|
|
|
link (scope, element, attrs) {
|
|
|
|
const msg = attrs.confirmationNeeded || 'Are you sure?'
|
|
|
|
const clickAction = attrs.ngClick
|
|
|
|
return element.bind('click', function () {
|
2018-10-25 16:50:16 +02:00
|
|
|
if (attrs.confirmationNeededIf != null) {
|
2018-10-25 16:51:20 +02:00
|
|
|
const confirmNeededIf = scope.$eval(attrs.confirmationNeededIf)
|
2018-10-25 16:50:16 +02:00
|
|
|
if (confirmNeededIf === true) {
|
2018-10-25 16:51:20 +02:00
|
|
|
if (window.confirm(msg)) {
|
|
|
|
return scope.$eval(clickAction)
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
} else {
|
2018-10-25 16:51:20 +02:00
|
|
|
return scope.$eval(clickAction)
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
} else {
|
2018-10-25 16:51:20 +02:00
|
|
|
if (window.confirm(msg)) {
|
|
|
|
return scope.$eval(clickAction)
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-25 16:51:20 +02:00
|
|
|
})
|
2016-03-23 18:39:41 +01:00
|
|
|
}
|
2018-10-25 16:51:20 +02:00
|
|
|
})
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
])
|