mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-30 11:24:21 +01:00
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
/*
|
|
* 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,
|
|
link(scope, element, attrs){
|
|
const msg = attrs.confirmationNeeded || "Are you sure?";
|
|
const clickAction = attrs.ngClick;
|
|
return element.bind('click', function() {
|
|
if (attrs.confirmationNeededIf != null) {
|
|
const confirmNeededIf = scope.$eval(attrs.confirmationNeededIf);
|
|
if (confirmNeededIf === true) {
|
|
if ( window.confirm(msg) ) {
|
|
return scope.$eval(clickAction);
|
|
}
|
|
} else {
|
|
return scope.$eval(clickAction);
|
|
}
|
|
} else {
|
|
if ( window.confirm(msg) ) {
|
|
return scope.$eval(clickAction);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
})
|
|
|
|
]);
|