Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
665da59
commit 076bd94
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
assets/javascripts/discourse/connectors/edit-topic/topic-controls-event.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{#if showEventControls}} | ||
{{add-event-controls event=buffered.event category=buffered.category noText=site.mobileView}} | ||
{{/if}} |
21 changes: 21 additions & 0 deletions
21
assets/javascripts/discourse/connectors/edit-topic/topic-controls-event.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
}) | ||
} | ||
} |