mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-25 23:44:54 +01:00
change linkToMindmaps logic
This commit is contained in:
parent
5fe892abfd
commit
e5d9380699
@ -67,13 +67,17 @@ public class LabelController extends BaseController {
|
|||||||
return new RestLabelList(all);
|
return new RestLabelList(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.PUT, value = "/labels/maps", consumes = {"application/json"})
|
@RequestMapping(method = RequestMethod.POST, value = "/labels/maps", consumes = {"application/json"})
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.ACCEPTED)
|
||||||
public void linkToMindMaps(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids) throws WiseMappingException {
|
public void linkToMindMaps(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids, @NotNull HttpServletResponse response) throws WiseMappingException {
|
||||||
int id = restLabel.getId();
|
int id = restLabel.getId();
|
||||||
final Label label = labelService.getLabelById(id);
|
Label label = labelService.getLabelById(id);
|
||||||
if (label == null) {
|
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(",")) {
|
for (String mindmapId : ids.split(",")) {
|
||||||
final Mindmap mindmap = mindmapService.findMindmapById(Integer.parseInt(mindmapId));
|
final Mindmap mindmap = mindmapService.findMindmapById(Integer.parseInt(mindmapId));
|
||||||
|
@ -11,9 +11,13 @@ $(function () {
|
|||||||
|
|
||||||
$(document).on('click', '#createLabelBtn',
|
$(document).on('click', '#createLabelBtn',
|
||||||
function () {
|
function () {
|
||||||
|
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
||||||
$("#new-folder-dialog-modal").dialogForm({
|
$("#new-folder-dialog-modal").dialogForm({
|
||||||
url:"c/restful/labels",
|
url:"c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','),
|
||||||
postUpdate: createLabelItem
|
postUpdate: function(data, id) {
|
||||||
|
createLabelItem(data, id);
|
||||||
|
tagMindmaps(data.title, data.color);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -35,39 +39,38 @@ $(function () {
|
|||||||
//append items to dropdown
|
//append items to dropdown
|
||||||
$.each(labels, function(index, value) {
|
$.each(labels, function(index, value) {
|
||||||
labelList.append(
|
labelList.append(
|
||||||
$('<li></li>')
|
//aca jay codigo repetido
|
||||||
|
$('<li class="chooseLabel"></li>').attr('value', value.id).attr('color', value.color)
|
||||||
.append('<a href="#" onclick="return false">' +
|
.append('<a href="#" onclick="return false">' +
|
||||||
'<i class="icon-tag"></i>' +
|
"<div class='labelColor' style='background: " + value.color + "'></div>" +
|
||||||
'<span style="margin-left: 5px">'+ value.title +
|
"<div class='labelName'>" + value.title + "</div>" +
|
||||||
'</span>' +
|
|
||||||
'</a>'));
|
'</a>'));
|
||||||
});
|
});
|
||||||
|
|
||||||
//add the defaultValue
|
//add the defaultValue
|
||||||
labelList.append('<li><div style="height: 1px; background-color: #d5d3d4"></div></li>')
|
labelList.append('<li><div class="listSeparator"></div></li>')
|
||||||
labelList.append(defaultValue);
|
labelList.append(defaultValue);
|
||||||
|
|
||||||
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
||||||
|
|
||||||
$("#add-label-dialog-modal").dialogForm({
|
$(document).one('click', '.chooseLabel',
|
||||||
type:'PUT',
|
function () {
|
||||||
url:"c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','),
|
var labelId = $(this).attr('value');
|
||||||
postUpdate: function() {
|
var labelName = $(this).text();
|
||||||
//tag selected mindmaps...
|
var labelColor = $(this).attr('color');
|
||||||
var rows = $('#mindmapListTable').dataTableExt.getSelectedRows();
|
|
||||||
for (var i = 0; i < rows.length; i++) {
|
jQuery.ajax("c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), {
|
||||||
var labelName = $(':selected', labelList).text();
|
type:'POST',
|
||||||
if ($(rows[i]).find('\'.labelTag:contains("' + labelName + '")\'').length == 0) {
|
dataType: "json",
|
||||||
$(rows[i]).find('.mindmapName').append(
|
contentType:"application/json; charset=utf-8",
|
||||||
labelTagsAsHtml([{
|
data: JSON.stringify({id: labelId}),
|
||||||
title: labelName,
|
success: function() {
|
||||||
color: $(':selected', labelList).attr('color')
|
tagMindmaps(labelName, labelColor);
|
||||||
}])
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -246,10 +249,3 @@ $(function () {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
function reloadTable() {
|
|
||||||
// Reload the table data ...
|
|
||||||
var dataTable = $('#mindmapListTable').dataTable();
|
|
||||||
dataTable.fnReloadAjax("c/restful/maps/?q=" + $(this).attr('data-filter'), callbackOnTableInit, true);
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
@ -36,3 +36,18 @@ function fetchLabels(options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tagMindmaps(labelName, labelColor) {
|
||||||
|
//tag selected mindmaps...
|
||||||
|
var rows = $('#mindmapListTable').dataTableExt.getSelectedRows();
|
||||||
|
for (var i = 0; i < rows.length; i++) {
|
||||||
|
if ($(rows[i]).find('\'.labelTag:contains("' + labelName + '")\'').length == 0) {
|
||||||
|
$(rows[i]).find('.mindmapName').append(
|
||||||
|
labelTagsAsHtml([{
|
||||||
|
title: labelName,
|
||||||
|
color: labelColor
|
||||||
|
}])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -195,8 +195,8 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="addLabelButton" class="btn-group act-multiple" style="display:none">
|
<div class="btn-group act-multiple" style="display:none">
|
||||||
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
<button id='addLabelButton' class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
||||||
<i class="icon-tag icon-white"></i>
|
<i class="icon-tag icon-white"></i>
|
||||||
<spring:message code="ADD_LABEL"/>
|
<spring:message code="ADD_LABEL"/>
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
|
Loading…
Reference in New Issue
Block a user