Skip to content

Commit 31a7eed

Browse files
committed
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.
1 parent ae0a635 commit 31a7eed

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

script/tree.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,21 @@ class PluginMoveTree {
217217
return;
218218
}
219219

220-
// check if item with same ID already exists FIXME this also needs to check the type!
221-
if (this.itemTree(src).querySelector(`li[data-id="${newID}"]`)) {
220+
// check if item with same ID and type already exists
221+
let dupSelector = `li[data-id="${newID}"]`;
222+
if (this.isItemMedia(src)) {
223+
dupSelector += '.move-media';
224+
} else {
225+
dupSelector += '.move-pages';
226+
}
227+
if (this.isItemNamespace(src)) {
228+
dupSelector += '.move-ns';
229+
} else {
230+
dupSelector += ':not(.move-ns)';
231+
}
232+
if (this.itemTree(src).querySelector(dupSelector)) {
222233
alert(LANG.plugins.move.duplicate.replace('%s', newID));
234+
src.classList.remove('selected');
223235
return;
224236
}
225237

0 commit comments

Comments
 (0)