ember.js - Ember: How to add "else" to wrap component? -


i have component hide parts of design depending on user permissions.

just hide not problem. need display when user has no access.

route template:

{{#restricted-access required-action="addroles"}}     <button class="btn btn-success"  {{action 'add'}}>         add new role     </button> {{else}}     can not add roles {{/restricted-access}} 

component check code:

actionallowed: function() {     var permission = this.get('current.user.role.roleactionlist');     return permissions.filterproperty('code', this.get('required-action')).length > 0; }.property('current.user.role.roleactionlist.length') 

component template:

{{#if actionallowed}}     {{yield}} {{/if}} 

i'm looking like

{{#if actionallowed}}     {{yield}} {{else}}     {{else yield}} {{/if}} 

where can add text defined in route template.

i guess can that:

{{#restricted-access required-action="addroles"}}     {{#access-granted}}         <button class="btn btn-success"  {{action 'add'}}>             add new role         </button>     {{#access-granted}}     {{#access-declined}}         can not add roles     {{/access-declined}} {{/restricted-access}} 

actually not had create additional components.

is there way implement required functionality in 1 component?

as else block string, pass parameter else text:

{{#restricted-access required-action="addroles" noaccesstext="you can not add roles"}}     <button class="btn btn-success"  {{action 'add'}}>         add new role     </button> {{/restricted-access}} 

template component:

{{#if actionallowed}}     {{yield}} {{else}}     {{noaccesstext}} {{/if}} 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -