mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Close modal with esc (#10929)
* added var to check if modal is open and an if for escape fullview * moved showconfirmmodal to utils, showconfirmmodal now uses showmodal, esc works in textinput * made esc global
This commit is contained in:
committed by
Torkel Ödegaard
parent
2c5f3fbc5b
commit
244ae555d9
@@ -10,6 +10,7 @@ export class UtilSrv {
|
||||
init() {
|
||||
appEvents.on('show-modal', this.showModal.bind(this), this.$rootScope);
|
||||
appEvents.on('hide-modal', this.hideModal.bind(this), this.$rootScope);
|
||||
appEvents.on('confirm-modal', this.showConfirmModal.bind(this), this.$rootScope);
|
||||
}
|
||||
|
||||
hideModal() {
|
||||
@@ -47,6 +48,38 @@ export class UtilSrv {
|
||||
modalEl.modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
showConfirmModal(payload) {
|
||||
var scope = this.$rootScope.$new();
|
||||
|
||||
scope.onConfirm = function() {
|
||||
payload.onConfirm();
|
||||
scope.dismiss();
|
||||
};
|
||||
|
||||
scope.updateConfirmText = function(value) {
|
||||
scope.confirmTextValid = payload.confirmText.toLowerCase() === value.toLowerCase();
|
||||
};
|
||||
|
||||
scope.title = payload.title;
|
||||
scope.text = payload.text;
|
||||
scope.text2 = payload.text2;
|
||||
scope.confirmText = payload.confirmText;
|
||||
|
||||
scope.onConfirm = payload.onConfirm;
|
||||
scope.onAltAction = payload.onAltAction;
|
||||
scope.altActionText = payload.altActionText;
|
||||
scope.icon = payload.icon || 'fa-check';
|
||||
scope.yesText = payload.yesText || 'Yes';
|
||||
scope.noText = payload.noText || 'Cancel';
|
||||
scope.confirmTextValid = scope.confirmText ? false : true;
|
||||
|
||||
appEvents.emit('show-modal', {
|
||||
src: 'public/app/partials/confirm_modal.html',
|
||||
scope: scope,
|
||||
modalClass: 'confirm-modal',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
coreModule.service('utilSrv', UtilSrv);
|
||||
|
||||
Reference in New Issue
Block a user