Don't filter env vars in controller

Depending on isNew can result in rerendering templates in some cases, which will
also create a new object controller, which in turn will reset isEditing value.
This commit is contained in:
Piotr Sarnacki 2015-02-06 13:20:56 +01:00
parent ab33383d15
commit 95619b42fb
2 changed files with 15 additions and 13 deletions

View File

@ -1,6 +1,6 @@
`import Ember from 'ember'`
Controller = Ember.ArrayController.extend
vars: Ember.computed.filterBy('model', 'isNew', false)
vars: Ember.computed.alias('model')
`export default Controller`

View File

@ -2,17 +2,19 @@
<ul class="env-vars">
{{#each vars itemController="envVar"}}
<li class="env-var">
{{#if isEditing}}
{{partial 'env_vars/form'}}
{{else}}
<a href="#" class="edit-var" {{action "edit"}}>Edit</a>
<a href="#" {{action "delete"}} {{bind-attr class=":delete-var isDeleting:deleting"}}>
Delete
</a>
<span class="name">{{name}}</span>
<span {{bind-attr class=":value :value-display public::secure"}}>{{value}}</span>
{{/if}}
</li>
{{#unless isNew}}
<li class="env-var">
{{#if isEditing}}
{{partial 'env_vars/form'}}
{{else}}
<a href="#" class="edit-var" {{action "edit"}}>Edit</a>
<a href="#" {{action "delete"}} {{bind-attr class=":delete-var isDeleting:deleting"}}>
Delete
</a>
<span class="name">{{name}}</span>
<span {{bind-attr class=":value :value-display public::secure"}}>{{value}}</span>
{{/if}}
</li>
{{/unless}}
{{/each}}
</ul>