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