mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 06:53:47 +08:00
Show modal if # of primary/secondary tags is less than required (#41)
This commit is contained in:
parent
fb17769074
commit
3c0efb3373
11
extensions/tags/js/forum/dist/extension.js
vendored
11
extensions/tags/js/forum/dist/extension.js
vendored
|
@ -49,9 +49,16 @@ System.register('flarum/tags/addTagComposer', ['flarum/extend', 'flarum/componen
|
|||
override(DiscussionComposer.prototype, 'onsubmit', function (original) {
|
||||
var _this2 = this;
|
||||
|
||||
if (!this.tags.length) {
|
||||
var chosenTags = this.tags;
|
||||
var chosenPrimaryTags = chosenTags.filter(function (tag) {
|
||||
return tag.position() !== null && !tag.isChild();
|
||||
});
|
||||
var chosenSecondaryTags = chosenTags.filter(function (tag) {
|
||||
return tag.position() === null;
|
||||
});
|
||||
if (!chosenTags.length || chosenPrimaryTags.length < app.forum.attribute('minPrimaryTags') || chosenSecondaryTags.length < app.forum.attribute('minSecondaryTags')) {
|
||||
app.modal.show(new TagDiscussionModal({
|
||||
selectedTags: [],
|
||||
selectedTags: chosenTags,
|
||||
onsubmit: function onsubmit(tags) {
|
||||
_this2.tags = tags;
|
||||
original();
|
||||
|
|
|
@ -43,10 +43,15 @@ export default function() {
|
|||
});
|
||||
|
||||
override(DiscussionComposer.prototype, 'onsubmit', function(original) {
|
||||
if (!this.tags.length) {
|
||||
const chosenTags = this.tags;
|
||||
const chosenPrimaryTags = chosenTags.filter(tag => tag.position() !== null && !tag.isChild());
|
||||
const chosenSecondaryTags = chosenTags.filter(tag => tag.position() === null);
|
||||
if (!chosenTags.length
|
||||
|| (chosenPrimaryTags.length < app.forum.attribute('minPrimaryTags'))
|
||||
|| (chosenSecondaryTags.length < app.forum.attribute('minSecondaryTags'))) {
|
||||
app.modal.show(
|
||||
new TagDiscussionModal({
|
||||
selectedTags: [],
|
||||
selectedTags: chosenTags,
|
||||
onsubmit: tags => {
|
||||
this.tags = tags;
|
||||
original();
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
namespace Flarum\Tags\Listener;
|
||||
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Event\DiscussionWasDeleted;
|
||||
use Flarum\Event\DiscussionWasStarted;
|
||||
use Flarum\Event\PostWasDeleted;
|
||||
|
|
Loading…
Reference in New Issue
Block a user