mirror of
https://github.com/flarum/core.git
synced 2025-08-15 04:44:08 +02:00
Fix extension to work with latest state changes
This commit is contained in:
@@ -17,7 +17,7 @@ function tagItem(tag) {
|
|||||||
{Button.component({
|
{Button.component({
|
||||||
className: 'Button Button--link',
|
className: 'Button Button--link',
|
||||||
icon: 'fas fa-pencil-alt',
|
icon: 'fas fa-pencil-alt',
|
||||||
onclick: () => app.modal.show(new EditTagModal({tag}))
|
onclick: () => app.modal.show(EditTagModal, {tag})
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{!tag.isChild() && tag.position() !== null ? (
|
{!tag.isChild() && tag.position() !== null ? (
|
||||||
@@ -44,12 +44,12 @@ export default class TagsPage extends Page {
|
|||||||
className: 'Button Button--primary',
|
className: 'Button Button--primary',
|
||||||
icon: 'fas fa-plus',
|
icon: 'fas fa-plus',
|
||||||
children: app.translator.trans('flarum-tags.admin.tags.create_tag_button'),
|
children: app.translator.trans('flarum-tags.admin.tags.create_tag_button'),
|
||||||
onclick: () => app.modal.show(new EditTagModal())
|
onclick: () => app.modal.show(EditTagModal)
|
||||||
})}
|
})}
|
||||||
{Button.component({
|
{Button.component({
|
||||||
className: 'Button',
|
className: 'Button',
|
||||||
children: app.translator.trans('flarum-tags.admin.tags.settings_button'),
|
children: app.translator.trans('flarum-tags.admin.tags.settings_button'),
|
||||||
onclick: () => app.modal.show(new TagSettingsModal())
|
onclick: () => app.modal.show(TagSettingsModal)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -5,8 +5,8 @@ import DiscussionComposer from 'flarum/components/DiscussionComposer';
|
|||||||
import TagDiscussionModal from './components/TagDiscussionModal';
|
import TagDiscussionModal from './components/TagDiscussionModal';
|
||||||
import tagsLabel from '../common/helpers/tagsLabel';
|
import tagsLabel from '../common/helpers/tagsLabel';
|
||||||
|
|
||||||
export default function() {
|
export default function () {
|
||||||
extend(IndexPage.prototype, 'newDiscussionAction', function(promise) {
|
extend(IndexPage.prototype, 'newDiscussionAction', function (promise) {
|
||||||
const tag = app.store.getBy('tags', 'slug', app.search.params().tags);
|
const tag = app.store.getBy('tags', 'slug', app.search.params().tags);
|
||||||
|
|
||||||
if (tag) {
|
if (tag) {
|
||||||
@@ -18,21 +18,19 @@ export default function() {
|
|||||||
|
|
||||||
// Add tag-selection abilities to the discussion composer.
|
// Add tag-selection abilities to the discussion composer.
|
||||||
DiscussionComposer.prototype.tags = [];
|
DiscussionComposer.prototype.tags = [];
|
||||||
DiscussionComposer.prototype.chooseTags = function() {
|
DiscussionComposer.prototype.chooseTags = function () {
|
||||||
app.modal.show(
|
app.modal.show(TagDiscussionModal, {
|
||||||
new TagDiscussionModal({
|
selectedTags: this.tags.slice(0),
|
||||||
selectedTags: this.tags.slice(0),
|
onsubmit: tags => {
|
||||||
onsubmit: tags => {
|
this.tags = tags;
|
||||||
this.tags = tags;
|
this.$('textarea').focus();
|
||||||
this.$('textarea').focus();
|
}
|
||||||
}
|
});
|
||||||
})
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add a tag-selection menu to the discussion composer's header, after the
|
// Add a tag-selection menu to the discussion composer's header, after the
|
||||||
// title.
|
// title.
|
||||||
extend(DiscussionComposer.prototype, 'headerItems', function(items) {
|
extend(DiscussionComposer.prototype, 'headerItems', function (items) {
|
||||||
items.add('tags', (
|
items.add('tags', (
|
||||||
<a className="DiscussionComposer-changeTags" onclick={this.chooseTags.bind(this)}>
|
<a className="DiscussionComposer-changeTags" onclick={this.chooseTags.bind(this)}>
|
||||||
{this.tags.length
|
{this.tags.length
|
||||||
@@ -42,29 +40,27 @@ export default function() {
|
|||||||
), 10);
|
), 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
override(DiscussionComposer.prototype, 'onsubmit', function(original) {
|
override(DiscussionComposer.prototype, 'onsubmit', function (original) {
|
||||||
const chosenTags = this.tags;
|
const chosenTags = this.tags;
|
||||||
const chosenPrimaryTags = chosenTags.filter(tag => tag.position() !== null && !tag.isChild());
|
const chosenPrimaryTags = chosenTags.filter(tag => tag.position() !== null && !tag.isChild());
|
||||||
const chosenSecondaryTags = chosenTags.filter(tag => tag.position() === null);
|
const chosenSecondaryTags = chosenTags.filter(tag => tag.position() === null);
|
||||||
if (!chosenTags.length
|
if (!chosenTags.length
|
||||||
|| (chosenPrimaryTags.length < app.forum.attribute('minPrimaryTags'))
|
|| (chosenPrimaryTags.length < app.forum.attribute('minPrimaryTags'))
|
||||||
|| (chosenSecondaryTags.length < app.forum.attribute('minSecondaryTags'))) {
|
|| (chosenSecondaryTags.length < app.forum.attribute('minSecondaryTags'))) {
|
||||||
app.modal.show(
|
app.modal.show(TagDiscussionModal, {
|
||||||
new TagDiscussionModal({
|
|
||||||
selectedTags: chosenTags,
|
selectedTags: chosenTags,
|
||||||
onsubmit: tags => {
|
onsubmit: tags => {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
original();
|
original();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
original();
|
original();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add the selected tags as data to submit to the server.
|
// Add the selected tags as data to submit to the server.
|
||||||
extend(DiscussionComposer.prototype, 'data', function(data) {
|
extend(DiscussionComposer.prototype, 'data', function (data) {
|
||||||
data.relationships = data.relationships || {};
|
data.relationships = data.relationships || {};
|
||||||
data.relationships.tags = this.tags;
|
data.relationships.tags = this.tags;
|
||||||
});
|
});
|
||||||
|
@@ -11,7 +11,7 @@ export default function() {
|
|||||||
items.add('tags', Button.component({
|
items.add('tags', Button.component({
|
||||||
children: app.translator.trans('flarum-tags.forum.discussion_controls.edit_tags_button'),
|
children: app.translator.trans('flarum-tags.forum.discussion_controls.edit_tags_button'),
|
||||||
icon: 'fas fa-tag',
|
icon: 'fas fa-tag',
|
||||||
onclick: () => app.modal.show(new TagDiscussionModal({discussion}))
|
onclick: () => app.modal.show(TagDiscussionModal, {discussion})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user