add datalist for object categories

This commit is contained in:
marlon-erler
2024-07-12 02:24:48 +02:00
parent 9b1cd38cc1
commit 4a36bbcc2d
7 changed files with 50 additions and 13 deletions
+20 -7
View File
@@ -387,7 +387,7 @@
return new Uint8Array(array); return new Uint8Array(array);
} }
// src/utility.ts // src/utility.tsx
var storageKeys = { var storageKeys = {
hasUnread(id) { hasUnread(id) {
return id + "has-unread-messages"; return id + "has-unread-messages";
@@ -417,6 +417,9 @@
return id + "composing-message"; return id + "composing-message";
} }
}; };
var stringToOptionTag = (value) => {
return /* @__PURE__ */ createElement("option", null, value);
};
// src/translations.ts // src/translations.ts
var englishTranslations = { var englishTranslations = {
@@ -919,6 +922,9 @@
} else { } else {
this.objects.set(messageObject.id, messageObject); this.objects.set(messageObject.id, messageObject);
} }
const latest = this.getMostRecentContent(messageObject);
if (!latest || !latest.categoryName) return;
usedObjectCategories.add(latest.categoryName);
}; };
addObjectAndSend = (messageObject) => { addObjectAndSend = (messageObject) => {
this.addObject(messageObject); this.addObject(messageObject);
@@ -1216,6 +1222,7 @@
function zoomIn() { function zoomIn() {
pageZoom.value += zoomStep; pageZoom.value += zoomStep;
} }
var usedObjectCategories = restoreListState("object-categories");
var chats = new ListState(); var chats = new ListState();
var chatIds = restoreListState("chat-ids"); var chatIds = restoreListState("chat-ids");
var selectedChat = new State(void 0); var selectedChat = new State(void 0);
@@ -1661,6 +1668,7 @@
"textarea", "textarea",
{ {
rows: "5", rows: "5",
class: "height-auto",
"bind:value": editingNoteContent, "bind:value": editingNoteContent,
placeholder: translation.noteContentPlaceholder placeholder: translation.noteContentPlaceholder
} }
@@ -1668,9 +1676,17 @@
"input", "input",
{ {
"bind:value": editingCategory, "bind:value": editingCategory,
placeholder: translation.categoryPlaceholder placeholder: translation.categoryPlaceholder,
list: "object-categories"
} }
))), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, icons.priority), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.priority), /* @__PURE__ */ createElement( ))), /* @__PURE__ */ createElement(
"datalist",
{
hidden: true,
id: "object-categories",
"children:append": [usedObjectCategories, stringToOptionTag]
}
), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, icons.priority), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.priority), /* @__PURE__ */ createElement(
"input", "input",
{ {
type: "number", type: "number",
@@ -1921,9 +1937,6 @@
} }
// src/Views/Overview/connectionSection.tsx // src/Views/Overview/connectionSection.tsx
var addressConverter = (address) => {
return /* @__PURE__ */ createElement("option", null, address);
};
function ConnectionSection() { function ConnectionSection() {
return /* @__PURE__ */ createElement("div", { class: "flex-column" }, /* @__PURE__ */ createElement("h2", null, translation.connection), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "cell_tower"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.serverAddress), /* @__PURE__ */ createElement( return /* @__PURE__ */ createElement("div", { class: "flex-column" }, /* @__PURE__ */ createElement("h2", null, translation.connection), /* @__PURE__ */ createElement("label", { class: "tile" }, /* @__PURE__ */ createElement("span", { class: "icon" }, "cell_tower"), /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, translation.serverAddress), /* @__PURE__ */ createElement(
"input", "input",
@@ -1938,7 +1951,7 @@
{ {
hidden: true, hidden: true,
id: "previous-addresses", id: "previous-addresses",
"children:append": [previousAddresses, addressConverter] "children:append": [previousAddresses, stringToOptionTag]
} }
))), /* @__PURE__ */ createElement("div", { class: "flex-row width-input justify-end" }, /* @__PURE__ */ createElement( ))), /* @__PURE__ */ createElement("div", { class: "flex-row width-input justify-end" }, /* @__PURE__ */ createElement(
"button", "button",
+4
View File
@@ -745,6 +745,10 @@ select + .icon,
height: 100% !important; height: 100% !important;
} }
.height-auto {
height: auto !important;
}
button:not(.tile):not(header *), button:not(.tile):not(header *),
footer, footer,
input:not([type="checkbox"]):not([type="radio"]), input:not([type="checkbox"]):not([type="radio"]),
+5
View File
@@ -9,6 +9,7 @@ import {
selectedChat, selectedChat,
senderName, senderName,
updateMailbox, updateMailbox,
usedObjectCategories,
} from "../Model/model"; } from "../Model/model";
import { decryptString, encryptString } from "../cryptUtility"; import { decryptString, encryptString } from "../cryptUtility";
@@ -348,6 +349,10 @@ export class Chat {
} else { } else {
this.objects.set(messageObject.id, messageObject); this.objects.set(messageObject.id, messageObject);
} }
const latest = this.getMostRecentContent(messageObject);
if (!latest || !latest.categoryName) return;
usedObjectCategories.add(latest.categoryName);
}; };
addObjectAndSend = (messageObject: MessageObject): void => { addObjectAndSend = (messageObject: MessageObject): void => {
+3
View File
@@ -157,6 +157,9 @@ export function zoomIn() {
pageZoom.value += zoomStep; pageZoom.value += zoomStep;
} }
export const usedObjectCategories =
React.restoreListState<string>("object-categories");
// CHAT // CHAT
export const chats = new React.ListState<Chat>(); export const chats = new React.ListState<Chat>();
export const chatIds = React.restoreListState<string>("chat-ids"); export const chatIds = React.restoreListState<string>("chat-ids");
+9
View File
@@ -3,7 +3,9 @@ import * as React from "bloatless-react";
import { Chat, MessageObject } from "../../Model/chatModel"; import { Chat, MessageObject } from "../../Model/chatModel";
import { icons } from "../../icons"; import { icons } from "../../icons";
import { stringToOptionTag } from "../../utility";
import { translation } from "../../translations"; import { translation } from "../../translations";
import { usedObjectCategories } from "../../Model/model";
export function ObjectDetailModal( export function ObjectDetailModal(
chat: Chat, chat: Chat,
@@ -151,6 +153,7 @@ export function ObjectDetailModal(
<span>{translation.note}</span> <span>{translation.note}</span>
<textarea <textarea
rows="5" rows="5"
class="height-auto"
bind:value={editingNoteContent} bind:value={editingNoteContent}
placeholder={translation.noteContentPlaceholder} placeholder={translation.noteContentPlaceholder}
></textarea> ></textarea>
@@ -164,9 +167,15 @@ export function ObjectDetailModal(
<input <input
bind:value={editingCategory} bind:value={editingCategory}
placeholder={translation.categoryPlaceholder} placeholder={translation.categoryPlaceholder}
list="object-categories"
></input> ></input>
</div> </div>
</label> </label>
<datalist
hidden
id="object-categories"
children:append={[usedObjectCategories, stringToOptionTag]}
></datalist>
<label class="tile"> <label class="tile">
<span class="icon">{icons.priority}</span> <span class="icon">{icons.priority}</span>
+2 -5
View File
@@ -17,12 +17,9 @@ import {
serverAddressInput, serverAddressInput,
} from "../../Model/model"; } from "../../Model/model";
import { stringToOptionTag } from "../../utility";
import { translation } from "../../translations"; import { translation } from "../../translations";
const addressConverter: React.StateItemConverter<string> = (address) => {
return <option>{address}</option>;
};
export function ConnectionSection() { export function ConnectionSection() {
return ( return (
<div class="flex-column"> <div class="flex-column">
@@ -41,7 +38,7 @@ export function ConnectionSection() {
<datalist <datalist
hidden hidden
id="previous-addresses" id="previous-addresses"
children:append={[previousAddresses, addressConverter]} children:append={[previousAddresses, stringToOptionTag]}
></datalist> ></datalist>
</div> </div>
</label> </label>
+6
View File
@@ -1,3 +1,5 @@
import * as React from "bloatless-react";
export const storageKeys = { export const storageKeys = {
hasUnread(id: string): string { hasUnread(id: string): string {
return id + "has-unread-messages"; return id + "has-unread-messages";
@@ -35,3 +37,7 @@ export const storageKeys = {
return id + "composing-message"; return id + "composing-message";
}, },
}; };
export const stringToOptionTag: React.StateItemConverter<string> = (value) => {
return <option>{value}</option>;
};