implement task sorting
This commit is contained in:
@@ -3,6 +3,7 @@ import * as React from "bloatless-react";
|
||||
import BoardModel, { TaskFileContent } from "../../Model/Files/boardModel";
|
||||
|
||||
import BoardViewModel from "./boardViewModel";
|
||||
import { padZero } from "../../Model/Utility/utility";
|
||||
|
||||
export default class TaskViewModel {
|
||||
boardModel: BoardModel;
|
||||
@@ -12,14 +13,33 @@ export default class TaskViewModel {
|
||||
// data
|
||||
task: TaskFileContent;
|
||||
|
||||
get sortingString(): string {
|
||||
const splitDate: string[] = this.date.value.split("-");
|
||||
const year = padZero(splitDate[0], 4);
|
||||
const month = padZero(splitDate[1], 2);
|
||||
const date = padZero(splitDate[2], 2);
|
||||
|
||||
const splitTime: string[] = 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 = (): string[] => {
|
||||
return this.boardModel.getTaskFilePath(this.task.fileId);
|
||||
};
|
||||
|
||||
// state
|
||||
name: React.State<string> = new React.State("");
|
||||
index: React.State<number> = new React.State(0);
|
||||
|
||||
name: React.State<string> = new React.State("");
|
||||
description: React.State<string> = new React.State("");
|
||||
|
||||
category: React.State<string> = new React.State("");
|
||||
@@ -43,6 +63,11 @@ export default class TaskViewModel {
|
||||
this.save();
|
||||
};
|
||||
|
||||
updateIndex = (): void => {
|
||||
const index: number = this.boardViewModel.taskIndexManager.getIndex(this);
|
||||
this.index.value = index;
|
||||
};
|
||||
|
||||
// settings
|
||||
save = (): void => {
|
||||
const newTaskFileContent: TaskFileContent =
|
||||
@@ -61,6 +86,7 @@ export default class TaskViewModel {
|
||||
|
||||
this.boardModel.updateTaskAndSend(newTaskFileContent);
|
||||
this.boardViewModel.showTaskInList(newTaskFileContent);
|
||||
this.boardViewModel.updateTaskIndices();
|
||||
};
|
||||
|
||||
deleteTask = (): void => {
|
||||
|
||||
Reference in New Issue
Block a user