mirror of
https://github.com/flarum/core.git
synced 2025-08-23 16:43:21 +02:00
Show modal if # of primary/secondary tags is less than required (#41)
This commit is contained in:
committed by
Franz Liedke
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) {
|
override(DiscussionComposer.prototype, 'onsubmit', function (original) {
|
||||||
var _this2 = this;
|
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({
|
app.modal.show(new TagDiscussionModal({
|
||||||
selectedTags: [],
|
selectedTags: chosenTags,
|
||||||
onsubmit: function onsubmit(tags) {
|
onsubmit: function onsubmit(tags) {
|
||||||
_this2.tags = tags;
|
_this2.tags = tags;
|
||||||
original();
|
original();
|
||||||
|
@@ -43,10 +43,15 @@ export default function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
override(DiscussionComposer.prototype, 'onsubmit', function(original) {
|
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(
|
app.modal.show(
|
||||||
new TagDiscussionModal({
|
new TagDiscussionModal({
|
||||||
selectedTags: [],
|
selectedTags: chosenTags,
|
||||||
onsubmit: tags => {
|
onsubmit: tags => {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
original();
|
original();
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Flarum\Tags\Listener;
|
namespace Flarum\Tags\Listener;
|
||||||
|
|
||||||
use Flarum\Core\Post;
|
|
||||||
use Flarum\Event\DiscussionWasDeleted;
|
use Flarum\Event\DiscussionWasDeleted;
|
||||||
use Flarum\Event\DiscussionWasStarted;
|
use Flarum\Event\DiscussionWasStarted;
|
||||||
use Flarum\Event\PostWasDeleted;
|
use Flarum\Event\PostWasDeleted;
|
||||||
|
Reference in New Issue
Block a user