Skip to content

Commit

Permalink
add event controls to topic edit
Browse files Browse the repository at this point in the history
  • Loading branch information
angusmcleod committed May 21, 2019
1 parent 665da59 commit 076bd94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
@@ -0,0 +1,3 @@
{{#if showEventControls}}
{{add-event-controls event=buffered.event category=buffered.category noText=site.mobileView}}
{{/if}}
@@ -0,0 +1,21 @@
import { getOwner } from 'discourse-common/lib/get-owner';
import Category from 'discourse/models/category';

export default {
setupComponent(attrs, component) {
const buffered = this.get('buffered');
const user = Discourse.User.current();
const showEventControls = (category) => {
return category.events_enabled && (
user.staff ||
user.trust_level >= category.events_min_trust_to_create
);
}
component.set('showEventControls', showEventControls(buffered.get('category')))
buffered.addObserver('category_id', () => {
if (this._state === 'destroying') return;
let category = Category.findById(this.get('buffered.category_id'));
component.set('showEventControls', showEventControls(category));
})
}
}

0 comments on commit 076bd94

Please sign in to comment.