From 31a7eed4e3166d19e48dc54e46d5e2ac9ae7dafc Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 19 Aug 2024 13:10:03 +0200 Subject: [PATCH] fix duplicate checking It's fine to have a page and a namespace named the same. Or a media file and a page named the same. --- script/tree.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/script/tree.js b/script/tree.js index 2d2705a..fa11027 100644 --- a/script/tree.js +++ b/script/tree.js @@ -217,9 +217,21 @@ class PluginMoveTree { return; } - // check if item with same ID already exists FIXME this also needs to check the type! - if (this.itemTree(src).querySelector(`li[data-id="${newID}"]`)) { + // check if item with same ID and type already exists + let dupSelector = `li[data-id="${newID}"]`; + if (this.isItemMedia(src)) { + dupSelector += '.move-media'; + } else { + dupSelector += '.move-pages'; + } + if (this.isItemNamespace(src)) { + dupSelector += '.move-ns'; + } else { + dupSelector += ':not(.move-ns)'; + } + if (this.itemTree(src).querySelector(dupSelector)) { alert(LANG.plugins.move.duplicate.replace('%s', newID)); + src.classList.remove('selected'); return; }