return parseFloat(task.getAttribute("data-created")!);
},
+ getState: function (task: Element): string {
+ return task.getAttribute("data-state") ?? "todo";
+ },
+
getTask: function (createTimestamp: string) {
for (const task of document.getElementsByClassName("task")) {
if (task.getAttribute("data-created") === createTimestamp) {
setState: function (stateTimestamp: string, createTimestamp: string, state: string) {
const task = this.getTask(createTimestamp);
if (task) {
- task.setAttribute(`data-${state}`, stateTimestamp);
+ task.setAttribute("data-state", state);
if (task instanceof HTMLElement) {
- task.style.display = "none"; // Until view filtering
+ task.style.display = state == "todo" ? "block" : "none"; // Until view filtering
}
}
},
undoLog.push(`Priority ${createTimestamp} ${oldPriority}`);
return log.recordAndApply(`${Date.now()} Priority ${createTimestamp} ${newPriority}`);
},
- setState: function (createTimestamp: string, state: string) {
- return log.recordAndApply(`${Date.now()} State ${createTimestamp} ${state}`);
+ setState: function (createTimestamp: string, newState: string, oldState: string) {
+ undoLog.push(`State ${createTimestamp} ${oldState}`);
+ return log.recordAndApply(`${Date.now()} State ${createTimestamp} ${newState}`);
},
undo: function () {
if (undoLog.length > 0) {
},
setState: function (state: string) {
- const createTimestamp = document.activeElement?.getAttribute("data-created");
+ const task = document.activeElement;
+ if (!task) return;
+ const createTimestamp = task.getAttribute("data-created")!;
this.moveCursor(1) || this.moveCursor(-1);
- return UI.setState(createTimestamp!, state);
+ return UI.setState(createTimestamp, state, Model.getState(task));
},
undo: function () {