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
|
||||
var ChatMessageViewModel = class {
|
||||
// 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
|
||||
var BoardViewModel = class {
|
||||
// init
|
||||
@@ -1782,6 +1828,7 @@
|
||||
this.coreViewModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
null,
|
||||
taskFileContent
|
||||
);
|
||||
this.selectTask(taskViewModel);
|
||||
@@ -1827,6 +1874,7 @@
|
||||
this.coreViewModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
null,
|
||||
taskFileContent
|
||||
);
|
||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||
@@ -1896,6 +1944,7 @@
|
||||
this.coreViewModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
null,
|
||||
taskFileContent
|
||||
);
|
||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||
@@ -1914,7 +1963,7 @@
|
||||
constructor(coreViewModel, storageModel2, boardModel, chatViewModel) {
|
||||
this.coreViewModel = coreViewModel;
|
||||
this.storageModel = storageModel2;
|
||||
this.boardModel = boardModel;
|
||||
this.boardsAndTasksModel = boardModel;
|
||||
this.chatViewModel = chatViewModel;
|
||||
boardModel.boardHandlerManager.addHandler(
|
||||
(boardInfoFileContent) => {
|
||||
@@ -1924,7 +1973,7 @@
|
||||
);
|
||||
}
|
||||
storageModel;
|
||||
boardModel;
|
||||
boardsAndTasksModel;
|
||||
chatViewModel;
|
||||
// data
|
||||
boardIndexManager = new IndexManager(
|
||||
@@ -1932,7 +1981,7 @@
|
||||
);
|
||||
// paths
|
||||
getBasePath = () => {
|
||||
return [...this.boardModel.getViewPath()];
|
||||
return [...this.boardsAndTasksModel.getViewPath()];
|
||||
};
|
||||
getBoardViewPath = (boardId) => {
|
||||
return [...this.getBasePath(), boardId];
|
||||
@@ -1952,18 +2001,18 @@
|
||||
// methods
|
||||
createBoard = () => {
|
||||
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.showBoardInList(boardInfoFileContent);
|
||||
this.boardModel.updateBoardAndSend(boardInfoFileContent);
|
||||
this.boardsAndTasksModel.updateBoardAndSend(boardInfoFileContent);
|
||||
this.updateBoardIndices();
|
||||
};
|
||||
updateBoard = (boardInfoFileContent) => {
|
||||
this.boardModel.updateBoardAndSend(boardInfoFileContent);
|
||||
this.boardsAndTasksModel.updateBoardAndSend(boardInfoFileContent);
|
||||
this.updateBoardIndices();
|
||||
};
|
||||
deleteBoard = (boardInfoFileContent) => {
|
||||
this.boardModel.deleteBoard(boardInfoFileContent.fileId);
|
||||
this.boardsAndTasksModel.deleteBoard(boardInfoFileContent.fileId);
|
||||
this.boardViewModels.remove(boardInfoFileContent.fileId);
|
||||
this.updateBoardIndices();
|
||||
};
|
||||
@@ -1972,7 +2021,7 @@
|
||||
const boardViewModel = new BoardViewModel(
|
||||
this.coreViewModel,
|
||||
this.storageModel,
|
||||
this.boardModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
boardInfo
|
||||
);
|
||||
@@ -2011,9 +2060,9 @@
|
||||
// load
|
||||
loadData = () => {
|
||||
this.boardViewModels.clear();
|
||||
const boardIds = this.boardModel.listBoardIds();
|
||||
const boardIds = this.boardsAndTasksModel.listBoardIds();
|
||||
for (const boardId of boardIds) {
|
||||
const boardInfo = this.boardModel.getBoardInfo(boardId);
|
||||
const boardInfo = this.boardsAndTasksModel.getBoardInfo(boardId);
|
||||
if (boardInfo == null) continue;
|
||||
this.showBoardInList(boardInfo);
|
||||
}
|
||||
@@ -2031,6 +2080,12 @@
|
||||
this.chatModel = chatModel;
|
||||
this.settingsViewModel = settingsViewModel2;
|
||||
this.chatListViewModel = chatListViewModel2;
|
||||
this.calendarViewModel = new CalendarPageViewModel(
|
||||
coreViewModel,
|
||||
this.storageModel,
|
||||
this.chatModel.fileModel.calendarModel,
|
||||
this.chatModel.fileModel.boardsAndTasksModel
|
||||
);
|
||||
this.taskPageViewModel = new TaskPageViewModel(
|
||||
this.coreViewModel,
|
||||
this.storageModel,
|
||||
@@ -2057,6 +2112,7 @@
|
||||
storageModel;
|
||||
settingsViewModel;
|
||||
chatListViewModel;
|
||||
calendarViewModel;
|
||||
taskPageViewModel;
|
||||
messagePageViewModel;
|
||||
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
|
||||
function RibbonButton(label, icon, isSelected, select) {
|
||||
return /* @__PURE__ */ createElement(
|
||||
@@ -3319,6 +3381,9 @@
|
||||
case "tasks" /* Tasks */: {
|
||||
return TaskPage(chatViewModel.taskPageViewModel);
|
||||
}
|
||||
case "calendar" /* Calendar */: {
|
||||
return CalendarPage(chatViewModel.calendarViewModel);
|
||||
}
|
||||
default: {
|
||||
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 { CalendarPage } from "./ChatPages/calendarPage";
|
||||
import { ChatViewToggleButton } from "./Components/chatViewToggleButton";
|
||||
import { MessagePage } from "./ChatPages/messagePage";
|
||||
import { SettingsPage } from "./ChatPages/settingsPage";
|
||||
@@ -23,6 +24,9 @@ export function ChatPage(chatViewModel: ChatViewModel) {
|
||||
case ChatPageType.Tasks: {
|
||||
return TaskPage(chatViewModel.taskPageViewModel);
|
||||
}
|
||||
case ChatPageType.Calendar: {
|
||||
return CalendarPage(chatViewModel.calendarViewModel)
|
||||
}
|
||||
default: {
|
||||
return MessagePage(chatViewModel.messagePageViewModel);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import * as React from "bloatless-react";
|
||||
|
||||
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 { Color } from "../../colors";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
@@ -17,6 +21,7 @@ export default class ChatViewModel {
|
||||
settingsViewModel: SettingsViewModel;
|
||||
chatListViewModel: ChatListViewModel;
|
||||
|
||||
calendarViewModel: CalendarPageViewModel;
|
||||
taskPageViewModel: TaskPageViewModel;
|
||||
messagePageViewModel: MessagePageViewModel;
|
||||
settingsPageViewModel: SettingsPageViewModel;
|
||||
@@ -91,6 +96,12 @@ export default class ChatViewModel {
|
||||
this.chatListViewModel = chatListViewModel;
|
||||
|
||||
// page viewModels
|
||||
this.calendarViewModel = new CalendarPageViewModel(
|
||||
coreViewModel,
|
||||
this.storageModel,
|
||||
this.chatModel.fileModel.calendarModel,
|
||||
this.chatModel.fileModel.boardsAndTasksModel
|
||||
);
|
||||
this.taskPageViewModel = new TaskPageViewModel(
|
||||
this.coreViewModel,
|
||||
this.storageModel,
|
||||
|
||||
@@ -82,6 +82,7 @@ export default class BoardViewModel {
|
||||
this.coreViewModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
null,
|
||||
taskFileContent
|
||||
);
|
||||
this.selectTask(taskViewModel);
|
||||
@@ -136,6 +137,7 @@ export default class BoardViewModel {
|
||||
this.coreViewModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
null,
|
||||
taskFileContent
|
||||
);
|
||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
||||
@@ -222,6 +224,7 @@ export default class BoardViewModel {
|
||||
this.coreViewModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
null,
|
||||
taskFileContent
|
||||
);
|
||||
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 { IndexManager } from "../../Model/Utility/utility";
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
import TaskViewModel from "./taskViewModel";
|
||||
|
||||
export default class TaskPageViewModel {
|
||||
storageModel: StorageModel;
|
||||
boardModel: BoardsAndTasksModel;
|
||||
boardsAndTasksModel: BoardsAndTasksModel;
|
||||
|
||||
chatViewModel: ChatViewModel;
|
||||
|
||||
@@ -24,7 +23,7 @@ export default class TaskPageViewModel {
|
||||
|
||||
// paths
|
||||
getBasePath = (): string[] => {
|
||||
return [...this.boardModel.getViewPath()];
|
||||
return [...this.boardsAndTasksModel.getViewPath()];
|
||||
};
|
||||
|
||||
getBoardViewPath = (boardId): string[] => {
|
||||
@@ -55,21 +54,21 @@ export default class TaskPageViewModel {
|
||||
if (this.cannotCreateBoard.value == true) return;
|
||||
|
||||
const boardInfoFileContent: BoardInfoFileContent =
|
||||
this.boardModel.createBoard(this.newBoardNameInput.value);
|
||||
this.boardsAndTasksModel.createBoard(this.newBoardNameInput.value);
|
||||
this.newBoardNameInput.value = "";
|
||||
|
||||
this.showBoardInList(boardInfoFileContent);
|
||||
this.boardModel.updateBoardAndSend(boardInfoFileContent);
|
||||
this.boardsAndTasksModel.updateBoardAndSend(boardInfoFileContent);
|
||||
this.updateBoardIndices();
|
||||
};
|
||||
|
||||
updateBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
||||
this.boardModel.updateBoardAndSend(boardInfoFileContent);
|
||||
this.boardsAndTasksModel.updateBoardAndSend(boardInfoFileContent);
|
||||
this.updateBoardIndices();
|
||||
};
|
||||
|
||||
deleteBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
||||
this.boardModel.deleteBoard(boardInfoFileContent.fileId);
|
||||
this.boardsAndTasksModel.deleteBoard(boardInfoFileContent.fileId);
|
||||
this.boardViewModels.remove(boardInfoFileContent.fileId);
|
||||
this.updateBoardIndices();
|
||||
};
|
||||
@@ -79,7 +78,7 @@ export default class TaskPageViewModel {
|
||||
const boardViewModel: BoardViewModel = new BoardViewModel(
|
||||
this.coreViewModel,
|
||||
this.storageModel,
|
||||
this.boardModel,
|
||||
this.boardsAndTasksModel,
|
||||
this,
|
||||
boardInfo
|
||||
);
|
||||
@@ -130,10 +129,10 @@ export default class TaskPageViewModel {
|
||||
loadData = (): void => {
|
||||
this.boardViewModels.clear();
|
||||
|
||||
const boardIds: string[] = this.boardModel.listBoardIds();
|
||||
const boardIds: string[] = this.boardsAndTasksModel.listBoardIds();
|
||||
for (const boardId of boardIds) {
|
||||
const boardInfo: BoardInfoFileContent | null =
|
||||
this.boardModel.getBoardInfo(boardId);
|
||||
this.boardsAndTasksModel.getBoardInfo(boardId);
|
||||
if (boardInfo == null) continue;
|
||||
|
||||
this.showBoardInList(boardInfo);
|
||||
@@ -151,7 +150,7 @@ export default class TaskPageViewModel {
|
||||
chatViewModel: ChatViewModel
|
||||
) {
|
||||
this.storageModel = storageModel;
|
||||
this.boardModel = boardModel;
|
||||
this.boardsAndTasksModel = boardModel;
|
||||
|
||||
this.chatViewModel = chatViewModel;
|
||||
|
||||
|
||||
@@ -6,13 +6,15 @@ import BoardsAndTasksModel, {
|
||||
import { localeCompare, padZero } from "../../Model/Utility/utility";
|
||||
|
||||
import BoardViewModel from "./boardViewModel";
|
||||
import CalendarPageViewModel from "./calendarPageViewModel";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
import { allowDrag } from "../../View/utility";
|
||||
|
||||
export default class TaskViewModel {
|
||||
boardsAndTasksModel: BoardsAndTasksModel;
|
||||
|
||||
boardViewModel: BoardViewModel;
|
||||
boardViewModel: BoardViewModel | null;
|
||||
calendarPageViewModel: CalendarPageViewModel | null;
|
||||
|
||||
// data
|
||||
task: TaskFileContent;
|
||||
@@ -77,11 +79,11 @@ export default class TaskViewModel {
|
||||
|
||||
// view
|
||||
open = (): void => {
|
||||
this.boardViewModel.selectTask(this);
|
||||
this.boardViewModel?.selectTask(this);
|
||||
};
|
||||
|
||||
close = (): void => {
|
||||
this.boardViewModel.closeTask();
|
||||
this.boardViewModel?.closeTask();
|
||||
};
|
||||
|
||||
closeAndSave = (): void => {
|
||||
@@ -90,6 +92,7 @@ export default class TaskViewModel {
|
||||
};
|
||||
|
||||
updateIndex = (): void => {
|
||||
if (this.boardViewModel == null) return;
|
||||
const index: number = this.boardViewModel.taskIndexManager.getIndex(this);
|
||||
this.index.value = index;
|
||||
};
|
||||
@@ -112,14 +115,24 @@ export default class TaskViewModel {
|
||||
newTaskFileContent.time = this.time.value;
|
||||
|
||||
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
|
||||
this.boardViewModel.showTaskInList(newTaskFileContent);
|
||||
this.boardViewModel.updateTaskIndices();
|
||||
|
||||
if (this.boardViewModel != null) {
|
||||
this.boardViewModel.showTaskInList(newTaskFileContent);
|
||||
this.boardViewModel.updateTaskIndices();
|
||||
}
|
||||
if (this.calendarPageViewModel != null) {
|
||||
}
|
||||
};
|
||||
|
||||
deleteTask = (): void => {
|
||||
this.close();
|
||||
this.boardsAndTasksModel.deleteTask(this.task.boardId, this.task.fileId);
|
||||
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
||||
|
||||
if (this.boardViewModel != null) {
|
||||
this.boardViewModel.removeTaskFromList(this.task.fileId);
|
||||
}
|
||||
if (this.calendarPageViewModel != null) {
|
||||
}
|
||||
};
|
||||
|
||||
// load
|
||||
@@ -168,12 +181,14 @@ export default class TaskViewModel {
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
boardModel: BoardsAndTasksModel,
|
||||
boardViewModel: BoardViewModel,
|
||||
boardsAndTasksModel: BoardsAndTasksModel,
|
||||
boardViewModel: BoardViewModel | null,
|
||||
calendarPageViewModel: CalendarPageViewModel | null,
|
||||
taskFileContent: TaskFileContent
|
||||
) {
|
||||
this.boardsAndTasksModel = boardModel;
|
||||
this.boardsAndTasksModel = boardsAndTasksModel;
|
||||
this.boardViewModel = boardViewModel;
|
||||
this.calendarPageViewModel = calendarPageViewModel;
|
||||
|
||||
this.task = taskFileContent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user