import * as moment from 'moment'; import { Model, XformToStoryContract, XformToCardContract, XformToListContract, StoryContract, CardContract, ListContract } from '../../sb/core'; import { UserContract } from "../contracts"; import pluralize from 'pluralize'; export class User extends Model implements XformToStoryContract, XformToCardContract, XformToListContract{ modelName = 'user'; // actions = [{ // icon: 'ellipsis-v', // actions: ['clusters', 'projects', 'teams', 'repositories', 'feeds', 'records'] // }]; toolbars = [{ actions: [{ icon: 'eye', title: 'view', type: 'link', iconOnly: true },{ icon: 'edit', title: 'edit', type: 'link', iconOnly: true },{ icon: 'remove', title: 'delete', type: 'link', iconOnly: true }], size: 'sm' }]; exclude = ['roleId', 'feedId', 'staffId', 'rememberToken'].concat(this.exclude); transform(datum: Object): UserContract{ return { id: datum['id'], teamId: datum['team_id'], roleId: datum['role_id'], feedId: datum['feed_id'], email: datum['email'], userType: datum['userType'], status: datum['status'], token: datum['token'], createdAt: moment(datum['created_at']).format(), updatedAt: moment(datum['updated_at']).format() }; } toStory(): StoryContract{ return { id: this.model.id, title: this.model.email, summary: null, detail: null, avatar: null, meta: [{ icon: '', value: this.model.updatedAt }, { icon: '', value: this.model.createdAt }], actions: this.actions, toolbars: this.toolbars }; } toCards(): CardContract[]{ let cards: CardContract[]=[]; this.models.forEach((model) => { cards.push({ id: model.id, title: model.email, summary: null, image: null, actions: this.actions, toolbars: this.toolbars, meta: null, url: { url: 'user/solo' }, boldPhrase: null, shyPhrase: null }); }); return cards; } toLists(): ListContract[]{ let lists: ListContract[] = []; this.models.forEach((model) => { lists.push({ id: model.id, title: model.email, summary: null, image: null, meta: null, actions: this.actions, toolbars: this.toolbars, url: '/' + model.id, align: null }); }); return lists; } }