Fix label delete

This commit is contained in:
Paulo Gustavo Veiga 2022-02-09 16:49:48 -08:00
parent 62e009b7e4
commit 571895a2b3
2 changed files with 8 additions and 11 deletions

View File

@ -74,7 +74,7 @@ public class MindmapController extends BaseController {
List<Mindmap> mindmaps = mindmapService.findMindmapsByUser(user); List<Mindmap> mindmaps = mindmapService.findMindmapsByUser(user);
mindmaps = mindmaps mindmaps = mindmaps
.stream() .stream()
.filter(m->filter.accept(m, user)) .filter(m -> filter.accept(m, user))
.collect(Collectors.toUnmodifiableList()); .collect(Collectors.toUnmodifiableList());
return new RestMindmapList(mindmaps, user); return new RestMindmapList(mindmaps, user);
@ -496,7 +496,7 @@ public class MindmapController extends BaseController {
} }
} }
@RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json", "application/wisemapping+xml"}) @RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json"})
@ResponseStatus(value = HttpStatus.CREATED) @ResponseStatus(value = HttpStatus.CREATED)
public void createMap(@RequestBody(required = false) RestMindmap restMindmap, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException { public void createMap(@RequestBody(required = false) RestMindmap restMindmap, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException {
// If a default maps has not been defined, just create one ... // If a default maps has not been defined, just create one ...
@ -508,11 +508,9 @@ public class MindmapController extends BaseController {
if (title != null && !title.isEmpty()) { if (title != null && !title.isEmpty()) {
restMindmap.setTitle(title); restMindmap.setTitle(title);
} }
if (description != null && !description.isEmpty()) {
restMindmap.setDescription(description); description = description != null && !description.isEmpty() ? description : "";
} else { restMindmap.setDescription(description);
restMindmap.setDescription("");
}
// Validate ... // Validate ...
final BindingResult result = new BeanPropertyBindingResult(restMindmap, ""); final BindingResult result = new BeanPropertyBindingResult(restMindmap, "");
@ -578,7 +576,7 @@ public class MindmapController extends BaseController {
return new ValidationException(result); return new ValidationException(result);
} }
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}/labels/{lid)}") @RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}/labels/{lid}")
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void removeLabelFromMap(@PathVariable int id, @PathVariable int lid) throws WiseMappingException { public void removeLabelFromMap(@PathVariable int id, @PathVariable int lid) throws WiseMappingException {
final User user = Utils.getUser(); final User user = Utils.getUser();
@ -590,7 +588,7 @@ public class MindmapController extends BaseController {
} }
mindmap.removeLabel(label); mindmap.removeLabel(label);
mindmapService.updateMindmap(mindmap,false); mindmapService.updateMindmap(mindmap, false);
} }
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}/labels", consumes = {"application/xml", "application/json"}) @RequestMapping(method = RequestMethod.POST, value = "/maps/{id}/labels", consumes = {"application/xml", "application/json"})
@ -604,6 +602,6 @@ public class MindmapController extends BaseController {
final Mindmap mindmap = findMindmapById(id); final Mindmap mindmap = findMindmapById(id);
mindmap.addLabel(label); mindmap.addLabel(label);
mindmapService.updateMindmap(mindmap,false); mindmapService.updateMindmap(mindmap, false);
} }
} }

View File

@ -38,7 +38,6 @@
var readOnly = ${readOnlyMode}; var readOnly = ${readOnlyMode};
var lockTimestamp = '${lockTimestamp}'; var lockTimestamp = '${lockTimestamp}';
var lockSession = '${lockSession}'; var lockSession = '${lockSession}';
var locale = '${locale}';
var mindmapLocked = ${mindmapLocked}; var mindmapLocked = ${mindmapLocked};
var mindmapLockedMsg = '<spring:message code="MINDMAP_LOCKED" arguments="${lockInfo.user.fullName},${lockInfo.user.email}"/>'; var mindmapLockedMsg = '<spring:message code="MINDMAP_LOCKED" arguments="${lockInfo.user.fullName},${lockInfo.user.email}"/>';
var userOptions = ${mindmap.properties}; var userOptions = ${mindmap.properties};