1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

All: Fixes #657: Disallow giving name of existing tag to another tag

This commit is contained in:
Laurent Cozic
2018-09-06 18:33:21 +01:00
parent ef1ae63233
commit 32c81ad8c2
3 changed files with 50 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ const BaseItem = require('lib/models/BaseItem.js');
const NoteTag = require('lib/models/NoteTag.js');
const Note = require('lib/models/Note.js');
const { time } = require('lib/time-utils.js');
const { _ } = require('lib/locale');
class Tag extends BaseItem {
@@ -153,6 +154,9 @@ class Tag extends BaseItem {
if (options && options.userSideValidation) {
if ('title' in o) {
o.title = o.title.trim().toLowerCase();
const existingTag = await Tag.loadByTitle(o.title);
if (existingTag && existingTag.id !== o.id) throw new Error(_('The tag "%s" already exists. Please choose a different name.', o.title));
}
}