2018-07-23 16:42:17 +02:00
|
|
|
import { BaseModel } from '../base.model';
|
2018-08-31 14:50:38 +02:00
|
|
|
import { User } from './user';
|
2018-06-30 16:56:18 +02:00
|
|
|
|
2018-07-12 14:11:31 +02:00
|
|
|
/**
|
|
|
|
* Representation of user group.
|
|
|
|
* @ignore
|
|
|
|
*/
|
2018-06-30 16:56:18 +02:00
|
|
|
export class Group extends BaseModel {
|
2018-07-12 14:11:31 +02:00
|
|
|
protected _collectionString: string;
|
2018-08-29 13:21:25 +02:00
|
|
|
public id: number;
|
|
|
|
public name: string;
|
|
|
|
public permissions: string[];
|
2018-06-30 16:56:18 +02:00
|
|
|
|
2018-09-04 11:33:28 +02:00
|
|
|
public constructor(input?: any) {
|
2018-07-12 14:11:31 +02:00
|
|
|
super();
|
|
|
|
this._collectionString = 'users/group';
|
2018-09-04 11:33:28 +02:00
|
|
|
if (input) {
|
|
|
|
this.deserialize(input);
|
|
|
|
}
|
2018-06-30 16:56:18 +02:00
|
|
|
}
|
2018-08-31 14:50:38 +02:00
|
|
|
|
|
|
|
public get users() {
|
|
|
|
// We have to use the string version to avoid circular dependencies.
|
|
|
|
return this.DS.filter<User>('users/user', user => {
|
|
|
|
return user.groups_id.includes(this.id);
|
|
|
|
});
|
|
|
|
}
|
2018-06-30 16:56:18 +02:00
|
|
|
}
|
2018-08-24 13:05:03 +02:00
|
|
|
|
|
|
|
BaseModel.registerCollectionElement('users/group', Group);
|