Fill current tags and selection

This commit is contained in:
Matias De lellis
2019-11-11 20:58:35 -03:00
parent 3ce6b401bb
commit 68d82ef82e
2 changed files with 15 additions and 7 deletions

View File

@@ -24,7 +24,7 @@
*/
const QnDialogs = {
tags: function (callback) {
tags: function (currentTags, selectedTags, callback) {
return $.when(this._getMessageTemplate()).then(function ($tmpl) {
var dialogName = 'qn-dialog-content';
var dialogId = '#' + dialogName;
@@ -45,11 +45,15 @@ const QnDialogs = {
input.select2({
placeholder: t('quicknotes', 'Enter tag name'),
tokenSeparators: [',', ' '],
tags: true,
allowClear: true
tokenSeparators: ',',
tags: currentTags.map(function (value) { return value.name; }),
allowClear: true,
toggleSelect: true
});
input.val(selectedTags.map(function (value) { return value.name; }));
input.trigger("change");
// wrap callback in _.once():
// only call callback once and not twice (button handler and close
// event) but call it for the close event, if ESC or the x is hit
@@ -62,7 +66,7 @@ const QnDialogs = {
click: function () {
input.select2('close');
if (callback !== undefined) {
callback(false, input.val());
callback(false, input.select2("val"));
}
$(dialogId).ocdialog('close');
}
@@ -71,7 +75,7 @@ const QnDialogs = {
click: function () {
input.select2('close');
if (callback !== undefined) {
callback(true, input.val());
callback(true, input.select2("val"));
}
$(dialogId).ocdialog('close');
},

View File

@@ -615,9 +615,13 @@ View.prototype = {
// handle tags button.
$('#modal-note-div #tag-button').click(function (event) {
event.stopPropagation();
var id = $("#modal-note-div .quicknote").data('id');
self._notes.load(id);
QnDialogs.tags(
self._tags.getAll(),
self._notes.getActive().tags,
function(result, value) {
if (result === true && value) {
if (result === true) {
OC.Notification.showTemporary("TEST TAGS DIALOG OK");
}
else {