You've already forked joplin
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user