29 lines
587 B
TypeScript
29 lines
587 B
TypeScript
![]() |
import _ from 'lodash';
|
||
|
import {BaseModel} from './base.model';
|
||
|
import {IdModel} from './id.model';
|
||
|
|
||
|
export class UserModel extends BaseModel{
|
||
|
_id: IdModel = null;
|
||
|
name = '';
|
||
|
origName = '';
|
||
|
email = '';
|
||
|
level = '';
|
||
|
location = '';
|
||
|
device_name = '';
|
||
|
edit = false;
|
||
|
|
||
|
deserialize(input: any): this {
|
||
|
Object.assign(this, input);
|
||
|
this.origName = this.name;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
sendFormat(mode = 'user') {
|
||
|
const keys = ['name', 'email', 'location', 'device_name'];
|
||
|
if (mode === 'admin') {
|
||
|
keys.push('level');
|
||
|
}
|
||
|
return _.pick(this, keys);
|
||
|
}
|
||
|
}
|