diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java b/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java index d782d154..96af9697 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java @@ -67,13 +67,17 @@ public class LabelController extends BaseController { return new RestLabelList(all); } - @RequestMapping(method = RequestMethod.PUT, value = "/labels/maps", consumes = {"application/json"}) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void linkToMindMaps(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids) throws WiseMappingException { + @RequestMapping(method = RequestMethod.POST, value = "/labels/maps", consumes = {"application/json"}) + @ResponseStatus(value = HttpStatus.ACCEPTED) + public void linkToMindMaps(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids, @NotNull HttpServletResponse response) throws WiseMappingException { int id = restLabel.getId(); - final Label label = labelService.getLabelById(id); + Label label = labelService.getLabelById(id); if (label == null) { - throw new LabelCouldNotFoundException("Label could not be found. Id: " + id); + // create label.. + validate(restLabel); + createLabel(restLabel); + label = restLabel.getDelegated(); + response.setHeader("ResourceId", Integer.toString(label.getId())); } for (String mindmapId : ids.split(",")) { final Mindmap mindmap = mindmapService.findMindmapById(Integer.parseInt(mindmapId)); diff --git a/wise-webapp/src/main/webapp/js/buttonActions.js b/wise-webapp/src/main/webapp/js/buttonActions.js index 03186a34..a58d0824 100644 --- a/wise-webapp/src/main/webapp/js/buttonActions.js +++ b/wise-webapp/src/main/webapp/js/buttonActions.js @@ -11,9 +11,13 @@ $(function () { $(document).on('click', '#createLabelBtn', function () { + var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); $("#new-folder-dialog-modal").dialogForm({ - url:"c/restful/labels", - postUpdate: createLabelItem + url:"c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), + postUpdate: function(data, id) { + createLabelItem(data, id); + tagMindmaps(data.title, data.color); + } }); } ); @@ -35,39 +39,38 @@ $(function () { //append items to dropdown $.each(labels, function(index, value) { labelList.append( - $('
') + //aca jay codigo repetido + $('').attr('value', value.id).attr('color', value.color) .append('' + - '' + - ''+ value.title + - '' + - '')); + "" + + "