Skip to content

Commit

Permalink
Merge pull request #7 from iosifnicolae2/main
Browse files Browse the repository at this point in the history
fix: resolve modals errors when they are not used
  • Loading branch information
django-superapp-team authored Jul 30, 2024
2 parents f45c9b1 + 2bf5f28 commit b4cbbda
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions static/admin_portal/js/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@ const dismissModal = (modalName) => {
}

// Patch the dismiss functions to remove the iframe when the modal is closed
const originalDismissChangeRelatedObjectPopup = dismissChangeRelatedObjectPopup;
const originalDismissDeleteRelatedObjectPopup = dismissDeleteRelatedObjectPopup;
const originalDismissAddRelatedObjectPopup = dismissAddRelatedObjectPopup;
const originalDismissChangeRelatedObjectPopup = typeof dismissChangeRelatedObjectPopup !== 'undefined'? dismissChangeRelatedObjectPopup: undefined;
const originalDismissDeleteRelatedObjectPopup = typeof dismissDeleteRelatedObjectPopup !== 'undefined'? dismissDeleteRelatedObjectPopup: undefined;
const originalDismissAddRelatedObjectPopup = typeof dismissAddRelatedObjectPopup !== 'undefined'? dismissAddRelatedObjectPopup: undefined;

// Reassigning modified functions
dismissChangeRelatedObjectPopup = (...args) => {
originalDismissChangeRelatedObjectPopup(...args);
dismissModal(args[0]?.name);
};

dismissDeleteRelatedObjectPopup = (...args) => {
originalDismissDeleteRelatedObjectPopup(...args);
dismissModal(args[0]?.name);
};
if(originalDismissChangeRelatedObjectPopup) {
dismissChangeRelatedObjectPopup = (...args) => {
originalDismissChangeRelatedObjectPopup(...args);
dismissModal(args[0]?.name);
};
}
if(originalDismissDeleteRelatedObjectPopup) {
dismissDeleteRelatedObjectPopup = (...args) => {
originalDismissDeleteRelatedObjectPopup(...args);
dismissModal(args[0]?.name);
};
}
if(originalDismissAddRelatedObjectPopup) {
dismissAddRelatedObjectPopup = (...args) => {
originalDismissAddRelatedObjectPopup(...args);
dismissModal(args[0]?.name);
};
}

dismissAddRelatedObjectPopup = (...args) => {
originalDismissAddRelatedObjectPopup(...args);
dismissModal(args[0]?.name);
};

// Patch window.open to open an iframe instead of a new window
const originalWindowOpen = window.open;
Expand Down

0 comments on commit b4cbbda

Please sign in to comment.