mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
Fix create, delete and drop orphan tags
This commit is contained in:
@@ -46,12 +46,19 @@ const QnDialogs = {
|
||||
input.select2({
|
||||
placeholder: t('quicknotes', 'Enter tag name'),
|
||||
tokenSeparators: ',',
|
||||
tags: currentTags.map(function (value) { return value.name; }),
|
||||
multiple: false,
|
||||
allowClear: true,
|
||||
toggleSelect: true
|
||||
toggleSelect: true,
|
||||
tags : function () {
|
||||
var data = [];
|
||||
currentTags.forEach(function (item, index) {
|
||||
data.push({id: item.id, text: item.name});
|
||||
});
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
||||
input.val(selectedTags.map(function (value) { return value.name; }));
|
||||
input.val(selectedTags.map(function (value) { return value.id; }));
|
||||
input.trigger("change");
|
||||
|
||||
// wrap callback in _.once():
|
||||
@@ -66,7 +73,7 @@ const QnDialogs = {
|
||||
click: function () {
|
||||
input.select2('close');
|
||||
if (callback !== undefined) {
|
||||
callback(false, input.select2("val"));
|
||||
callback(false, input.select2("data"));
|
||||
}
|
||||
$(dialogId).ocdialog('close');
|
||||
}
|
||||
@@ -75,7 +82,7 @@ const QnDialogs = {
|
||||
click: function () {
|
||||
input.select2('close');
|
||||
if (callback !== undefined) {
|
||||
callback(true, input.select2("val"));
|
||||
callback(true, input.select2("data"));
|
||||
}
|
||||
$(dialogId).ocdialog('close');
|
||||
},
|
||||
|
||||
10
js/script.js
10
js/script.js
@@ -330,7 +330,10 @@ View.prototype = {
|
||||
var content = $('#modal-note-div #content-editable').html().trim();
|
||||
var color = this.colorToHex($("#modal-note-div .quicknote").css("background-color"));
|
||||
var tags = $("#modal-note-div .slim-tag").toArray().map(function (value) {
|
||||
return value.textContent.trim();
|
||||
return {
|
||||
id: value.getAttribute('data-id'),
|
||||
name: value.textContent.trim()
|
||||
};
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -352,6 +355,7 @@ View.prototype = {
|
||||
var modalnote = $("#modal-note-div .quicknote");
|
||||
var modaltitle = $('#modal-note-div #title-editable');
|
||||
var modalcontent = $('#modal-note-div #content-editable');
|
||||
var modaltags = $('#modal-note-div .note-tags');
|
||||
|
||||
self._notes.unsetActive();
|
||||
|
||||
@@ -361,6 +365,7 @@ View.prototype = {
|
||||
modalnote.data('id', -1);
|
||||
modaltitle.html("");
|
||||
modalcontent.html("");
|
||||
modaltags.html("");
|
||||
|
||||
self.render();
|
||||
}).fail(function () {
|
||||
@@ -632,7 +637,8 @@ View.prototype = {
|
||||
var modalTags = $('#modal-note-div .note-tags');
|
||||
modalTags.html('');
|
||||
newTags.forEach(function (item, index) {
|
||||
var tag = $('<div class="slim-tag" data-id="-1">' + item + '</div>');
|
||||
var noteId = parseInt(item.id) || -1;
|
||||
var tag = $('<div class="slim-tag" data-id="' + noteId + '">' + item.text + '</div>');
|
||||
modalTags.append(tag);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user