Skip to content

Commit

Permalink
allow deleting below minEntries
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Aug 22, 2024
1 parent 4439082 commit 339d57f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
11 changes: 1 addition & 10 deletions src/fields/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,7 @@ public function canDeleteElement(NestedElementInterface $element, User $user): ?
return false;
}

// Make sure we aren't hitting the Min Entries limit
return !$this->minEntriesReached($owner);
return true;
}

/**
Expand All @@ -602,14 +601,6 @@ public function canDeleteElementForSite(NestedElementInterface $element, User $u
return false;
}

private function minEntriesReached(ElementInterface $owner): bool
{
return (
$this->minEntries &&
$this->minEntries >= $this->totalEntries($owner)
);
}

private function maxEntriesReached(ElementInterface $owner): bool
{
return (
Expand Down
4 changes: 1 addition & 3 deletions src/web/assets/cp/src/js/NestedElementManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ Craft.NestedElementManager = Garnish.Base.extend(
return true;
}

const total = this.getTotalElements();

return total !== null && total - (num || 1) >= this.settings.minElements;
return this.getTotalElements() !== null;
},

getElementIds() {
Expand Down

0 comments on commit 339d57f

Please sign in to comment.