This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/group.js.es6
2016-03-08 12:25:46 +01:00

45 lines
975 B
JavaScript

import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
var Tab = Em.Object.extend({
@computed('name')
location(name) {
return 'group.' + name;
},
@computed('name')
message(name) {
return I18n.t('groups.' + name);
}
});
export default Ember.Controller.extend({
counts: null,
showing: 'posts',
@observes('counts')
countsChanged() {
const counts = this.get('counts');
this.get('tabs').forEach(tab => {
tab.set('count', counts.get(tab.get('name')));
});
},
@observes('showing')
showingChanged() {
const showing = this.get('showing');
this.get('tabs').forEach(tab => {
tab.set('active', showing === tab.get('name'));
});
},
tabs: [
Tab.create({ name: 'posts', active: true, 'location': 'group.index' }),
Tab.create({ name: 'topics' }),
Tab.create({ name: 'mentions' }),
Tab.create({ name: 'members' }),
Tab.create({ name: 'messages' }),
]
});