add more object content fields

This commit is contained in:
marlon-erler
2024-07-11 21:30:57 +02:00
parent 990f115463
commit 9a312780d1
4 changed files with 125 additions and 12 deletions
+46 -7
View File
@@ -492,8 +492,14 @@
objectTitle: "Object title", objectTitle: "Object title",
objectTitlePlaceholder: "My object", objectTitlePlaceholder: "My object",
objectVersion: "Object version", objectVersion: "Object version",
noteContent: "Note", note: "Note",
noteContentPlaceholder: "Take a note...", noteContentPlaceholder: "Take a note...",
category: "Category",
priority: "Priority",
priorityPlaceholder: "2",
categoryPlaceholder: "Define a category",
date: "Date",
time: "Time",
resendObjects: "Resend all objects", resendObjects: "Resend all objects",
deleteObject: "Delete object" deleteObject: "Delete object"
}; };
@@ -572,7 +578,7 @@
objectTitle: "T\xEDtulo", objectTitle: "T\xEDtulo",
objectTitlePlaceholder: "Mi objeto", objectTitlePlaceholder: "Mi objeto",
objectVersion: "Version del objeto", objectVersion: "Version del objeto",
noteContent: "Nota", note: "Nota",
noteContentPlaceholder: "Toma nota...", noteContentPlaceholder: "Toma nota...",
resendObjects: "Reenviar todos objetos", resendObjects: "Reenviar todos objetos",
deleteObject: "Eliminar objeto" deleteObject: "Eliminar objeto"
@@ -650,7 +656,7 @@
objectTitle: "Titel", objectTitle: "Titel",
objectTitlePlaceholder: "Mein Objekt", objectTitlePlaceholder: "Mein Objekt",
objectVersion: "Version des Objekts", objectVersion: "Version des Objekts",
noteContent: "Notiz", note: "Notiz",
noteContentPlaceholder: "Notiz eingeben...", noteContentPlaceholder: "Notiz eingeben...",
resendObjects: "Objekte erneut senden", resendObjects: "Objekte erneut senden",
deleteObject: "Objekt l\xF6schen" deleteObject: "Objekt l\xF6schen"
@@ -1298,8 +1304,24 @@
[selectedMessageObject], [selectedMessageObject],
() => selectedMessageObject.value.noteContent ?? "" () => selectedMessageObject.value.noteContent ?? ""
); );
const editingCategory = createProxyState(
[selectedMessageObject],
() => selectedMessageObject.value.categoryName ?? ""
);
const editingDate = createProxyState(
[selectedMessageObject],
() => selectedMessageObject.value.isoDate ?? (/* @__PURE__ */ new Date()).toISOString()
);
const editingTime = createProxyState(
[selectedMessageObject],
() => selectedMessageObject.value.isoTime ?? (/* @__PURE__ */ new Date()).toISOString()
);
const editingPriority = createProxyState(
[selectedMessageObject],
() => selectedMessageObject.value.priority ?? 0
);
bulkSubscribe( bulkSubscribe(
[editingNoteContent], [editingNoteContent, editingCategory, editingDate, editingPriority],
() => didEditContent.value = true () => didEditContent.value = true
); );
function handleKeyDown(e) { function handleKeyDown(e) {
@@ -1320,7 +1342,11 @@
chat.addObjectContent(messageObject, { chat.addObjectContent(messageObject, {
isoDateVersionCreated: (/* @__PURE__ */ new Date()).toISOString(), isoDateVersionCreated: (/* @__PURE__ */ new Date()).toISOString(),
id: UUID(), id: UUID(),
noteContent: editingNoteContent.value noteContent: editingNoteContent.value,
priority: editingPriority.value,
categoryName: editingCategory.value,
isoDate: editingDate.value,
isoTime: editingTime.value
}); });
} }
chat.addObjectAndSend(messageObject); chat.addObjectAndSend(messageObject);
@@ -1340,14 +1366,27 @@
isPresented.subscribe(() => setTimeout(() => input.focus(), 100)); isPresented.subscribe(() => setTimeout(() => input.focus(), 100));
return /* @__PURE__ */ createElement("div", { class: "modal", "toggle:open": isPresented, "on:keydown": handleKeyDown }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("main", null, /* @__PURE__ */ createElement("h2", null, chat.getObjectTitle(messageObject)), /* @__PURE__ */ createElement("span", { class: "secondary" }, messageObject.id), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "label"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.objectTitle), input)), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "history"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.objectVersion), /* @__PURE__ */ createElement("select", { "bind:value": selectedMessageObjectId }, ...chat.getSortedContents(messageObject).map((content) => /* @__PURE__ */ createElement("option", { value: content.id }, new Date( return /* @__PURE__ */ createElement("div", { class: "modal", "toggle:open": isPresented, "on:keydown": handleKeyDown }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("main", null, /* @__PURE__ */ createElement("h2", null, chat.getObjectTitle(messageObject)), /* @__PURE__ */ createElement("span", { class: "secondary" }, messageObject.id), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "label"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.objectTitle), input)), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "history"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.objectVersion), /* @__PURE__ */ createElement("select", { "bind:value": selectedMessageObjectId }, ...chat.getSortedContents(messageObject).map((content) => /* @__PURE__ */ createElement("option", { value: content.id }, new Date(
content.isoDateVersionCreated content.isoDateVersionCreated
).toLocaleString()))), /* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_drop_down"))), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "sticky_note_2"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.noteContent), /* @__PURE__ */ createElement( ).toLocaleString()))), /* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_drop_down"))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "sticky_note_2"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.note), /* @__PURE__ */ createElement(
"textarea", "textarea",
{ {
rows: "5", rows: "5",
"bind:value": editingNoteContent, "bind:value": editingNoteContent,
placeholder: translation.noteContentPlaceholder placeholder: translation.noteContentPlaceholder
} }
))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("button", { class: "danger width-input", "on:click": deleteAndClose }, translation.deleteObject, /* @__PURE__ */ createElement("span", { class: "icon" }, "delete")))), /* @__PURE__ */ createElement("div", { class: "flex-row" }, /* @__PURE__ */ createElement("button", { class: "flex-1 width-100 danger", "on:click": closeModal }, translation.discard), /* @__PURE__ */ createElement("button", { class: "flex-1 width-100 primary", "on:click": saveAndClose }, translation.save, /* @__PURE__ */ createElement("span", { class: "icon" }, "save"))))); ))), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "category"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.category), /* @__PURE__ */ createElement(
"input",
{
"bind:value": editingCategory,
placeholder: translation.categoryPlaceholder
}
))), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "priority_high"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.priority), /* @__PURE__ */ createElement(
"input",
{
type: "number",
"bind:value": editingPriority,
placeholder: translation.priorityPlaceholder
}
))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "calendar_month"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.date), /* @__PURE__ */ createElement("input", { type: "date", "bind:value": editingDate }))), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "schedule"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.time), /* @__PURE__ */ createElement("input", { type: "time", "bind:value": editingTime }))), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("button", { class: "danger width-input", "on:click": deleteAndClose }, translation.deleteObject, /* @__PURE__ */ createElement("span", { class: "icon" }, "delete")))), /* @__PURE__ */ createElement("div", { class: "flex-row" }, /* @__PURE__ */ createElement("button", { class: "flex-1 width-100 danger", "on:click": closeModal }, translation.discard), /* @__PURE__ */ createElement("button", { class: "flex-1 width-100 primary", "on:click": saveAndClose }, translation.save, /* @__PURE__ */ createElement("span", { class: "icon" }, "save")))));
} }
// src/Views/Objects/chatObjectView.tsx // src/Views/Objects/chatObjectView.tsx
+4
View File
@@ -39,6 +39,10 @@ export interface MessageObjectContent {
id: string; id: string;
noteContent?: string; noteContent?: string;
categoryName?: string;
isoDate?: string;
isoTime?: string;
priority?: number;
} }
// chat // chat
+66 -2
View File
@@ -21,13 +21,30 @@ export function ObjectDetailModal(
chat.getObjectContentFromId(messageObject, selectedMessageObjectId.value) chat.getObjectContentFromId(messageObject, selectedMessageObjectId.value)
); );
// properties
const didEditContent = new React.State(false); const didEditContent = new React.State(false);
const editingNoteContent = React.createProxyState( const editingNoteContent = React.createProxyState(
[selectedMessageObject], [selectedMessageObject],
() => selectedMessageObject.value.noteContent ?? "" () => selectedMessageObject.value.noteContent ?? ""
); );
const editingCategory = React.createProxyState(
[selectedMessageObject],
() => selectedMessageObject.value.categoryName ?? ""
);
const editingDate = React.createProxyState(
[selectedMessageObject],
() => selectedMessageObject.value.isoDate ?? new Date().toISOString()
);
const editingTime = React.createProxyState(
[selectedMessageObject],
() => selectedMessageObject.value.isoTime ?? new Date().toISOString()
);
const editingPriority = React.createProxyState(
[selectedMessageObject],
() => selectedMessageObject.value.priority ?? 0
);
React.bulkSubscribe( React.bulkSubscribe(
[editingNoteContent], [editingNoteContent, editingCategory, editingDate, editingPriority],
() => (didEditContent.value = true) () => (didEditContent.value = true)
); );
@@ -56,6 +73,10 @@ export function ObjectDetailModal(
id: React.UUID(), id: React.UUID(),
noteContent: editingNoteContent.value, noteContent: editingNoteContent.value,
priority: editingPriority.value,
categoryName: editingCategory.value,
isoDate: editingDate.value,
isoTime: editingTime.value,
}); });
} }
@@ -115,10 +136,12 @@ export function ObjectDetailModal(
</div> </div>
</label> </label>
<hr></hr>
<label class="tile"> <label class="tile">
<span class="icon">sticky_note_2</span> <span class="icon">sticky_note_2</span>
<div> <div>
<span>{translation.noteContent}</span> <span>{translation.note}</span>
<textarea <textarea
rows="5" rows="5"
bind:value={editingNoteContent} bind:value={editingNoteContent}
@@ -127,6 +150,47 @@ export function ObjectDetailModal(
</div> </div>
</label> </label>
<label class="tile">
<span class="icon">category</span>
<div>
<span>{translation.category}</span>
<input
bind:value={editingCategory}
placeholder={translation.categoryPlaceholder}
></input>
</div>
</label>
<label class="tile">
<span class="icon">priority_high</span>
<div>
<span>{translation.priority}</span>
<input
type="number"
bind:value={editingPriority}
placeholder={translation.priorityPlaceholder}
></input>
</div>
</label>
<hr></hr>
<label class="tile">
<span class="icon">calendar_month</span>
<div>
<span>{translation.date}</span>
<input type="date" bind:value={editingDate}></input>
</div>
</label>
<label class="tile">
<span class="icon">schedule</span>
<div>
<span>{translation.time}</span>
<input type="time" bind:value={editingTime}></input>
</div>
</label>
<hr></hr> <hr></hr>
<button class="danger width-input" on:click={deleteAndClose}> <button class="danger width-input" on:click={deleteAndClose}>
+9 -3
View File
@@ -96,8 +96,14 @@ const englishTranslations = {
objectTitlePlaceholder: "My object", objectTitlePlaceholder: "My object",
objectVersion: "Object version", objectVersion: "Object version",
noteContent: "Note", note: "Note",
noteContentPlaceholder: "Take a note...", noteContentPlaceholder: "Take a note...",
category: "Category",
priority: "Priority",
priorityPlaceholder: "2",
categoryPlaceholder: "Define a category",
date: "Date",
time: "Time",
resendObjects: "Resend all objects", resendObjects: "Resend all objects",
deleteObject: "Delete object", deleteObject: "Delete object",
@@ -203,7 +209,7 @@ const allTranslations: { [key: string]: typeof englishTranslations } = {
objectTitlePlaceholder: "Mi objeto", objectTitlePlaceholder: "Mi objeto",
objectVersion: "Version del objeto", objectVersion: "Version del objeto",
noteContent: "Nota", note: "Nota",
noteContentPlaceholder: "Toma nota...", noteContentPlaceholder: "Toma nota...",
resendObjects: "Reenviar todos objetos", resendObjects: "Reenviar todos objetos",
@@ -307,7 +313,7 @@ const allTranslations: { [key: string]: typeof englishTranslations } = {
objectTitlePlaceholder: "Mein Objekt", objectTitlePlaceholder: "Mein Objekt",
objectVersion: "Version des Objekts", objectVersion: "Version des Objekts",
noteContent: "Notiz", note: "Notiz",
noteContentPlaceholder: "Notiz eingeben...", noteContentPlaceholder: "Notiz eingeben...",
resendObjects: "Objekte erneut senden", resendObjects: "Objekte erneut senden",