mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
Fill current tags and selection
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
const QnDialogs = {
|
const QnDialogs = {
|
||||||
|
|
||||||
tags: function (callback) {
|
tags: function (currentTags, selectedTags, callback) {
|
||||||
return $.when(this._getMessageTemplate()).then(function ($tmpl) {
|
return $.when(this._getMessageTemplate()).then(function ($tmpl) {
|
||||||
var dialogName = 'qn-dialog-content';
|
var dialogName = 'qn-dialog-content';
|
||||||
var dialogId = '#' + dialogName;
|
var dialogId = '#' + dialogName;
|
||||||
@@ -45,11 +45,15 @@ const QnDialogs = {
|
|||||||
|
|
||||||
input.select2({
|
input.select2({
|
||||||
placeholder: t('quicknotes', 'Enter tag name'),
|
placeholder: t('quicknotes', 'Enter tag name'),
|
||||||
tokenSeparators: [',', ' '],
|
tokenSeparators: ',',
|
||||||
tags: true,
|
tags: currentTags.map(function (value) { return value.name; }),
|
||||||
allowClear: true
|
allowClear: true,
|
||||||
|
toggleSelect: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
input.val(selectedTags.map(function (value) { return value.name; }));
|
||||||
|
input.trigger("change");
|
||||||
|
|
||||||
// wrap callback in _.once():
|
// wrap callback in _.once():
|
||||||
// only call callback once and not twice (button handler and close
|
// 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
|
// event) but call it for the close event, if ESC or the x is hit
|
||||||
@@ -62,7 +66,7 @@ const QnDialogs = {
|
|||||||
click: function () {
|
click: function () {
|
||||||
input.select2('close');
|
input.select2('close');
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback(false, input.val());
|
callback(false, input.select2("val"));
|
||||||
}
|
}
|
||||||
$(dialogId).ocdialog('close');
|
$(dialogId).ocdialog('close');
|
||||||
}
|
}
|
||||||
@@ -71,7 +75,7 @@ const QnDialogs = {
|
|||||||
click: function () {
|
click: function () {
|
||||||
input.select2('close');
|
input.select2('close');
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback(true, input.val());
|
callback(true, input.select2("val"));
|
||||||
}
|
}
|
||||||
$(dialogId).ocdialog('close');
|
$(dialogId).ocdialog('close');
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -615,9 +615,13 @@ View.prototype = {
|
|||||||
// handle tags button.
|
// handle tags button.
|
||||||
$('#modal-note-div #tag-button').click(function (event) {
|
$('#modal-note-div #tag-button').click(function (event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
var id = $("#modal-note-div .quicknote").data('id');
|
||||||
|
self._notes.load(id);
|
||||||
QnDialogs.tags(
|
QnDialogs.tags(
|
||||||
|
self._tags.getAll(),
|
||||||
|
self._notes.getActive().tags,
|
||||||
function(result, value) {
|
function(result, value) {
|
||||||
if (result === true && value) {
|
if (result === true) {
|
||||||
OC.Notification.showTemporary("TEST TAGS DIALOG OK");
|
OC.Notification.showTemporary("TEST TAGS DIALOG OK");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user