Skip to content

Commit

Permalink
fix duplicate checking
Browse files Browse the repository at this point in the history
It's fine to have a page and a namespace named the same. Or a media file
and a page named the same.
  • Loading branch information
splitbrain committed Aug 19, 2024
1 parent ae0a635 commit 31a7eed
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions script/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 31a7eed

Please sign in to comment.