Skip to content

Commit

Permalink
prototype of hard overwrite (re getredash#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Short committed Dec 20, 2017
1 parent 748f834 commit f0789fe
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions client/app/pages/queries/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,25 @@ function QueryViewCtrl(
errorMessage: 'Query could not be saved',
}, customOptions);

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

return Query.save(request, (updatedQuery) => {
toastr.success(options.successMessage);
$scope.query.version = updatedQuery.version;
}, (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 });
// no way this code is going upstream
window.overwriteQuery = () => $scope.$apply(() => {
options.force = true;
$scope.saveQuery(options, data);
});
toastr.error(
'It seems like the query has been modified by another user. ' +
($scope.isQueryOwner ? '<a href="#" onclick="overwriteQuery()">Overwrite anyway</a>?' : 'Please copy/backup your changes and reload this page.'),
{ autoDismiss: false, allowHtml: true, timeout: 0 },
);
} else {
toastr.error(options.errorMessage);
}
Expand Down

0 comments on commit f0789fe

Please sign in to comment.