Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(attributes): port the attribute owner line and drop the legacy widget
Elian Doranad637a092b06
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 5bb5b8b5c1..44a6dca4a3 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -521,9 +521,7 @@"tooltip": "If you check this option, Trilium will attempt to shrink the uploaded images by scaling and optimization which may affect the perceived image quality. If unchecked, images will be uploaded without changes."},"attribute_detail": {- "attr_detail_title": "Attribute Detail Title","close_button_title": "Cancel changes and close",- "attr_is_owned_by": "Attribute is owned by","attr_name_title": "Attribute name can be composed of alphanumeric characters, colon and underscore only","name": "Name","value": "Value",diff --git a/apps/client/src/widgets/attribute_widgets/attribute_detail.tsx b/apps/client/src/widgets/attribute_widgets/attribute_detail.tsxindex d22361e5a4..506db3e31d 100644--- a/apps/client/src/widgets/attribute_widgets/attribute_detail.tsx+++ b/apps/client/src/widgets/attribute_widgets/attribute_detail.tsx@@ -331,6 +331,15 @@ function AttributeForm({ opts, attrType, currentNoteId, onAttributesChanged, onSreturn (<>+ {!isOwned && attribute.noteId && (+ <div class="attr-is-owned-by">+ {/* TODO: the attribute type is not translated, as in the widget this was ported from. */}+ {attribute.type === "label" ? "Label" : "Relation"}+ {` ${t("attribute_detail.is_owned_by_note")} `}+ <NoteLink notePath={attribute.noteId} />+ </div>+ )}+<table class="attr-edit-table"><tbody><tr title={t("attribute_detail.attr_name_title")}>diff --git a/apps/client/src/widgets/attribute_widgets/attribute_detail_old.ts b/apps/client/src/widgets/attribute_widgets/attribute_detail_old.tsdeleted file mode 100644index aecb5a7c84..0000000000--- a/apps/client/src/widgets/attribute_widgets/attribute_detail_old.ts+++ /dev/null@@ -1,38 +0,0 @@-import { t } from "../../services/i18n.js";-import linkService from "../../services/link.js";-import NoteContextAwareWidget from "../note_context_aware_widget.js";-import type { AttributeDetailOpts } from "./attribute_detail.jsx";--const TPL = /*html*/`-<div>- <div class="attr-is-owned-by">${t("attribute_detail.attr_is_owned_by")}</div>-</div>`;--export default class AttributeDetailWidget extends NoteContextAwareWidget {- private $attrIsOwnedBy!: JQuery<HTMLElement>;-- doRender() {- this.$widget = $(TPL);-- this.$attrIsOwnedBy = this.$widget.find(".attr-is-owned-by");- }-- async showAttributeDetail({ attribute, isOwned }: AttributeDetailOpts) {- if (isOwned) {- this.$attrIsOwnedBy.hide();- } else if (attribute.noteId) {- this.$attrIsOwnedBy- .show()- .empty()- .append(attribute.type === "label" ? "Label" : "Relation")- .append(` ${t("attribute_detail.is_owned_by_note")} `)- .append(await linkService.createLink(attribute.noteId));- }-- this.toggleInt(true);- }-- hide() {- this.toggleInt(false);- }-}