2017-06-06 07:27:30 -05:00
|
|
|
///<reference path="../../headers/common.d.ts" />
|
|
|
|
|
|
|
|
import coreModule from 'app/core/core_module';
|
|
|
|
|
|
|
|
const template = `
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h2 class="modal-header-title">
|
|
|
|
<i class="fa fa-exclamation"></i>
|
|
|
|
<span class="p-l-1">Unsaved changes</span>
|
|
|
|
</h2>
|
|
|
|
|
2017-09-21 02:05:59 -05:00
|
|
|
<a class="modal-header-close" ng-click="ctrl.dismiss();">
|
2017-06-06 07:27:30 -05:00
|
|
|
<i class="fa fa-remove"></i>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="modal-content text-center">
|
|
|
|
|
|
|
|
<div class="confirm-modal-text">
|
2017-10-11 17:57:33 -05:00
|
|
|
Do you want to save your changes?
|
2017-06-06 07:27:30 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="confirm-modal-buttons">
|
|
|
|
<button type="button" class="btn btn-inverse" ng-click="ctrl.dismiss()">Cancel</button>
|
|
|
|
<button type="button" class="btn btn-danger" ng-click="ctrl.discard()">Discard</button>
|
|
|
|
<button type="button" class="btn btn-success" ng-click="ctrl.save()">Save</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
|
|
|
|
export class UnsavedChangesModalCtrl {
|
|
|
|
clone: any;
|
|
|
|
dismiss: () => void;
|
|
|
|
|
|
|
|
/** @ngInject */
|
2017-09-21 09:40:18 -05:00
|
|
|
constructor(private unsavedChangesSrv) {
|
2017-06-06 07:27:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
discard() {
|
|
|
|
this.dismiss();
|
|
|
|
this.unsavedChangesSrv.tracker.discardChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
save() {
|
|
|
|
this.dismiss();
|
|
|
|
this.unsavedChangesSrv.tracker.saveChanges();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unsavedChangesModalDirective() {
|
|
|
|
return {
|
|
|
|
restrict: 'E',
|
|
|
|
template: template,
|
|
|
|
controller: UnsavedChangesModalCtrl,
|
|
|
|
bindToController: true,
|
|
|
|
controllerAs: 'ctrl',
|
|
|
|
scope: {dismiss: "&"}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
coreModule.directive('unsavedChangesModal', unsavedChangesModalDirective);
|