@ViewChild('scheduleObj', { static: false }) scheduleObj: ScheduleComponent;
@ViewChild('menuObj', { static: false }) menuObj: ContextMenuComponent;
@ViewChild('drawer', { static: false }) drawer: any;
public holidayDataSource: Holiday[];
currentProgram: number;
currentDate: Date = new Date();
currentView: View = "TimelineWorkWeek";
allowMove = false;
public eventSettings: EventSettingsModel = { dataSource: [] };
public resourceDataSource: Resource[] = [];
public rowAutoHeight = true;
public timeScale: TimeScaleModel = {
enable: false
};
public group: GroupModel = {
allowGroupEdit: true, // Shared Events
enableCompactView: true,
resources: ['Employees']
};
public contextMenu: ScheduleContextMenu;
private unsubscribeAll$: Subject<any>;
private viewMapping = {
'week': 'TimelineWorkWeek',
'month': 'TimelineMonth'
};
private eventColorMapping = {
'provisional': '#a15252',
'agreed': 'accent'
};
constructor(
private route: ActivatedRoute,
private router: Router,
dialog: MatDialog,
private dialogService: DialogService,
private planningService: PlanningService,
private programService: ProgramService,
private assignmentService: AssignmentService,
@Inject(WINDOW) private window: Window
) {
this.unsubscribeAll$ = new Subject();
this.contextMenu = new ScheduleContextMenu(dialog, dialogService, assignmentService);
}
ngOnInit() {
this.route.data.pipe(takeUntil(this.unsubscribeAll$))
.subscribe(res => {
this.currentProgram = res.data.program;
this.currentDate = res.data.date;
this.currentView = this.viewMapping[res.data.view] as any;
});
this.programService.resourcesChanges.pipe(takeUntil(this.unsubscribeAll$))
.subscribe((res: Resource[]) => this.handleResources(res));
this.programService.holidayChanges.pipe(takeUntil(this.unsubscribeAll$))
.subscribe((res: Holiday[]) => this.holidayDataSource = res);
this.programService.assignmentsChanges.pipe(takeUntil(this.unsubscribeAll$))
.subscribe(res => this.handleAssignments(res));
this.assignmentService.assignmentChanges.pipe(takeUntil(this.unsubscribeAll$))
.subscribe((res) => this.onAssignmentModified(res[0], res[1]));
}