diff --git a/apps/client/src/services/attributes.ts b/apps/client/src/services/attributes.ts index 370fd1ce1..91ebbff5c 100644 --- a/apps/client/src/services/attributes.ts +++ b/apps/client/src/services/attributes.ts @@ -2,6 +2,7 @@ import server from "./server.js"; import froca from "./froca.js"; import type FNote from "../entities/fnote.js"; import type { AttributeRow } from "./load_results.js"; +import { AttributeType } from "@triliumnext/commons"; async function addLabel(noteId: string, name: string, value: string = "", isInheritable = false) { await server.put(`notes/${noteId}/attribute`, { @@ -25,6 +26,14 @@ async function removeAttributeById(noteId: string, attributeId: string) { await server.remove(`notes/${noteId}/attributes/${attributeId}`); } +export async function removeOwnedAttributesByNameOrType(note: FNote, type: AttributeType, name: string) { + for (const attr of note.getOwnedAttributes()) { + if (attr.type === type && attr.name === name) { + await server.remove(`notes/${note.noteId}/attributes/${attr.attributeId}`); + } + } +} + /** * Removes a label identified by its name from the given note, if it exists. Note that the label must be owned, i.e. * it will not remove inherited attributes. diff --git a/apps/client/src/widgets/react/FormTextArea.tsx b/apps/client/src/widgets/react/FormTextArea.tsx index 85945cbe1..801244c8c 100644 --- a/apps/client/src/widgets/react/FormTextArea.tsx +++ b/apps/client/src/widgets/react/FormTextArea.tsx @@ -3,16 +3,20 @@ interface FormTextAreaProps { currentValue: string; onBlur?(newValue: string): void; rows: number; + className?: string; + placeholder?: string; } -export default function FormTextArea({ id, onBlur, rows, currentValue }: FormTextAreaProps) { +export default function FormTextArea({ id, onBlur, rows, currentValue, className, placeholder }: FormTextAreaProps) { return ( ) } diff --git a/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx b/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx index 074ac3560..932892dc8 100644 --- a/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx +++ b/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx @@ -1,6 +1,14 @@ +import { ComponentChildren } from "preact"; import { t } from "../../services/i18n"; import Button from "../react/Button"; import { TabContext } from "./ribbon-interface"; +import Dropdown from "../react/Dropdown"; +import ActionButton from "../react/ActionButton"; +import FormTextArea from "../react/FormTextArea"; +import { AttributeType, OptionNames } from "@triliumnext/commons"; +import { removeOwnedAttributesByNameOrType } from "../../services/attributes"; +import { note } from "mermaid/dist/rendering-util/rendering-elements/shapes/note.js"; +import FNote from "../../entities/fnote"; interface SearchOption { searchOption: string; @@ -73,8 +81,58 @@ export default function SearchDefinitionTab({ note }: TabContext) { ))} +
+#abc
- {t("search_string.label_abc")}#year = 2019
- {t("search_string.label_year")}#rock #pop
- {t("search_string.label_rock_pop")}#rock or #pop
- {t("search_string.label_rock_or_pop")}#year <= 2000
- {t("search_string.label_year_comparison")}note.dateCreated >= MONTH-1
- {t("search_string.label_date_created")}