Skip to content

Commit

Permalink
Merge branch 'master' into archived-queries
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez authored Jan 25, 2019
2 parents 914f827 + d204c15 commit 034ba12
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions client/app/pages/queries/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ function QueryViewCtrl(
customOptions,
);

if (options.force) {
delete request.version;
}

function overwrite() {
options.force = true;
$scope.saveQuery(options, data);
}

return Query.save(
request,
(updatedQuery) => {
Expand All @@ -242,11 +251,20 @@ function QueryViewCtrl(
},
(error) => {
if (error.status === 409) {
toastr.error(
'It seems like the query has been modified by another user. ' +
'Please copy/backup your changes and reload this page.',
{ autoDismiss: false },
);
const errorMessage = 'It seems like the query has been modified by another user.';

if ($scope.isQueryOwner) {
const title = 'Overwrite Query';
const message = errorMessage + '<br>Are you sure you want to overwrite the query with your version?';
const confirm = { class: 'btn-warning', title: 'Overwrite' };

AlertDialog.open(title, message, confirm).then(overwrite);
} else {
toastr.error(
errorMessage + ' Please copy/backup your changes and reload this page.',
{ autoDismiss: false },
);
}
} else {
toastr.error(options.errorMessage);
}
Expand Down

0 comments on commit 034ba12

Please sign in to comment.