Skip to content

Commit

Permalink
added check to make sure the space to be added does not already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoodward committed May 14, 2024
1 parent f56558a commit f6300e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions duradmin/src/main/webapp/jquery/dc/api/durastore-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,27 @@ var dc;
* @param Object callback The callback must implement success and failure methods. options begin method is supported.
*/
dc.store.AddSpace = function(space, publicFlag, callback){
// Check if space already exists
var exists = false;
dc.ajax({
url: "/duradmin/spaces/json",
data: "storeId=" + space.storeId,
cache: false,
async: false,
success: function (data) {
$.each(data.spaces, function (index, current_space) {
if (space.spaceId == current_space.spaceId) {
exists = true;
}
});
},
failure: {},
});
if (exists) {
return callback.failure('The space already exists.');
}

// Add space
dc.ajax(
{
url: "/duradmin/spaces/space",
Expand Down
5 changes: 4 additions & 1 deletion duradmin/src/main/webapp/js/spaces-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,10 @@ $(function() {
$("#spaces-list").selectablelist("setCurrentItemById", space.spaceId);
that._spacesListPane.spaceslistpane("scrollToCurrentSpace");
}

},
failure : function(message) {
dc.done();
alert("Error: " + message);
},
});
this._addSpaceDialog.dialog("close");
Expand Down

0 comments on commit f6300e5

Please sign in to comment.