Permalink
Browse files

feat(actions): check visibility of the actions

  • Loading branch information...
jeremyvergnas authored and doktordirk committed Nov 10, 2016
1 parent a5e3c7d commit ae2f844f95d44c82e9dbb856b78fe1968e6bf293
Showing with 9 additions and 1 deletion.
  1. +1 −1 src/bootstrap/datatable.html
  2. +8 −0 src/datatable.js
@@ -70,7 +70,7 @@
<i class="fa fa-trash"></i>
</button>
<button repeat.for="action of actions" t="[title]${action.title}" title.bind="action.title || ''" disabled.bind="checkDisabled(action, row)" class="btn btn-sm btn-${action.type || 'default'}" click.trigger="doCustomAction(action, row)">
<button repeat.for="action of actions" if.bind="checkVisibility(action, row)" t="[title]${action.title}" title.bind="action.title || ''" disabled.bind="checkDisabled(action, row)" class="btn btn-sm btn-${action.type || 'default'}" click.trigger="doCustomAction(action, row)">
<i if.bind="action.icon" class="fa fa-${action.icon}"></i>
<span if.bind="!action.icon && action.title" t="${action.title}">${action.title}</span>
</button>
@@ -143,6 +143,14 @@ export class DataTable {
return false;
}
checkVisibility(action, row) {
if (typeof action.visible === 'function') {
return action.visible(row);
}
return true;
}
showActions() {
return this.destroy !== null || this.edit !== null || this.actions.length > 0;
}

0 comments on commit ae2f844

Please sign in to comment.