2018-10-01 15:36:16 +02:00
|
|
|
import { BaseViewModel } from '../../base/base-view-model';
|
2019-01-19 21:55:06 +01:00
|
|
|
import { MotionCommentSection } from 'app/shared/models/motions/motion-comment-section';
|
2019-02-01 13:56:08 +01:00
|
|
|
import { ViewGroup } from 'app/site/users/models/view-group';
|
2018-10-01 15:36:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Motion comment section class for the View
|
|
|
|
*
|
|
|
|
* Stores a motion comment section including all (implicit) references
|
|
|
|
* Provides "safe" access to variables and functions in {@link MotionCommentSection}
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
export class ViewMotionCommentSection extends BaseViewModel {
|
|
|
|
private _section: MotionCommentSection;
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
private _readGroups: ViewGroup[];
|
|
|
|
private _writeGroups: ViewGroup[];
|
2018-10-01 15:36:16 +02:00
|
|
|
|
|
|
|
public get section(): MotionCommentSection {
|
|
|
|
return this._section;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.section.id;
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get name(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.section.name;
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get read_groups_id(): number[] {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.section.read_groups_id;
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get write_groups_id(): number[] {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.section.write_groups_id;
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get read_groups(): ViewGroup[] {
|
|
|
|
return this._readGroups;
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get write_groups(): ViewGroup[] {
|
|
|
|
return this._writeGroups;
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public set name(name: string) {
|
|
|
|
this._section.name = name;
|
|
|
|
}
|
|
|
|
|
2019-02-08 16:02:46 +01:00
|
|
|
/**
|
|
|
|
* This is set by the repository
|
|
|
|
*/
|
|
|
|
public getVerboseName;
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public constructor(section: MotionCommentSection, readGroups: ViewGroup[], writeGroups: ViewGroup[]) {
|
2019-02-08 16:02:46 +01:00
|
|
|
super(MotionCommentSection.COLLECTIONSTRING);
|
2018-10-01 15:36:16 +02:00
|
|
|
this._section = section;
|
2019-02-01 13:56:08 +01:00
|
|
|
this._readGroups = readGroups;
|
|
|
|
this._writeGroups = writeGroups;
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 16:02:46 +01:00
|
|
|
public getTitle = () => {
|
2018-10-01 15:36:16 +02:00
|
|
|
return this.name;
|
2019-02-08 16:02:46 +01:00
|
|
|
};
|
2018-10-01 15:36:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the local objects if required
|
|
|
|
* @param section
|
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateDependencies(update: BaseViewModel): void {
|
|
|
|
if (update instanceof ViewGroup) {
|
|
|
|
this.updateGroup(update);
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Implement updating of groups
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateGroup(group: ViewGroup): void {
|
|
|
|
console.log('implement update group of motion comment section');
|
|
|
|
}
|
2018-10-01 15:36:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Duplicate this motion into a copy of itself
|
|
|
|
*/
|
|
|
|
public copy(): ViewMotionCommentSection {
|
2019-02-01 13:56:08 +01:00
|
|
|
return new ViewMotionCommentSection(this._section, this._readGroups, this._writeGroups);
|
2018-10-01 15:36:16 +02:00
|
|
|
}
|
|
|
|
}
|