Initialize item-lists on init event; allow items to be hidden

This commit is contained in:
Toby Zerner 2015-03-05 12:06:40 +10:30
parent 109fe23607
commit 98476757ae
4 changed files with 17 additions and 13 deletions

View File

@ -13,12 +13,12 @@ export default Ember.Component.extend({
if (!Ember.isArray(items)) {
return [];
}
var instances = [];
items.forEach(function(item) {
item.reopenClass({
isListItem: item.proto().tagName === 'li',
listItemClass: item.proto().listItemClass
});
item = item.create();
item.set('isListItem', item.constructor.proto().tagName === 'li');
instances.pushObject(item);
});
return items;
return instances;
})
});

View File

@ -7,7 +7,7 @@ import SeparatorItem from 'flarum/components/ui/separator-item';
export default Ember.Mixin.create({
itemLists: [],
initItemLists: Ember.on('didInsertElement', function() {
initItemLists: Ember.on('init', function() {
var self = this;
this.get('itemLists').forEach(function(name) {
self.initItemList(name);

View File

@ -1,7 +1,9 @@
{{#each item in listItems}}
{{#if item.isListItem}}
{{view item}}
{{else}}
<li class="{{item.listItemClass}}">{{view item}}</li>
{{/if}}
{{#unless item.isHiddenInList}}
{{#if item.isListItem}}
{{view item}}
{{else}}
<li class="{{item.listItemClass}}">{{view item}}</li>
{{/if}}
{{/unless}}
{{/each}}

View File

@ -54,12 +54,14 @@ export default Ember.View.extend(HasItemLists, {
buttonClass: 'btn-primary',
listItemClass: 'primary-control',
}), 'controls');
},
items.pushObjectWithTag(StreamScrubber.extend({
addStreamScrubber: Ember.on('didInsertElement', function() {
this.get('sidebar').pushObjectWithTag(StreamScrubber.extend({
streamContent: this.get('streamContent'),
listItemClass: 'title-control'
}), 'scrubber');
},
}),
populateControls: function(items) {
var view = this;