Fix up bug with the way we hide list items

If we use an #unless condition, then when the view is removed from the
template, it is destroyed, and cannot be inserted again. So we’ll just
keep the item there the whole time, and toggle its visibility with CSS.
This commit is contained in:
Toby Zerner 2015-02-10 19:55:22 +10:30
parent 090e8c6061
commit ffef6af403
3 changed files with 10 additions and 10 deletions

View File

@ -9,8 +9,9 @@ var precompileTemplate = Ember.Handlebars.compile;
hover which details who edited the post and when.
*/
export default Ember.Component.extend({
tagName: 'span',
tagName: 'li',
classNames: ['post-edited'],
classNameBindings: ['hidden'],
attributeBindings: ['title'],
layout: precompileTemplate('{{fa-icon "pencil"}}'),
@ -20,7 +21,7 @@ export default Ember.Component.extend({
// In the context of an item list, this item will be hidden if the post
// hasn't been edited, or if it's been hidden.
hideItem: Ember.computed('post.isEdited', 'post.isHidden', function() {
hidden: Ember.computed('post.isEdited', 'post.isHidden', function() {
return !this.get('post.isEdited') || this.get('post.isHidden');
}),

View File

@ -9,9 +9,10 @@ var precompileTemplate = Ember.Handlebars.compile;
*/
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['hidden'],
layout: precompileTemplate('<a href="#" class="btn btn-default btn-more" {{action "toggle"}}>{{fa-icon "ellipsis-h"}}</a>'),
hideItem: Ember.computed.not('post.isHidden'),
hidden: Ember.computed.not('post.isHidden'),
actions: {
toggle: function() {

View File

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