Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
feat(exclude): exclude columns from entity
Browse files Browse the repository at this point in the history
  • Loading branch information
VMBindraban committed Aug 3, 2016
1 parent 0b84a54 commit 0075050
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -48,5 +48,5 @@ this.userEntity = entityManager.getEntity('users');
```

```html
<filter entity.bind="userEntity" criteria.bind="criteria"></filter>
<filter entity.bind="userEntity" criteria.bind="criteria" exclude-columns="password, createdAt"></filter>
```
3 changes: 3 additions & 0 deletions doc/Usage.md
Expand Up @@ -26,6 +26,9 @@ This is as simple as `EntityManager.getEntity('resource')`. *[More information](

If you don't use the `@type` decorator it will assume that the column is `text`.

### exclude-columns
When using an entity, you can exclude columns (comma separated) from showing up in the filter.

### criteria
The generated criteria object. Use this object to query your application.

Expand Down
7 changes: 7 additions & 0 deletions src/filter.js
Expand Up @@ -8,6 +8,7 @@ export class Filter extends CriteriaBuilder {
@bindable({defaultBindingMode: bindingMode.twoWay}) criteria = {};
@bindable columns = [];
@bindable entity = null;
@bindable excludeColumns;

filters = [];
fieldElement = {
Expand Down Expand Up @@ -210,9 +211,15 @@ export class Filter extends CriteriaBuilder {
}

generateFields(columns, entityName) {
let excludeColumns = (this.excludeColumns) ? this.excludeColumns.replace(/\s/g, '').split(',') : [];

for (let column in columns) {
let columnName = (entityName) ? entityName + '.' + column : column;

if (excludeColumns.indexOf(columnName) > -1) {
continue;
}

this.columns.push({
name: columnName,
value: columnName,
Expand Down

0 comments on commit 0075050

Please sign in to comment.