fix event sorting

This commit is contained in:
marlon-erler
2024-07-26 06:20:16 +02:00
parent 0efa09eff3
commit 0c09dfc486
8 changed files with 296 additions and 231 deletions
+163 -143
View File
@@ -1430,11 +1430,10 @@
// src/ViewModel/Pages/taskViewModel.ts // src/ViewModel/Pages/taskViewModel.ts
var TaskViewModel = class { var TaskViewModel = class {
// init // init
constructor(coreViewModel, boardsAndTasksModel, boardViewModel, calendarPageViewModel, taskFileContent) { constructor(coreViewModel, boardsAndTasksModel, containingModel, taskFileContent) {
this.coreViewModel = coreViewModel; this.coreViewModel = coreViewModel;
this.boardsAndTasksModel = boardsAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.boardViewModel = boardViewModel; this.containingModel = containingModel;
this.calendarPageViewModel = calendarPageViewModel;
this.task = taskFileContent; this.task = taskFileContent;
this.loadAllData(); this.loadAllData();
this.selectedVersionId.subscribeSilent((selectedVersionId) => { this.selectedVersionId.subscribeSilent((selectedVersionId) => {
@@ -1442,8 +1441,7 @@
}); });
} }
boardsAndTasksModel; boardsAndTasksModel;
boardViewModel; containingModel;
calendarPageViewModel;
// data // data
task; task;
get sortingString() { get sortingString() {
@@ -1490,18 +1488,17 @@
}; };
// view // view
open = () => { open = () => {
this.boardViewModel?.selectTask(this); this.containingModel.selectTask(this);
}; };
close = () => { close = () => {
this.boardViewModel?.closeTask(); this.containingModel.closeTask();
}; };
closeAndSave = () => { closeAndSave = () => {
this.close(); this.close();
this.save(); this.save();
}; };
updateIndex = () => { updateIndex = () => {
if (this.boardViewModel == null) return; const index = this.containingModel.taskIndexManager.getIndex(this);
const index = this.boardViewModel.taskIndexManager.getIndex(this);
this.index.value = index; this.index.value = index;
}; };
// settings // settings
@@ -1519,23 +1516,13 @@
newTaskFileContent.date = this.date.value; newTaskFileContent.date = this.date.value;
newTaskFileContent.time = this.time.value; newTaskFileContent.time = this.time.value;
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent); this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
if (this.boardViewModel != null) { this.containingModel.showTask(newTaskFileContent);
this.boardViewModel.showTaskInList(newTaskFileContent); this.containingModel.updateTaskIndices();
this.boardViewModel.updateTaskIndices();
}
if (this.calendarPageViewModel != null) {
this.calendarPageViewModel.showTask(newTaskFileContent);
}
}; };
deleteTask = () => { deleteTask = () => {
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.containingModel.removeTaskFromView(this.task);
this.boardViewModel.removeTaskFromList(this.task.fileId);
}
if (this.calendarPageViewModel != null) {
this.calendarPageViewModel.removeTaskFromView(this.task);
}
}; };
// load // load
loadVersionIds = () => { loadVersionIds = () => {
@@ -1584,19 +1571,66 @@
}; };
}; };
// src/ViewModel/Pages/calendarPageViewModel.ts // src/ViewModel/Pages/taskContainingPageViewModel.ts
var CalendarPageViewModel = class { var TaskContainingPageViewModel = class {
coreViewModel;
boardsAndTasksModel;
// state
taskIndexManager = new IndexManager(
(taskViewModel) => taskViewModel.sortingString
);
selectedTaskViewModel = new State(void 0);
taskViewModels = new MapState();
// methods
createTask = (boardId) => {
const taskFileContent = this.boardsAndTasksModel.createTask(boardId);
const taskViewModel = new TaskViewModel(
this.coreViewModel,
this.boardsAndTasksModel,
this,
taskFileContent
);
this.selectTask(taskViewModel);
this.updateTaskIndices();
};
// view
showTask = (taskFileContent) => {
};
removeTaskFromView = (taskFileContent) => {
};
selectTask = (selectedTask) => {
this.selectedTaskViewModel.value = selectedTask;
};
closeTask = () => {
this.selectedTaskViewModel.value = void 0;
};
updateTaskIndices = () => {
this.taskIndexManager.update([...this.taskViewModels.value.values()]);
for (const boardViewModel of this.taskViewModels.value.values()) {
boardViewModel.updateIndex();
}
};
// init // init
constructor(coreViewModel, storageModel2, calendarModel, boardAndTasksModel, chatViewModel) { constructor(coreViewModel, boardsAndTasksModel) {
this.coreViewModel = coreViewModel;
this.boardsAndTasksModel = boardsAndTasksModel;
}
};
// src/ViewModel/Pages/calendarPageViewModel.ts
var CalendarPageViewModel = class extends TaskContainingPageViewModel {
// init
constructor(coreViewModel, storageModel2, calendarModel, boardsAndTasksModel, chatViewModel) {
super(coreViewModel, boardsAndTasksModel);
this.coreViewModel = coreViewModel; this.coreViewModel = coreViewModel;
this.storageModel = storageModel2; this.storageModel = storageModel2;
this.calendarModel = calendarModel; this.calendarModel = calendarModel;
this.boardsAndTasksModel = boardAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
bulkSubscribe([this.selectedYear, this.selectedMonth], () => { bulkSubscribe([this.selectedYear, this.selectedMonth], () => {
this.loadMonthTasks(); this.loadMonthTasks();
}); });
boardAndTasksModel.taskHandlerManager.addHandler( boardsAndTasksModel.taskHandlerManager.addHandler(
(taskFileContent) => { (taskFileContent) => {
this.showTask(taskFileContent); this.showTask(taskFileContent);
} }
@@ -1622,7 +1656,6 @@
selectedMonth = new State(0); selectedMonth = new State(0);
selectedDate = new State(0); selectedDate = new State(0);
monthGrid = new State(void 0); monthGrid = new State(void 0);
taskViewModelsToShow = new ListState();
// view // view
getTaskMapState = (taskFileContent) => { getTaskMapState = (taskFileContent) => {
if (this.monthGrid.value == null) return null; if (this.monthGrid.value == null) return null;
@@ -1642,16 +1675,17 @@
const taskViewModel = new TaskViewModel( const taskViewModel = new TaskViewModel(
this.coreViewModel, this.coreViewModel,
this.boardsAndTasksModel, this.boardsAndTasksModel,
null,
this, this,
taskFileContent taskFileContent
); );
const mapState = this.getTaskMapState(taskFileContent); const mapState = this.getTaskMapState(taskFileContent);
mapState?.set(taskFileContent.fileId, taskViewModel); mapState?.set(taskFileContent.fileId, taskViewModel);
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
}; };
removeTaskFromView = (taskFileContent) => { removeTaskFromView = (taskFileContent) => {
const mapState = this.getTaskMapState(taskFileContent); const mapState = this.getTaskMapState(taskFileContent);
mapState?.remove(taskFileContent.fileId); mapState?.remove(taskFileContent.fileId);
this.taskViewModels.remove(taskFileContent.fileId);
}; };
showToday = () => { showToday = () => {
const today = /* @__PURE__ */ new Date(); const today = /* @__PURE__ */ new Date();
@@ -1673,7 +1707,6 @@
this.selectedMonth.value = 1; this.selectedMonth.value = 1;
} }
}; };
// storage
// load // load
loadMonthTasks = () => { loadMonthTasks = () => {
this.monthGrid.value = this.calendarModel.generateMonthGrid( this.monthGrid.value = this.calendarModel.generateMonthGrid(
@@ -1687,6 +1720,7 @@
if (taskFileContent == null) continue; if (taskFileContent == null) continue;
this.showTask(taskFileContent); this.showTask(taskFileContent);
} }
this.updateTaskIndices();
}; };
loadData = () => { loadData = () => {
this.loadMonthTasks(); this.loadMonthTasks();
@@ -1894,12 +1928,13 @@
}; };
// src/ViewModel/Pages/boardViewModel.ts // src/ViewModel/Pages/boardViewModel.ts
var BoardViewModel = class { var BoardViewModel = class extends TaskContainingPageViewModel {
// init // init
constructor(coreViewModel, storageModel2, boardModel, taskPageViewModel, boardInfo) { constructor(coreViewModel, storageModel2, boardsAndTasksModel, taskPageViewModel, boardInfo) {
super(coreViewModel, boardsAndTasksModel);
this.coreViewModel = coreViewModel; this.coreViewModel = coreViewModel;
this.storageModel = storageModel2; this.storageModel = storageModel2;
this.boardsAndTasksModel = boardModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.taskPageViewModel = taskPageViewModel; this.taskPageViewModel = taskPageViewModel;
this.boardInfo = boardInfo; this.boardInfo = boardInfo;
this.loadListRelevantData(); this.loadListRelevantData();
@@ -1914,10 +1949,10 @@
this.selectedPage.subscribeSilent(() => { this.selectedPage.subscribeSilent(() => {
this.storeLastUsedView(); this.storeLastUsedView();
}); });
boardModel.taskHandlerManager.addHandler( boardsAndTasksModel.taskHandlerManager.addHandler(
(taskFileContent) => { (taskFileContent) => {
if (taskFileContent.boardId != this.boardInfo.fileId) return; if (taskFileContent.boardId != this.boardInfo.fileId) return;
this.showTaskInList(taskFileContent); this.showTask(taskFileContent);
this.updateTaskIndices(); this.updateTaskIndices();
} }
); );
@@ -1927,9 +1962,6 @@
taskPageViewModel; taskPageViewModel;
// data // data
boardInfo; boardInfo;
taskIndexManager = new IndexManager(
(taskViewModel) => taskViewModel.sortingString
);
// state // state
name = new State(""); name = new State("");
color = new State("standard" /* Standard */); color = new State("standard" /* Standard */);
@@ -1937,11 +1969,9 @@
selectedPage = new State( selectedPage = new State(
"list" /* List */ "list" /* List */
); );
selectedTaskViewModel = new State(void 0);
isSelected; isSelected;
isPresentingSettingsModal = new State(false); isPresentingSettingsModal = new State(false);
isPresentingFilterModal = new State(false); isPresentingFilterModal = new State(false);
taskViewModels = new MapState();
filteredTaskViewModels = new ListState(); filteredTaskViewModels = new ListState();
// paths // paths
getBasePath = () => { getBasePath = () => {
@@ -1967,22 +1997,6 @@
this.close(); this.close();
}; };
// methods // methods
createTask = () => {
const taskFileContent = this.boardsAndTasksModel.createTask(this.boardInfo.fileId);
const taskViewModel = new TaskViewModel(
this.coreViewModel,
this.boardsAndTasksModel,
this,
null,
taskFileContent
);
this.selectTask(taskViewModel);
this.updateTaskIndices();
};
removeTaskFromList = (taskId) => {
this.taskViewModels.remove(taskId);
this.updateIndex();
};
handleDropWithinBoard = (category, status) => { handleDropWithinBoard = (category, status) => {
const draggedObject = this.coreViewModel.draggedObject.value; const draggedObject = this.coreViewModel.draggedObject.value;
if (draggedObject instanceof TaskViewModel == false) return; if (draggedObject instanceof TaskViewModel == false) return;
@@ -2006,24 +2020,27 @@
this.selectedPage.value = lastUsedView; this.selectedPage.value = lastUsedView;
}; };
// view // view
showTaskInList = (taskFileContent) => { showTask = (taskFileContent) => {
if (taskFileContent.boardId != this.boardInfo.fileId) { if (taskFileContent.boardId != this.boardInfo.fileId) {
this.boardsAndTasksModel.deleteTaskReference( this.boardsAndTasksModel.deleteTaskReference(
this.boardInfo.fileId, this.boardInfo.fileId,
taskFileContent.fileId taskFileContent.fileId
); );
this.removeTaskFromList(taskFileContent.fileId); this.removeTaskFromView(taskFileContent);
return; return;
} }
const taskViewModel = new TaskViewModel( const taskViewModel = new TaskViewModel(
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);
}; };
removeTaskFromView = (taskFileContent) => {
this.taskViewModels.remove(taskFileContent.fileId);
this.updateIndex();
};
select = () => { select = () => {
this.taskPageViewModel.selectBoard(this); this.taskPageViewModel.selectBoard(this);
}; };
@@ -2044,22 +2061,10 @@
hideFilterModal = () => { hideFilterModal = () => {
this.isPresentingFilterModal.value = false; this.isPresentingFilterModal.value = false;
}; };
selectTask = (selectedTask) => {
this.selectedTaskViewModel.value = selectedTask;
};
closeTask = () => {
this.selectedTaskViewModel.value = void 0;
};
updateIndex = () => { updateIndex = () => {
const index = this.taskPageViewModel.boardIndexManager.getIndex(this); const index = this.taskPageViewModel.boardIndexManager.getIndex(this);
this.index.value = index; this.index.value = index;
}; };
updateTaskIndices = () => {
this.taskIndexManager.update([...this.taskViewModels.value.values()]);
for (const boardViewModel of this.taskViewModels.value.values()) {
boardViewModel.updateIndex();
}
};
// load // load
loadListRelevantData = () => { loadListRelevantData = () => {
this.name.value = this.boardInfo.name; this.name.value = this.boardInfo.name;
@@ -2077,7 +2082,6 @@
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);
@@ -2544,7 +2548,11 @@
offsetElements.push(/* @__PURE__ */ createElement("div", null)); offsetElements.push(/* @__PURE__ */ createElement("div", null));
} }
const converter = (taskViewModel) => { const converter = (taskViewModel) => {
return /* @__PURE__ */ createElement("span", { class: "ellipsis secondary" }, taskViewModel.task.name); const view = /* @__PURE__ */ createElement("span", { class: "ellipsis secondary" }, taskViewModel.task.name);
taskViewModel.index.subscribe((newIndex) => {
view.style.order = newIndex;
});
return view;
}; };
return /* @__PURE__ */ createElement("div", { class: "month-grid-wrapper" }, /* @__PURE__ */ createElement("div", { class: "day-labels" }, ...dayLabels), /* @__PURE__ */ createElement("div", { class: "month-grid" }, ...offsetElements, ...Object.entries(monthGrid.days).map((entry) => { return /* @__PURE__ */ createElement("div", { class: "month-grid-wrapper" }, /* @__PURE__ */ createElement("div", { class: "day-labels" }, ...dayLabels), /* @__PURE__ */ createElement("div", { class: "month-grid" }, ...offsetElements, ...Object.entries(monthGrid.days).map((entry) => {
const [date, mapState] = entry; const [date, mapState] = entry;
@@ -2575,6 +2583,75 @@
}))); })));
} }
// src/View/Components/option.tsx
function Option(text, value, selectedOnCreate) {
return /* @__PURE__ */ createElement("option", { value, "toggle:selected": selectedOnCreate }, text);
}
var StringToOption = (string) => {
return Option(string, string, false);
};
var VersionIdToOption = (versionId) => {
const [date, rest] = versionId.split("T");
const [time] = rest.split(".");
const readableName = `${date} ${time}`;
return Option(readableName, versionId, false);
};
// src/View/Components/dangerousActionButton.tsx
function DangerousActionButton(label, icon, action) {
const isActionRequested = new State(false);
const cannotConfirm = createProxyState(
[isActionRequested],
() => isActionRequested.value == false
);
function requestAction() {
isActionRequested.value = true;
}
function abort() {
isActionRequested.value = false;
}
return /* @__PURE__ */ createElement("div", { class: "flex-row" }, /* @__PURE__ */ createElement("button", { class: "flex", "on:click": abort, "toggle:hidden": cannotConfirm }, translations.general.abortButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "undo")), /* @__PURE__ */ createElement(
"button",
{
class: "danger flex",
"on:click": requestAction,
"toggle:hidden": isActionRequested
},
label,
/* @__PURE__ */ createElement("span", { class: "icon" }, icon)
), /* @__PURE__ */ createElement(
"button",
{
class: "danger flex",
"on:click": action,
"toggle:hidden": cannotConfirm
},
translations.general.confirmButton,
/* @__PURE__ */ createElement("span", { class: "icon" }, "warning")
));
}
// src/View/Modals/taskSettingsModal.tsx
function TaskSettingsModal(taskViewModel) {
return /* @__PURE__ */ createElement("div", { class: "modal", open: true }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("main", null, /* @__PURE__ */ createElement("h2", null, translations.chatPage.task.taskSettingsHeadline), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "history"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.general.fileVersionLabel), /* @__PURE__ */ createElement(
"select",
{
"bind:value": taskViewModel.selectedVersionId,
"children:append": [taskViewModel.versionIds, VersionIdToOption]
}
), /* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_drop_down"))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "label"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskNameLabel), /* @__PURE__ */ createElement("input", { "bind:value": taskViewModel.name }))), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "description"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskDescriptionLabel), /* @__PURE__ */ createElement(
"textarea",
{
rows: "10",
"bind:value": taskViewModel.description
}
))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "category"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskCategoryLabel), /* @__PURE__ */ createElement("input", { "bind:value": taskViewModel.category }))), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "clock_loader_40"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskStatusLabel), /* @__PURE__ */ createElement("input", { "bind:value": taskViewModel.status }))), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "priority_high"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskPriorityLabel), /* @__PURE__ */ createElement("input", { type: "number", "bind:value": taskViewModel.priority }))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "calendar_month"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskDateLabel), /* @__PURE__ */ createElement("input", { type: "date", "bind:value": taskViewModel.date }))), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "schedule"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskTimeLabel), /* @__PURE__ */ createElement("input", { type: "time", "bind:value": taskViewModel.time }))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "width-input" }, DangerousActionButton(
translations.chatPage.task.deleteTaskButton,
"delete_forever",
taskViewModel.deleteTask
))), /* @__PURE__ */ createElement("div", { class: "flex-row width-100" }, /* @__PURE__ */ createElement("button", { class: "flex", "on:click": taskViewModel.close }, translations.general.closeButton), /* @__PURE__ */ createElement("button", { class: "flex primary", "on:click": taskViewModel.closeAndSave }, translations.general.saveButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "save")))));
}
// src/View/Components/taskEntry.tsx // src/View/Components/taskEntry.tsx
function TaskEntry(taskViewModel) { function TaskEntry(taskViewModel) {
const details = { const details = {
@@ -2657,6 +2734,18 @@
} }
} }
); );
const taskSettingsModal = createProxyState(
[calendarPageViewModel.selectedTaskViewModel],
() => {
if (calendarPageViewModel.selectedTaskViewModel.value == void 0) {
return /* @__PURE__ */ createElement("div", null);
} else {
return TaskSettingsModal(
calendarPageViewModel.selectedTaskViewModel.value
);
}
}
);
return /* @__PURE__ */ createElement("div", { id: "calendar-page" }, /* @__PURE__ */ createElement("div", { class: "pane-wrapper" }, /* @__PURE__ */ createElement("div", { class: "pane" }, /* @__PURE__ */ createElement("div", { class: "toolbar" }, /* @__PURE__ */ createElement("span", null, /* @__PURE__ */ createElement( return /* @__PURE__ */ createElement("div", { id: "calendar-page" }, /* @__PURE__ */ createElement("div", { class: "pane-wrapper" }, /* @__PURE__ */ createElement("div", { class: "pane" }, /* @__PURE__ */ createElement("div", { class: "toolbar" }, /* @__PURE__ */ createElement("span", null, /* @__PURE__ */ createElement(
"button", "button",
{ {
@@ -2713,7 +2802,7 @@
"set:color": calendarPageViewModel.chatViewModel.displayedColor "set:color": calendarPageViewModel.chatViewModel.displayedColor
}, },
/* @__PURE__ */ createElement("div", { class: "pane" }, /* @__PURE__ */ createElement("div", { class: "content", "children:set": sidePaneContent })) /* @__PURE__ */ createElement("div", { class: "pane" }, /* @__PURE__ */ createElement("div", { class: "content", "children:set": sidePaneContent }))
)); ), /* @__PURE__ */ createElement("div", { "children:set": taskSettingsModal }));
} }
// src/View/Components/ribbonButton.tsx // src/View/Components/ribbonButton.tsx
@@ -2864,40 +2953,6 @@
})); }));
} }
// src/View/Components/dangerousActionButton.tsx
function DangerousActionButton(label, icon, action) {
const isActionRequested = new State(false);
const cannotConfirm = createProxyState(
[isActionRequested],
() => isActionRequested.value == false
);
function requestAction() {
isActionRequested.value = true;
}
function abort() {
isActionRequested.value = false;
}
return /* @__PURE__ */ createElement("div", { class: "flex-row" }, /* @__PURE__ */ createElement("button", { class: "flex", "on:click": abort, "toggle:hidden": cannotConfirm }, translations.general.abortButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "undo")), /* @__PURE__ */ createElement(
"button",
{
class: "danger flex",
"on:click": requestAction,
"toggle:hidden": isActionRequested
},
label,
/* @__PURE__ */ createElement("span", { class: "icon" }, icon)
), /* @__PURE__ */ createElement(
"button",
{
class: "danger flex",
"on:click": action,
"toggle:hidden": cannotConfirm
},
translations.general.confirmButton,
/* @__PURE__ */ createElement("span", { class: "icon" }, "warning")
));
}
// src/View/Components/deletableListItem.tsx // src/View/Components/deletableListItem.tsx
function DeletableListItem(text, primaryButton, ondelete) { function DeletableListItem(text, primaryButton, ondelete) {
return /* @__PURE__ */ createElement("div", { class: "tile flex-row justify-apart align-center padding-0" }, /* @__PURE__ */ createElement("span", { class: "padding-h ellipsis" }, text), /* @__PURE__ */ createElement("div", { class: "flex-row justify-end" }, primaryButton, /* @__PURE__ */ createElement( return /* @__PURE__ */ createElement("div", { class: "tile flex-row justify-apart align-center padding-0" }, /* @__PURE__ */ createElement("span", { class: "padding-h ellipsis" }, text), /* @__PURE__ */ createElement("div", { class: "flex-row justify-end" }, primaryButton, /* @__PURE__ */ createElement(
@@ -3442,41 +3497,6 @@
)), /* @__PURE__ */ createElement("button", { "on:click": close }, translations.general.closeButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "close")))); )), /* @__PURE__ */ createElement("button", { "on:click": close }, translations.general.closeButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "close"))));
} }
// src/View/Components/option.tsx
function Option(text, value, selectedOnCreate) {
return /* @__PURE__ */ createElement("option", { value, "toggle:selected": selectedOnCreate }, text);
}
var StringToOption = (string) => {
return Option(string, string, false);
};
var VersionIdToOption = (versionId) => {
const [date, rest] = versionId.split("T");
const [time] = rest.split(".");
const readableName = `${date} ${time}`;
return Option(readableName, versionId, false);
};
// src/View/Modals/taskSettingsModal.tsx
function TaskSettingsModal(taskViewModel) {
return /* @__PURE__ */ createElement("div", { class: "modal", open: true }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("main", null, /* @__PURE__ */ createElement("h2", null, translations.chatPage.task.taskSettingsHeadline), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "history"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.general.fileVersionLabel), /* @__PURE__ */ createElement(
"select",
{
"bind:value": taskViewModel.selectedVersionId,
"children:append": [taskViewModel.versionIds, VersionIdToOption]
}
), /* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_drop_down"))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "label"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskNameLabel), /* @__PURE__ */ createElement("input", { "bind:value": taskViewModel.name }))), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "description"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskDescriptionLabel), /* @__PURE__ */ createElement(
"textarea",
{
rows: "10",
"bind:value": taskViewModel.description
}
))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "category"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskCategoryLabel), /* @__PURE__ */ createElement("input", { "bind:value": taskViewModel.category }))), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "clock_loader_40"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskStatusLabel), /* @__PURE__ */ createElement("input", { "bind:value": taskViewModel.status }))), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "priority_high"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskPriorityLabel), /* @__PURE__ */ createElement("input", { type: "number", "bind:value": taskViewModel.priority }))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "calendar_month"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskDateLabel), /* @__PURE__ */ createElement("input", { type: "date", "bind:value": taskViewModel.date }))), /* @__PURE__ */ createElement("label", { class: "tile flex-no" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "schedule"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.task.taskTimeLabel), /* @__PURE__ */ createElement("input", { type: "time", "bind:value": taskViewModel.time }))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "width-input" }, DangerousActionButton(
translations.chatPage.task.deleteTaskButton,
"delete_forever",
taskViewModel.deleteTask
))), /* @__PURE__ */ createElement("div", { class: "flex-row width-100" }, /* @__PURE__ */ createElement("button", { class: "flex", "on:click": taskViewModel.close }, translations.general.closeButton), /* @__PURE__ */ createElement("button", { class: "flex primary", "on:click": taskViewModel.closeAndSave }, translations.general.saveButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "save")))));
}
// src/View/ChatPages/boardPage.tsx // src/View/ChatPages/boardPage.tsx
function BoardPage(boardViewModel) { function BoardPage(boardViewModel) {
boardViewModel.loadData(); boardViewModel.loadData();
+16
View File
@@ -4,6 +4,7 @@ import * as React from "bloatless-react";
import CalendarPageViewModel from "../../ViewModel/Pages/calendarPageViewModel"; import CalendarPageViewModel from "../../ViewModel/Pages/calendarPageViewModel";
import { MonthGrid } from "../Components/monthGrid"; import { MonthGrid } from "../Components/monthGrid";
import { TaskSettingsModal } from "../Modals/taskSettingsModal";
import { TaskViewModelToEntry } from "../Components/taskEntry"; import { TaskViewModelToEntry } from "../Components/taskEntry";
import { translations } from "../translations"; import { translations } from "../translations";
@@ -49,6 +50,19 @@ export function CalendarPage(calendarPageViewModel: CalendarPageViewModel) {
} }
); );
const taskSettingsModal = React.createProxyState(
[calendarPageViewModel.selectedTaskViewModel],
() => {
if (calendarPageViewModel.selectedTaskViewModel.value == undefined) {
return <div></div>;
} else {
return TaskSettingsModal(
calendarPageViewModel.selectedTaskViewModel.value
);
}
}
);
return ( return (
<div id="calendar-page"> <div id="calendar-page">
<div class="pane-wrapper"> <div class="pane-wrapper">
@@ -131,6 +145,8 @@ export function CalendarPage(calendarPageViewModel: CalendarPageViewModel) {
<div class="content" children:set={sidePaneContent}></div> <div class="content" children:set={sidePaneContent}></div>
</div> </div>
</div> </div>
<div children:set={taskSettingsModal}></div>
</div> </div>
); );
} }
+9 -1
View File
@@ -29,7 +29,15 @@ export function MonthGrid<T>(
const converter: React.StateItemConverter<TaskViewModel> = ( const converter: React.StateItemConverter<TaskViewModel> = (
taskViewModel taskViewModel
) => { ) => {
return <span class="ellipsis secondary">{taskViewModel.task.name}</span>; const view = (
<span class="ellipsis secondary">{taskViewModel.task.name}</span>
);
taskViewModel.index.subscribe((newIndex) => {
view.style.order = newIndex;
});
return view;
}; };
return ( return (
+1 -1
View File
@@ -101,7 +101,7 @@ export default class ChatViewModel {
this.storageModel, this.storageModel,
this.chatModel.fileModel.boardsAndTasksModel.calendarModel, this.chatModel.fileModel.boardsAndTasksModel.calendarModel,
this.chatModel.fileModel.boardsAndTasksModel, this.chatModel.fileModel.boardsAndTasksModel,
this this,
); );
this.taskPageViewModel = new TaskPageViewModel( this.taskPageViewModel = new TaskPageViewModel(
this.coreViewModel, this.coreViewModel,
+15 -50
View File
@@ -9,10 +9,11 @@ import { Color } from "../../colors";
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 TaskContainingPageViewModel from "./taskContainingPageViewModel";
import TaskPageViewModel from "./taskPageViewModel"; import TaskPageViewModel from "./taskPageViewModel";
import TaskViewModel from "./taskViewModel"; import TaskViewModel from "./taskViewModel";
export default class BoardViewModel { export default class BoardViewModel extends TaskContainingPageViewModel {
storageModel: StorageModel; storageModel: StorageModel;
boardsAndTasksModel: BoardsAndTasksModel; boardsAndTasksModel: BoardsAndTasksModel;
@@ -21,10 +22,6 @@ export default class BoardViewModel {
// data // data
boardInfo: BoardInfoFileContent; boardInfo: BoardInfoFileContent;
taskIndexManager: IndexManager<TaskViewModel> = new IndexManager(
(taskViewModel: TaskViewModel) => taskViewModel.sortingString
);
// state // state
name: React.State<string> = new React.State(""); name: React.State<string> = new React.State("");
color: React.State<Color> = new React.State<any>(Color.Standard); color: React.State<Color> = new React.State<any>(Color.Standard);
@@ -34,14 +31,11 @@ export default class BoardViewModel {
selectedPage: React.State<BoardPageType> = new React.State<any>( selectedPage: React.State<BoardPageType> = new React.State<any>(
BoardPageType.List BoardPageType.List
); );
selectedTaskViewModel: React.State<TaskViewModel | undefined> =
new React.State<any>(undefined);
isSelected: React.State<boolean>; isSelected: React.State<boolean>;
isPresentingSettingsModal: React.State<boolean> = new React.State(false); isPresentingSettingsModal: React.State<boolean> = new React.State(false);
isPresentingFilterModal: React.State<boolean> = new React.State(false); isPresentingFilterModal: React.State<boolean> = new React.State(false);
taskViewModels: React.MapState<TaskViewModel> = new React.MapState();
filteredTaskViewModels: React.ListState<TaskViewModel> = filteredTaskViewModels: React.ListState<TaskViewModel> =
new React.ListState(); new React.ListState();
@@ -75,25 +69,6 @@ export default class BoardViewModel {
}; };
// methods // methods
createTask = (): void => {
const taskFileContent: TaskFileContent =
this.boardsAndTasksModel.createTask(this.boardInfo.fileId);
const taskViewModel: TaskViewModel = new TaskViewModel(
this.coreViewModel,
this.boardsAndTasksModel,
this,
null,
taskFileContent
);
this.selectTask(taskViewModel);
this.updateTaskIndices();
};
removeTaskFromList = (taskId: string): void => {
this.taskViewModels.remove(taskId);
this.updateIndex();
};
handleDropWithinBoard = (category?: string, status?: string): void => { handleDropWithinBoard = (category?: string, status?: string): void => {
const draggedObject: any = this.coreViewModel.draggedObject.value; const draggedObject: any = this.coreViewModel.draggedObject.value;
if (draggedObject instanceof TaskViewModel == false) return; if (draggedObject instanceof TaskViewModel == false) return;
@@ -122,14 +97,14 @@ export default class BoardViewModel {
}; };
// view // view
showTaskInList = (taskFileContent: TaskFileContent): void => { showTask = (taskFileContent: TaskFileContent): void => {
if (taskFileContent.boardId != this.boardInfo.fileId) { if (taskFileContent.boardId != this.boardInfo.fileId) {
// remove task that was moved to different board // remove task that was moved to different board
this.boardsAndTasksModel.deleteTaskReference( this.boardsAndTasksModel.deleteTaskReference(
this.boardInfo.fileId, this.boardInfo.fileId,
taskFileContent.fileId taskFileContent.fileId
); );
this.removeTaskFromList(taskFileContent.fileId); this.removeTaskFromView(taskFileContent);
return; return;
} }
@@ -137,12 +112,16 @@ 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);
}; };
removeTaskFromView = (taskFileContent: TaskFileContent): void => {
this.taskViewModels.remove(taskFileContent.fileId);
this.updateIndex();
};
select = (): void => { select = (): void => {
this.taskPageViewModel.selectBoard(this); this.taskPageViewModel.selectBoard(this);
}; };
@@ -169,27 +148,12 @@ export default class BoardViewModel {
this.isPresentingFilterModal.value = false; this.isPresentingFilterModal.value = false;
}; };
selectTask = (selectedTask: TaskViewModel): void => {
this.selectedTaskViewModel.value = selectedTask;
};
closeTask = () => {
this.selectedTaskViewModel.value = undefined;
};
updateIndex = (): void => { updateIndex = (): void => {
const index: number = const index: number =
this.taskPageViewModel.boardIndexManager.getIndex(this); this.taskPageViewModel.boardIndexManager.getIndex(this);
this.index.value = index; this.index.value = index;
}; };
updateTaskIndices = (): void => {
this.taskIndexManager.update([...this.taskViewModels.value.values()]);
for (const boardViewModel of this.taskViewModels.value.values()) {
boardViewModel.updateIndex();
}
};
// load // load
loadListRelevantData = (): void => { loadListRelevantData = (): void => {
this.name.value = this.boardInfo.name; this.name.value = this.boardInfo.name;
@@ -211,7 +175,6 @@ 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);
@@ -229,13 +192,15 @@ export default class BoardViewModel {
constructor( constructor(
public coreViewModel: CoreViewModel, public coreViewModel: CoreViewModel,
storageModel: StorageModel, storageModel: StorageModel,
boardModel: BoardsAndTasksModel, boardsAndTasksModel: BoardsAndTasksModel,
taskPageViewModel: TaskPageViewModel, taskPageViewModel: TaskPageViewModel,
boardInfo: BoardInfoFileContent boardInfo: BoardInfoFileContent
) { ) {
super(coreViewModel, boardsAndTasksModel);
// set // set
this.storageModel = storageModel; this.storageModel = storageModel;
this.boardsAndTasksModel = boardModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.taskPageViewModel = taskPageViewModel; this.taskPageViewModel = taskPageViewModel;
this.boardInfo = boardInfo; this.boardInfo = boardInfo;
@@ -259,10 +224,10 @@ export default class BoardViewModel {
}); });
// handlers // handlers
boardModel.taskHandlerManager.addHandler( boardsAndTasksModel.taskHandlerManager.addHandler(
(taskFileContent: TaskFileContent) => { (taskFileContent: TaskFileContent) => {
if (taskFileContent.boardId != this.boardInfo.fileId) return; if (taskFileContent.boardId != this.boardInfo.fileId) return;
this.showTaskInList(taskFileContent); this.showTask(taskFileContent);
this.updateTaskIndices(); this.updateTaskIndices();
} }
); );
+13 -9
View File
@@ -8,9 +8,10 @@ import CalendarModel, { MonthGrid } from "../../Model/Files/calendarModel";
import ChatViewModel from "../Chat/chatViewModel"; import ChatViewModel from "../Chat/chatViewModel";
import CoreViewModel from "../Global/coreViewModel"; import CoreViewModel from "../Global/coreViewModel";
import StorageModel from "../../Model/Global/storageModel"; import StorageModel from "../../Model/Global/storageModel";
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
import TaskViewModel from "./taskViewModel"; import TaskViewModel from "./taskViewModel";
export default class CalendarPageViewModel { export default class CalendarPageViewModel extends TaskContainingPageViewModel {
storageModel: StorageModel; storageModel: StorageModel;
calendarModel: CalendarModel; calendarModel: CalendarModel;
boardsAndTasksModel: BoardsAndTasksModel; boardsAndTasksModel: BoardsAndTasksModel;
@@ -38,8 +39,6 @@ export default class CalendarPageViewModel {
monthGrid: React.State<MonthGrid<React.MapState<TaskViewModel>> | undefined> = monthGrid: React.State<MonthGrid<React.MapState<TaskViewModel>> | undefined> =
new React.State<any>(undefined); new React.State<any>(undefined);
taskViewModelsToShow: React.ListState<TaskViewModel> = new React.ListState();
// view // view
getTaskMapState = ( getTaskMapState = (
taskFileContent: TaskFileContent taskFileContent: TaskFileContent
@@ -65,19 +64,22 @@ export default class CalendarPageViewModel {
const taskViewModel: TaskViewModel = new TaskViewModel( const taskViewModel: TaskViewModel = new TaskViewModel(
this.coreViewModel, this.coreViewModel,
this.boardsAndTasksModel, this.boardsAndTasksModel,
null,
this, this,
taskFileContent taskFileContent
); );
const mapState: React.MapState<TaskViewModel> | null = const mapState: React.MapState<TaskViewModel> | null =
this.getTaskMapState(taskFileContent); this.getTaskMapState(taskFileContent);
mapState?.set(taskFileContent.fileId, taskViewModel); mapState?.set(taskFileContent.fileId, taskViewModel);
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
}; };
removeTaskFromView = (taskFileContent: TaskFileContent): void => { removeTaskFromView = (taskFileContent: TaskFileContent): void => {
const mapState: React.MapState<TaskViewModel> | null = const mapState: React.MapState<TaskViewModel> | null =
this.getTaskMapState(taskFileContent); this.getTaskMapState(taskFileContent);
mapState?.remove(taskFileContent.fileId); mapState?.remove(taskFileContent.fileId);
this.taskViewModels.remove(taskFileContent.fileId);
}; };
showToday = (): void => { showToday = (): void => {
@@ -105,8 +107,6 @@ export default class CalendarPageViewModel {
} }
}; };
// storage
// load // load
loadMonthTasks = (): void => { loadMonthTasks = (): void => {
this.monthGrid.value = this.calendarModel.generateMonthGrid( this.monthGrid.value = this.calendarModel.generateMonthGrid(
@@ -122,6 +122,8 @@ export default class CalendarPageViewModel {
if (taskFileContent == null) continue; if (taskFileContent == null) continue;
this.showTask(taskFileContent); this.showTask(taskFileContent);
} }
this.updateTaskIndices();
}; };
loadData = (): void => { loadData = (): void => {
@@ -134,12 +136,14 @@ export default class CalendarPageViewModel {
public coreViewModel: CoreViewModel, public coreViewModel: CoreViewModel,
storageModel: StorageModel, storageModel: StorageModel,
calendarModel: CalendarModel, calendarModel: CalendarModel,
boardAndTasksModel: BoardsAndTasksModel, boardsAndTasksModel: BoardsAndTasksModel,
chatViewModel: ChatViewModel chatViewModel: ChatViewModel
) { ) {
super(coreViewModel, boardsAndTasksModel);
this.storageModel = storageModel; this.storageModel = storageModel;
this.calendarModel = calendarModel; this.calendarModel = calendarModel;
this.boardsAndTasksModel = boardAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
@@ -148,7 +152,7 @@ export default class CalendarPageViewModel {
}); });
// handlers // handlers
boardAndTasksModel.taskHandlerManager.addHandler( boardsAndTasksModel.taskHandlerManager.addHandler(
(taskFileContent: TaskFileContent) => { (taskFileContent: TaskFileContent) => {
this.showTask(taskFileContent); this.showTask(taskFileContent);
} }
@@ -0,0 +1,68 @@
import * as React from "bloatless-react";
import BoardsAndTasksModel, {
TaskFileContent,
} from "../../Model/Files/boardsAndTasksModel";
import BoardViewModel from "./boardViewModel";
import CalendarPageViewModel from "./calendarPageViewModel";
import CoreViewModel from "../Global/coreViewModel";
import { IndexManager } from "../../Model/Utility/utility";
import TaskViewModel from "./taskViewModel";
export default class TaskContainingPageViewModel {
coreViewModel: CoreViewModel;
boardsAndTasksModel: BoardsAndTasksModel;
// state
taskIndexManager: IndexManager<TaskViewModel> = new IndexManager(
(taskViewModel: TaskViewModel) => taskViewModel.sortingString
);
selectedTaskViewModel: React.State<TaskViewModel | undefined> =
new React.State<any>(undefined);
taskViewModels: React.MapState<TaskViewModel> = new React.MapState();
// methods
createTask = (boardId: string): void => {
const taskFileContent: TaskFileContent =
this.boardsAndTasksModel.createTask(boardId);
const taskViewModel: TaskViewModel = new TaskViewModel(
this.coreViewModel,
this.boardsAndTasksModel,
this,
taskFileContent
);
this.selectTask(taskViewModel);
this.updateTaskIndices();
};
// view
showTask = (taskFileContent: TaskFileContent): void => {};
removeTaskFromView = (taskFileContent: TaskFileContent): void => {};
selectTask = (selectedTask: TaskViewModel): void => {
this.selectedTaskViewModel.value = selectedTask;
};
closeTask = () => {
this.selectedTaskViewModel.value = undefined;
};
updateTaskIndices = (): void => {
this.taskIndexManager.update([...this.taskViewModels.value.values()]);
for (const boardViewModel of this.taskViewModels.value.values()) {
boardViewModel.updateIndex();
}
};
// init
constructor(
coreViewModel: CoreViewModel,
boardsAndTasksModel: BoardsAndTasksModel
) {
this.coreViewModel = coreViewModel;
this.boardsAndTasksModel = boardsAndTasksModel;
}
}
+10 -26
View File
@@ -5,16 +5,14 @@ import BoardsAndTasksModel, {
} from "../../Model/Files/boardsAndTasksModel"; } from "../../Model/Files/boardsAndTasksModel";
import { localeCompare, padZero } from "../../Model/Utility/utility"; import { localeCompare, padZero } from "../../Model/Utility/utility";
import BoardViewModel from "./boardViewModel";
import CalendarPageViewModel from "./calendarPageViewModel";
import CoreViewModel from "../Global/coreViewModel"; import CoreViewModel from "../Global/coreViewModel";
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
import { allowDrag } from "../../View/utility"; import { allowDrag } from "../../View/utility";
export default class TaskViewModel { export default class TaskViewModel {
boardsAndTasksModel: BoardsAndTasksModel; boardsAndTasksModel: BoardsAndTasksModel;
boardViewModel: BoardViewModel | null; containingModel: TaskContainingPageViewModel;
calendarPageViewModel: CalendarPageViewModel | null;
// data // data
task: TaskFileContent; task: TaskFileContent;
@@ -79,11 +77,11 @@ export default class TaskViewModel {
// view // view
open = (): void => { open = (): void => {
this.boardViewModel?.selectTask(this); this.containingModel.selectTask(this);
}; };
close = (): void => { close = (): void => {
this.boardViewModel?.closeTask(); this.containingModel.closeTask();
}; };
closeAndSave = (): void => { closeAndSave = (): void => {
@@ -92,8 +90,7 @@ export default class TaskViewModel {
}; };
updateIndex = (): void => { updateIndex = (): void => {
if (this.boardViewModel == null) return; const index: number = this.containingModel.taskIndexManager.getIndex(this);
const index: number = this.boardViewModel.taskIndexManager.getIndex(this);
this.index.value = index; this.index.value = index;
}; };
@@ -116,25 +113,14 @@ export default class TaskViewModel {
this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent); this.boardsAndTasksModel.updateTaskAndSend(newTaskFileContent);
if (this.boardViewModel != null) { this.containingModel.showTask(newTaskFileContent);
this.boardViewModel.showTaskInList(newTaskFileContent); this.containingModel.updateTaskIndices();
this.boardViewModel.updateTaskIndices();
}
if (this.calendarPageViewModel != null) {
this.calendarPageViewModel.showTask(newTaskFileContent);
}
}; };
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);
this.containingModel.removeTaskFromView(this.task);
if (this.boardViewModel != null) {
this.boardViewModel.removeTaskFromList(this.task.fileId);
}
if (this.calendarPageViewModel != null) {
this.calendarPageViewModel.removeTaskFromView(this.task);
}
}; };
// load // load
@@ -184,13 +170,11 @@ export default class TaskViewModel {
constructor( constructor(
public coreViewModel: CoreViewModel, public coreViewModel: CoreViewModel,
boardsAndTasksModel: BoardsAndTasksModel, boardsAndTasksModel: BoardsAndTasksModel,
boardViewModel: BoardViewModel | null, containingModel: TaskContainingPageViewModel,
calendarPageViewModel: CalendarPageViewModel | null,
taskFileContent: TaskFileContent taskFileContent: TaskFileContent
) { ) {
this.boardsAndTasksModel = boardsAndTasksModel; this.boardsAndTasksModel = boardsAndTasksModel;
this.boardViewModel = boardViewModel; this.containingModel = containingModel;
this.calendarPageViewModel = calendarPageViewModel;
this.task = taskFileContent; this.task = taskFileContent;