From bdbd5fa123d16fee9c2e52aabb7ace711b8e96dd Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Fri, 25 Sep 2026 19:57:35 +0200 Subject: [PATCH] fix bugs with calendar page, highlight next event --- dist/index.js | 529 ++++++++++-------- dist/styles.css | 15 +- dist/sw.js | 2 +- dist/version.txt | 2 +- src/Model/Utility/utility.ts | 4 + src/View/ChatPages/calendarPage.tsx | 1 - src/View/Components/taskEntry.tsx | 73 ++- src/View/translations.ts | 8 + src/ViewModel/Global/coreViewModel.ts | 15 +- src/ViewModel/Global/fileTransferViewModel.ts | 3 +- src/ViewModel/Global/notificationViewModel.ts | 1 - src/ViewModel/Global/storageViewModel.ts | 1 - src/ViewModel/Pages/boardViewModel.ts | 1 - src/ViewModel/Pages/calendarPageViewModel.ts | 43 +- src/ViewModel/Pages/taskViewModel.ts | 9 + 15 files changed, 411 insertions(+), 296 deletions(-) diff --git a/dist/index.js b/dist/index.js index 16d8fadd..3eddc38a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -538,7 +538,9 @@ searchEventsHeadline: "Search Events", /// events: "Events", - noEvents: "No events" + noEvents: "No events", + // + eventNext: "Up next" } } }; @@ -770,7 +772,8 @@ monthInputPlaceholder: "01", searchEventsHeadline: "Ereignisse suchen", events: "Ereignisse", - noEvents: "Keine Ereignisse" + noEvents: "Keine Ereignisse", + eventNext: "Als n\xE4chstes" } } }, @@ -1000,7 +1003,8 @@ monthInputPlaceholder: "01", searchEventsHeadline: "Buscar Eventos", events: "Eventos", - noEvents: "No hay eventos" + noEvents: "No hay eventos", + eventNext: "A continuaci\xF3n" } } } @@ -1055,6 +1059,13 @@ function createTimestamp() { return (/* @__PURE__ */ new Date()).toISOString(); } + function formatISO(date) { + return date.toISOString().split("T")[0]; + } + function formatTime(date) { + const time = [date.getHours(), date.getMinutes()]; + return time.join(":"); + } function checkDoesObjectMatchSearch(query, getStringsOfObject, object) { if (query == "") return true; const stringsInObject = getStringsOfObject(object); @@ -1364,7 +1375,6 @@ if (!(e instanceof KeyboardEvent)) return console.trace("NOT A KEY EVENT"); if (_CoreViewModel.checkIsKeystroke(e) == false) return; - console.log(e.key); e.preventDefault(); const contexts = this.contexts; while (contexts.length > 0) { @@ -1377,14 +1387,16 @@ // CHRON this.chronHandlerManager = new HandlerManager(); this.todayDate = new State(/* @__PURE__ */ new Date()); + this.time = new State("99:99"); this.startChron = () => { - setInterval(this.chronHandlerManager.trigger, 2e3); + setInterval(this.chronHandlerManager.trigger, 1e3); }; this.handleChron = () => { const newDate = /* @__PURE__ */ new Date(); - if (this.unwrappedTodayDate.toDateString() == newDate.toDateString()) - return; - this.todayDate.value = /* @__PURE__ */ new Date(); + if (this.unwrappedTodayDate.toDateString() != newDate.toDateString()) + this.todayDate.value = /* @__PURE__ */ new Date(); + if (formatTime(newDate) != this.time.value) + this.time.value = formatTime(newDate); }; // DRAG & DROP this.draggedObject = new State(void 0); @@ -1430,9 +1442,6 @@ }; this.configureServiceWorker(); this.checkUpdates(); - this.noUpdateAvailable.subscribe(() => { - console.log(this.noUpdateAvailable.value, this.latestVersion.value, this.version.value); - }); this.startChron(); this.chronHandlerManager.setHandler( "core-view-model", @@ -1804,7 +1813,6 @@ this.calculateUsage = () => { this.occupiedSpaceMB.value = this.coreViewModel.storageModel.calculateUsage(); this.maximumSpaceMB.value = this.coreViewModel.storageModel.determineCapacity(); - console.log(this.occupiedSpaceMB.value, this.maximumSpaceMB.value); }; // view this.showStorageModal = () => { @@ -2206,7 +2214,7 @@ }; this.downloadFile = async () => { if (this.cannotExport.value == true) return; - const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0]; + const date = formatISO(/* @__PURE__ */ new Date()); const backup = await this.coreViewModel.fileTransferModel.generateBackup( this.selectedPaths.value.values(), this.exportKey.value @@ -2945,6 +2953,255 @@ boardId: "" }; + // src/ViewModel/Pages/taskContainingPageViewModel.ts + var TaskContainingPageViewModel = class extends Context { + // init + constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, contextDebugDescription) { + super(contextDebugDescription); + this.coreViewModel = coreViewModel2; + this.chatViewModel = chatViewModel; + this.boardsAndTasksModel = boardsAndTasksModel; + // state + this.taskIndexManager = new IndexManager( + (taskViewModel) => taskViewModel.sortingString + ); + this.selectedTaskViewModel = new State(void 0); + this.taskViewModels = new MapState(); + this.taskCategorySuggestions = new ListState(); + this.taskStatusSuggestions = new ListState(); + // methods + this.createTaskFromBoardId = (boardId) => { + const taskFileContent = this.boardsAndTasksModel.createTask(boardId); + const taskViewModel = new TaskViewModel( + this.coreViewModel, + this.chatViewModel, + this.boardsAndTasksModel, + this, + taskFileContent + ); + taskViewModel.open(); + this.updateTaskIndices(); + }; + // view + this.showTask = (taskFileContent) => { + }; + this.removeTaskFromView = (taskFileContent) => { + }; + this.selectTask = (selectedTask) => { + this.selectedTaskViewModel.value = selectedTask; + }; + this.closeTask = () => { + this.selectedTaskViewModel.value = void 0; + }; + this.updateTaskIndices = () => { + this.taskIndexManager.update([...this.taskViewModels.value.values()]); + for (const taskViewModel of this.taskViewModels.value.values()) { + taskViewModel.updateIndex(); + } + }; + } + }; + + // src/ViewModel/Pages/calendarPageViewModel.ts + var CALENDAR_EVENT_BOARD_ID = "events"; + var CalendarPageViewModel = class extends TaskContainingPageViewModel { + // init + constructor(coreViewModel2, chatViewModel, calendarModel, boardsAndTasksModel) { + super(coreViewModel2, chatViewModel, boardsAndTasksModel, "calendar"); + this.coreViewModel = coreViewModel2; + this.chatViewModel = chatViewModel; + this.calendarModel = calendarModel; + this.boardsAndTasksModel = boardsAndTasksModel; + // paths + this.getBasePath = () => { + return [...this.calendarModel.getViewPath()]; + }; + // state + this.currentTodayDate = void 0; + this.selectedYear = new State(0); + this.selectedMonth = new State(0); + this.selectedDate = new State(0); + this.monthGrid = new State(void 0); + this.nextTask = new State(void 0); + // methods + this.createEvent = () => { + const taskFileContent = this.boardsAndTasksModel.createTask(CALENDAR_EVENT_BOARD_ID); + taskFileContent.date = CalendarModel.getISODateString( + this.selectedYear.value.toString(), + this.selectedMonth.value.toString(), + this.selectedDate.value.toString() + ); + const taskViewModel = new TaskViewModel( + this.coreViewModel, + this.chatViewModel, + this.boardsAndTasksModel, + this, + taskFileContent + ); + taskViewModel.open(); + this.updateTaskIndices(); + }; + this.getEventsForDate = () => { + const paddedDate = CalendarModel.padDateOrMonth( + this.selectedDate.toString() + ); + if (this.monthGrid.value == void 0) { + return void 0; + } + return this.monthGrid.value.days[paddedDate]; + }; + // view + this.getTaskMapState = (taskFileContent) => { + if (this.monthGrid.value == null) return null; + const date = CalendarModel.isoToDateString( + taskFileContent.date ?? "" + ); + return this.monthGrid.value.days[date]; + }; + this.showTask = (taskFileContent) => { + const monthString = CalendarModel.isoToMonthString( + taskFileContent.date ?? "" + ); + if (monthString == void 0 || monthString != this.monthString) { + this.removeTaskFromView(taskFileContent); + this.calendarModel.deleteTaskReference( + this.monthString, + taskFileContent.fileId + ); + return; + } + const taskViewModel = new TaskViewModel( + this.coreViewModel, + this.chatViewModel, + this.boardsAndTasksModel, + this, + taskFileContent + ); + const mapState = this.getTaskMapState(taskFileContent); + this.taskViewModels.handleRemoval(taskViewModel, () => { + mapState?.remove(taskFileContent.fileId); + }); + this.taskViewModels.remove(taskFileContent.fileId); + this.taskViewModels.set(taskFileContent.fileId, taskViewModel); + mapState?.set(taskFileContent.fileId, taskViewModel); + this.updateTaskIndices(); + }; + this.removeTaskFromView = (taskFileContent) => { + this.taskViewModels.remove(taskFileContent.fileId); + }; + this.showToday = () => { + const today = this.coreViewModel.todayDate.value; + this.selectedYear.value = today.getFullYear(); + this.selectedMonth.value = today.getMonth() + 1; + this.selectedDate.value = today.getDate(); + }; + this.showPreviousMonth = () => { + this.selectedMonth.value -= 1; + if (this.selectedMonth.value <= 0) { + this.selectedYear.value -= 1; + this.selectedMonth.value = 12; + } + }; + this.showNextMonth = () => { + this.selectedMonth.value += 1; + if (this.selectedMonth.value >= 13) { + this.selectedYear.value += 1; + this.selectedMonth.value = 1; + } + }; + this.handleDrop = (year, month, date) => { + const ISOString = CalendarModel.getISODateString( + year, + month, + date + ); + const draggedObject = this.coreViewModel.draggedObject.value; + if (draggedObject instanceof TaskViewModel == false) return; + draggedObject.setDate(ISOString); + }; + this.handleChron = () => { + this.updateMonthGrid(); + this.updateNextTask(); + }; + this.updateMonthGrid = () => { + const today = formatISO(this.coreViewModel.todayDate.value); + if (this.currentTodayDate == today) + return; + this.loadMonthTasks(); + this.currentTodayDate = today; + this.selectedDate.callSubscriptions(); + }; + this.updateNextTask = () => { + if (this.selectedDateString != this.currentTodayDate) { + this.nextTask.value = void 0; + return; + } + const tasks = this.getEventsForDate(); + if (tasks == void 0) return; + for (const task of [...tasks.value.values()]) { + if (task.time.value <= this.coreViewModel.time.value) continue; + this.nextTask.value = task; + break; + } + ; + }; + // load + this.loadMonthTasks = () => { + this.monthGrid.value = this.calendarModel.generateMonthGrid( + this.coreViewModel, + 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); + } + }; + this.loadData = () => { + }; + this.calendarModel = calendarModel; + this.boardsAndTasksModel = boardsAndTasksModel; + this.chatViewModel = chatViewModel; + bulkSubscribe([this.selectedYear, this.selectedMonth], () => { + this.loadMonthTasks(); + }); + this.selectedDate.subscribeSilent(() => { + this.updateNextTask(); + }); + boardsAndTasksModel.taskHandlerManager.setHandler( + "calendar" + this.chatViewModel.chatModel.id, + (taskFileContent) => { + this.showTask(taskFileContent); + } + ); + this.coreViewModel.chronHandlerManager.setHandler( + `calendar-${this.chatViewModel.chatModel.id}`, + this.handleChron + ); + this.showToday(); + this.registerKeyStroke("-" /* Reset */, this.showToday); + this.registerKeyStroke("k", this.showPreviousMonth); + this.registerKeyStroke("l", this.showNextMonth); + this.registerKeyStroke("a" /* Create */, this.createEvent); + this.chatViewModel.registerContext("calendar" /* Calendar */, this); + } + // data + get monthString() { + return CalendarModel.getMonthString( + this.selectedYear.value.toString(), + this.selectedMonth.value.toString() + ); + } + get selectedDateString() { + return [this.selectedYear.value, this.selectedMonth.value, this.selectedDate.value].map((x, i) => i == 0 ? x : CalendarModel.padDateOrMonth(x.toString())).join("-"); + } + }; + // src/ViewModel/Pages/taskViewModel.ts var TaskViewModel = class extends Context { // init @@ -2969,6 +3226,7 @@ this.priority = new State(""); this.date = new State(""); this.time = new State(""); + this.isNotNext = new State(true); this.selectedVersionId = new State(""); this.versionIds = new ListState(); this.isPresentingFullScreenDescription = new State( @@ -3077,6 +3335,11 @@ this.loadAllData = () => { this.loadTaskData(); this.loadVersionIds(); + if (this.containingViewModel instanceof CalendarPageViewModel) { + this.containingViewModel.nextTask.subscribe((nextTask) => { + this.isNotNext.value = nextTask != this; + }); + } }; this.loadTaskData = () => { this.boardId.value = this.task.boardId; @@ -3131,55 +3394,6 @@ } }; - // src/ViewModel/Pages/taskContainingPageViewModel.ts - var TaskContainingPageViewModel = class extends Context { - // init - constructor(coreViewModel2, chatViewModel, boardsAndTasksModel, contextDebugDescription) { - super(contextDebugDescription); - this.coreViewModel = coreViewModel2; - this.chatViewModel = chatViewModel; - this.boardsAndTasksModel = boardsAndTasksModel; - // state - this.taskIndexManager = new IndexManager( - (taskViewModel) => taskViewModel.sortingString - ); - this.selectedTaskViewModel = new State(void 0); - this.taskViewModels = new MapState(); - this.taskCategorySuggestions = new ListState(); - this.taskStatusSuggestions = new ListState(); - // methods - this.createTaskFromBoardId = (boardId) => { - const taskFileContent = this.boardsAndTasksModel.createTask(boardId); - const taskViewModel = new TaskViewModel( - this.coreViewModel, - this.chatViewModel, - this.boardsAndTasksModel, - this, - taskFileContent - ); - taskViewModel.open(); - this.updateTaskIndices(); - }; - // view - this.showTask = (taskFileContent) => { - }; - this.removeTaskFromView = (taskFileContent) => { - }; - this.selectTask = (selectedTask) => { - this.selectedTaskViewModel.value = selectedTask; - }; - this.closeTask = () => { - this.selectedTaskViewModel.value = void 0; - }; - this.updateTaskIndices = () => { - this.taskIndexManager.update([...this.taskViewModels.value.values()]); - for (const taskViewModel of this.taskViewModels.value.values()) { - taskViewModel.updateIndex(); - } - }; - } - }; - // src/ViewModel/Utility/searchViewModel.ts var SearchViewModel = class { // init @@ -3365,7 +3579,6 @@ this, taskFileContent ); - console.log("STILL HERE", taskFileContent.fileId); this.taskViewModels.set(taskFileContent.fileId, taskViewModel); }; this.removeTaskFromView = (taskFileContent) => { @@ -4525,180 +4738,6 @@ } }; - // src/ViewModel/Pages/calendarPageViewModel.ts - var CALENDAR_EVENT_BOARD_ID = "events"; - var CalendarPageViewModel = class extends TaskContainingPageViewModel { - // init - constructor(coreViewModel2, chatViewModel, calendarModel, boardsAndTasksModel) { - super(coreViewModel2, chatViewModel, boardsAndTasksModel, "calendar"); - this.coreViewModel = coreViewModel2; - this.chatViewModel = chatViewModel; - this.calendarModel = calendarModel; - this.boardsAndTasksModel = boardsAndTasksModel; - // paths - this.getBasePath = () => { - return [...this.calendarModel.getViewPath()]; - }; - // state - this.currentTodayDate = void 0; - this.selectedYear = new State(0); - this.selectedMonth = new State(0); - this.selectedDate = new State(0); - this.monthGrid = new State(void 0); - // methods - this.createEvent = () => { - const taskFileContent = this.boardsAndTasksModel.createTask(CALENDAR_EVENT_BOARD_ID); - taskFileContent.date = CalendarModel.getISODateString( - this.selectedYear.value.toString(), - this.selectedMonth.value.toString(), - this.selectedDate.value.toString() - ); - const taskViewModel = new TaskViewModel( - this.coreViewModel, - this.chatViewModel, - this.boardsAndTasksModel, - this, - taskFileContent - ); - taskViewModel.open(); - this.updateTaskIndices(); - }; - this.getEventsForDate = () => { - const paddedDate = CalendarModel.padDateOrMonth( - this.selectedDate.toString() - ); - if (this.monthGrid.value == void 0) { - return void 0; - } - return this.monthGrid.value.days[paddedDate]; - }; - // view - this.getTaskMapState = (taskFileContent) => { - if (this.monthGrid.value == null) return null; - const date = CalendarModel.isoToDateString( - taskFileContent.date ?? "" - ); - return this.monthGrid.value.days[date]; - }; - this.showTask = (taskFileContent) => { - const monthString = CalendarModel.isoToMonthString( - taskFileContent.date ?? "" - ); - if (monthString == void 0 || monthString != this.monthString) { - this.removeTaskFromView(taskFileContent); - this.calendarModel.deleteTaskReference( - this.monthString, - taskFileContent.fileId - ); - return; - } - const taskViewModel = new TaskViewModel( - this.coreViewModel, - this.chatViewModel, - this.boardsAndTasksModel, - this, - taskFileContent - ); - const mapState = this.getTaskMapState(taskFileContent); - this.taskViewModels.handleRemoval(taskViewModel, () => { - mapState?.remove(taskFileContent.fileId); - }); - this.taskViewModels.remove(taskFileContent.fileId); - this.taskViewModels.set(taskFileContent.fileId, taskViewModel); - mapState?.set(taskFileContent.fileId, taskViewModel); - this.updateTaskIndices(); - }; - this.removeTaskFromView = (taskFileContent) => { - this.taskViewModels.remove(taskFileContent.fileId); - }; - this.showToday = () => { - const today = this.coreViewModel.todayDate.value; - this.selectedYear.value = today.getFullYear(); - this.selectedMonth.value = today.getMonth() + 1; - this.selectedDate.value = today.getDate(); - }; - this.showPreviousMonth = () => { - this.selectedMonth.value -= 1; - if (this.selectedMonth.value <= 0) { - this.selectedYear.value -= 1; - this.selectedMonth.value = 12; - } - }; - this.showNextMonth = () => { - this.selectedMonth.value += 1; - if (this.selectedMonth.value >= 13) { - this.selectedYear.value += 1; - this.selectedMonth.value = 1; - } - }; - this.handleDrop = (year, month, date) => { - const ISOString = CalendarModel.getISODateString( - year, - month, - date - ); - const draggedObject = this.coreViewModel.draggedObject.value; - if (draggedObject instanceof TaskViewModel == false) return; - draggedObject.setDate(ISOString); - }; - this.updateMonthGrid = () => { - if (this.currentTodayDate == this.coreViewModel.todayDate.value.toISOString()) - return; - this.loadMonthTasks(); - this.currentTodayDate = this.coreViewModel.todayDate.value.toISOString(); - }; - // load - this.loadMonthTasks = () => { - this.monthGrid.value = this.calendarModel.generateMonthGrid( - this.coreViewModel, - 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); - } - }; - this.loadData = () => { - this.loadMonthTasks(); - }; - this.calendarModel = calendarModel; - this.boardsAndTasksModel = boardsAndTasksModel; - this.chatViewModel = chatViewModel; - bulkSubscribe([this.selectedYear, this.selectedMonth], () => { - this.loadMonthTasks(); - }); - boardsAndTasksModel.taskHandlerManager.setHandler( - "calendar" + this.chatViewModel.chatModel.id, - (taskFileContent) => { - this.showTask(taskFileContent); - } - ); - this.coreViewModel.chronHandlerManager.setHandler( - `calendar-${this.chatViewModel.chatModel.id}`, - this.updateMonthGrid - ); - this.showToday(); - this.registerKeyStroke("-" /* Reset */, this.showToday); - this.registerKeyStroke("k", this.showPreviousMonth); - this.registerKeyStroke("l", this.showNextMonth); - this.registerKeyStroke("a" /* Create */, this.createEvent); - this.chatViewModel.registerContext("calendar" /* Calendar */, this); - } - // data - get monthString() { - return CalendarModel.getMonthString( - this.selectedYear.value.toString(), - this.selectedMonth.value.toString() - ); - } - }; - // src/ViewModel/Chat/chatViewModel.ts var ChatViewModel6 = class extends ContextHost { // init @@ -4881,7 +4920,6 @@ }; this.openNotification = () => { const notification = this.marquee.value; - console.log(notification); if (notification == void 0) return; const chat = [ ...this.chatListViewModel.chatViewModels.value.values() @@ -5238,16 +5276,28 @@ calendar_month: taskViewModel.date.value || "---", schedule: taskViewModel.time.value || "---" }; + const className = createProxyState( + [taskViewModel.isNotNext], + () => `${taskViewModel.isNotNext.value ? "standard" : "primary"} tile flex-no` + ); const view = /* @__PURE__ */ createElement( "button", { draggable: "true", - class: "tile flex-no", + "set:class": className, style: "user-select: none; -webkit-user-select: none", "on:click": taskViewModel.open, "on:dragstart": taskViewModel.dragStart }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement( + "span", + { + class: "secondary", + "toggle:hidden": taskViewModel.isNotNext + }, + taskViewModel.coreViewModel.translations.chatPage.calendar.eventNext, + /* @__PURE__ */ createElement("hr", null) + ), /* @__PURE__ */ createElement( "b", { class: "ellipsis", @@ -6867,7 +6917,6 @@ calendarPageViewModel.selectedDate ], () => { - console.log(calendarPageViewModel.selectedDate.value); const listState = calendarPageViewModel.getEventsForDate(); if (listState == void 0) { return /* @__PURE__ */ createElement("div", null); diff --git a/dist/styles.css b/dist/styles.css index a54c3d19..7e429b8f 100644 --- a/dist/styles.css +++ b/dist/styles.css @@ -151,7 +151,7 @@ a { } .background-primary { - background: var(--primary); + background: var(--primary) !important; } /* text */ @@ -641,6 +641,19 @@ input[type="radio"] { padding: 0px; } +.padding-top-0 { + padding-top: 0 !important; +} +.padding-left-0 { + padding-left: 0 !important; +} +.padding-right-0 { + padding-right: 0 !important; +} +.padding-bottom-0 { + padding-bottom: 0 !important; +} + .padding-0 { padding: 0 !important; } diff --git a/dist/sw.js b/dist/sw.js index 1b77a135..7d282114 100644 --- a/dist/sw.js +++ b/dist/sw.js @@ -1,4 +1,4 @@ -const VERSION = "2610 Beta 5.4" +const VERSION = "2610 Beta 6" function processUrl(event) { const url = event.request.url; diff --git a/dist/version.txt b/dist/version.txt index 9f6583f0..d0eb5093 100644 --- a/dist/version.txt +++ b/dist/version.txt @@ -1 +1 @@ -2610 Beta 5.4 +2610 Beta 6 diff --git a/src/Model/Utility/utility.ts b/src/Model/Utility/utility.ts index 2cc93fdb..ce39b974 100644 --- a/src/Model/Utility/utility.ts +++ b/src/Model/Utility/utility.ts @@ -18,6 +18,10 @@ export function createTimestamp(): string { return new Date().toISOString(); } +export function formatISO(date: Date): string { + return date.toISOString().split("T")[0]; +} + export function formatTime(date: Date): string { const time = [date.getHours(), date.getMinutes()]; return time.join(":"); diff --git a/src/View/ChatPages/calendarPage.tsx b/src/View/ChatPages/calendarPage.tsx index ddbc82f3..44aa1d14 100644 --- a/src/View/ChatPages/calendarPage.tsx +++ b/src/View/ChatPages/calendarPage.tsx @@ -47,7 +47,6 @@ export function CalendarPage( calendarPageViewModel.selectedDate, ], () => { - console.log(calendarPageViewModel.selectedDate.value); const listState = calendarPageViewModel.getEventsForDate(); if (listState == undefined) { diff --git a/src/View/Components/taskEntry.tsx b/src/View/Components/taskEntry.tsx index 87104119..f5ae2685 100644 --- a/src/View/Components/taskEntry.tsx +++ b/src/View/Components/taskEntry.tsx @@ -11,45 +11,56 @@ export function TaskEntry(taskViewModel: TaskViewModel) { schedule: taskViewModel.time.value || "---", }; + const className = React.createProxyState([taskViewModel.isNotNext], ()=> + `${taskViewModel.isNotNext.value ? "standard" : "primary"} tile flex-no` + ) + const view = ( - ); + > +
+ + {taskViewModel.coreViewModel.translations.chatPage.calendar.eventNext} +
+
+ +
+
+ {...Object.entries(details).map((entry) => ( + + + {entry[0]} + + {entry[1]} + + ))} +
+
+ +); - taskViewModel.index.subscribe((newIndex) => { - view.style.order = newIndex; - }); +taskViewModel.index.subscribe((newIndex) => { + view.style.order = newIndex; +}); - return view; +return view; } export const TaskViewModelToEntry: React.StateItemConverter = ( diff --git a/src/View/translations.ts b/src/View/translations.ts index 583e7602..4d86bc8d 100644 --- a/src/View/translations.ts +++ b/src/View/translations.ts @@ -338,6 +338,10 @@ const englishTranslations = { events: "Events", noEvents: "No events", + + // + + eventNext: "Up next", }, }, }; @@ -657,6 +661,8 @@ export const allTranslations: { events: "Ereignisse", noEvents: "Keine Ereignisse", + + eventNext: "Als nächstes", }, }, }, @@ -971,6 +977,8 @@ export const allTranslations: { events: "Eventos", noEvents: "No hay eventos", + + eventNext: "A continuación", }, }, }, diff --git a/src/ViewModel/Global/coreViewModel.ts b/src/ViewModel/Global/coreViewModel.ts index df12dc57..30fe454e 100644 --- a/src/ViewModel/Global/coreViewModel.ts +++ b/src/ViewModel/Global/coreViewModel.ts @@ -59,7 +59,6 @@ export default class CoreViewModel { if (!(e instanceof KeyboardEvent)) return console.trace("NOT A KEY EVENT"); if (CoreViewModel.checkIsKeystroke(e) == false) return; - console.log(e.key); e.preventDefault(); const contexts: Context[] = this.contexts; while (contexts.length > 0) { @@ -73,24 +72,21 @@ export default class CoreViewModel { // CHRON chronHandlerManager = new HandlerManager(); todayDate = new React.State(new Date()); - time = new React.State<[number, number]>([0, 0]); + time = new React.State("99:99"); get unwrappedTodayDate(): Date { return new Date(this.todayDate.value); } - get timeString(): string { - return this.time.value.join(":"); - } startChron = (): void => { - setInterval(this.chronHandlerManager.trigger, 2000); + setInterval(this.chronHandlerManager.trigger, 1000); }; handleChron = (): void => { const newDate = new Date(); if (this.unwrappedTodayDate.toDateString() != newDate.toDateString()) this.todayDate.value = new Date(); - if (formatTime(newDate) != this.timeString) - this.time.value = [newDate.getHours(), newDate.getMinutes()]; + if (formatTime(newDate) != this.time.value) + this.time.value = formatTime(newDate); }; // DRAG & DROP @@ -154,9 +150,6 @@ export default class CoreViewModel { this.configureServiceWorker(); this.checkUpdates(); - this.noUpdateAvailable.subscribe(() => { - console.log(this.noUpdateAvailable.value, this.latestVersion.value, this.version.value); - }) this.startChron(); this.chronHandlerManager.setHandler( diff --git a/src/ViewModel/Global/fileTransferViewModel.ts b/src/ViewModel/Global/fileTransferViewModel.ts index 10919ce1..644b92ff 100644 --- a/src/ViewModel/Global/fileTransferViewModel.ts +++ b/src/ViewModel/Global/fileTransferViewModel.ts @@ -7,6 +7,7 @@ import StorageModel, { } from "../../Model/Global/storageModel"; import { TransferData } from "../../Model/Global/fileTransferModel"; import ChatModel from "../../Model/Chat/chatModel"; +import {formatISO} from "../../Model/Utility/utility"; export default class FileTransferViewModel extends Context { // state @@ -142,7 +143,7 @@ export default class FileTransferViewModel extends Context { downloadFile = async (): Promise => { if (this.cannotExport.value == true) return; - const date = new Date().toISOString().split("T")[0]; + const date = formatISO(new Date()); const backup: Blob = await this.coreViewModel.fileTransferModel.generateBackup( diff --git a/src/ViewModel/Global/notificationViewModel.ts b/src/ViewModel/Global/notificationViewModel.ts index f2efc305..8312bdf5 100644 --- a/src/ViewModel/Global/notificationViewModel.ts +++ b/src/ViewModel/Global/notificationViewModel.ts @@ -35,7 +35,6 @@ export default class NotificationViewModel { openNotification = () => { const notification: Notification | undefined = this.marquee.value; - console.log(notification); if (notification == undefined) return; const chat = [ diff --git a/src/ViewModel/Global/storageViewModel.ts b/src/ViewModel/Global/storageViewModel.ts index ba31d44d..b5f10db4 100644 --- a/src/ViewModel/Global/storageViewModel.ts +++ b/src/ViewModel/Global/storageViewModel.ts @@ -52,7 +52,6 @@ export default class StorageViewModel extends Context { calculateUsage = (): void => { this.occupiedSpaceMB.value = this.coreViewModel.storageModel.calculateUsage(); this.maximumSpaceMB.value = this.coreViewModel.storageModel.determineCapacity(); - console.log(this.occupiedSpaceMB.value, this.maximumSpaceMB.value); } // view diff --git a/src/ViewModel/Pages/boardViewModel.ts b/src/ViewModel/Pages/boardViewModel.ts index f5eb2cb6..cb49edd6 100644 --- a/src/ViewModel/Pages/boardViewModel.ts +++ b/src/ViewModel/Pages/boardViewModel.ts @@ -153,7 +153,6 @@ export default class BoardViewModel extends TaskContainingPageViewModel { this, taskFileContent, ); - console.log("STILL HERE", taskFileContent.fileId); this.taskViewModels.set(taskFileContent.fileId, taskViewModel); }; diff --git a/src/ViewModel/Pages/calendarPageViewModel.ts b/src/ViewModel/Pages/calendarPageViewModel.ts index 539cf1cf..b667dc43 100644 --- a/src/ViewModel/Pages/calendarPageViewModel.ts +++ b/src/ViewModel/Pages/calendarPageViewModel.ts @@ -8,6 +8,7 @@ import CalendarModel, { MonthGrid } from "../../Model/Files/calendarModel"; import BoardsAndTasksModel, { TaskFileContent, } from "../../Model/Files/boardsAndTasksModel"; +import {formatISO, formatTime} from "../../Model/Utility/utility"; export const CALENDAR_EVENT_BOARD_ID = "events"; @@ -20,6 +21,12 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel { ); } + get selectedDateString(): string { + return [this.selectedYear.value, this.selectedMonth.value, this.selectedDate.value] + .map((x, i) => i == 0 ? x : CalendarModel.padDateOrMonth(x.toString())) + .join("-"); + } + // paths getBasePath = (): string[] => { return [...this.calendarModel.getViewPath()]; @@ -34,6 +41,8 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel { monthGrid: React.State< MonthGrid> | undefined > = new React.State(undefined); + + nextTask: React.State = new React.State(undefined); // methods createEvent = (): void => { @@ -157,17 +166,37 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel { draggedObject.setDate(ISOString); }; + handleChron = (): void => { + this.updateMonthGrid(); + this.updateNextTask(); + } + updateMonthGrid = (): void => { + const today = formatISO(this.coreViewModel.todayDate.value) if ( - this.currentTodayDate == - this.coreViewModel.todayDate.value.toISOString() + this.currentTodayDate == today ) return; this.loadMonthTasks(); - this.currentTodayDate = - this.coreViewModel.todayDate.value.toISOString(); + this.currentTodayDate = today; + this.selectedDate.callSubscriptions(); }; + updateNextTask = (): void => { + if (this.selectedDateString != this.currentTodayDate) { + this.nextTask.value = undefined; + return; + } + + const tasks = this.getEventsForDate(); + if (tasks == undefined) return; + for (const task of [...tasks.value.values()]) { + if (task.time.value <= this.coreViewModel.time.value) continue; + this.nextTask.value = task; + break; + }; + } + // load loadMonthTasks = (): void => { this.monthGrid.value = this.calendarModel.generateMonthGrid( @@ -189,7 +218,6 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel { }; loadData = (): void => { - this.loadMonthTasks(); }; // init @@ -209,6 +237,9 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel { React.bulkSubscribe([this.selectedYear, this.selectedMonth], () => { this.loadMonthTasks(); }); + this.selectedDate.subscribeSilent(()=>{ + this.updateNextTask(); + }) // handlers boardsAndTasksModel.taskHandlerManager.setHandler( @@ -219,7 +250,7 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel { ); this.coreViewModel.chronHandlerManager.setHandler( `calendar-${this.chatViewModel.chatModel.id}`, - this.updateMonthGrid, + this.handleChron, ); // initiate diff --git a/src/ViewModel/Pages/taskViewModel.ts b/src/ViewModel/Pages/taskViewModel.ts index 7dd47052..f7d80af4 100644 --- a/src/ViewModel/Pages/taskViewModel.ts +++ b/src/ViewModel/Pages/taskViewModel.ts @@ -8,6 +8,7 @@ import { localeCompare, padZero } from "../../Model/Utility/utility"; import BoardsAndTasksModel, { TaskFileContent, } from "../../Model/Files/boardsAndTasksModel"; +import CalendarPageViewModel from "./calendarPageViewModel"; export default class TaskViewModel extends Context { // util @@ -55,6 +56,8 @@ export default class TaskViewModel extends Context { date: React.State = new React.State(""); time: React.State = new React.State(""); + isNotNext: React.State = new React.State(true); + selectedVersionId: React.State = new React.State(""); versionIds: React.ListState = new React.ListState(); @@ -196,6 +199,12 @@ export default class TaskViewModel extends Context { loadAllData = (): void => { this.loadTaskData(); this.loadVersionIds(); + + if (this.containingViewModel instanceof CalendarPageViewModel) { + this.containingViewModel.nextTask.subscribe((nextTask)=>{ + this.isNotNext.value = nextTask != this; + }) + } }; loadTaskData = (): void => {