mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
Removes close behavior when clicking outside of modal and dialog components
This commit is contained in:
@@ -1,30 +1,7 @@
|
|||||||
const templateUrl = require('~components/dialog/dialog.partial.html');
|
const templateUrl = require('~components/dialog/dialog.partial.html');
|
||||||
|
|
||||||
const overlayClass = 'at-Dialog';
|
|
||||||
|
|
||||||
function DialogController () {
|
|
||||||
const vm = this || {};
|
|
||||||
|
|
||||||
vm.handleClick = ({ target }) => {
|
|
||||||
if (!vm.onClose) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const targetElement = $(target);
|
|
||||||
|
|
||||||
if (targetElement.hasClass(overlayClass)) {
|
|
||||||
vm.onClose();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogController.$inject = [
|
|
||||||
'$element',
|
|
||||||
];
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
templateUrl,
|
templateUrl,
|
||||||
controller: DialogController,
|
|
||||||
controllerAs: 'vm',
|
controllerAs: 'vm',
|
||||||
transclude: true,
|
transclude: true,
|
||||||
bindings: {
|
bindings: {
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ function atModalLink (scope, el, attrs, controllers) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function AtModalController ($timeout, eventService, strings) {
|
function AtModalController (strings) {
|
||||||
const vm = this;
|
const vm = this;
|
||||||
|
|
||||||
let overlay;
|
let overlay;
|
||||||
let listeners;
|
|
||||||
|
|
||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
|
|
||||||
@@ -33,12 +32,6 @@ function AtModalController ($timeout, eventService, strings) {
|
|||||||
vm.modal.title = title;
|
vm.modal.title = title;
|
||||||
vm.modal.message = message;
|
vm.modal.message = message;
|
||||||
|
|
||||||
if (!vm.modal.preventOutsideClick) {
|
|
||||||
listeners = eventService.addListeners([
|
|
||||||
[overlay, 'click', vm.clickToHide]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
overlay.style.display = 'block';
|
overlay.style.display = 'block';
|
||||||
overlay.style.opacity = 1;
|
overlay.style.opacity = 1;
|
||||||
};
|
};
|
||||||
@@ -46,10 +39,6 @@ function AtModalController ($timeout, eventService, strings) {
|
|||||||
vm.hide = () => {
|
vm.hide = () => {
|
||||||
overlay.style.opacity = 0;
|
overlay.style.opacity = 0;
|
||||||
|
|
||||||
if (!vm.modal.preventOutsideClick) {
|
|
||||||
eventService.remove(listeners);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
overlay.style.display = 'none';
|
overlay.style.display = 'none';
|
||||||
}, DEFAULT_ANIMATION_DURATION);
|
}, DEFAULT_ANIMATION_DURATION);
|
||||||
@@ -67,8 +56,6 @@ function AtModalController ($timeout, eventService, strings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtModalController.$inject = [
|
AtModalController.$inject = [
|
||||||
'$timeout',
|
|
||||||
'EventService',
|
|
||||||
'ComponentsStrings'
|
'ComponentsStrings'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f
|
|||||||
scope = _scope_;
|
scope = _scope_;
|
||||||
({ modal } = scope[scope.ns]);
|
({ modal } = scope[scope.ns]);
|
||||||
|
|
||||||
modal.preventOutsideClick = true;
|
|
||||||
|
|
||||||
scope.$watch('vm.promptData.triggerModalOpen', () => {
|
scope.$watch('vm.promptData.triggerModalOpen', () => {
|
||||||
vm.actionButtonClicked = false;
|
vm.actionButtonClicked = false;
|
||||||
if(vm.promptData && vm.promptData.triggerModalOpen) {
|
if(vm.promptData && vm.promptData.triggerModalOpen) {
|
||||||
|
|||||||
Reference in New Issue
Block a user