prepare CalendarPageViewModel, allow TaskViewModel to be used by BoardViewModel or CalendarPageViewModel
This commit is contained in:
Vendored
+215
-150
@@ -1365,6 +1365,192 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// src/View/utility.ts
|
||||||
|
function allowDrop(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
function allowDrag(event) {
|
||||||
|
event.dataTransfer?.setData("text", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/ViewModel/Pages/taskViewModel.ts
|
||||||
|
var TaskViewModel = class {
|
||||||
|
// init
|
||||||
|
constructor(coreViewModel, boardsAndTasksModel, boardViewModel, calendarPageViewModel, taskFileContent) {
|
||||||
|
this.coreViewModel = coreViewModel;
|
||||||
|
this.boardsAndTasksModel = boardsAndTasksModel;
|
||||||
|
this.boardViewModel = boardViewModel;
|
||||||
|
this.calendarPageViewModel = calendarPageViewModel;
|
||||||
|
this.task = taskFileContent;
|
||||||
|
this.loadAllData();
|
||||||
|
this.selectedVersionId.subscribeSilent((selectedVersionId) => {
|
||||||
|
this.switchVersion(selectedVersionId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
boardsAndTasksModel;
|
||||||
|
boardViewModel;
|
||||||
|
calendarPageViewModel;
|
||||||
|
// data
|
||||||
|
task;
|
||||||
|
get sortingString() {
|
||||||
|
const splitDate = this.date.value.split("-");
|
||||||
|
const year = padZero(splitDate[0], 4);
|
||||||
|
const month = padZero(splitDate[1], 2);
|
||||||
|
const date = padZero(splitDate[2], 2);
|
||||||
|
const splitTime = this.time.value.split(":");
|
||||||
|
const hour = padZero(splitTime[0], 2);
|
||||||
|
const minute = padZero(splitTime[1], 2);
|
||||||
|
const priorityNumber = parseInt(this.priority.value);
|
||||||
|
const invertedPriority = 100 - priorityNumber;
|
||||||
|
return year + month + date + hour + minute + invertedPriority + this.name.value;
|
||||||
|
}
|
||||||
|
// paths
|
||||||
|
getFilePath = () => {
|
||||||
|
return this.boardsAndTasksModel.getTaskFilePath(this.task.fileId);
|
||||||
|
};
|
||||||
|
// state
|
||||||
|
index = new State(0);
|
||||||
|
boardId = new State("");
|
||||||
|
name = new State("");
|
||||||
|
description = new State("");
|
||||||
|
category = new State("");
|
||||||
|
status = new State("");
|
||||||
|
priority = new State("");
|
||||||
|
date = new State("");
|
||||||
|
time = new State("");
|
||||||
|
selectedVersionId = new State("");
|
||||||
|
versionIds = new ListState();
|
||||||
|
// methods
|
||||||
|
dragStart = (event) => {
|
||||||
|
allowDrag(event);
|
||||||
|
this.coreViewModel.draggedObject.value = this;
|
||||||
|
};
|
||||||
|
setCategoryAndStatus = (category, status) => {
|
||||||
|
if (category != void 0) this.category.value = category;
|
||||||
|
if (status != void 0) this.status.value = status;
|
||||||
|
this.save();
|
||||||
|
};
|
||||||
|
setBoardId = (boardId) => {
|
||||||
|
this.boardId.value = boardId;
|
||||||
|
this.save();
|
||||||
|
};
|
||||||
|
// view
|
||||||
|
open = () => {
|
||||||
|
this.boardViewModel?.selectTask(this);
|
||||||
|
};
|
||||||
|
close = () => {
|
||||||
|
this.boardViewModel?.closeTask();
|
||||||
|
};
|
||||||
|
closeAndSave = () => {
|
||||||
|
this.close();
|
||||||
|
this.save();
|
||||||
|
};
|
||||||
|
updateIndex = () => {
|
||||||
|
if (this.boardViewModel == null) return;
|
||||||
|
const index = this.boardViewModel.taskIndexManager.getIndex(this);
|
||||||
|
this.index.value = index;
|
||||||
|
};
|
||||||
|
// settings
|
||||||
|
save = () => {
|
||||||
|
const newTaskFileContent = BoardsAndTasksModel.createTaskFileContent(
|
||||||
|
this.task.fileId,
|
||||||
|
this.name.value,
|
||||||
|
this.task.boardId
|
||||||
|
);
|
||||||
|
newTaskFileContent.boardId = this.boardId.value;
|
||||||
|
newTaskFileContent.description = this.description.value;
|
||||||
|
newTaskFileContent.status = this.status.value;
|
||||||
|
newTaskFileContent.category = this.category.value;
|
||||||
|
newTaskFileContent.priority = this.priority.value;
|
||||||
|
newTaskFileContent.date = this.date.value;
|
||||||
|
newTaskFileContent.time = this.time.value;
|
||||||
|
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
||||||
|
if (this.boardViewModel != null) {
|
||||||
|
this.boardViewModel.showTaskInList(newTaskFileContent);
|
||||||
|
this.boardViewModel.updateTaskIndices();
|
||||||
|
}
|
||||||
|
if (this.calendarPageViewModel != null) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
deleteTask = () => {
|
||||||
|
this.close();
|
||||||
|
this.boardsAndTasksModel.deleteTask(this.task.boardId, this.task.fileId);
|
||||||
|
if (this.boardViewModel != null) {
|
||||||
|
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
||||||
|
}
|
||||||
|
if (this.calendarPageViewModel != null) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// load
|
||||||
|
loadVersionIds = () => {
|
||||||
|
const versionIds = this.boardsAndTasksModel.listTaskVersionIds(
|
||||||
|
this.task.fileId
|
||||||
|
);
|
||||||
|
const sortedVersionIds = versionIds.sort(localeCompare).reverse();
|
||||||
|
this.versionIds.clear();
|
||||||
|
this.versionIds.add(...sortedVersionIds);
|
||||||
|
};
|
||||||
|
switchVersion = (versionId) => {
|
||||||
|
const taskFileContent = this.boardsAndTasksModel.getSpecificTaskFileContent(
|
||||||
|
this.task.fileId,
|
||||||
|
versionId
|
||||||
|
);
|
||||||
|
if (taskFileContent == null) return;
|
||||||
|
this.task = taskFileContent;
|
||||||
|
this.loadTaskData();
|
||||||
|
};
|
||||||
|
loadAllData = () => {
|
||||||
|
this.loadTaskData();
|
||||||
|
this.loadVersionIds();
|
||||||
|
};
|
||||||
|
loadTaskData = () => {
|
||||||
|
this.boardId.value = this.task.boardId;
|
||||||
|
this.name.value = this.task.name;
|
||||||
|
this.description.value = this.task.description ?? "";
|
||||||
|
this.category.value = this.task.category ?? "";
|
||||||
|
this.status.value = this.task.status ?? "";
|
||||||
|
this.priority.value = this.task.priority ?? "";
|
||||||
|
this.date.value = this.task.date ?? "";
|
||||||
|
this.time.value = this.task.time ?? "";
|
||||||
|
this.selectedVersionId.value = this.task.fileContentId;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// src/ViewModel/Pages/calendarPageViewModel.ts
|
||||||
|
var CalendarPageViewModel = class {
|
||||||
|
// init
|
||||||
|
constructor(coreViewModel, storageModel2, calendarModel, boardAndTasksModel) {
|
||||||
|
this.coreViewModel = coreViewModel;
|
||||||
|
this.storageModel = storageModel2;
|
||||||
|
this.calendarModel = calendarModel;
|
||||||
|
this.boardAndTasksModel = boardAndTasksModel;
|
||||||
|
}
|
||||||
|
storageModel;
|
||||||
|
calendarModel;
|
||||||
|
boardAndTasksModel;
|
||||||
|
// paths
|
||||||
|
getBasePath = () => {
|
||||||
|
return [...this.calendarModel.getViewPath()];
|
||||||
|
};
|
||||||
|
// state
|
||||||
|
taskViewModels = new MapState();
|
||||||
|
// view
|
||||||
|
showTask = (taskFileContent) => {
|
||||||
|
const taskViewModel = new TaskViewModel(
|
||||||
|
this.coreViewModel,
|
||||||
|
this.boardAndTasksModel,
|
||||||
|
null,
|
||||||
|
this,
|
||||||
|
taskFileContent
|
||||||
|
);
|
||||||
|
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||||
|
};
|
||||||
|
// storage
|
||||||
|
// load
|
||||||
|
loadData = () => {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// src/ViewModel/Chat/chatMessageViewModel.ts
|
// src/ViewModel/Chat/chatMessageViewModel.ts
|
||||||
var ChatMessageViewModel = class {
|
var ChatMessageViewModel = class {
|
||||||
// init
|
// init
|
||||||
@@ -1562,146 +1748,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/View/utility.ts
|
|
||||||
function allowDrop(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
function allowDrag(event) {
|
|
||||||
event.dataTransfer?.setData("text", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
// src/ViewModel/Pages/taskViewModel.ts
|
|
||||||
var TaskViewModel = class {
|
|
||||||
// init
|
|
||||||
constructor(coreViewModel, boardModel, boardViewModel, taskFileContent) {
|
|
||||||
this.coreViewModel = coreViewModel;
|
|
||||||
this.boardsAndTasksModel = boardModel;
|
|
||||||
this.boardViewModel = boardViewModel;
|
|
||||||
this.task = taskFileContent;
|
|
||||||
this.loadAllData();
|
|
||||||
this.selectedVersionId.subscribeSilent((selectedVersionId) => {
|
|
||||||
this.switchVersion(selectedVersionId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
boardsAndTasksModel;
|
|
||||||
boardViewModel;
|
|
||||||
// data
|
|
||||||
task;
|
|
||||||
get sortingString() {
|
|
||||||
const splitDate = this.date.value.split("-");
|
|
||||||
const year = padZero(splitDate[0], 4);
|
|
||||||
const month = padZero(splitDate[1], 2);
|
|
||||||
const date = padZero(splitDate[2], 2);
|
|
||||||
const splitTime = this.time.value.split(":");
|
|
||||||
const hour = padZero(splitTime[0], 2);
|
|
||||||
const minute = padZero(splitTime[1], 2);
|
|
||||||
const priorityNumber = parseInt(this.priority.value);
|
|
||||||
const invertedPriority = 100 - priorityNumber;
|
|
||||||
return year + month + date + hour + minute + invertedPriority + this.name.value;
|
|
||||||
}
|
|
||||||
// paths
|
|
||||||
getFilePath = () => {
|
|
||||||
return this.boardsAndTasksModel.getTaskFilePath(this.task.fileId);
|
|
||||||
};
|
|
||||||
// state
|
|
||||||
index = new State(0);
|
|
||||||
boardId = new State("");
|
|
||||||
name = new State("");
|
|
||||||
description = new State("");
|
|
||||||
category = new State("");
|
|
||||||
status = new State("");
|
|
||||||
priority = new State("");
|
|
||||||
date = new State("");
|
|
||||||
time = new State("");
|
|
||||||
selectedVersionId = new State("");
|
|
||||||
versionIds = new ListState();
|
|
||||||
// methods
|
|
||||||
dragStart = (event) => {
|
|
||||||
allowDrag(event);
|
|
||||||
this.coreViewModel.draggedObject.value = this;
|
|
||||||
};
|
|
||||||
setCategoryAndStatus = (category, status) => {
|
|
||||||
if (category != void 0) this.category.value = category;
|
|
||||||
if (status != void 0) this.status.value = status;
|
|
||||||
this.save();
|
|
||||||
};
|
|
||||||
setBoardId = (boardId) => {
|
|
||||||
this.boardId.value = boardId;
|
|
||||||
this.save();
|
|
||||||
};
|
|
||||||
// view
|
|
||||||
open = () => {
|
|
||||||
this.boardViewModel.selectTask(this);
|
|
||||||
};
|
|
||||||
close = () => {
|
|
||||||
this.boardViewModel.closeTask();
|
|
||||||
};
|
|
||||||
closeAndSave = () => {
|
|
||||||
this.close();
|
|
||||||
this.save();
|
|
||||||
};
|
|
||||||
updateIndex = () => {
|
|
||||||
const index = this.boardViewModel.taskIndexManager.getIndex(this);
|
|
||||||
this.index.value = index;
|
|
||||||
};
|
|
||||||
// settings
|
|
||||||
save = () => {
|
|
||||||
const newTaskFileContent = BoardsAndTasksModel.createTaskFileContent(
|
|
||||||
this.task.fileId,
|
|
||||||
this.name.value,
|
|
||||||
this.task.boardId
|
|
||||||
);
|
|
||||||
newTaskFileContent.boardId = this.boardId.value;
|
|
||||||
newTaskFileContent.description = this.description.value;
|
|
||||||
newTaskFileContent.status = this.status.value;
|
|
||||||
newTaskFileContent.category = this.category.value;
|
|
||||||
newTaskFileContent.priority = this.priority.value;
|
|
||||||
newTaskFileContent.date = this.date.value;
|
|
||||||
newTaskFileContent.time = this.time.value;
|
|
||||||
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
|
||||||
this.boardViewModel.showTaskInList(newTaskFileContent);
|
|
||||||
this.boardViewModel.updateTaskIndices();
|
|
||||||
};
|
|
||||||
deleteTask = () => {
|
|
||||||
this.close();
|
|
||||||
this.boardsAndTasksModel.deleteTask(this.task.boardId, this.task.fileId);
|
|
||||||
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
|
||||||
};
|
|
||||||
// load
|
|
||||||
loadVersionIds = () => {
|
|
||||||
const versionIds = this.boardsAndTasksModel.listTaskVersionIds(
|
|
||||||
this.task.fileId
|
|
||||||
);
|
|
||||||
const sortedVersionIds = versionIds.sort(localeCompare).reverse();
|
|
||||||
this.versionIds.clear();
|
|
||||||
this.versionIds.add(...sortedVersionIds);
|
|
||||||
};
|
|
||||||
switchVersion = (versionId) => {
|
|
||||||
const taskFileContent = this.boardsAndTasksModel.getSpecificTaskFileContent(
|
|
||||||
this.task.fileId,
|
|
||||||
versionId
|
|
||||||
);
|
|
||||||
if (taskFileContent == null) return;
|
|
||||||
this.task = taskFileContent;
|
|
||||||
this.loadTaskData();
|
|
||||||
};
|
|
||||||
loadAllData = () => {
|
|
||||||
this.loadTaskData();
|
|
||||||
this.loadVersionIds();
|
|
||||||
};
|
|
||||||
loadTaskData = () => {
|
|
||||||
this.boardId.value = this.task.boardId;
|
|
||||||
this.name.value = this.task.name;
|
|
||||||
this.description.value = this.task.description ?? "";
|
|
||||||
this.category.value = this.task.category ?? "";
|
|
||||||
this.status.value = this.task.status ?? "";
|
|
||||||
this.priority.value = this.task.priority ?? "";
|
|
||||||
this.date.value = this.task.date ?? "";
|
|
||||||
this.time.value = this.task.time ?? "";
|
|
||||||
this.selectedVersionId.value = this.task.fileContentId;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// src/ViewModel/Pages/boardViewModel.ts
|
// src/ViewModel/Pages/boardViewModel.ts
|
||||||
var BoardViewModel = class {
|
var BoardViewModel = class {
|
||||||
// init
|
// init
|
||||||
@@ -1782,6 +1828,7 @@
|
|||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardsAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
this,
|
this,
|
||||||
|
null,
|
||||||
taskFileContent
|
taskFileContent
|
||||||
);
|
);
|
||||||
this.selectTask(taskViewModel);
|
this.selectTask(taskViewModel);
|
||||||
@@ -1827,6 +1874,7 @@
|
|||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardsAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
this,
|
this,
|
||||||
|
null,
|
||||||
taskFileContent
|
taskFileContent
|
||||||
);
|
);
|
||||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||||
@@ -1896,6 +1944,7 @@
|
|||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardsAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
this,
|
this,
|
||||||
|
null,
|
||||||
taskFileContent
|
taskFileContent
|
||||||
);
|
);
|
||||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||||
@@ -1914,7 +1963,7 @@
|
|||||||
constructor(coreViewModel, storageModel2, boardModel, chatViewModel) {
|
constructor(coreViewModel, storageModel2, boardModel, chatViewModel) {
|
||||||
this.coreViewModel = coreViewModel;
|
this.coreViewModel = coreViewModel;
|
||||||
this.storageModel = storageModel2;
|
this.storageModel = storageModel2;
|
||||||
this.boardModel = boardModel;
|
this.boardsAndTasksModel = boardModel;
|
||||||
this.chatViewModel = chatViewModel;
|
this.chatViewModel = chatViewModel;
|
||||||
boardModel.boardHandlerManager.addHandler(
|
boardModel.boardHandlerManager.addHandler(
|
||||||
(boardInfoFileContent) => {
|
(boardInfoFileContent) => {
|
||||||
@@ -1924,7 +1973,7 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
storageModel;
|
storageModel;
|
||||||
boardModel;
|
boardsAndTasksModel;
|
||||||
chatViewModel;
|
chatViewModel;
|
||||||
// data
|
// data
|
||||||
boardIndexManager = new IndexManager(
|
boardIndexManager = new IndexManager(
|
||||||
@@ -1932,7 +1981,7 @@
|
|||||||
);
|
);
|
||||||
// paths
|
// paths
|
||||||
getBasePath = () => {
|
getBasePath = () => {
|
||||||
return [...this.boardModel.getViewPath()];
|
return [...this.boardsAndTasksModel.getViewPath()];
|
||||||
};
|
};
|
||||||
getBoardViewPath = (boardId) => {
|
getBoardViewPath = (boardId) => {
|
||||||
return [...this.getBasePath(), boardId];
|
return [...this.getBasePath(), boardId];
|
||||||
@@ -1952,18 +2001,18 @@
|
|||||||
// methods
|
// methods
|
||||||
createBoard = () => {
|
createBoard = () => {
|
||||||
if (this.cannotCreateBoard.value == true) return;
|
if (this.cannotCreateBoard.value == true) return;
|
||||||
const boardInfoFileContent = this.boardModel.createBoard(this.newBoardNameInput.value);
|
const boardInfoFileContent = this.boardsAndTasksModel.createBoard(this.newBoardNameInput.value);
|
||||||
this.newBoardNameInput.value = "";
|
this.newBoardNameInput.value = "";
|
||||||
this.showBoardInList(boardInfoFileContent);
|
this.showBoardInList(boardInfoFileContent);
|
||||||
this.boardModel.updateBoardAndSend(boardInfoFileContent);
|
this.boardsAndTasksModel.updateBoardAndSend(boardInfoFileContent);
|
||||||
this.updateBoardIndices();
|
this.updateBoardIndices();
|
||||||
};
|
};
|
||||||
updateBoard = (boardInfoFileContent) => {
|
updateBoard = (boardInfoFileContent) => {
|
||||||
this.boardModel.updateBoardAndSend(boardInfoFileContent);
|
this.boardsAndTasksModel.updateBoardAndSend(boardInfoFileContent);
|
||||||
this.updateBoardIndices();
|
this.updateBoardIndices();
|
||||||
};
|
};
|
||||||
deleteBoard = (boardInfoFileContent) => {
|
deleteBoard = (boardInfoFileContent) => {
|
||||||
this.boardModel.deleteBoard(boardInfoFileContent.fileId);
|
this.boardsAndTasksModel.deleteBoard(boardInfoFileContent.fileId);
|
||||||
this.boardViewModels.remove(boardInfoFileContent.fileId);
|
this.boardViewModels.remove(boardInfoFileContent.fileId);
|
||||||
this.updateBoardIndices();
|
this.updateBoardIndices();
|
||||||
};
|
};
|
||||||
@@ -1972,7 +2021,7 @@
|
|||||||
const boardViewModel = new BoardViewModel(
|
const boardViewModel = new BoardViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.storageModel,
|
this.storageModel,
|
||||||
this.boardModel,
|
this.boardsAndTasksModel,
|
||||||
this,
|
this,
|
||||||
boardInfo
|
boardInfo
|
||||||
);
|
);
|
||||||
@@ -2011,9 +2060,9 @@
|
|||||||
// load
|
// load
|
||||||
loadData = () => {
|
loadData = () => {
|
||||||
this.boardViewModels.clear();
|
this.boardViewModels.clear();
|
||||||
const boardIds = this.boardModel.listBoardIds();
|
const boardIds = this.boardsAndTasksModel.listBoardIds();
|
||||||
for (const boardId of boardIds) {
|
for (const boardId of boardIds) {
|
||||||
const boardInfo = this.boardModel.getBoardInfo(boardId);
|
const boardInfo = this.boardsAndTasksModel.getBoardInfo(boardId);
|
||||||
if (boardInfo == null) continue;
|
if (boardInfo == null) continue;
|
||||||
this.showBoardInList(boardInfo);
|
this.showBoardInList(boardInfo);
|
||||||
}
|
}
|
||||||
@@ -2031,6 +2080,12 @@
|
|||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
this.settingsViewModel = settingsViewModel2;
|
this.settingsViewModel = settingsViewModel2;
|
||||||
this.chatListViewModel = chatListViewModel2;
|
this.chatListViewModel = chatListViewModel2;
|
||||||
|
this.calendarViewModel = new CalendarPageViewModel(
|
||||||
|
coreViewModel,
|
||||||
|
this.storageModel,
|
||||||
|
this.chatModel.fileModel.calendarModel,
|
||||||
|
this.chatModel.fileModel.boardsAndTasksModel
|
||||||
|
);
|
||||||
this.taskPageViewModel = new TaskPageViewModel(
|
this.taskPageViewModel = new TaskPageViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.storageModel,
|
this.storageModel,
|
||||||
@@ -2057,6 +2112,7 @@
|
|||||||
storageModel;
|
storageModel;
|
||||||
settingsViewModel;
|
settingsViewModel;
|
||||||
chatListViewModel;
|
chatListViewModel;
|
||||||
|
calendarViewModel;
|
||||||
taskPageViewModel;
|
taskPageViewModel;
|
||||||
messagePageViewModel;
|
messagePageViewModel;
|
||||||
settingsPageViewModel;
|
settingsPageViewModel;
|
||||||
@@ -2182,6 +2238,12 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// src/View/ChatPages/calendarPage.tsx
|
||||||
|
function CalendarPage(calendarPageViewModel) {
|
||||||
|
calendarPageViewModel.loadData();
|
||||||
|
return /* @__PURE__ */ createElement("div", { id: "calendar-page" });
|
||||||
|
}
|
||||||
|
|
||||||
// src/View/Components/ribbonButton.tsx
|
// src/View/Components/ribbonButton.tsx
|
||||||
function RibbonButton(label, icon, isSelected, select) {
|
function RibbonButton(label, icon, isSelected, select) {
|
||||||
return /* @__PURE__ */ createElement(
|
return /* @__PURE__ */ createElement(
|
||||||
@@ -3319,6 +3381,9 @@
|
|||||||
case "tasks" /* Tasks */: {
|
case "tasks" /* Tasks */: {
|
||||||
return TaskPage(chatViewModel.taskPageViewModel);
|
return TaskPage(chatViewModel.taskPageViewModel);
|
||||||
}
|
}
|
||||||
|
case "calendar" /* Calendar */: {
|
||||||
|
return CalendarPage(chatViewModel.calendarViewModel);
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return MessagePage(chatViewModel.messagePageViewModel);
|
return MessagePage(chatViewModel.messagePageViewModel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
|
import CalendarPageViewModel from "../../ViewModel/Pages/calendarPageViewModel";
|
||||||
|
|
||||||
|
export function CalendarPage(calendarPageViewModel: CalendarPageViewModel) {
|
||||||
|
calendarPageViewModel.loadData();
|
||||||
|
|
||||||
|
return <div id="calendar-page"></div>;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import * as React from "bloatless-react";
|
|||||||
|
|
||||||
import ChatViewModel, { ChatPageType } from "../ViewModel/Chat/chatViewModel";
|
import ChatViewModel, { ChatPageType } from "../ViewModel/Chat/chatViewModel";
|
||||||
|
|
||||||
|
import { CalendarPage } from "./ChatPages/calendarPage";
|
||||||
import { ChatViewToggleButton } from "./Components/chatViewToggleButton";
|
import { ChatViewToggleButton } from "./Components/chatViewToggleButton";
|
||||||
import { MessagePage } from "./ChatPages/messagePage";
|
import { MessagePage } from "./ChatPages/messagePage";
|
||||||
import { SettingsPage } from "./ChatPages/settingsPage";
|
import { SettingsPage } from "./ChatPages/settingsPage";
|
||||||
@@ -23,6 +24,9 @@ export function ChatPage(chatViewModel: ChatViewModel) {
|
|||||||
case ChatPageType.Tasks: {
|
case ChatPageType.Tasks: {
|
||||||
return TaskPage(chatViewModel.taskPageViewModel);
|
return TaskPage(chatViewModel.taskPageViewModel);
|
||||||
}
|
}
|
||||||
|
case ChatPageType.Calendar: {
|
||||||
|
return CalendarPage(chatViewModel.calendarViewModel)
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return MessagePage(chatViewModel.messagePageViewModel);
|
return MessagePage(chatViewModel.messagePageViewModel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import * as React from "bloatless-react";
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
import ChatModel, { ChatMessage } from "../../Model/Chat/chatModel";
|
import ChatModel, { ChatMessage } from "../../Model/Chat/chatModel";
|
||||||
import StorageModel, { StorageModelSubPath, filePaths } from "../../Model/Global/storageModel";
|
import StorageModel, {
|
||||||
|
StorageModelSubPath,
|
||||||
|
filePaths,
|
||||||
|
} from "../../Model/Global/storageModel";
|
||||||
|
|
||||||
|
import CalendarPageViewModel from "../Pages/calendarPageViewModel";
|
||||||
import ChatListViewModel from "./chatListViewModel";
|
import ChatListViewModel from "./chatListViewModel";
|
||||||
import { Color } from "../../colors";
|
import { Color } from "../../colors";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel from "../Global/coreViewModel";
|
||||||
@@ -17,6 +21,7 @@ export default class ChatViewModel {
|
|||||||
settingsViewModel: SettingsViewModel;
|
settingsViewModel: SettingsViewModel;
|
||||||
chatListViewModel: ChatListViewModel;
|
chatListViewModel: ChatListViewModel;
|
||||||
|
|
||||||
|
calendarViewModel: CalendarPageViewModel;
|
||||||
taskPageViewModel: TaskPageViewModel;
|
taskPageViewModel: TaskPageViewModel;
|
||||||
messagePageViewModel: MessagePageViewModel;
|
messagePageViewModel: MessagePageViewModel;
|
||||||
settingsPageViewModel: SettingsPageViewModel;
|
settingsPageViewModel: SettingsPageViewModel;
|
||||||
@@ -91,6 +96,12 @@ export default class ChatViewModel {
|
|||||||
this.chatListViewModel = chatListViewModel;
|
this.chatListViewModel = chatListViewModel;
|
||||||
|
|
||||||
// page viewModels
|
// page viewModels
|
||||||
|
this.calendarViewModel = new CalendarPageViewModel(
|
||||||
|
coreViewModel,
|
||||||
|
this.storageModel,
|
||||||
|
this.chatModel.fileModel.calendarModel,
|
||||||
|
this.chatModel.fileModel.boardsAndTasksModel
|
||||||
|
);
|
||||||
this.taskPageViewModel = new TaskPageViewModel(
|
this.taskPageViewModel = new TaskPageViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.storageModel,
|
this.storageModel,
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ export default class BoardViewModel {
|
|||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardsAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
this,
|
this,
|
||||||
|
null,
|
||||||
taskFileContent
|
taskFileContent
|
||||||
);
|
);
|
||||||
this.selectTask(taskViewModel);
|
this.selectTask(taskViewModel);
|
||||||
@@ -136,6 +137,7 @@ export default class BoardViewModel {
|
|||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardsAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
this,
|
this,
|
||||||
|
null,
|
||||||
taskFileContent
|
taskFileContent
|
||||||
);
|
);
|
||||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||||
@@ -222,6 +224,7 @@ export default class BoardViewModel {
|
|||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardsAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
this,
|
this,
|
||||||
|
null,
|
||||||
taskFileContent
|
taskFileContent
|
||||||
);
|
);
|
||||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
|
import BoardsAndTasksModel, {
|
||||||
|
TaskFileContent,
|
||||||
|
} from "../../Model/Files/boardsAndTasksModel";
|
||||||
|
|
||||||
|
import CalendarModel from "../../Model/Files/calendarModel";
|
||||||
|
import CoreViewModel from "../Global/coreViewModel";
|
||||||
|
import StorageModel from "../../Model/Global/storageModel";
|
||||||
|
import TaskViewModel from "./taskViewModel";
|
||||||
|
|
||||||
|
export default class CalendarPageViewModel {
|
||||||
|
storageModel: StorageModel;
|
||||||
|
calendarModel: CalendarModel;
|
||||||
|
boardAndTasksModel: BoardsAndTasksModel;
|
||||||
|
|
||||||
|
// paths
|
||||||
|
getBasePath = (): string[] => {
|
||||||
|
return [...this.calendarModel.getViewPath()];
|
||||||
|
};
|
||||||
|
|
||||||
|
// state
|
||||||
|
taskViewModels: React.MapState<TaskViewModel> = new React.MapState();
|
||||||
|
|
||||||
|
// view
|
||||||
|
showTask = (taskFileContent: TaskFileContent): void => {
|
||||||
|
const taskViewModel: TaskViewModel = new TaskViewModel(
|
||||||
|
this.coreViewModel,
|
||||||
|
this.boardAndTasksModel,
|
||||||
|
null,
|
||||||
|
this,
|
||||||
|
taskFileContent
|
||||||
|
);
|
||||||
|
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||||
|
};
|
||||||
|
|
||||||
|
// storage
|
||||||
|
|
||||||
|
// load
|
||||||
|
loadData = (): void => {}
|
||||||
|
|
||||||
|
// init
|
||||||
|
constructor(
|
||||||
|
public coreViewModel: CoreViewModel,
|
||||||
|
storageModel: StorageModel,
|
||||||
|
calendarModel: CalendarModel,
|
||||||
|
boardAndTasksModel: BoardsAndTasksModel,
|
||||||
|
) {
|
||||||
|
this.storageModel = storageModel;
|
||||||
|
this.calendarModel = calendarModel;
|
||||||
|
this.boardAndTasksModel = boardAndTasksModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TaskPageViewModelSubPath {
|
||||||
|
LastUsedBoard = "last-used-board",
|
||||||
|
}
|
||||||
@@ -9,11 +9,10 @@ import ChatViewModel from "../Chat/chatViewModel";
|
|||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel from "../Global/coreViewModel";
|
||||||
import { IndexManager } from "../../Model/Utility/utility";
|
import { IndexManager } from "../../Model/Utility/utility";
|
||||||
import StorageModel from "../../Model/Global/storageModel";
|
import StorageModel from "../../Model/Global/storageModel";
|
||||||
import TaskViewModel from "./taskViewModel";
|
|
||||||
|
|
||||||
export default class TaskPageViewModel {
|
export default class TaskPageViewModel {
|
||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
boardModel: BoardsAndTasksModel;
|
boardsAndTasksModel: BoardsAndTasksModel;
|
||||||
|
|
||||||
chatViewModel: ChatViewModel;
|
chatViewModel: ChatViewModel;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ export default class TaskPageViewModel {
|
|||||||
|
|
||||||
// paths
|
// paths
|
||||||
getBasePath = (): string[] => {
|
getBasePath = (): string[] => {
|
||||||
return [...this.boardModel.getViewPath()];
|
return [...this.boardsAndTasksModel.getViewPath()];
|
||||||
};
|
};
|
||||||
|
|
||||||
getBoardViewPath = (boardId): string[] => {
|
getBoardViewPath = (boardId): string[] => {
|
||||||
@@ -55,21 +54,21 @@ export default class TaskPageViewModel {
|
|||||||
if (this.cannotCreateBoard.value == true) return;
|
if (this.cannotCreateBoard.value == true) return;
|
||||||
|
|
||||||
const boardInfoFileContent: BoardInfoFileContent =
|
const boardInfoFileContent: BoardInfoFileContent =
|
||||||
this.boardModel.createBoard(this.newBoardNameInput.value);
|
this.boardsAndTasksModel.createBoard(this.newBoardNameInput.value);
|
||||||
this.newBoardNameInput.value = "";
|
this.newBoardNameInput.value = "";
|
||||||
|
|
||||||
this.showBoardInList(boardInfoFileContent);
|
this.showBoardInList(boardInfoFileContent);
|
||||||
this.boardModel.updateBoardAndSend(boardInfoFileContent);
|
this.boardsAndTasksModel.updateBoardAndSend(boardInfoFileContent);
|
||||||
this.updateBoardIndices();
|
this.updateBoardIndices();
|
||||||
};
|
};
|
||||||
|
|
||||||
updateBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
updateBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
||||||
this.boardModel.updateBoardAndSend(boardInfoFileContent);
|
this.boardsAndTasksModel.updateBoardAndSend(boardInfoFileContent);
|
||||||
this.updateBoardIndices();
|
this.updateBoardIndices();
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
deleteBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
||||||
this.boardModel.deleteBoard(boardInfoFileContent.fileId);
|
this.boardsAndTasksModel.deleteBoard(boardInfoFileContent.fileId);
|
||||||
this.boardViewModels.remove(boardInfoFileContent.fileId);
|
this.boardViewModels.remove(boardInfoFileContent.fileId);
|
||||||
this.updateBoardIndices();
|
this.updateBoardIndices();
|
||||||
};
|
};
|
||||||
@@ -79,7 +78,7 @@ export default class TaskPageViewModel {
|
|||||||
const boardViewModel: BoardViewModel = new BoardViewModel(
|
const boardViewModel: BoardViewModel = new BoardViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.storageModel,
|
this.storageModel,
|
||||||
this.boardModel,
|
this.boardsAndTasksModel,
|
||||||
this,
|
this,
|
||||||
boardInfo
|
boardInfo
|
||||||
);
|
);
|
||||||
@@ -130,10 +129,10 @@ export default class TaskPageViewModel {
|
|||||||
loadData = (): void => {
|
loadData = (): void => {
|
||||||
this.boardViewModels.clear();
|
this.boardViewModels.clear();
|
||||||
|
|
||||||
const boardIds: string[] = this.boardModel.listBoardIds();
|
const boardIds: string[] = this.boardsAndTasksModel.listBoardIds();
|
||||||
for (const boardId of boardIds) {
|
for (const boardId of boardIds) {
|
||||||
const boardInfo: BoardInfoFileContent | null =
|
const boardInfo: BoardInfoFileContent | null =
|
||||||
this.boardModel.getBoardInfo(boardId);
|
this.boardsAndTasksModel.getBoardInfo(boardId);
|
||||||
if (boardInfo == null) continue;
|
if (boardInfo == null) continue;
|
||||||
|
|
||||||
this.showBoardInList(boardInfo);
|
this.showBoardInList(boardInfo);
|
||||||
@@ -151,7 +150,7 @@ export default class TaskPageViewModel {
|
|||||||
chatViewModel: ChatViewModel
|
chatViewModel: ChatViewModel
|
||||||
) {
|
) {
|
||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
this.boardModel = boardModel;
|
this.boardsAndTasksModel = boardModel;
|
||||||
|
|
||||||
this.chatViewModel = chatViewModel;
|
this.chatViewModel = chatViewModel;
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ import BoardsAndTasksModel, {
|
|||||||
import { localeCompare, padZero } from "../../Model/Utility/utility";
|
import { localeCompare, padZero } from "../../Model/Utility/utility";
|
||||||
|
|
||||||
import BoardViewModel from "./boardViewModel";
|
import BoardViewModel from "./boardViewModel";
|
||||||
|
import CalendarPageViewModel from "./calendarPageViewModel";
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel from "../Global/coreViewModel";
|
||||||
import { allowDrag } from "../../View/utility";
|
import { allowDrag } from "../../View/utility";
|
||||||
|
|
||||||
export default class TaskViewModel {
|
export default class TaskViewModel {
|
||||||
boardsAndTasksModel: BoardsAndTasksModel;
|
boardsAndTasksModel: BoardsAndTasksModel;
|
||||||
|
|
||||||
boardViewModel: BoardViewModel;
|
boardViewModel: BoardViewModel | null;
|
||||||
|
calendarPageViewModel: CalendarPageViewModel | null;
|
||||||
|
|
||||||
// data
|
// data
|
||||||
task: TaskFileContent;
|
task: TaskFileContent;
|
||||||
@@ -77,11 +79,11 @@ export default class TaskViewModel {
|
|||||||
|
|
||||||
// view
|
// view
|
||||||
open = (): void => {
|
open = (): void => {
|
||||||
this.boardViewModel.selectTask(this);
|
this.boardViewModel?.selectTask(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
close = (): void => {
|
close = (): void => {
|
||||||
this.boardViewModel.closeTask();
|
this.boardViewModel?.closeTask();
|
||||||
};
|
};
|
||||||
|
|
||||||
closeAndSave = (): void => {
|
closeAndSave = (): void => {
|
||||||
@@ -90,6 +92,7 @@ export default class TaskViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
updateIndex = (): void => {
|
updateIndex = (): void => {
|
||||||
|
if (this.boardViewModel == null) return;
|
||||||
const index: number = this.boardViewModel.taskIndexManager.getIndex(this);
|
const index: number = this.boardViewModel.taskIndexManager.getIndex(this);
|
||||||
this.index.value = index;
|
this.index.value = index;
|
||||||
};
|
};
|
||||||
@@ -112,14 +115,24 @@ export default class TaskViewModel {
|
|||||||
newTaskFileContent.time = this.time.value;
|
newTaskFileContent.time = this.time.value;
|
||||||
|
|
||||||
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
||||||
|
|
||||||
|
if (this.boardViewModel != null) {
|
||||||
this.boardViewModel.showTaskInList(newTaskFileContent);
|
this.boardViewModel.showTaskInList(newTaskFileContent);
|
||||||
this.boardViewModel.updateTaskIndices();
|
this.boardViewModel.updateTaskIndices();
|
||||||
|
}
|
||||||
|
if (this.calendarPageViewModel != null) {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteTask = (): void => {
|
deleteTask = (): void => {
|
||||||
this.close();
|
this.close();
|
||||||
this.boardsAndTasksModel.deleteTask(this.task.boardId, this.task.fileId);
|
this.boardsAndTasksModel.deleteTask(this.task.boardId, this.task.fileId);
|
||||||
|
|
||||||
|
if (this.boardViewModel != null) {
|
||||||
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
||||||
|
}
|
||||||
|
if (this.calendarPageViewModel != null) {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// load
|
// load
|
||||||
@@ -168,12 +181,14 @@ export default class TaskViewModel {
|
|||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
public coreViewModel: CoreViewModel,
|
public coreViewModel: CoreViewModel,
|
||||||
boardModel: BoardsAndTasksModel,
|
boardsAndTasksModel: BoardsAndTasksModel,
|
||||||
boardViewModel: BoardViewModel,
|
boardViewModel: BoardViewModel | null,
|
||||||
|
calendarPageViewModel: CalendarPageViewModel | null,
|
||||||
taskFileContent: TaskFileContent
|
taskFileContent: TaskFileContent
|
||||||
) {
|
) {
|
||||||
this.boardsAndTasksModel = boardModel;
|
this.boardsAndTasksModel = boardsAndTasksModel;
|
||||||
this.boardViewModel = boardViewModel;
|
this.boardViewModel = boardViewModel;
|
||||||
|
this.calendarPageViewModel = calendarPageViewModel;
|
||||||
|
|
||||||
this.task = taskFileContent;
|
this.task = taskFileContent;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user