mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +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);
|
||||
}
|
||||
|
||||
@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));
|
||||
|
@ -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(
|
||||
$('<li></li>')
|
||||
//aca jay codigo repetido
|
||||
$('<li class="chooseLabel"></li>').attr('value', value.id).attr('color', value.color)
|
||||
.append('<a href="#" onclick="return false">' +
|
||||
'<i class="icon-tag"></i>' +
|
||||
'<span style="margin-left: 5px">'+ value.title +
|
||||
'</span>' +
|
||||
'</a>'));
|
||||
"<div class='labelColor' style='background: " + value.color + "'></div>" +
|
||||
"<div class='labelName'>" + value.title + "</div>" +
|
||||
|
||||
'</a>'));
|
||||
});
|
||||
|
||||
//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);
|
||||
|
||||
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
||||
|
||||
$("#add-label-dialog-modal").dialogForm({
|
||||
type:'PUT',
|
||||
url:"c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','),
|
||||
postUpdate: function() {
|
||||
//tag selected mindmaps...
|
||||
var rows = $('#mindmapListTable').dataTableExt.getSelectedRows();
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var labelName = $(':selected', labelList).text();
|
||||
if ($(rows[i]).find('\'.labelTag:contains("' + labelName + '")\'').length == 0) {
|
||||
$(rows[i]).find('.mindmapName').append(
|
||||
labelTagsAsHtml([{
|
||||
title: labelName,
|
||||
color: $(':selected', labelList).attr('color')
|
||||
}])
|
||||
)
|
||||
}
|
||||
$(document).one('click', '.chooseLabel',
|
||||
function () {
|
||||
var labelId = $(this).attr('value');
|
||||
var labelName = $(this).text();
|
||||
var labelColor = $(this).attr('color');
|
||||
|
||||
jQuery.ajax("c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), {
|
||||
type:'POST',
|
||||
dataType: "json",
|
||||
contentType:"application/json; charset=utf-8",
|
||||
data: JSON.stringify({id: labelId}),
|
||||
success: function() {
|
||||
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>
|
||||
</div>
|
||||
|
||||
<div id="addLabelButton" class="btn-group act-multiple" style="display:none">
|
||||
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="btn-group act-multiple" style="display:none">
|
||||
<button id='addLabelButton' class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="icon-tag icon-white"></i>
|
||||
<spring:message code="ADD_LABEL"/>
|
||||
<span class="caret"></span>
|
||||
|
Loading…
Reference in New Issue
Block a user