dynamically update calendar
This commit is contained in:
Vendored
+14
-1
@@ -1522,6 +1522,7 @@
|
|||||||
this.boardViewModel.updateTaskIndices();
|
this.boardViewModel.updateTaskIndices();
|
||||||
}
|
}
|
||||||
if (this.calendarPageViewModel != null) {
|
if (this.calendarPageViewModel != null) {
|
||||||
|
this.calendarPageViewModel.showTask(newTaskFileContent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
deleteTask = () => {
|
deleteTask = () => {
|
||||||
@@ -1531,6 +1532,7 @@
|
|||||||
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
||||||
}
|
}
|
||||||
if (this.calendarPageViewModel != null) {
|
if (this.calendarPageViewModel != null) {
|
||||||
|
this.calendarPageViewModel.removeTaskFromView(this.task);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// load
|
// load
|
||||||
@@ -1591,6 +1593,11 @@
|
|||||||
bulkSubscribe([this.selectedYear, this.selectedMonth], () => {
|
bulkSubscribe([this.selectedYear, this.selectedMonth], () => {
|
||||||
this.loadTasks();
|
this.loadTasks();
|
||||||
});
|
});
|
||||||
|
boardAndTasksModel.taskHandlerManager.addHandler(
|
||||||
|
(taskFileContent) => {
|
||||||
|
this.showTask(taskFileContent);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
storageModel;
|
storageModel;
|
||||||
calendarModel;
|
calendarModel;
|
||||||
@@ -1621,6 +1628,12 @@
|
|||||||
return this.monthGrid.value.days[dateString];
|
return this.monthGrid.value.days[dateString];
|
||||||
};
|
};
|
||||||
showTask = (taskFileContent) => {
|
showTask = (taskFileContent) => {
|
||||||
|
const monthString = CalendarModel.isoToMonthString(
|
||||||
|
taskFileContent.date ?? ""
|
||||||
|
);
|
||||||
|
if (monthString == void 0 || monthString != this.monthString) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const taskViewModel = new TaskViewModel(
|
const taskViewModel = new TaskViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardsAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
@@ -1631,7 +1644,7 @@
|
|||||||
const mapState = this.getTaskMapState(taskFileContent);
|
const mapState = this.getTaskMapState(taskFileContent);
|
||||||
mapState?.set(taskFileContent.fileId, taskViewModel);
|
mapState?.set(taskFileContent.fileId, taskViewModel);
|
||||||
};
|
};
|
||||||
removeTaskFromList = (taskFileContent) => {
|
removeTaskFromView = (taskFileContent) => {
|
||||||
const mapState = this.getTaskMapState(taskFileContent);
|
const mapState = this.getTaskMapState(taskFileContent);
|
||||||
mapState?.remove(taskFileContent.fileId);
|
mapState?.remove(taskFileContent.fileId);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,6 +49,14 @@ export default class CalendarPageViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
showTask = (taskFileContent: TaskFileContent): void => {
|
showTask = (taskFileContent: TaskFileContent): void => {
|
||||||
|
const monthString: string | undefined = CalendarModel.isoToMonthString(
|
||||||
|
taskFileContent.date ?? ""
|
||||||
|
);
|
||||||
|
if (monthString == undefined || monthString != this.monthString) {
|
||||||
|
// TODO remove
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const taskViewModel: TaskViewModel = new TaskViewModel(
|
const taskViewModel: TaskViewModel = new TaskViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardsAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
@@ -61,7 +69,7 @@ export default class CalendarPageViewModel {
|
|||||||
mapState?.set(taskFileContent.fileId, taskViewModel);
|
mapState?.set(taskFileContent.fileId, taskViewModel);
|
||||||
};
|
};
|
||||||
|
|
||||||
removeTaskFromList = (taskFileContent: TaskFileContent): void => {
|
removeTaskFromView = (taskFileContent: TaskFileContent): void => {
|
||||||
const mapState: React.MapState<TaskViewModel> | null =
|
const mapState: React.MapState<TaskViewModel> | null =
|
||||||
this.getTaskMapState(taskFileContent);
|
this.getTaskMapState(taskFileContent);
|
||||||
mapState?.remove(taskFileContent.fileId);
|
mapState?.remove(taskFileContent.fileId);
|
||||||
@@ -121,7 +129,7 @@ export default class CalendarPageViewModel {
|
|||||||
public coreViewModel: CoreViewModel,
|
public coreViewModel: CoreViewModel,
|
||||||
storageModel: StorageModel,
|
storageModel: StorageModel,
|
||||||
calendarModel: CalendarModel,
|
calendarModel: CalendarModel,
|
||||||
boardAndTasksModel: BoardsAndTasksModel,
|
boardAndTasksModel: BoardsAndTasksModel
|
||||||
) {
|
) {
|
||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
this.calendarModel = calendarModel;
|
this.calendarModel = calendarModel;
|
||||||
@@ -130,6 +138,13 @@ export default class CalendarPageViewModel {
|
|||||||
React.bulkSubscribe([this.selectedYear, this.selectedMonth], () => {
|
React.bulkSubscribe([this.selectedYear, this.selectedMonth], () => {
|
||||||
this.loadTasks();
|
this.loadTasks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// handlers
|
||||||
|
boardAndTasksModel.taskHandlerManager.addHandler(
|
||||||
|
(taskFileContent: TaskFileContent) => {
|
||||||
|
this.showTask(taskFileContent);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ export default class TaskViewModel {
|
|||||||
this.boardViewModel.updateTaskIndices();
|
this.boardViewModel.updateTaskIndices();
|
||||||
}
|
}
|
||||||
if (this.calendarPageViewModel != null) {
|
if (this.calendarPageViewModel != null) {
|
||||||
|
this.calendarPageViewModel.showTask(newTaskFileContent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -132,6 +133,7 @@ export default class TaskViewModel {
|
|||||||
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
||||||
}
|
}
|
||||||
if (this.calendarPageViewModel != null) {
|
if (this.calendarPageViewModel != null) {
|
||||||
|
this.calendarPageViewModel.removeTaskFromView(this.task);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user