Skip to content

Commit

Permalink
remove model for user
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavk96 committed Jul 12, 2019
1 parent cc0df36 commit c209cec
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 95 deletions.
143 changes: 56 additions & 87 deletions app/controllers/admin/users/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,100 +10,69 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
@computed()
get columns() {
return [
// {
// name : 'Name',
// valuePath : 'firstName',
// cellComponent : 'ui-table/cell/admin/users/cell-first-name',
// options : {
// hasRestorePrivileges: this.hasRestorePrivileges
// },
// actions: {
// moveToUserDetails : this.moveToUserDetails.bind(this),
// deleteUser : this.deleteUser.bind(this),
// openEditModal : this.openEditModal.bind(this),
// restoreUser : this.restoreUser.bind(this)
// }
//
// },
{
name : 'Name',
valuePath : null,
cellComponent : 'ui-table/cell/admin/users/cell-first-name',
options : {
hasRestorePrivileges: this.hasRestorePrivileges
},
actions: {
moveToUserDetails : this.moveToUserDetails.bind(this),
deleteUser : this.deleteUser.bind(this),
openEditModal : this.openEditModal.bind(this),
restoreUser : this.restoreUser.bind(this)
}

},
{
name : 'Email',
valuePath : 'email'


},
// {
// name : 'Status',
// valuePath : 'status',
// cellComponent : 'ui-table/cell/admin/users/cell-status'
//
//
// },
// {
// name : 'System Roles',
// valuePath : 'systemRoles',
// cellComponent : 'ui-table/cell/admin/users/cell-system-roles'
//
//
// },
// {
// name : 'Event Roles',
// valuePath : 'eventRoles',
// cellComponent : 'ui-table/cell/admin/users/cell-event-roles'
//
//
// },
// {
// name : 'User Links',
// valuePath : 'userLinks',
// cellComponent : 'ui-table/cell/admin/users/cell-user-links'
//
//
// },
// {
// name : 'Member Since',
// valuePath : 'createdAt',
// cellComponent : 'ui-table/cell/admin/users/cell-created-at'
// },
// {
// name : 'Last Accessed',
// valuePath : 'lastAccessedAt',
// cellComponent : 'ui-table/cell/cell-simple-date',
// options : {
// dateFormat: 'MMMM DD, YYYY - hh:mm A'
// }
//
//
// }
];
}
{
name : 'Status',
valuePath : 'status',
cellComponent : 'ui-table/cell/admin/users/cell-status'

@computed('model.[]')
get rows() {
console.log(this.model);
console.log(this.model.map(row => {
return {
firstName : row,
email : row.email,
status : row,
systemRoles : row,
eventRoles : row,
userLinks : row,
createdAt : row,
lastAccessedAt : row
};
}));
return this.model.map(row => {
return {
firstName : row,
email : row.email,
status : row,
systemRoles : row,
eventRoles : row,
userLinks : row,
createdAt : row,
lastAccessedAt : row
};
});

},
{
name : 'System Roles',
valuePath : null,
cellComponent : 'ui-table/cell/admin/users/cell-system-roles'


},
{
name : 'Event Roles',
valuePath : null,
cellComponent : 'ui-table/cell/admin/users/cell-event-roles'


},
{
name : 'User Links',
valuePath : null,
cellComponent : 'ui-table/cell/admin/users/cell-user-links'


},
{
name : 'Member Since',
valuePath : 'createdAt',
cellComponent : 'ui-table/cell/admin/users/cell-created-at'
},
{
name : 'Last Accessed',
valuePath : 'lastAccessedAt',
cellComponent : 'ui-table/cell/cell-simple-date',
options : {
dateFormat: 'MMMM DD, YYYY - hh:mm A'
}
}
];
}

@action
Expand Down
20 changes: 20 additions & 0 deletions app/mixins/ember-table-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ export default Mixin.create({
delete query.sort;
}
return query;
},

/**
* Convert the given ArrayProxy or Promise<ArrayProxy> to a native Array.
*
* @param promise
* @return {Promise<Array>}
*/
async asArray(promise) {
console.log(promise);
const resolved = await promise;
console.log(resolved);
console.log(resolved.toArray());
if (resolved.toArray) {
return {
data : resolved.toArray(),
metaData : resolved.meta
};
}
return resolved;
}


Expand Down
3 changes: 1 addition & 2 deletions app/routes/admin/users/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ export default class extends Route.extend(EmberTableRouteMixin) {
};

queryString = this.applySortFilters(queryString, params);

return this.store.query('user', queryString);
return this.asArray(this.store.query('user', queryString));
}
@action
refreshRoute() {
Expand Down
4 changes: 2 additions & 2 deletions app/templates/admin/users/list.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="sixteen wide column">
{{tables/default columns=columns
rows=model.arrangedContent
rows=model.data
currentPage=page
pageSize=per_page
searchQuery=search
sortBy=sort_by
sortDir=sort_dir
metaData=model.meta
metaData=model.metaData
filterOptions=filterOptions
widthConstraint="eq-container"
resizeMode="fluid"
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/tables/default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{{#r.cell as |cell column row|}}
{{#if column.cellComponent}}
{{#component column.cellComponent
record=(get row column.valuePath)
record=(if column.valuePath (get row column.valuePath) row)
extraRecords=(get-properties row column.extraValuePaths)
props=(hash options=column.options actions=column.actions)
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span>
{{moment-from-now record.createdAt}}
{{moment-from-now record}}
</span>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#if (eq record.status 'active')}}
{{#if (eq record 'active')}}
<div class="ui green label">{{t 'Active'}}</div>
{{else if (eq record.status 'inactive')}}
{{else if (eq record 'inactive')}}
<div class="ui yellow label">{{t 'Inactive'}}</div>
{{else}}
<div class="ui red label">{{t 'Deleted'}}</div>
Expand Down

0 comments on commit c209cec

Please sign in to comment.