fix(tags): tag selection modal shown when no tags can be selected (#3448)

This commit is contained in:
Sami Mazouz 2022-06-20 16:53:11 +01:00 committed by GitHub
parent 3e56bd3dc6
commit 613523c9b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,10 +65,15 @@ export default function () {
const chosenSecondaryTags = chosenTags.filter((tag) => tag.position() === null);
const selectableTags = getSelectableTags();
const minPrimaryTags = parseInt(app.forum.attribute('minPrimaryTags'));
const minSecondaryTags = parseInt(app.forum.attribute('minSecondaryTags'));
const maxPrimaryTags = parseInt(app.forum.attribute('maxPrimaryTags'));
const maxSecondaryTags = parseInt(app.forum.attribute('maxSecondaryTags'));
if (
(!chosenTags.length ||
chosenPrimaryTags.length < app.forum.attribute('minPrimaryTags') ||
chosenSecondaryTags.length < app.forum.attribute('minSecondaryTags')) &&
((!chosenTags.length && maxPrimaryTags !== 0 && maxSecondaryTags !== 0) ||
chosenPrimaryTags.length < minPrimaryTags ||
chosenSecondaryTags.length < minSecondaryTags) &&
selectableTags.length
) {
app.modal.show(TagDiscussionModal, {