Skip to content

Commit

Permalink
Merge pull request #805 from lmcapacho/develop
Browse files Browse the repository at this point in the history
Update close window functionality with Save and Close option
  • Loading branch information
cavearr authored Jan 21, 2025
2 parents c3b58b3 + 5b99d42 commit 58ec83d
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions app/scripts/controllers/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,34 +625,51 @@ angular
exit();
};

function exit() {

alertify.dialog('closeDialog', function factory() {
return {
main: function (message) {
this.setContent(message);
},
setup: function () {
return {
buttons: [
{ text: gettextCatalog.getString("Save"), className: 'ajs-ok' },
{ text: gettextCatalog.getString("Discard"), className: 'ajs-ok' },
{ text: gettextCatalog.getString("Cancel"), className: 'ajs-cancel', key: 27 }
],
focus: { element: 3 },
options: {
movable: false, maximizable: false,
closable: false, resizable: false
}
};
},
callback: function (closeEvent) {
switch (closeEvent.index) {
case 0:
$scope.saveProject();
win.close(true);
break;
case 1:
win.close(true);
break;
}
}
};
});

function exit() {
if (project.changed) {
alertify.set("confirm", "labels", {
ok: gettextCatalog.getString("Close"),
});
alertify.set("confirm", "defaultFocus", "cancel");
alertify.confirm(
alertify.closeDialog(
utils.bold(
gettextCatalog.getString("Do you want to close " +
"the application?")
) +
"<br>" +
gettextCatalog.getString(
"Your changes will be lost if you don’t save them"
),
function () {
// Close
_exit();
},
function () {
// Cancel
setTimeout(function () {
alertify.set("confirm", "labels", {
ok: gettextCatalog.getString("OK"),
});
alertify.set("confirm", "defaultFocus", "ok");
}, 200);
}
)
);
} else {
_exit();
Expand Down

0 comments on commit 58ec83d

Please sign in to comment.