OpenSlides/client/src/app/site/motions/models/view-motion-comment-section.ts

90 lines
2.4 KiB
TypeScript
Raw Normal View History

2018-10-01 15:36:16 +02:00
import { BaseViewModel } from '../../base/base-view-model';
import { MotionCommentSection } from 'app/shared/models/motions/motion-comment-section';
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 {
2019-02-12 09:25:56 +01:00
public static COLLECTIONSTRING = MotionCommentSection.COLLECTIONSTRING;
2018-10-01 15:36:16 +02:00
private _section: MotionCommentSection;
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 {
return this.section.id;
2018-10-01 15:36:16 +02:00
}
public get name(): string {
return this.section.name;
2018-10-01 15:36:16 +02:00
}
public get read_groups_id(): number[] {
return this.section.read_groups_id;
2018-10-01 15:36:16 +02:00
}
public get write_groups_id(): number[] {
return this.section.write_groups_id;
2018-10-01 15:36:16 +02:00
}
public get read_groups(): ViewGroup[] {
return this._readGroups;
2018-10-01 15:36:16 +02: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;
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;
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
*/
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
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 {
return new ViewMotionCommentSection(this._section, this._readGroups, this._writeGroups);
2018-10-01 15:36:16 +02:00
}
}