add method to delete board
This commit is contained in:
Vendored
+10
-1
@@ -536,7 +536,7 @@
|
|||||||
return this.fileModel.getModelContainerPath("taskModel");
|
return this.fileModel.getModelContainerPath("taskModel");
|
||||||
};
|
};
|
||||||
getBoardFilePath = (boardId) => {
|
getBoardFilePath = (boardId) => {
|
||||||
return [...this.fileModel.getFilePath(boardId), boardId];
|
return [...this.fileModel.getFilePath(boardId)];
|
||||||
};
|
};
|
||||||
getBoardContainerPath = () => {
|
getBoardContainerPath = () => {
|
||||||
return [...this.getBasePath(), subDirectories.boards];
|
return [...this.getBasePath(), subDirectories.boards];
|
||||||
@@ -590,6 +590,14 @@
|
|||||||
);
|
);
|
||||||
this.storageModel.write(boardDirectoryPath, "");
|
this.storageModel.write(boardDirectoryPath, "");
|
||||||
};
|
};
|
||||||
|
deleteBoard = (boardId) => {
|
||||||
|
const boardFilePath = this.getBoardFilePath(boardId);
|
||||||
|
const boardDirectoryPath = this.getBoardDirectoryPath(boardId);
|
||||||
|
console.log(boardFilePath);
|
||||||
|
console.log(boardDirectoryPath);
|
||||||
|
this.storageModel.removeRecursively(boardFilePath);
|
||||||
|
this.storageModel.removeRecursively(boardDirectoryPath);
|
||||||
|
};
|
||||||
//tasks
|
//tasks
|
||||||
createTask = (boardId, name) => {
|
createTask = (boardId, name) => {
|
||||||
const taskFileVersion = _TaskModel.createTaskFileVersion(
|
const taskFileVersion = _TaskModel.createTaskFileVersion(
|
||||||
@@ -764,6 +772,7 @@
|
|||||||
"coral" /* Coral */
|
"coral" /* Coral */
|
||||||
);
|
);
|
||||||
this.taskModel.createOrUpdateBoard(newInfo);
|
this.taskModel.createOrUpdateBoard(newInfo);
|
||||||
|
setTimeout(() => this.taskModel.deleteBoard(boardId), 7e3);
|
||||||
}
|
}
|
||||||
// utility
|
// utility
|
||||||
static generateFileVersionId = (creationDate) => {
|
static generateFileVersionId = (creationDate) => {
|
||||||
|
|||||||
@@ -138,6 +138,25 @@ export default class FileModel {
|
|||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
|
|
||||||
this.taskModel = new TaskModel(this.storageModel, chatModel, this);
|
this.taskModel = new TaskModel(this.storageModel, chatModel, this);
|
||||||
|
|
||||||
|
// DEV
|
||||||
|
// this.taskModel.createBoard("Hello");
|
||||||
|
// const boards = this.taskModel.listBoardIds();
|
||||||
|
// console.log(boards);
|
||||||
|
|
||||||
|
// const boardId = boards[0];
|
||||||
|
|
||||||
|
// const firstBoardInfo = this.taskModel.getBoardInfo(boardId);
|
||||||
|
// console.log(firstBoardInfo);
|
||||||
|
|
||||||
|
// const newInfo = TaskModel.createBoardInfoFileVersion(
|
||||||
|
// boardId,
|
||||||
|
// "renamed",
|
||||||
|
// Color.Coral
|
||||||
|
// );
|
||||||
|
// this.taskModel.createOrUpdateBoard(newInfo);
|
||||||
|
|
||||||
|
// setTimeout(() => this.taskModel.deleteBoard(boardId), 7000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default class TaskModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getBoardFilePath = (boardId: string): string[] => {
|
getBoardFilePath = (boardId: string): string[] => {
|
||||||
return [...this.fileModel.getFilePath(boardId), boardId];
|
return [...this.fileModel.getFilePath(boardId)];
|
||||||
};
|
};
|
||||||
|
|
||||||
getBoardContainerPath = (): string[] => {
|
getBoardContainerPath = (): string[] => {
|
||||||
@@ -102,6 +102,14 @@ export default class TaskModel {
|
|||||||
this.storageModel.write(boardDirectoryPath, "");
|
this.storageModel.write(boardDirectoryPath, "");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
deleteBoard = (boardId: string): void => {
|
||||||
|
const boardFilePath: string[] = this.getBoardFilePath(boardId);
|
||||||
|
const boardDirectoryPath: string[] = this.getBoardDirectoryPath(boardId);
|
||||||
|
|
||||||
|
this.storageModel.removeRecursively(boardFilePath);
|
||||||
|
this.storageModel.removeRecursively(boardDirectoryPath);
|
||||||
|
};
|
||||||
|
|
||||||
//tasks
|
//tasks
|
||||||
createTask = (boardId: string, name: string): void => {
|
createTask = (boardId: string, name: string): void => {
|
||||||
const taskFileVersion: TaskFileVersion = TaskModel.createTaskFileVersion(
|
const taskFileVersion: TaskFileVersion = TaskModel.createTaskFileVersion(
|
||||||
|
|||||||
Reference in New Issue
Block a user