mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Rename and delete actions working ...
This commit is contained in:
parent
391c523b43
commit
5498c681a4
@ -33,7 +33,7 @@ mindplot.RESTPersistenceManager = new Class({
|
||||
};
|
||||
|
||||
var request = new Request({
|
||||
url:this.saveUrl + mapId + "?minor=" + !saveHistory,
|
||||
url:this.saveUrl.replace("{id}", mapId) + "?minor=" + !saveHistory,
|
||||
method: 'put',
|
||||
onSuccess:function(responseText, responseXML) {
|
||||
events.onSuccess();
|
||||
|
@ -54,9 +54,9 @@ public class MindmapController extends BaseController {
|
||||
return new ModelAndView("mapsView", "list", restMindmapList);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateMap(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
|
||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
@ -79,6 +79,58 @@ public class MindmapController extends BaseController {
|
||||
updateMindmap(minor, mindMap, user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The intention of this method is the update of several properties at once ...
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateMap(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
|
||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Update document properties ...
|
||||
final String properties = restMindmap.getProperties();
|
||||
if (properties != null) {
|
||||
mindMap.setProperties(properties);
|
||||
}
|
||||
final String xml = restMindmap.getXml();
|
||||
if (xml != null) {
|
||||
mindMap.setXmlStr(xml);
|
||||
}
|
||||
|
||||
// Update title ...
|
||||
final String title = restMindmap.getTitle();
|
||||
if (title != null && !title.equals(mindMap.getTitle())) {
|
||||
if (mindmapService.getMindmapByTitle(title, user) != null) {
|
||||
throw buildValidationException("title", "You already have a map with this title");
|
||||
}
|
||||
mindMap.setTitle(title);
|
||||
}
|
||||
|
||||
// Update description ...
|
||||
final String description = restMindmap.getDescription();
|
||||
if (description != null) {
|
||||
mindMap.setDescription(description);
|
||||
}
|
||||
|
||||
final String tags = restMindmap.getTags();
|
||||
if (tags != null) {
|
||||
mindMap.setTags(tags);
|
||||
}
|
||||
|
||||
// Update map ...
|
||||
updateMindmap(minor, mindMap, user);
|
||||
}
|
||||
|
||||
private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException {
|
||||
final BindingResult result = new BeanPropertyBindingResult(new RestMindmap(), "");
|
||||
result.rejectValue(fieldName, "error.not-specified", null, message);
|
||||
return new ValidationException(result);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changeMapTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
|
||||
@ -88,7 +140,8 @@ public class MindmapController extends BaseController {
|
||||
|
||||
// Is there a map with the same name ?
|
||||
if (mindmapService.getMindmapByTitle(title, user) != null) {
|
||||
throw new IllegalArgumentException("Map already exists with this title");
|
||||
|
||||
throw buildValidationException("title", "You already have a mindmap with this title");
|
||||
}
|
||||
|
||||
// Update map ...
|
||||
|
@ -224,6 +224,7 @@ COLOR=Color
|
||||
SHARE=Share
|
||||
UNEXPECTED_ERROR=Outch!!. An unexpected error has occurred.
|
||||
UNEXPECTED_ERROR_DETAILS=We're sorry, an error has occurred and we can't process your request. Please try again, or go to the home page.
|
||||
UNEXPECTED_ERROR_SERVER_ERROR=We're sorry, an error has occurred and we can't process your request. Refresh the page and try again. If the problem persist, contact the administrator.
|
||||
NO_ENOUGH_PERMISSIONS=Outch!!. This map is not available anymore.
|
||||
NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this map. This map has been changed to private or deleted.
|
||||
SHARING=Sharing
|
||||
|
@ -53,6 +53,7 @@ jQuery.fn.dataTableExt.removeSelectedRows = function() {
|
||||
trs.each(function() {
|
||||
$('#mindmapListTable').dataTable().fnDeleteRow(this);
|
||||
});
|
||||
updateStatus();
|
||||
};
|
||||
|
||||
|
||||
@ -62,18 +63,24 @@ jQuery.fn.dialogForm = function(options) {
|
||||
var url = options.url;
|
||||
|
||||
// Clear previous state ...
|
||||
$("#" + containerId + " .errorMessage").text("").removeClass("alert alert-error");
|
||||
$("#" + containerId + " .control-group").removeClass('error');
|
||||
$("#" + containerId + " input").attr('value', '');
|
||||
$("#" + containerId).find('.errorMessage').text("").removeClass("alert alert-error");
|
||||
$("#" + containerId).find('.control-group').removeClass('error');
|
||||
|
||||
// Clear form values ...
|
||||
if (options.clearForm == undefined || options.clearForm) {
|
||||
$("#" + containerId).find('input').attr('value', '');
|
||||
}
|
||||
|
||||
// Reset button state ...
|
||||
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||
acceptBtn.button('reset');
|
||||
|
||||
acceptBtn.click(function() {
|
||||
var formData = {};
|
||||
$('#' + containerId + ' input').each(function(index, elem) {
|
||||
formData[elem.name] = elem.value;
|
||||
});
|
||||
|
||||
$(acceptBtn).button('loading');
|
||||
var dialogElem = this;
|
||||
jQuery.ajax(url, {
|
||||
async:false,
|
||||
@ -86,7 +93,6 @@ jQuery.fn.dialogForm = function(options) {
|
||||
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
||||
var redirectUrl = options.redirect;
|
||||
redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId);
|
||||
$(acceptBtn).button('loading');
|
||||
window.location = redirectUrl;
|
||||
|
||||
} else if (options.postUpdate) {
|
||||
@ -105,14 +111,18 @@ jQuery.fn.dialogForm = function(options) {
|
||||
var message = fieldErrors[fieldName];
|
||||
var inputField = $("#" + containerId + " input[name='" + fieldName + "']");
|
||||
|
||||
$("#" + containerId + " .errorMessage").text(message).addClass("alert alert-error");
|
||||
$("#" + containerId).find(".errorMessage").text(message).addClass("alert alert-error");
|
||||
inputField.parent().addClass('error');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
alert("Unexpected error removing maps. Refresh before continue.");
|
||||
console.log(errorThrown);
|
||||
console.log(jqXHR);
|
||||
|
||||
dialogElem.modal('hide');
|
||||
$('#messagesPanel div').text(errorThrown).parent().show();
|
||||
}
|
||||
|
||||
}
|
||||
@ -136,22 +146,19 @@ function updateStatus() {
|
||||
$("#mindmapListTable tbody input:checked").parent().parent().addClass('row-selected');
|
||||
$("#mindmapListTable tbody input:not(:checked)").parent().parent().removeClass('row-selected');
|
||||
|
||||
$("#buttonsToolbar .act-multiple").hide();
|
||||
$("#buttonsToolbar .act-single").hide();
|
||||
$('#buttonsToolbar').find('.act-single').hide().end().find('.act-multiple').hide();
|
||||
|
||||
var tableElem = $('#mindmapListTable');
|
||||
var selectedRows = tableElem.dataTableExt.getSelectedRows();
|
||||
|
||||
if (selectedRows.length > 0) {
|
||||
if (selectedRows.length == 1) {
|
||||
$("#buttonsToolbar .act-single").show();
|
||||
$("#buttonsToolbar .act-multiple").show();
|
||||
$('#buttonsToolbar').find('.act-single').show().end().find('.act-multiple').show();
|
||||
|
||||
// Can be executed by the owner ?
|
||||
var rowData = tableElem.dataTable().fnGetData(selectedRows[0]);
|
||||
if (rowData.ownerEmail != principalEmail) {
|
||||
$("#buttonsToolbar #publishBtn").hide();
|
||||
$("#buttonsToolbar #shareBtn").hide();
|
||||
$("#buttonsToolbar").find('#publishBtn').hide().end().find('#shareBtn').hide();
|
||||
}
|
||||
} else {
|
||||
$("#buttonsToolbar .act-multiple").show();
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
// Configure designer options ...
|
||||
var options = loadDesignerOptions();
|
||||
options.persistenceManager = new mindplot.RESTPersistenceManager("service/maps/");
|
||||
options.persistenceManager = new mindplot.RESTPersistenceManager("service/maps/{id}/document");
|
||||
var userOptions = ${mindmap.properties};
|
||||
options.zoom = userOptions.zoom;
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td class="formLabel">
|
||||
<span class="fieldRequired">*</span>
|
||||
<spring:message code="NAME"/>:
|
||||
</td>
|
||||
<td>
|
||||
@ -34,8 +33,8 @@
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input type="submit" value="<spring:message code="IMPORT"/>" class="btn-primary">
|
||||
<input type="button" value="<spring:message code="CANCEL"/>" class="btn-secondary"
|
||||
<input type="submit" value="<spring:message code="IMPORT"/>" class="btn btn-primary">
|
||||
<input type="button" value="<spring:message code="CANCEL"/>" class="btn"
|
||||
onclick="window.location='/c/mymaps.htm'">
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -78,7 +78,7 @@
|
||||
oLanguage : {
|
||||
"sSearch" : "",
|
||||
"sInfo" : "_START_-_END_ of _TOTAL_",
|
||||
"sEmptyTable": "Hey, you don't have any mindmap. Go head and create one clicking the 'New' button !!!"
|
||||
"sEmptyTable": "Hey, you don't have any mindmap. Go ahead and create one clicking on the 'New' button !!!"
|
||||
},
|
||||
bStateSave:true
|
||||
});
|
||||
@ -167,16 +167,15 @@
|
||||
// Initialize dialog ...
|
||||
$("#rename-dialog-modal").dialogForm({
|
||||
type: 'PUT',
|
||||
clearForm: false,
|
||||
postUpdate: function(reqBodyData) {
|
||||
// Remove old entry ...
|
||||
dataTable.fnDeleteRow(rowData);
|
||||
tableElem.dataTableExt.removeSelectedRows();
|
||||
|
||||
// Add a new one...
|
||||
rowData.title = reqBodyData.title;
|
||||
rowData.description = reqBodyData.description;
|
||||
dataTable.fnAddData(rowData);
|
||||
dataTable.fnAddData(JSON.parse(JSON.stringify(rowData)));
|
||||
},
|
||||
url : "../service/maps/" + mapId + "/title"
|
||||
url : "../service/maps/" + mapId
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -256,24 +255,31 @@
|
||||
<jsp:param name="showLogout" value="true"/>
|
||||
</jsp:include>
|
||||
|
||||
|
||||
<div id="mindmapListContainer">
|
||||
<div id="messagesPanel" class="alert alert-error alert-block fade in hide" style="margin-top: 10px">
|
||||
<strong><spring:message code="UNEXPECTED_ERROR"/></strong>
|
||||
|
||||
<p><spring:message code="UNEXPECTED_ERROR_SERVER_ERROR"/></p>
|
||||
|
||||
<div></div>
|
||||
</div>
|
||||
|
||||
<div id="buttonsToolbar" class="btn-toolbar">
|
||||
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-info" id="newBtn"><i class="icon-file icon-white"></i> New</button>
|
||||
<button class="btn btn-info" id="importBtn"><i class="icon-upload icon-white"></i> Import</button>
|
||||
<button id="newBtn" class="btn btn-info"><i class="icon-file icon-white"></i> New</button>
|
||||
<button id="importBtn" class="btn btn-info"><i class="icon-upload icon-white"></i> Import</button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group act-multiple" id="deleteBtn" style="display:none">
|
||||
<button class="btn btn-info"><i class="icon-trash icon-white"></i> Delete</button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group act-single" id="infoBtn" style="display:none">
|
||||
<div id="infoBtn" class="btn-group act-single" style="display:none">
|
||||
<button class="btn btn-info"><i class="icon-exclamation-sign icon-white"></i> Info</button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group act-single" id="actionsBtn" style="display:none">
|
||||
<div id="actionsBtn" class="btn-group act-single" style="display:none">
|
||||
<button class="btn btn-info dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="icon-asterisk icon-white"></i> More
|
||||
<span class="caret"></span>
|
||||
@ -323,7 +329,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Creating ...">Create</button>
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Saving ...">Create</button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -354,7 +360,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Duplicating ...">Duplicate</button>
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Saving ...">Duplicate</button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -383,7 +389,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept">Rename</button>
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Saving ...">Rename</button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -402,7 +408,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept">Delete</button>
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Saving ...">Delete</button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -446,7 +452,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<jsp:include page="footer.jsp"/>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -219,7 +219,7 @@ public class RestMindmapTCase {
|
||||
mapToUpdate.setProperties("{zoom:x}");
|
||||
|
||||
// Update map ...
|
||||
final String resourceUrl = HOST_PORT + resourceUri.toString();
|
||||
final String resourceUrl = HOST_PORT + resourceUri.toString() + "/document";
|
||||
requestHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
final HttpEntity<RestMindmap> updateEntity = new HttpEntity<RestMindmap>(mapToUpdate, requestHeaders);
|
||||
template.put(resourceUrl, updateEntity);
|
||||
|
Loading…
Reference in New Issue
Block a user