add month grid
This commit is contained in:
Vendored
+50
@@ -380,6 +380,10 @@ body[showing-chat] #chat-page-wrapper {
|
|||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
#chat-page > div > #main > div > .pane-wrapper > .pane > .toolbar > span {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
#chat-page > div > #main > div > .pane-wrapper > .pane > .toolbar > span.title {
|
#chat-page > div > #main > div > .pane-wrapper > .pane > .toolbar > span.title {
|
||||||
padding-left: var(--content-padding);
|
padding-left: var(--content-padding);
|
||||||
}
|
}
|
||||||
@@ -447,6 +451,52 @@ body[showing-chat] #chat-page-wrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* src/View/ChatPages/calendarPage.css */
|
||||||
|
#chat-page > div > #main > #calendar-page > .pane-wrapper > .pane > .toolbar .input-wrapper {
|
||||||
|
display: flex;
|
||||||
|
padding: var(--gap-between-tiles);
|
||||||
|
gap: var(--gap-between-tiles);
|
||||||
|
}
|
||||||
|
#chat-page > div > #main > #calendar-page > .pane-wrapper > .pane > .toolbar .input-wrapper > input {
|
||||||
|
min-height: unset;
|
||||||
|
height: calc(var(--control-height) - 2 * var(--gap-between-tiles));
|
||||||
|
appearance: textfield;
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
}
|
||||||
|
#calendar-page .input-wrapper > input::-webkit-outer-spin-button,
|
||||||
|
#calendar-page .input-wrapper > input::-webkit-innner-spin-button {
|
||||||
|
appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
#chat-page > div > #main > #calendar-page > .pane-wrapper > .pane > .toolbar .input-wrapper > .year-input {
|
||||||
|
width: 4.4rem;
|
||||||
|
}
|
||||||
|
#chat-page > div > #main > #calendar-page > .pane-wrapper > .pane > .toolbar .input-wrapper > .month-input {
|
||||||
|
width: 3.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* src/View/Components/monthGrid.css */
|
||||||
|
.month-grid-wrapper {
|
||||||
|
display: grid;
|
||||||
|
gap: var(--gap-between-tiles);
|
||||||
|
height: 100%;
|
||||||
|
animation: slide-up var(--animation-duration);
|
||||||
|
grid-template-columns: repeat(7, minmax(0px, 1fr));
|
||||||
|
grid-auto-rows: 1fr;
|
||||||
|
}
|
||||||
|
.month-grid-wrapper .tile > div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.month-grid-wrapper .tile {
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* src/View/ChatPages/messagePage.css */
|
/* src/View/ChatPages/messagePage.css */
|
||||||
#chat-page #main #message-page .content {
|
#chat-page #main #message-page .content {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
|
|||||||
Vendored
+319
-114
@@ -175,6 +175,9 @@
|
|||||||
);
|
);
|
||||||
return proxyState;
|
return proxyState;
|
||||||
}
|
}
|
||||||
|
function bulkSubscribe(statesToSubscibe, fn) {
|
||||||
|
statesToSubscibe.forEach((state) => state.subscribeSilent(fn));
|
||||||
|
}
|
||||||
function createElement(tagName, attributes = {}, ...children) {
|
function createElement(tagName, attributes = {}, ...children) {
|
||||||
const element = document.createElement(tagName);
|
const element = document.createElement(tagName);
|
||||||
if (attributes != null)
|
if (attributes != null)
|
||||||
@@ -613,6 +616,78 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// src/Model/Files/calendarModel.ts
|
||||||
|
var CalendarModel = class _CalendarModel {
|
||||||
|
storageModel;
|
||||||
|
fileModel;
|
||||||
|
settingsModel;
|
||||||
|
// paths
|
||||||
|
getBasePath = () => {
|
||||||
|
return this.fileModel.getModelContainerPath("calendar" /* ModelCalendar */);
|
||||||
|
};
|
||||||
|
getViewPath = () => {
|
||||||
|
return [...this.getBasePath(), "view" /* ModelView */];
|
||||||
|
};
|
||||||
|
getMonthContainerPath = () => {
|
||||||
|
return [...this.getBasePath(), "months" /* Months */];
|
||||||
|
};
|
||||||
|
getMonthPath = (monthString) => {
|
||||||
|
return [...this.getMonthContainerPath(), monthString];
|
||||||
|
};
|
||||||
|
// main
|
||||||
|
storeTaskReference = (taskFileContent) => {
|
||||||
|
if (taskFileContent.date == void 0) return;
|
||||||
|
const monthString = _CalendarModel.isoToMonthString(
|
||||||
|
taskFileContent.date
|
||||||
|
);
|
||||||
|
const monthPath = this.getMonthPath(monthString);
|
||||||
|
const referencePath = [...monthPath, taskFileContent.fileId];
|
||||||
|
this.storageModel.write(referencePath, "");
|
||||||
|
};
|
||||||
|
listTaskIds = (monthString) => {
|
||||||
|
const monthPath = this.getMonthPath(monthString);
|
||||||
|
return this.storageModel.list(monthPath);
|
||||||
|
};
|
||||||
|
generateMonthGrid = (year, month, defaultValueCreator) => {
|
||||||
|
const date = /* @__PURE__ */ new Date();
|
||||||
|
date.setFullYear(year);
|
||||||
|
date.setMonth(month - 1);
|
||||||
|
date.setDate(1);
|
||||||
|
const offset = date.getDay() - parseInt(this.settingsModel.firstDayOfWeek);
|
||||||
|
date.setMonth(month);
|
||||||
|
date.setDate(-1);
|
||||||
|
const daysInMonth = date.getDate() + 1;
|
||||||
|
const grid = {
|
||||||
|
offset,
|
||||||
|
days: {}
|
||||||
|
};
|
||||||
|
for (let i = 0; i < daysInMonth; i++) {
|
||||||
|
grid.days[i + 1] = defaultValueCreator();
|
||||||
|
}
|
||||||
|
return grid;
|
||||||
|
};
|
||||||
|
// init
|
||||||
|
constructor(storageModel2, settingsModel2, fileModel) {
|
||||||
|
this.storageModel = storageModel2;
|
||||||
|
this.settingsModel = settingsModel2;
|
||||||
|
this.fileModel = fileModel;
|
||||||
|
}
|
||||||
|
// utility
|
||||||
|
static isoToMonthString = (dateISOString) => {
|
||||||
|
const [year, month, _] = dateISOString.split("-");
|
||||||
|
return _CalendarModel.getMonthString(year, month);
|
||||||
|
};
|
||||||
|
static isoToDateString = (dateISOString) => {
|
||||||
|
const [year, month, date, _] = dateISOString.split("-");
|
||||||
|
return date;
|
||||||
|
};
|
||||||
|
static getMonthString = (year = "", month = "") => {
|
||||||
|
const paddedYear = year.padStart(4, "0");
|
||||||
|
const paddedMonth = month.padStart(2, "0");
|
||||||
|
return `${paddedYear}-${paddedMonth}`;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// src/colors.ts
|
// src/colors.ts
|
||||||
var Color = /* @__PURE__ */ ((Color2) => {
|
var Color = /* @__PURE__ */ ((Color2) => {
|
||||||
Color2["Standard"] = "standard";
|
Color2["Standard"] = "standard";
|
||||||
@@ -628,8 +703,10 @@
|
|||||||
// src/Model/Files/boardsAndTasksModel.ts
|
// src/Model/Files/boardsAndTasksModel.ts
|
||||||
var BoardsAndTasksModel = class _BoardsAndTasksModel {
|
var BoardsAndTasksModel = class _BoardsAndTasksModel {
|
||||||
storageModel;
|
storageModel;
|
||||||
|
settingsModel;
|
||||||
chatModel;
|
chatModel;
|
||||||
fileModel;
|
fileModel;
|
||||||
|
calendarModel;
|
||||||
// data
|
// data
|
||||||
boardHandlerManager = new HandlerManager();
|
boardHandlerManager = new HandlerManager();
|
||||||
taskHandlerManager = new HandlerManager();
|
taskHandlerManager = new HandlerManager();
|
||||||
@@ -731,13 +808,13 @@
|
|||||||
this.chatModel.sendMessage("", taskFileContent);
|
this.chatModel.sendMessage("", taskFileContent);
|
||||||
};
|
};
|
||||||
storeTask = (taskFileContent) => {
|
storeTask = (taskFileContent) => {
|
||||||
console.log(taskFileContent);
|
|
||||||
this.fileModel.storeFileContent(taskFileContent);
|
this.fileModel.storeFileContent(taskFileContent);
|
||||||
const taskReferencePath = this.getTaskReferencePath(
|
const taskReferencePath = this.getTaskReferencePath(
|
||||||
taskFileContent.boardId,
|
taskFileContent.boardId,
|
||||||
taskFileContent.fileId
|
taskFileContent.fileId
|
||||||
);
|
);
|
||||||
this.storageModel.write(taskReferencePath, "");
|
this.storageModel.write(taskReferencePath, "");
|
||||||
|
this.calendarModel.storeTaskReference(taskFileContent);
|
||||||
};
|
};
|
||||||
listTaskIds = (boardId) => {
|
listTaskIds = (boardId) => {
|
||||||
const taskContainerPath = this.getTaskContainerPath(boardId);
|
const taskContainerPath = this.getTaskContainerPath(boardId);
|
||||||
@@ -773,14 +850,20 @@
|
|||||||
this.storageModel.removeRecursively(taskReferencePath);
|
this.storageModel.removeRecursively(taskReferencePath);
|
||||||
};
|
};
|
||||||
// init
|
// init
|
||||||
constructor(storageModel2, chatModel, fileModel) {
|
constructor(storageModel2, settingsModel2, chatModel, fileModel) {
|
||||||
|
this.storageModel = storageModel2;
|
||||||
|
this.settingsModel = settingsModel2;
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
this.fileModel = fileModel;
|
this.fileModel = fileModel;
|
||||||
this.storageModel = storageModel2;
|
this.calendarModel = new CalendarModel(
|
||||||
|
this.storageModel,
|
||||||
|
this.settingsModel,
|
||||||
|
this.fileModel
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// utility
|
// utility
|
||||||
static createBoardInfoFileContent = (fileId, name, color) => {
|
static createBoardInfoFileContent = (fileId, name, color) => {
|
||||||
const fileContent = FileModel.createFileContent(
|
const fileContent = FileModel2.createFileContent(
|
||||||
fileId,
|
fileId,
|
||||||
"board-info"
|
"board-info"
|
||||||
);
|
);
|
||||||
@@ -791,7 +874,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
static createTaskFileContent = (fileId, name, boardId) => {
|
static createTaskFileContent = (fileId, name, boardId) => {
|
||||||
const fileContent = FileModel.createFileContent(
|
const fileContent = FileModel2.createFileContent(
|
||||||
fileId,
|
fileId,
|
||||||
"task"
|
"task"
|
||||||
);
|
);
|
||||||
@@ -821,60 +904,12 @@
|
|||||||
boardId: ""
|
boardId: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/Model/Files/calendarModel.ts
|
|
||||||
var CalendarModel = class _CalendarModel {
|
|
||||||
storageModel;
|
|
||||||
fileModel;
|
|
||||||
// paths
|
|
||||||
getBasePath = () => {
|
|
||||||
return this.fileModel.getModelContainerPath("calendar" /* ModelCalendar */);
|
|
||||||
};
|
|
||||||
getViewPath = () => {
|
|
||||||
return [...this.getBasePath(), "view" /* ModelView */];
|
|
||||||
};
|
|
||||||
getMonthContainerPath = () => {
|
|
||||||
return [...this.getBasePath(), "months" /* Months */];
|
|
||||||
};
|
|
||||||
getMonthPath = (monthString) => {
|
|
||||||
return [...this.getMonthContainerPath(), monthString];
|
|
||||||
};
|
|
||||||
// handlers
|
|
||||||
handleFileContent = (fileContent) => {
|
|
||||||
if (checkMatchesObjectStructure(fileContent, TaskFileContentReference) == false)
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
// main
|
|
||||||
storeTaskReference = (taskFileContent) => {
|
|
||||||
if (taskFileContent.date == void 0) return;
|
|
||||||
const monthString = _CalendarModel.isoToMonthString(
|
|
||||||
taskFileContent.date
|
|
||||||
);
|
|
||||||
const monthPath = this.getMonthPath(monthString);
|
|
||||||
const referencePath = [...monthPath, taskFileContent.fileId];
|
|
||||||
this.storageModel.write(referencePath, "");
|
|
||||||
};
|
|
||||||
listTaskIds = (monthString) => {
|
|
||||||
const monthPath = this.getMonthPath(monthString);
|
|
||||||
return this.storageModel.list(monthPath);
|
|
||||||
};
|
|
||||||
// init
|
|
||||||
constructor(storageModel2, fileModel) {
|
|
||||||
this.storageModel = storageModel2;
|
|
||||||
this.fileModel = fileModel;
|
|
||||||
}
|
|
||||||
// utility
|
|
||||||
static isoToMonthString = (dateISOString) => {
|
|
||||||
const [year, month, _] = dateISOString.split("-");
|
|
||||||
return `${year}-${month}`;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// src/Model/Files/fileModel.ts
|
// src/Model/Files/fileModel.ts
|
||||||
var FileModel = class _FileModel {
|
var FileModel2 = class _FileModel {
|
||||||
chatModel;
|
|
||||||
storageModel;
|
storageModel;
|
||||||
|
settingsModel;
|
||||||
|
chatModel;
|
||||||
boardsAndTasksModel;
|
boardsAndTasksModel;
|
||||||
calendarModel;
|
|
||||||
// paths
|
// paths
|
||||||
getBasePath = () => {
|
getBasePath = () => {
|
||||||
return StorageModel.getPath(
|
return StorageModel.getPath(
|
||||||
@@ -908,7 +943,6 @@
|
|||||||
const didStore = this.storeFileContent(fileContent);
|
const didStore = this.storeFileContent(fileContent);
|
||||||
if (didStore == false) return;
|
if (didStore == false) return;
|
||||||
this.boardsAndTasksModel.handleFileContent(fileContent);
|
this.boardsAndTasksModel.handleFileContent(fileContent);
|
||||||
this.calendarModel.handleFileContent(fileContent);
|
|
||||||
};
|
};
|
||||||
// methods
|
// methods
|
||||||
addFileContentAndSend = (fileContent) => {
|
addFileContentAndSend = (fileContent) => {
|
||||||
@@ -957,11 +991,16 @@
|
|||||||
return fileContent;
|
return fileContent;
|
||||||
};
|
};
|
||||||
// init
|
// init
|
||||||
constructor(chatModel, storageModel2) {
|
constructor(storageModel2, settingsModel2, chatModel) {
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
|
this.settingsModel = settingsModel2;
|
||||||
this.storageModel = storageModel2;
|
this.storageModel = storageModel2;
|
||||||
this.boardsAndTasksModel = new BoardsAndTasksModel(this.storageModel, chatModel, this);
|
this.boardsAndTasksModel = new BoardsAndTasksModel(
|
||||||
this.calendarModel = new CalendarModel(this.storageModel, this);
|
this.storageModel,
|
||||||
|
this.settingsModel,
|
||||||
|
chatModel,
|
||||||
|
this
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// utility
|
// utility
|
||||||
static generateFileContentId = (creationDate) => {
|
static generateFileContentId = (creationDate) => {
|
||||||
@@ -1077,16 +1116,28 @@
|
|||||||
}
|
}
|
||||||
// paths
|
// paths
|
||||||
getBasePath = () => {
|
getBasePath = () => {
|
||||||
return StorageModel.getPath("chat" /* Chat */, filePaths.chat.chatBase(this.id));
|
return StorageModel.getPath(
|
||||||
|
"chat" /* Chat */,
|
||||||
|
filePaths.chat.chatBase(this.id)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
getInfoPath = () => {
|
getInfoPath = () => {
|
||||||
return StorageModel.getPath("chat" /* Chat */, filePaths.chat.info(this.id));
|
return StorageModel.getPath(
|
||||||
|
"chat" /* Chat */,
|
||||||
|
filePaths.chat.info(this.id)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
getColorPath = () => {
|
getColorPath = () => {
|
||||||
return StorageModel.getPath("chat" /* Chat */, filePaths.chat.color(this.id));
|
return StorageModel.getPath(
|
||||||
|
"chat" /* Chat */,
|
||||||
|
filePaths.chat.color(this.id)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
getMessageDirPath = () => {
|
getMessageDirPath = () => {
|
||||||
return StorageModel.getPath("chat" /* Chat */, filePaths.chat.messages(this.id));
|
return StorageModel.getPath(
|
||||||
|
"chat" /* Chat */,
|
||||||
|
filePaths.chat.messages(this.id)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
getMessagePath = (id) => {
|
getMessagePath = (id) => {
|
||||||
return [...this.getMessageDirPath(), id];
|
return [...this.getMessageDirPath(), id];
|
||||||
@@ -1226,7 +1277,7 @@
|
|||||||
this.loadInfo();
|
this.loadInfo();
|
||||||
this.loadColor();
|
this.loadColor();
|
||||||
this.subscribe();
|
this.subscribe();
|
||||||
this.fileModel = new FileModel(this, this.storageModel);
|
this.fileModel = new FileModel2(this.storageModel, this.settingsModel, this);
|
||||||
}
|
}
|
||||||
// utility
|
// utility
|
||||||
static generateChatInfo = (primaryChannel) => {
|
static generateChatInfo = (primaryChannel) => {
|
||||||
@@ -1514,6 +1565,18 @@
|
|||||||
this.time.value = this.task.time ?? "";
|
this.time.value = this.task.time ?? "";
|
||||||
this.selectedVersionId.value = this.task.fileContentId;
|
this.selectedVersionId.value = this.task.fileContentId;
|
||||||
};
|
};
|
||||||
|
// utility
|
||||||
|
static getStringsForFilter = (taskViewModel) => {
|
||||||
|
return [
|
||||||
|
taskViewModel.task.name,
|
||||||
|
taskViewModel.task.description ?? "",
|
||||||
|
taskViewModel.task.category ?? "",
|
||||||
|
taskViewModel.task.status ?? "",
|
||||||
|
taskViewModel.task.priority ?? "",
|
||||||
|
taskViewModel.task.date ?? "",
|
||||||
|
taskViewModel.task.time ?? ""
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/ViewModel/Pages/calendarPageViewModel.ts
|
// src/ViewModel/Pages/calendarPageViewModel.ts
|
||||||
@@ -1523,31 +1586,90 @@
|
|||||||
this.coreViewModel = coreViewModel;
|
this.coreViewModel = coreViewModel;
|
||||||
this.storageModel = storageModel2;
|
this.storageModel = storageModel2;
|
||||||
this.calendarModel = calendarModel;
|
this.calendarModel = calendarModel;
|
||||||
this.boardAndTasksModel = boardAndTasksModel;
|
this.boardsAndTasksModel = boardAndTasksModel;
|
||||||
|
bulkSubscribe([this.selectedYear, this.selectedMonth], () => {
|
||||||
|
this.loadTasks();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
storageModel;
|
storageModel;
|
||||||
calendarModel;
|
calendarModel;
|
||||||
boardAndTasksModel;
|
boardsAndTasksModel;
|
||||||
|
// data
|
||||||
|
get monthString() {
|
||||||
|
return CalendarModel.getMonthString(
|
||||||
|
this.selectedYear.value.toString(),
|
||||||
|
this.selectedMonth.value.toString()
|
||||||
|
);
|
||||||
|
}
|
||||||
// paths
|
// paths
|
||||||
getBasePath = () => {
|
getBasePath = () => {
|
||||||
return [...this.calendarModel.getViewPath()];
|
return [...this.calendarModel.getViewPath()];
|
||||||
};
|
};
|
||||||
// state
|
// state
|
||||||
taskViewModels = new MapState();
|
selectedYear = new State(0);
|
||||||
|
selectedMonth = new State(0);
|
||||||
|
monthGrid = new State(void 0);
|
||||||
// view
|
// view
|
||||||
|
getTaskMapState = (taskFileContent) => {
|
||||||
|
if (this.monthGrid.value == null) return null;
|
||||||
|
const dateString = CalendarModel.isoToDateString(
|
||||||
|
taskFileContent.date ?? ""
|
||||||
|
);
|
||||||
|
if (dateString == void 0) return null;
|
||||||
|
return this.monthGrid.value.days[dateString];
|
||||||
|
};
|
||||||
showTask = (taskFileContent) => {
|
showTask = (taskFileContent) => {
|
||||||
const taskViewModel = new TaskViewModel(
|
const taskViewModel = new TaskViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
null,
|
null,
|
||||||
this,
|
this,
|
||||||
taskFileContent
|
taskFileContent
|
||||||
);
|
);
|
||||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
const mapState = this.getTaskMapState(taskFileContent);
|
||||||
|
mapState?.set(taskFileContent.fileId, taskViewModel);
|
||||||
|
};
|
||||||
|
removeTaskFromList = (taskFileContent) => {
|
||||||
|
const mapState = this.getTaskMapState(taskFileContent);
|
||||||
|
mapState?.remove(taskFileContent.fileId);
|
||||||
|
};
|
||||||
|
showToday = () => {
|
||||||
|
const today = /* @__PURE__ */ new Date();
|
||||||
|
this.selectedYear.value = today.getFullYear();
|
||||||
|
this.selectedMonth.value = today.getMonth() + 1;
|
||||||
|
};
|
||||||
|
showPreviousMonth = () => {
|
||||||
|
this.selectedMonth.value -= 1;
|
||||||
|
if (this.selectedMonth.value <= 0) {
|
||||||
|
this.selectedYear.value -= 1;
|
||||||
|
this.selectedMonth.value = 12;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
showNextMonth = () => {
|
||||||
|
this.selectedMonth.value += 1;
|
||||||
|
if (this.selectedMonth.value >= 13) {
|
||||||
|
this.selectedYear.value += 1;
|
||||||
|
this.selectedMonth.value = 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// storage
|
// storage
|
||||||
// load
|
// load
|
||||||
|
loadTasks = () => {
|
||||||
|
this.monthGrid.value = this.calendarModel.generateMonthGrid(
|
||||||
|
this.selectedYear.value,
|
||||||
|
this.selectedMonth.value,
|
||||||
|
() => new MapState()
|
||||||
|
);
|
||||||
|
const taskIds = this.calendarModel.listTaskIds(this.monthString);
|
||||||
|
for (const taskId of taskIds) {
|
||||||
|
const taskFileContent = this.boardsAndTasksModel.getLatestTaskFileContent(taskId);
|
||||||
|
if (taskFileContent == null) continue;
|
||||||
|
this.showTask(taskFileContent);
|
||||||
|
}
|
||||||
|
};
|
||||||
loadData = () => {
|
loadData = () => {
|
||||||
|
this.loadTasks();
|
||||||
|
this.showToday();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1568,7 +1690,9 @@
|
|||||||
sender;
|
sender;
|
||||||
dateSent;
|
dateSent;
|
||||||
body = new State("");
|
body = new State("");
|
||||||
status = new State(void 0);
|
status = new State(
|
||||||
|
void 0
|
||||||
|
);
|
||||||
sentByUser;
|
sentByUser;
|
||||||
// state
|
// state
|
||||||
isPresentingInfoModal = new State(false);
|
isPresentingInfoModal = new State(false);
|
||||||
@@ -1915,18 +2039,6 @@
|
|||||||
boardViewModel.updateIndex();
|
boardViewModel.updateIndex();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// filter
|
|
||||||
getStringsFromTaskViewModel = (taskViewModel) => {
|
|
||||||
return [
|
|
||||||
taskViewModel.task.name,
|
|
||||||
taskViewModel.task.description ?? "",
|
|
||||||
taskViewModel.task.category ?? "",
|
|
||||||
taskViewModel.task.status ?? "",
|
|
||||||
taskViewModel.task.priority ?? "",
|
|
||||||
taskViewModel.task.date ?? "",
|
|
||||||
taskViewModel.task.time ?? ""
|
|
||||||
];
|
|
||||||
};
|
|
||||||
// load
|
// load
|
||||||
loadListRelevantData = () => {
|
loadListRelevantData = () => {
|
||||||
this.name.value = this.boardInfo.name;
|
this.name.value = this.boardInfo.name;
|
||||||
@@ -1992,7 +2104,9 @@
|
|||||||
// state
|
// state
|
||||||
newBoardNameInput = new State("");
|
newBoardNameInput = new State("");
|
||||||
boardViewModels = new MapState();
|
boardViewModels = new MapState();
|
||||||
selectedBoardId = new State(void 0);
|
selectedBoardId = new State(
|
||||||
|
void 0
|
||||||
|
);
|
||||||
// guards
|
// guards
|
||||||
cannotCreateBoard = createProxyState(
|
cannotCreateBoard = createProxyState(
|
||||||
[this.newBoardNameInput],
|
[this.newBoardNameInput],
|
||||||
@@ -2083,7 +2197,7 @@
|
|||||||
this.calendarViewModel = new CalendarPageViewModel(
|
this.calendarViewModel = new CalendarPageViewModel(
|
||||||
coreViewModel,
|
coreViewModel,
|
||||||
this.storageModel,
|
this.storageModel,
|
||||||
this.chatModel.fileModel.calendarModel,
|
this.chatModel.fileModel.boardsAndTasksModel.calendarModel,
|
||||||
this.chatModel.fileModel.boardsAndTasksModel
|
this.chatModel.fileModel.boardsAndTasksModel
|
||||||
);
|
);
|
||||||
this.taskPageViewModel = new TaskPageViewModel(
|
this.taskPageViewModel = new TaskPageViewModel(
|
||||||
@@ -2182,7 +2296,9 @@
|
|||||||
// state
|
// state
|
||||||
newChatPrimaryChannel = new State("");
|
newChatPrimaryChannel = new State("");
|
||||||
chatViewModels = new ListState();
|
chatViewModels = new ListState();
|
||||||
selectedChat = new State(void 0);
|
selectedChat = new State(
|
||||||
|
void 0
|
||||||
|
);
|
||||||
// guards
|
// guards
|
||||||
cannotCreateChat = createProxyState(
|
cannotCreateChat = createProxyState(
|
||||||
[this.newChatPrimaryChannel],
|
[this.newChatPrimaryChannel],
|
||||||
@@ -2238,36 +2354,25 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/View/ChatPages/calendarPage.tsx
|
// src/View/Components/monthGrid.tsx
|
||||||
function CalendarPage(calendarPageViewModel) {
|
function MonthGrid2(monthGrid) {
|
||||||
calendarPageViewModel.loadData();
|
const offsetElements = [];
|
||||||
return /* @__PURE__ */ createElement("div", { id: "calendar-page" });
|
for (let i = 0; i < monthGrid.offset; i++) {
|
||||||
|
offsetElements.push(/* @__PURE__ */ createElement("div", null));
|
||||||
}
|
}
|
||||||
|
const converter = (taskViewModel) => {
|
||||||
// src/View/Components/ribbonButton.tsx
|
return /* @__PURE__ */ createElement("span", { class: "ellipsis secondary" }, taskViewModel.task.name);
|
||||||
function RibbonButton(label, icon, isSelected, select) {
|
};
|
||||||
return /* @__PURE__ */ createElement(
|
return /* @__PURE__ */ createElement("div", { class: "month-grid-wrapper" }, ...offsetElements, ...Object.entries(monthGrid.days).map((entry) => {
|
||||||
"button",
|
const [date, mapState] = entry;
|
||||||
|
return /* @__PURE__ */ createElement("button", { class: "tile" }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("b", null, date), /* @__PURE__ */ createElement(
|
||||||
|
"div",
|
||||||
{
|
{
|
||||||
class: "ribbon-button",
|
class: "flex-column gap clip",
|
||||||
"aria-label": label,
|
"children:append": [mapState, converter]
|
||||||
"toggle:selected": isSelected,
|
|
||||||
"on:click": select
|
|
||||||
},
|
|
||||||
/* @__PURE__ */ createElement("span", { class: "icon" }, icon)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
)));
|
||||||
// src/View/Components/chatViewToggleButton.tsx
|
}));
|
||||||
function ChatViewToggleButton(label, icon, page, chatViewModel) {
|
|
||||||
function select() {
|
|
||||||
chatViewModel.selectedPage.value = page;
|
|
||||||
}
|
|
||||||
const isSelected = createProxyState(
|
|
||||||
[chatViewModel.selectedPage],
|
|
||||||
() => chatViewModel.selectedPage.value == page
|
|
||||||
);
|
|
||||||
return RibbonButton(label, icon, isSelected, select);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/View/translations.ts
|
// src/View/translations.ts
|
||||||
@@ -2402,6 +2507,15 @@
|
|||||||
filterTasksHeadline: "Filter Tasks",
|
filterTasksHeadline: "Filter Tasks",
|
||||||
///
|
///
|
||||||
renameCategoryInputPlaceholder: "Rename category,"
|
renameCategoryInputPlaceholder: "Rename category,"
|
||||||
|
},
|
||||||
|
calendar: {
|
||||||
|
todayButtonAudioLabel: "go to today",
|
||||||
|
previousMonthButtonAudioLabel: "previous month",
|
||||||
|
nextMonthButtonAudioLabel: "next month",
|
||||||
|
yearInputAudioLabel: "year",
|
||||||
|
monthInputAudioLabel: "month",
|
||||||
|
yearInputPlaceholder: "2000",
|
||||||
|
monthInputPlaceholder: "01"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2411,6 +2525,97 @@
|
|||||||
var language = navigator.language.substring(0, 2);
|
var language = navigator.language.substring(0, 2);
|
||||||
var translations = allTranslations[language] || allTranslations.en;
|
var translations = allTranslations[language] || allTranslations.en;
|
||||||
|
|
||||||
|
// src/View/ChatPages/calendarPage.tsx
|
||||||
|
function CalendarPage(calendarPageViewModel) {
|
||||||
|
calendarPageViewModel.loadData();
|
||||||
|
const mainContent = createProxyState(
|
||||||
|
[calendarPageViewModel.monthGrid],
|
||||||
|
() => {
|
||||||
|
if (calendarPageViewModel.monthGrid.value == void 0) {
|
||||||
|
return /* @__PURE__ */ createElement("div", null);
|
||||||
|
} else {
|
||||||
|
return MonthGrid2(calendarPageViewModel.monthGrid.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(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
class: "ghost",
|
||||||
|
"aria-label": translations.chatPage.calendar.todayButtonAudioLabel,
|
||||||
|
"on:click": calendarPageViewModel.showToday
|
||||||
|
},
|
||||||
|
/* @__PURE__ */ createElement("span", { class: "icon" }, "today")
|
||||||
|
)), /* @__PURE__ */ createElement("span", null, /* @__PURE__ */ createElement(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
class: "ghost",
|
||||||
|
"aria-label": translations.chatPage.calendar.previousMonthButtonAudioLabel,
|
||||||
|
"on:click": calendarPageViewModel.showPreviousMonth
|
||||||
|
},
|
||||||
|
/* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_back")
|
||||||
|
), /* @__PURE__ */ createElement("span", { class: "input-wrapper" }, /* @__PURE__ */ createElement(
|
||||||
|
"input",
|
||||||
|
{
|
||||||
|
class: "year-input",
|
||||||
|
type: "number",
|
||||||
|
"aria-label": translations.chatPage.calendar.yearInputAudioLabel,
|
||||||
|
placeholder: translations.chatPage.calendar.yearInputPlaceholder,
|
||||||
|
"bind:value": calendarPageViewModel.selectedYear
|
||||||
|
}
|
||||||
|
), /* @__PURE__ */ createElement(
|
||||||
|
"input",
|
||||||
|
{
|
||||||
|
class: "month-input",
|
||||||
|
type: "number",
|
||||||
|
"aria-label": translations.chatPage.calendar.monthInputAudioLabel,
|
||||||
|
placeholder: translations.chatPage.calendar.monthInputPlaceholder,
|
||||||
|
"bind:value": calendarPageViewModel.selectedMonth
|
||||||
|
}
|
||||||
|
)), /* @__PURE__ */ createElement(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
class: "ghost",
|
||||||
|
"aria-label": translations.chatPage.calendar.nextMonthButtonAudioLabel,
|
||||||
|
"on:click": calendarPageViewModel.showNextMonth
|
||||||
|
},
|
||||||
|
/* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_forward")
|
||||||
|
)), /* @__PURE__ */ createElement("span", null, /* @__PURE__ */ createElement(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
class: "ghost",
|
||||||
|
"aria-label": translations.chatPage.task.createTaskButtonAudioLabel
|
||||||
|
},
|
||||||
|
/* @__PURE__ */ createElement("span", { class: "icon" }, "add")
|
||||||
|
))), /* @__PURE__ */ createElement("div", { class: "content", "children:set": mainContent }))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/View/Components/ribbonButton.tsx
|
||||||
|
function RibbonButton(label, icon, isSelected, select) {
|
||||||
|
return /* @__PURE__ */ createElement(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
class: "ribbon-button",
|
||||||
|
"aria-label": label,
|
||||||
|
"toggle:selected": isSelected,
|
||||||
|
"on:click": select
|
||||||
|
},
|
||||||
|
/* @__PURE__ */ createElement("span", { class: "icon" }, icon)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/View/Components/chatViewToggleButton.tsx
|
||||||
|
function ChatViewToggleButton(label, icon, page, chatViewModel) {
|
||||||
|
function select() {
|
||||||
|
chatViewModel.selectedPage.value = page;
|
||||||
|
}
|
||||||
|
const isSelected = createProxyState(
|
||||||
|
[chatViewModel.selectedPage],
|
||||||
|
() => chatViewModel.selectedPage.value == page
|
||||||
|
);
|
||||||
|
return RibbonButton(label, icon, isSelected, select);
|
||||||
|
}
|
||||||
|
|
||||||
// src/View/Modals/chatMessageInfoModal.tsx
|
// src/View/Modals/chatMessageInfoModal.tsx
|
||||||
function ChatMessageInfoModal(chatMessageViewModel) {
|
function ChatMessageInfoModal(chatMessageViewModel) {
|
||||||
return /* @__PURE__ */ createElement("div", { class: "modal", "toggle:open": chatMessageViewModel.isPresentingInfoModal }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("main", null, /* @__PURE__ */ createElement("h2", null, translations.chatPage.message.messageInfoHeadline), /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("div", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "account_circle"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.message.sentBy), /* @__PURE__ */ createElement("b", { class: "break-word" }, chatMessageViewModel.sender))), /* @__PURE__ */ createElement("div", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "schedule"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.message.timeSent), /* @__PURE__ */ createElement("b", { class: "break-word" }, chatMessageViewModel.dateSent))), /* @__PURE__ */ createElement("div", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "forum"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.message.channel), /* @__PURE__ */ createElement("b", { class: "break-word" }, chatMessageViewModel.channel))), /* @__PURE__ */ createElement("div", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "description"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.message.messageContent), /* @__PURE__ */ createElement(
|
return /* @__PURE__ */ createElement("div", { class: "modal", "toggle:open": chatMessageViewModel.isPresentingInfoModal }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("main", null, /* @__PURE__ */ createElement("h2", null, translations.chatPage.message.messageInfoHeadline), /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("div", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "account_circle"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.message.sentBy), /* @__PURE__ */ createElement("b", { class: "break-word" }, chatMessageViewModel.sender))), /* @__PURE__ */ createElement("div", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "schedule"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.message.timeSent), /* @__PURE__ */ createElement("b", { class: "break-word" }, chatMessageViewModel.dateSent))), /* @__PURE__ */ createElement("div", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "forum"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.message.channel), /* @__PURE__ */ createElement("b", { class: "break-word" }, chatMessageViewModel.channel))), /* @__PURE__ */ createElement("div", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "description"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translations.chatPage.message.messageContent), /* @__PURE__ */ createElement(
|
||||||
@@ -3281,7 +3486,7 @@
|
|||||||
boardViewModel.taskViewModels,
|
boardViewModel.taskViewModels,
|
||||||
boardViewModel.filteredTaskViewModels,
|
boardViewModel.filteredTaskViewModels,
|
||||||
TaskViewModelToEntry,
|
TaskViewModelToEntry,
|
||||||
boardViewModel.getStringsFromTaskViewModel,
|
TaskViewModel.getStringsForFilter,
|
||||||
boardViewModel.isPresentingFilterModal
|
boardViewModel.isPresentingFilterModal
|
||||||
), /* @__PURE__ */ createElement("div", { "children:set": taskSettingsModal }));
|
), /* @__PURE__ */ createElement("div", { "children:set": taskSettingsModal }));
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+4
@@ -28,6 +28,10 @@ ANIMATION
|
|||||||
--animation-duration: 0.4s;
|
--animation-duration: 0.4s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.slide-up {
|
||||||
|
animation: slide-up var(--animation-duration)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
COLORS
|
COLORS
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import {
|
|||||||
parseValidObject,
|
parseValidObject,
|
||||||
stringify,
|
stringify,
|
||||||
} from "../Utility/utility";
|
} from "../Utility/utility";
|
||||||
import StorageModel, { StorageModelSubPath, filePaths } from "../Global/storageModel";
|
import StorageModel, {
|
||||||
|
StorageModelSubPath,
|
||||||
|
filePaths,
|
||||||
|
} from "../Global/storageModel";
|
||||||
import { decryptString, encryptString } from "../Utility/crypto";
|
import { decryptString, encryptString } from "../Utility/crypto";
|
||||||
|
|
||||||
import ChatListModel from "./chatListModel";
|
import ChatListModel from "./chatListModel";
|
||||||
@@ -39,19 +42,31 @@ export default class ChatModel {
|
|||||||
|
|
||||||
// paths
|
// paths
|
||||||
getBasePath = (): string[] => {
|
getBasePath = (): string[] => {
|
||||||
return StorageModel.getPath(StorageModelSubPath.Chat, filePaths.chat.chatBase(this.id));
|
return StorageModel.getPath(
|
||||||
|
StorageModelSubPath.Chat,
|
||||||
|
filePaths.chat.chatBase(this.id)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
getInfoPath = (): string[] => {
|
getInfoPath = (): string[] => {
|
||||||
return StorageModel.getPath(StorageModelSubPath.Chat, filePaths.chat.info(this.id));
|
return StorageModel.getPath(
|
||||||
|
StorageModelSubPath.Chat,
|
||||||
|
filePaths.chat.info(this.id)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
getColorPath = (): string[] => {
|
getColorPath = (): string[] => {
|
||||||
return StorageModel.getPath(StorageModelSubPath.Chat, filePaths.chat.color(this.id));
|
return StorageModel.getPath(
|
||||||
|
StorageModelSubPath.Chat,
|
||||||
|
filePaths.chat.color(this.id)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
getMessageDirPath = (): string[] => {
|
getMessageDirPath = (): string[] => {
|
||||||
return StorageModel.getPath(StorageModelSubPath.Chat, filePaths.chat.messages(this.id));
|
return StorageModel.getPath(
|
||||||
|
StorageModelSubPath.Chat,
|
||||||
|
filePaths.chat.messages(this.id)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
getMessagePath = (id: string): string[] => {
|
getMessagePath = (id: string): string[] => {
|
||||||
@@ -236,7 +251,7 @@ export default class ChatModel {
|
|||||||
this.loadColor();
|
this.loadColor();
|
||||||
this.subscribe();
|
this.subscribe();
|
||||||
|
|
||||||
this.fileModel = new FileModel(this, this.storageModel);
|
this.fileModel = new FileModel(this.storageModel, this.settingsModel, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
|
|||||||
@@ -6,17 +6,22 @@ import {
|
|||||||
} from "../Utility/typeSafety";
|
} from "../Utility/typeSafety";
|
||||||
import FileModel, { FileContent, FileModelSubPath } from "./fileModel";
|
import FileModel, { FileContent, FileModelSubPath } from "./fileModel";
|
||||||
|
|
||||||
|
import CalendarModel from "./calendarModel";
|
||||||
import ChatModel from "../Chat/chatModel";
|
import ChatModel from "../Chat/chatModel";
|
||||||
import { Color } from "../../colors";
|
import { Color } from "../../colors";
|
||||||
import { HandlerManager } from "../Utility/utility";
|
import { HandlerManager } from "../Utility/utility";
|
||||||
|
import SettingsModel from "../Global/settingsModel";
|
||||||
import StorageModel from "../Global/storageModel";
|
import StorageModel from "../Global/storageModel";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
|
|
||||||
export default class BoardsAndTasksModel {
|
export default class BoardsAndTasksModel {
|
||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
|
settingsModel: SettingsModel;
|
||||||
chatModel: ChatModel;
|
chatModel: ChatModel;
|
||||||
fileModel: FileModel;
|
fileModel: FileModel;
|
||||||
|
|
||||||
|
calendarModel: CalendarModel;
|
||||||
|
|
||||||
// data
|
// data
|
||||||
boardHandlerManager: HandlerManager<BoardInfoFileContent> =
|
boardHandlerManager: HandlerManager<BoardInfoFileContent> =
|
||||||
new HandlerManager();
|
new HandlerManager();
|
||||||
@@ -153,8 +158,6 @@ export default class BoardsAndTasksModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
storeTask = (taskFileContent: TaskFileContent): void => {
|
storeTask = (taskFileContent: TaskFileContent): void => {
|
||||||
console.log(taskFileContent);
|
|
||||||
|
|
||||||
// store info
|
// store info
|
||||||
this.fileModel.storeFileContent(taskFileContent);
|
this.fileModel.storeFileContent(taskFileContent);
|
||||||
|
|
||||||
@@ -164,6 +167,9 @@ export default class BoardsAndTasksModel {
|
|||||||
taskFileContent.fileId
|
taskFileContent.fileId
|
||||||
);
|
);
|
||||||
this.storageModel.write(taskReferencePath, "");
|
this.storageModel.write(taskReferencePath, "");
|
||||||
|
|
||||||
|
// add to calendar
|
||||||
|
this.calendarModel.storeTaskReference(taskFileContent);
|
||||||
};
|
};
|
||||||
|
|
||||||
listTaskIds = (boardId: string): string[] => {
|
listTaskIds = (boardId: string): string[] => {
|
||||||
@@ -214,12 +220,20 @@ export default class BoardsAndTasksModel {
|
|||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
storageModel: StorageModel,
|
storageModel: StorageModel,
|
||||||
|
settingsModel: SettingsModel,
|
||||||
chatModel: ChatModel,
|
chatModel: ChatModel,
|
||||||
fileModel: FileModel
|
fileModel: FileModel
|
||||||
) {
|
) {
|
||||||
|
this.storageModel = storageModel;
|
||||||
|
this.settingsModel = settingsModel;
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
this.fileModel = fileModel;
|
this.fileModel = fileModel;
|
||||||
this.storageModel = storageModel;
|
|
||||||
|
this.calendarModel = new CalendarModel(
|
||||||
|
this.storageModel,
|
||||||
|
this.settingsModel,
|
||||||
|
this.fileModel
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
// this file extends the BoardsAndTasksModel regarding calendar features.
|
|
||||||
// it is responsible for managing calendar-realted reference files for tasks.
|
// it is responsible for managing calendar-realted reference files for tasks.
|
||||||
|
|
||||||
import BoardsAndTasksModel, {
|
import FileModel, { FileModelSubPath } from "./fileModel";
|
||||||
TaskFileContent,
|
|
||||||
TaskFileContentReference,
|
|
||||||
} from "./boardsAndTasksModel";
|
|
||||||
import FileModel, { FileContent, FileModelSubPath } from "./fileModel";
|
|
||||||
|
|
||||||
|
import SettingsModel from "../Global/settingsModel";
|
||||||
import StorageModel from "../Global/storageModel";
|
import StorageModel from "../Global/storageModel";
|
||||||
import { checkMatchesObjectStructure } from "../Utility/typeSafety";
|
import { TaskFileContent } from "./boardsAndTasksModel";
|
||||||
|
|
||||||
export default class CalendarModel {
|
export default class CalendarModel {
|
||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
fileModel: FileModel;
|
fileModel: FileModel;
|
||||||
|
settingsModel: SettingsModel;
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
getBasePath = (): string[] => {
|
getBasePath = (): string[] => {
|
||||||
@@ -31,18 +28,10 @@ export default class CalendarModel {
|
|||||||
return [...this.getMonthContainerPath(), monthString];
|
return [...this.getMonthContainerPath(), monthString];
|
||||||
};
|
};
|
||||||
|
|
||||||
// handlers
|
|
||||||
handleFileContent = (fileContent: FileContent<string>): void => {
|
|
||||||
if (
|
|
||||||
checkMatchesObjectStructure(fileContent, TaskFileContentReference) ==
|
|
||||||
false
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
// main
|
// main
|
||||||
storeTaskReference = (taskFileContent: TaskFileContent): void => {
|
storeTaskReference = (taskFileContent: TaskFileContent): void => {
|
||||||
if (taskFileContent.date == undefined) return;
|
if (taskFileContent.date == undefined) return;
|
||||||
|
|
||||||
const monthString: string = CalendarModel.isoToMonthString(
|
const monthString: string = CalendarModel.isoToMonthString(
|
||||||
taskFileContent.date
|
taskFileContent.date
|
||||||
);
|
);
|
||||||
@@ -58,21 +47,73 @@ export default class CalendarModel {
|
|||||||
return this.storageModel.list(monthPath);
|
return this.storageModel.list(monthPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
generateMonthGrid = <T>(
|
||||||
|
year: number,
|
||||||
|
month: number,
|
||||||
|
defaultValueCreator: () => T
|
||||||
|
): MonthGrid<T> => {
|
||||||
|
// get first day of month
|
||||||
|
const date: Date = new Date();
|
||||||
|
date.setFullYear(year);
|
||||||
|
date.setMonth(month - 1);
|
||||||
|
date.setDate(1);
|
||||||
|
|
||||||
|
// get offset
|
||||||
|
const offset: number =
|
||||||
|
date.getDay() - parseInt(this.settingsModel.firstDayOfWeek);
|
||||||
|
|
||||||
|
// get total day count
|
||||||
|
date.setMonth(month);
|
||||||
|
date.setDate(-1);
|
||||||
|
const daysInMonth: number = date.getDate() + 1;
|
||||||
|
|
||||||
|
const grid: MonthGrid<T> = {
|
||||||
|
offset,
|
||||||
|
days: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let i = 0; i < daysInMonth; i++) {
|
||||||
|
grid.days[i + 1] = defaultValueCreator();
|
||||||
|
}
|
||||||
|
|
||||||
|
return grid;
|
||||||
|
};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
storageModel: StorageModel,
|
storageModel: StorageModel,
|
||||||
fileModel: FileModel, ) {
|
settingsModel: SettingsModel,
|
||||||
|
fileModel: FileModel
|
||||||
|
) {
|
||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
|
this.settingsModel = settingsModel;
|
||||||
this.fileModel = fileModel;
|
this.fileModel = fileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
static isoToMonthString = (dateISOString: string): string => {
|
static isoToMonthString = (dateISOString: string): string => {
|
||||||
const [year, month, _] = dateISOString.split("-");
|
const [year, month, _] = dateISOString.split("-");
|
||||||
return `${year}-${month}`;
|
return CalendarModel.getMonthString(year, month);
|
||||||
|
};
|
||||||
|
|
||||||
|
static isoToDateString = (dateISOString: string): string | undefined => {
|
||||||
|
const [year, month, date, _] = dateISOString.split("-");
|
||||||
|
return date;
|
||||||
|
};
|
||||||
|
|
||||||
|
static getMonthString = (year: string = "", month: string = ""): string => {
|
||||||
|
const paddedYear: string = year.padStart(4, "0");
|
||||||
|
const paddedMonth: string = month.padStart(2, "0");
|
||||||
|
return `${paddedYear}-${paddedMonth}`;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum CalendarModelSubPaths {
|
export enum CalendarModelSubPaths {
|
||||||
Months = "months",
|
Months = "months",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// types
|
||||||
|
export interface MonthGrid<T> {
|
||||||
|
offset: number;
|
||||||
|
days: { [date: string]: T };
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
// this file is responsible for managing files within chats.
|
// this file is responsible for managing files within chats.
|
||||||
|
|
||||||
import { DATA_VERSION, ValidObject } from "../Utility/typeSafety";
|
import { DATA_VERSION, ValidObject } from "../Utility/typeSafety";
|
||||||
|
import StorageModel, {
|
||||||
|
StorageModelSubPath,
|
||||||
|
filePaths,
|
||||||
|
} from "../Global/storageModel";
|
||||||
import {
|
import {
|
||||||
HandlerManager,
|
|
||||||
StringEntryObject,
|
StringEntryObject,
|
||||||
createTimestamp,
|
createTimestamp,
|
||||||
parseValidObject,
|
parseValidObject,
|
||||||
stringify,
|
stringify,
|
||||||
} from "../Utility/utility";
|
} from "../Utility/utility";
|
||||||
import StorageModel, { StorageModelSubPath, filePaths } from "../Global/storageModel";
|
|
||||||
|
|
||||||
import BoardsAndTasksModel from "./boardsAndTasksModel";
|
import BoardsAndTasksModel from "./boardsAndTasksModel";
|
||||||
import CalendarModel from "./calendarModel";
|
|
||||||
import ChatModel from "../Chat/chatModel";
|
import ChatModel from "../Chat/chatModel";
|
||||||
|
import SettingsModel from "../Global/settingsModel";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
|
|
||||||
export default class FileModel {
|
export default class FileModel {
|
||||||
chatModel: ChatModel;
|
|
||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
|
settingsModel: SettingsModel;
|
||||||
|
|
||||||
|
chatModel: ChatModel;
|
||||||
boardsAndTasksModel: BoardsAndTasksModel;
|
boardsAndTasksModel: BoardsAndTasksModel;
|
||||||
calendarModel: CalendarModel;
|
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
getBasePath = (): string[] => {
|
getBasePath = (): string[] => {
|
||||||
@@ -34,9 +36,7 @@ export default class FileModel {
|
|||||||
return [...this.getBasePath(), FileModelSubPath.Data];
|
return [...this.getBasePath(), FileModelSubPath.Data];
|
||||||
};
|
};
|
||||||
|
|
||||||
getModelContainerPath = (
|
getModelContainerPath = (modelName: FileModelSubPath): string[] => {
|
||||||
modelName: FileModelSubPath
|
|
||||||
): string[] => {
|
|
||||||
return [...this.getBasePath(), FileModelSubPath.Model, modelName];
|
return [...this.getBasePath(), FileModelSubPath.Model, modelName];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,7 +65,6 @@ export default class FileModel {
|
|||||||
if (didStore == false) return;
|
if (didStore == false) return;
|
||||||
|
|
||||||
this.boardsAndTasksModel.handleFileContent(fileContent);
|
this.boardsAndTasksModel.handleFileContent(fileContent);
|
||||||
this.calendarModel.handleFileContent(fileContent);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
@@ -137,12 +136,21 @@ export default class FileModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(chatModel: ChatModel, storageModel: StorageModel) {
|
constructor(
|
||||||
|
storageModel: StorageModel,
|
||||||
|
settingsModel: SettingsModel,
|
||||||
|
chatModel: ChatModel
|
||||||
|
) {
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
|
this.settingsModel = settingsModel;
|
||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
|
|
||||||
this.boardsAndTasksModel = new BoardsAndTasksModel(this.storageModel, chatModel, this);
|
this.boardsAndTasksModel = new BoardsAndTasksModel(
|
||||||
this.calendarModel = new CalendarModel(this.storageModel, this);
|
this.storageModel,
|
||||||
|
this.settingsModel,
|
||||||
|
chatModel,
|
||||||
|
this
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
@@ -175,10 +183,12 @@ export enum FileModelSubPath {
|
|||||||
ModelView = "view",
|
ModelView = "view",
|
||||||
ModelTask = "tasks",
|
ModelTask = "tasks",
|
||||||
ModelCalendar = "calendar",
|
ModelCalendar = "calendar",
|
||||||
};
|
}
|
||||||
|
|
||||||
// types
|
// types
|
||||||
export interface FileContent<T extends string> extends ValidObject, StringEntryObject {
|
export interface FileContent<T extends string>
|
||||||
|
extends ValidObject,
|
||||||
|
StringEntryObject {
|
||||||
fileId: string;
|
fileId: string;
|
||||||
fileContentId: string;
|
fileContentId: string;
|
||||||
creationDate: string;
|
creationDate: string;
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export function BoardPage(boardViewModel: BoardViewModel) {
|
|||||||
boardViewModel.taskViewModels,
|
boardViewModel.taskViewModels,
|
||||||
boardViewModel.filteredTaskViewModels,
|
boardViewModel.filteredTaskViewModels,
|
||||||
TaskViewModelToEntry,
|
TaskViewModelToEntry,
|
||||||
boardViewModel.getStringsFromTaskViewModel,
|
TaskViewModel.getStringsForFilter,
|
||||||
boardViewModel.isPresentingFilterModal
|
boardViewModel.isPresentingFilterModal
|
||||||
)}
|
)}
|
||||||
<div children:set={taskSettingsModal}></div>
|
<div children:set={taskSettingsModal}></div>
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#chat-page
|
||||||
|
> div
|
||||||
|
> #main
|
||||||
|
> #calendar-page
|
||||||
|
> .pane-wrapper
|
||||||
|
> .pane
|
||||||
|
> .toolbar
|
||||||
|
.input-wrapper {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
padding: var(--gap-between-tiles);
|
||||||
|
gap: var(--gap-between-tiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
#chat-page
|
||||||
|
> div
|
||||||
|
> #main
|
||||||
|
> #calendar-page
|
||||||
|
> .pane-wrapper
|
||||||
|
> .pane
|
||||||
|
> .toolbar
|
||||||
|
.input-wrapper
|
||||||
|
> input {
|
||||||
|
min-height: unset;
|
||||||
|
height: calc(var(--control-height) - 2 * var(--gap-between-tiles));
|
||||||
|
|
||||||
|
appearance: textfield;
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
#calendar-page .input-wrapper > input::-webkit-outer-spin-button,
|
||||||
|
#calendar-page .input-wrapper > input::-webkit-innner-spin-button {
|
||||||
|
appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#chat-page
|
||||||
|
> div
|
||||||
|
> #main
|
||||||
|
> #calendar-page
|
||||||
|
> .pane-wrapper
|
||||||
|
> .pane
|
||||||
|
> .toolbar
|
||||||
|
.input-wrapper
|
||||||
|
> .year-input {
|
||||||
|
width: 4.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#chat-page
|
||||||
|
> div
|
||||||
|
> #main
|
||||||
|
> #calendar-page
|
||||||
|
> .pane-wrapper
|
||||||
|
> .pane
|
||||||
|
> .toolbar
|
||||||
|
.input-wrapper
|
||||||
|
> .month-input {
|
||||||
|
width: 3.1rem;
|
||||||
|
}
|
||||||
@@ -1,9 +1,101 @@
|
|||||||
|
import "./calendarPage.css";
|
||||||
|
|
||||||
import * as React from "bloatless-react";
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
import CalendarPageViewModel from "../../ViewModel/Pages/calendarPageViewModel";
|
import CalendarPageViewModel from "../../ViewModel/Pages/calendarPageViewModel";
|
||||||
|
import { MonthGrid } from "../Components/monthGrid";
|
||||||
|
import { TaskViewModelToEntry } from "../Components/taskEntry";
|
||||||
|
import { createPropertyValueIndexState } from "../Components/propertyValueList";
|
||||||
|
import { translations } from "../translations";
|
||||||
|
|
||||||
export function CalendarPage(calendarPageViewModel: CalendarPageViewModel) {
|
export function CalendarPage(calendarPageViewModel: CalendarPageViewModel) {
|
||||||
calendarPageViewModel.loadData();
|
calendarPageViewModel.loadData();
|
||||||
|
|
||||||
return <div id="calendar-page"></div>;
|
const mainContent = React.createProxyState(
|
||||||
|
[calendarPageViewModel.monthGrid],
|
||||||
|
() => {
|
||||||
|
if (calendarPageViewModel.monthGrid.value == undefined) {
|
||||||
|
return <div></div>;
|
||||||
|
} else {
|
||||||
|
return MonthGrid(calendarPageViewModel.monthGrid.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div id="calendar-page">
|
||||||
|
<div class="pane-wrapper">
|
||||||
|
<div class="pane">
|
||||||
|
<div class="toolbar">
|
||||||
|
<span>
|
||||||
|
<button
|
||||||
|
class="ghost"
|
||||||
|
aria-label={
|
||||||
|
translations.chatPage.calendar.todayButtonAudioLabel
|
||||||
|
}
|
||||||
|
on:click={calendarPageViewModel.showToday}
|
||||||
|
>
|
||||||
|
<span class="icon">today</span>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<button
|
||||||
|
class="ghost"
|
||||||
|
aria-label={
|
||||||
|
translations.chatPage.calendar.previousMonthButtonAudioLabel
|
||||||
|
}
|
||||||
|
on:click={calendarPageViewModel.showPreviousMonth}
|
||||||
|
>
|
||||||
|
<span class="icon">arrow_back</span>
|
||||||
|
</button>
|
||||||
|
<span class="input-wrapper">
|
||||||
|
<input
|
||||||
|
class="year-input"
|
||||||
|
type="number"
|
||||||
|
aria-label={
|
||||||
|
translations.chatPage.calendar.yearInputAudioLabel
|
||||||
|
}
|
||||||
|
placeholder={
|
||||||
|
translations.chatPage.calendar.yearInputPlaceholder
|
||||||
|
}
|
||||||
|
bind:value={calendarPageViewModel.selectedYear}
|
||||||
|
></input>
|
||||||
|
<input
|
||||||
|
class="month-input"
|
||||||
|
type="number"
|
||||||
|
aria-label={
|
||||||
|
translations.chatPage.calendar.monthInputAudioLabel
|
||||||
|
}
|
||||||
|
placeholder={
|
||||||
|
translations.chatPage.calendar.monthInputPlaceholder
|
||||||
|
}
|
||||||
|
bind:value={calendarPageViewModel.selectedMonth}
|
||||||
|
></input>
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
class="ghost"
|
||||||
|
aria-label={
|
||||||
|
translations.chatPage.calendar.nextMonthButtonAudioLabel
|
||||||
|
}
|
||||||
|
on:click={calendarPageViewModel.showNextMonth}
|
||||||
|
>
|
||||||
|
<span class="icon">arrow_forward</span>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<button
|
||||||
|
class="ghost"
|
||||||
|
aria-label={
|
||||||
|
translations.chatPage.task.createTaskButtonAudioLabel
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span class="icon">add</span>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="content" children:set={mainContent}></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
.month-grid-wrapper {
|
||||||
|
display: grid;
|
||||||
|
gap: var(--gap-between-tiles);
|
||||||
|
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
animation: slide-up var(--animation-duration);
|
||||||
|
|
||||||
|
grid-template-columns: repeat(7, minmax(0px, 1fr));
|
||||||
|
grid-auto-rows: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.month-grid-wrapper .tile > div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.month-grid-wrapper .tile {
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import "./monthGrid.css";
|
||||||
|
|
||||||
|
import * as React from "bloatless-react";
|
||||||
|
import { MonthGrid } from "../../Model/Files/calendarModel";
|
||||||
|
import TaskViewModel from "../../ViewModel/Pages/taskViewModel";
|
||||||
|
|
||||||
|
export function MonthGrid<T>(monthGrid: MonthGrid<React.MapState<T>>) {
|
||||||
|
const offsetElements: HTMLElement[] = [];
|
||||||
|
for (let i = 0; i < monthGrid.offset; i++) {
|
||||||
|
offsetElements.push(<div></div>);
|
||||||
|
}
|
||||||
|
|
||||||
|
const converter: React.StateItemConverter<TaskViewModel> = (
|
||||||
|
taskViewModel
|
||||||
|
) => {
|
||||||
|
return <span class="ellipsis secondary">{taskViewModel.task.name}</span>;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="month-grid-wrapper">
|
||||||
|
{...offsetElements}
|
||||||
|
{...Object.entries(monthGrid.days).map((entry) => {
|
||||||
|
const [date, mapState] = entry;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button class="tile">
|
||||||
|
<div>
|
||||||
|
<b>{date}</b>
|
||||||
|
<div
|
||||||
|
class="flex-column gap clip"
|
||||||
|
children:append={[mapState, converter]}
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
|
export const StringToTextSpan: React.StateItemConverter<string> = (
|
||||||
|
string: string
|
||||||
|
) => {
|
||||||
|
return <span>{string}</span>
|
||||||
|
};
|
||||||
@@ -195,6 +195,11 @@ body[showing-chat] #chat-page-wrapper {
|
|||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#chat-page > div > #main > div > .pane-wrapper > .pane > .toolbar > span {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
#chat-page > div > #main > div > .pane-wrapper > .pane > .toolbar > span.title {
|
#chat-page > div > #main > div > .pane-wrapper > .pane > .toolbar > span.title {
|
||||||
padding-left: var(--content-padding);
|
padding-left: var(--content-padding);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,19 @@ const englishTranslations = {
|
|||||||
|
|
||||||
renameCategoryInputPlaceholder: "Rename category,"
|
renameCategoryInputPlaceholder: "Rename category,"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
calendar: {
|
||||||
|
todayButtonAudioLabel: "go to today",
|
||||||
|
|
||||||
|
previousMonthButtonAudioLabel: "previous month",
|
||||||
|
nextMonthButtonAudioLabel: "next month",
|
||||||
|
|
||||||
|
yearInputAudioLabel: "year",
|
||||||
|
monthInputAudioLabel: "month",
|
||||||
|
|
||||||
|
yearInputPlaceholder: "2000",
|
||||||
|
monthInputPlaceholder: "01",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ export default class ChatListViewModel {
|
|||||||
newChatPrimaryChannel: React.State<string> = new React.State("");
|
newChatPrimaryChannel: React.State<string> = new React.State("");
|
||||||
chatViewModels: React.ListState<ChatViewModel> = new React.ListState();
|
chatViewModels: React.ListState<ChatViewModel> = new React.ListState();
|
||||||
|
|
||||||
selectedChat: React.State<ChatViewModel | undefined> = new React.State<
|
selectedChat: React.State<ChatViewModel | undefined> = new React.State<any>(
|
||||||
ChatViewModel | undefined
|
undefined
|
||||||
>(undefined);
|
);
|
||||||
|
|
||||||
// guards
|
// guards
|
||||||
cannotCreateChat = React.createProxyState(
|
cannotCreateChat = React.createProxyState(
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ export default class ChatMessageViewModel {
|
|||||||
sender: string;
|
sender: string;
|
||||||
dateSent: string;
|
dateSent: string;
|
||||||
body: React.State<string> = new React.State("");
|
body: React.State<string> = new React.State("");
|
||||||
status: React.State<ChatMessageStatus | any> = new React.State<
|
status: React.State<ChatMessageStatus | any> = new React.State<any>(
|
||||||
ChatMessageStatus | undefined
|
undefined
|
||||||
>(undefined);
|
);
|
||||||
sentByUser: boolean;
|
sentByUser: boolean;
|
||||||
|
|
||||||
// state
|
// state
|
||||||
@@ -36,11 +36,11 @@ export default class ChatMessageViewModel {
|
|||||||
// view
|
// view
|
||||||
showInfoModal = (): void => {
|
showInfoModal = (): void => {
|
||||||
this.isPresentingInfoModal.value = true;
|
this.isPresentingInfoModal.value = true;
|
||||||
}
|
};
|
||||||
|
|
||||||
hideInfoModal = (): void => {
|
hideInfoModal = (): void => {
|
||||||
this.isPresentingInfoModal.value = false;
|
this.isPresentingInfoModal.value = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
// load
|
// load
|
||||||
loadData = (): void => {
|
loadData = (): void => {
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export default class ChatViewModel {
|
|||||||
settingsPageViewModel: SettingsPageViewModel;
|
settingsPageViewModel: SettingsPageViewModel;
|
||||||
|
|
||||||
// state
|
// state
|
||||||
displayedColor: React.State<Color> = new React.State<Color>(Color.Standard);
|
displayedColor: React.State<Color> = new React.State<any>(Color.Standard);
|
||||||
selectedPage: React.State<ChatPageType> = new React.State<ChatPageType>(
|
selectedPage: React.State<ChatPageType> = new React.State<any>(
|
||||||
ChatPageType.Messages
|
ChatPageType.Messages
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ export default class ChatViewModel {
|
|||||||
this.calendarViewModel = new CalendarPageViewModel(
|
this.calendarViewModel = new CalendarPageViewModel(
|
||||||
coreViewModel,
|
coreViewModel,
|
||||||
this.storageModel,
|
this.storageModel,
|
||||||
this.chatModel.fileModel.calendarModel,
|
this.chatModel.fileModel.boardsAndTasksModel.calendarModel,
|
||||||
this.chatModel.fileModel.boardsAndTasksModel
|
this.chatModel.fileModel.boardsAndTasksModel
|
||||||
);
|
);
|
||||||
this.taskPageViewModel = new TaskPageViewModel(
|
this.taskPageViewModel = new TaskPageViewModel(
|
||||||
|
|||||||
@@ -27,15 +27,15 @@ export default class BoardViewModel {
|
|||||||
|
|
||||||
// state
|
// state
|
||||||
name: React.State<string> = new React.State("");
|
name: React.State<string> = new React.State("");
|
||||||
color: React.State<Color> = new React.State<Color>(Color.Standard);
|
color: React.State<Color> = new React.State<any>(Color.Standard);
|
||||||
|
|
||||||
index: React.State<number> = new React.State(0);
|
index: React.State<number> = new React.State(0);
|
||||||
|
|
||||||
selectedPage: React.State<BoardPageType> = new React.State<BoardPageType>(
|
selectedPage: React.State<BoardPageType> = new React.State<any>(
|
||||||
BoardPageType.List
|
BoardPageType.List
|
||||||
);
|
);
|
||||||
selectedTaskViewModel: React.State<TaskViewModel | undefined> =
|
selectedTaskViewModel: React.State<TaskViewModel | undefined> =
|
||||||
new React.State<TaskViewModel | undefined>(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);
|
||||||
@@ -190,19 +190,6 @@ export default class BoardViewModel {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// filter
|
|
||||||
getStringsFromTaskViewModel = (taskViewModel: TaskViewModel): string[] => {
|
|
||||||
return [
|
|
||||||
taskViewModel.task.name,
|
|
||||||
taskViewModel.task.description ?? "",
|
|
||||||
taskViewModel.task.category ?? "",
|
|
||||||
taskViewModel.task.status ?? "",
|
|
||||||
taskViewModel.task.priority ?? "",
|
|
||||||
taskViewModel.task.date ?? "",
|
|
||||||
taskViewModel.task.time ?? "",
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
// load
|
// load
|
||||||
loadListRelevantData = (): void => {
|
loadListRelevantData = (): void => {
|
||||||
this.name.value = this.boardInfo.name;
|
this.name.value = this.boardInfo.name;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import * as React from "bloatless-react";
|
|||||||
import BoardsAndTasksModel, {
|
import BoardsAndTasksModel, {
|
||||||
TaskFileContent,
|
TaskFileContent,
|
||||||
} from "../../Model/Files/boardsAndTasksModel";
|
} from "../../Model/Files/boardsAndTasksModel";
|
||||||
|
import CalendarModel, { MonthGrid } from "../../Model/Files/calendarModel";
|
||||||
|
|
||||||
import CalendarModel from "../../Model/Files/calendarModel";
|
|
||||||
import CoreViewModel from "../Global/coreViewModel";
|
import CoreViewModel from "../Global/coreViewModel";
|
||||||
import StorageModel from "../../Model/Global/storageModel";
|
import StorageModel from "../../Model/Global/storageModel";
|
||||||
import TaskViewModel from "./taskViewModel";
|
import TaskViewModel from "./taskViewModel";
|
||||||
@@ -12,7 +12,15 @@ import TaskViewModel from "./taskViewModel";
|
|||||||
export default class CalendarPageViewModel {
|
export default class CalendarPageViewModel {
|
||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
calendarModel: CalendarModel;
|
calendarModel: CalendarModel;
|
||||||
boardAndTasksModel: BoardsAndTasksModel;
|
boardsAndTasksModel: BoardsAndTasksModel;
|
||||||
|
|
||||||
|
// data
|
||||||
|
get monthString(): string {
|
||||||
|
return CalendarModel.getMonthString(
|
||||||
|
this.selectedYear.value.toString(),
|
||||||
|
this.selectedMonth.value.toString()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
getBasePath = (): string[] => {
|
getBasePath = (): string[] => {
|
||||||
@@ -20,35 +28,106 @@ export default class CalendarPageViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// state
|
// state
|
||||||
taskViewModels: React.MapState<TaskViewModel> = new React.MapState();
|
selectedYear: React.State<number> = new React.State(0);
|
||||||
|
selectedMonth: React.State<number> = new React.State(0);
|
||||||
|
|
||||||
|
monthGrid: React.State<MonthGrid<React.MapState<TaskViewModel>> | undefined> =
|
||||||
|
new React.State<any>(undefined);
|
||||||
|
|
||||||
// view
|
// view
|
||||||
|
getTaskMapState = (
|
||||||
|
taskFileContent: TaskFileContent
|
||||||
|
): React.MapState<TaskViewModel> | null => {
|
||||||
|
if (this.monthGrid.value == null) return null;
|
||||||
|
|
||||||
|
const dateString: string | undefined = CalendarModel.isoToDateString(
|
||||||
|
taskFileContent.date ?? ""
|
||||||
|
);
|
||||||
|
if (dateString == undefined) return null;
|
||||||
|
return this.monthGrid.value.days[dateString];
|
||||||
|
};
|
||||||
|
|
||||||
showTask = (taskFileContent: TaskFileContent): void => {
|
showTask = (taskFileContent: TaskFileContent): void => {
|
||||||
const taskViewModel: TaskViewModel = new TaskViewModel(
|
const taskViewModel: TaskViewModel = new TaskViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
this.boardAndTasksModel,
|
this.boardsAndTasksModel,
|
||||||
null,
|
null,
|
||||||
this,
|
this,
|
||||||
taskFileContent
|
taskFileContent
|
||||||
);
|
);
|
||||||
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
|
const mapState: React.MapState<TaskViewModel> | null =
|
||||||
|
this.getTaskMapState(taskFileContent);
|
||||||
|
mapState?.set(taskFileContent.fileId, taskViewModel);
|
||||||
|
};
|
||||||
|
|
||||||
|
removeTaskFromList = (taskFileContent: TaskFileContent): void => {
|
||||||
|
const mapState: React.MapState<TaskViewModel> | null =
|
||||||
|
this.getTaskMapState(taskFileContent);
|
||||||
|
mapState?.remove(taskFileContent.fileId);
|
||||||
|
};
|
||||||
|
|
||||||
|
showToday = (): void => {
|
||||||
|
const today: Date = new Date();
|
||||||
|
this.selectedYear.value = today.getFullYear();
|
||||||
|
this.selectedMonth.value = today.getMonth() + 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
showPreviousMonth = (): void => {
|
||||||
|
this.selectedMonth.value -= 1;
|
||||||
|
|
||||||
|
if (this.selectedMonth.value <= 0) {
|
||||||
|
this.selectedYear.value -= 1;
|
||||||
|
this.selectedMonth.value = 12;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
showNextMonth = (): void => {
|
||||||
|
this.selectedMonth.value += 1;
|
||||||
|
|
||||||
|
if (this.selectedMonth.value >= 13) {
|
||||||
|
this.selectedYear.value += 1;
|
||||||
|
this.selectedMonth.value = 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// storage
|
// storage
|
||||||
|
|
||||||
// load
|
// load
|
||||||
loadData = (): void => {}
|
loadTasks = (): void => {
|
||||||
|
this.monthGrid.value = this.calendarModel.generateMonthGrid(
|
||||||
|
this.selectedYear.value,
|
||||||
|
this.selectedMonth.value,
|
||||||
|
() => new React.MapState()
|
||||||
|
);
|
||||||
|
const taskIds: string[] = this.calendarModel.listTaskIds(this.monthString);
|
||||||
|
|
||||||
|
for (const taskId of taskIds) {
|
||||||
|
const taskFileContent: TaskFileContent | null =
|
||||||
|
this.boardsAndTasksModel.getLatestTaskFileContent(taskId);
|
||||||
|
if (taskFileContent == null) continue;
|
||||||
|
this.showTask(taskFileContent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData = (): void => {
|
||||||
|
this.loadTasks();
|
||||||
|
this.showToday();
|
||||||
|
};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
public coreViewModel: CoreViewModel,
|
public coreViewModel: CoreViewModel,
|
||||||
storageModel: StorageModel,
|
storageModel: StorageModel,
|
||||||
calendarModel: CalendarModel,
|
calendarModel: CalendarModel,
|
||||||
boardAndTasksModel: BoardsAndTasksModel,
|
boardAndTasksModel: BoardsAndTasksModel
|
||||||
) {
|
) {
|
||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
this.calendarModel = calendarModel;
|
this.calendarModel = calendarModel;
|
||||||
this.boardAndTasksModel = boardAndTasksModel;
|
this.boardsAndTasksModel = boardAndTasksModel;
|
||||||
|
|
||||||
|
React.bulkSubscribe([this.selectedYear, this.selectedMonth], () => {
|
||||||
|
this.loadTasks();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default class SettingsPageViewModel {
|
|||||||
this.shouldShowEncryptionKey.value == true ? "text" : "password"
|
this.shouldShowEncryptionKey.value == true ? "text" : "password"
|
||||||
);
|
);
|
||||||
|
|
||||||
color: React.State<Color> = new React.State<Color>(Color.Standard);
|
color: React.State<Color> = new React.State<any>(Color.Standard);
|
||||||
|
|
||||||
// guards
|
// guards
|
||||||
cannotSetPrimaryChannel: React.State<boolean> = React.createProxyState(
|
cannotSetPrimaryChannel: React.State<boolean> = React.createProxyState(
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ export default class TaskPageViewModel {
|
|||||||
|
|
||||||
boardViewModels: React.MapState<BoardViewModel> = new React.MapState();
|
boardViewModels: React.MapState<BoardViewModel> = new React.MapState();
|
||||||
|
|
||||||
selectedBoardId: React.State<string | undefined> = new React.State<
|
selectedBoardId: React.State<string | undefined> = new React.State<any>(
|
||||||
string | undefined
|
undefined
|
||||||
>(undefined);
|
);
|
||||||
|
|
||||||
// guards
|
// guards
|
||||||
cannotCreateBoard: React.State<boolean> = React.createProxyState(
|
cannotCreateBoard: React.State<boolean> = React.createProxyState(
|
||||||
|
|||||||
@@ -200,4 +200,17 @@ export default class TaskViewModel {
|
|||||||
this.switchVersion(selectedVersionId);
|
this.switchVersion(selectedVersionId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// utility
|
||||||
|
static getStringsForFilter = (taskViewModel: TaskViewModel): string[] => {
|
||||||
|
return [
|
||||||
|
taskViewModel.task.name,
|
||||||
|
taskViewModel.task.description ?? "",
|
||||||
|
taskViewModel.task.category ?? "",
|
||||||
|
taskViewModel.task.status ?? "",
|
||||||
|
taskViewModel.task.priority ?? "",
|
||||||
|
taskViewModel.task.date ?? "",
|
||||||
|
taskViewModel.task.time ?? "",
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user