mirror of
https://github.com/zadam/trilium.git
synced 2025-12-15 12:49:53 +01:00
feat(status_bar): attribute button (not yet interactive)
This commit is contained in:
@@ -2159,6 +2159,9 @@
|
|||||||
"backlinks_title_one": "This note is linked from {{count}} other note.\n\nClick to view the list of backlinks.",
|
"backlinks_title_one": "This note is linked from {{count}} other note.\n\nClick to view the list of backlinks.",
|
||||||
"backlinks_title_other": "This note is linked from {{count}} other notes.\n\nClick to view the list of backlinks.",
|
"backlinks_title_other": "This note is linked from {{count}} other notes.\n\nClick to view the list of backlinks.",
|
||||||
"attachments_title_one": "This note has {{count}} attachment. Click to open the list of attachments in a new tab.",
|
"attachments_title_one": "This note has {{count}} attachment. Click to open the list of attachments in a new tab.",
|
||||||
"attachments_title_other": "This note has {{count}} attachments. Click to open the list of attachments in a new tab."
|
"attachments_title_other": "This note has {{count}} attachments. Click to open the list of attachments in a new tab.",
|
||||||
|
"attributes_one": "{{count}} attribute",
|
||||||
|
"attributes_other": "{{count}} attributes",
|
||||||
|
"attributes_title": "Click to open a dedicated pane to edit this note's owned attributes, as well as to see the list of inherited attributes."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { formatDateTime } from "../../utils/formatters";
|
|||||||
import { BacklinksList, useBacklinkCount } from "../FloatingButtonsDefinitions";
|
import { BacklinksList, useBacklinkCount } from "../FloatingButtonsDefinitions";
|
||||||
import Dropdown, { DropdownProps } from "../react/Dropdown";
|
import Dropdown, { DropdownProps } from "../react/Dropdown";
|
||||||
import { FormDropdownDivider, FormListItem } from "../react/FormList";
|
import { FormDropdownDivider, FormListItem } from "../react/FormList";
|
||||||
import { useActiveNoteContext, useStaticTooltip } from "../react/hooks";
|
import { useActiveNoteContext, useStaticTooltip, useTriliumEvent } from "../react/hooks";
|
||||||
import Icon from "../react/Icon";
|
import Icon from "../react/Icon";
|
||||||
import { ParentComponent } from "../react/react_utils";
|
import { ParentComponent } from "../react/react_utils";
|
||||||
import { ContentLanguagesModal, useLanguageSwitcher } from "../ribbon/BasicPropertiesTab";
|
import { ContentLanguagesModal, useLanguageSwitcher } from "../ribbon/BasicPropertiesTab";
|
||||||
@@ -24,6 +24,7 @@ import { NoteSizeWidget, useNoteMetadata } from "../ribbon/NoteInfoTab";
|
|||||||
import { useAttachments } from "../type_widgets/Attachment";
|
import { useAttachments } from "../type_widgets/Attachment";
|
||||||
import { useProcessedLocales } from "../type_widgets/options/components/LocaleSelector";
|
import { useProcessedLocales } from "../type_widgets/options/components/LocaleSelector";
|
||||||
import Breadcrumb from "./Breadcrumb";
|
import Breadcrumb from "./Breadcrumb";
|
||||||
|
import attributes from "../../services/attributes";
|
||||||
|
|
||||||
interface StatusBarContext {
|
interface StatusBarContext {
|
||||||
note: FNote;
|
note: FNote;
|
||||||
@@ -43,6 +44,7 @@ export default function StatusBar() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="actions-row">
|
<div className="actions-row">
|
||||||
|
<AttributesButton {...context} />
|
||||||
<AttachmentCount {...context} />
|
<AttachmentCount {...context} />
|
||||||
<BacklinksBadge {...context} />
|
<BacklinksBadge {...context} />
|
||||||
<LanguageSwitcher {...context} />
|
<LanguageSwitcher {...context} />
|
||||||
@@ -217,7 +219,7 @@ function AttachmentCount({ note }: StatusBarContext) {
|
|||||||
|
|
||||||
return (note && count > 0 &&
|
return (note && count > 0 &&
|
||||||
<StatusBarButton
|
<StatusBarButton
|
||||||
className="attachment-count"
|
className="attachment-count-button"
|
||||||
icon="bx bx-paperclip"
|
icon="bx bx-paperclip"
|
||||||
text={count}
|
text={count}
|
||||||
title={t("status_bar.attachments_title", { count })}
|
title={t("status_bar.attachments_title", { count })}
|
||||||
@@ -226,3 +228,25 @@ function AttachmentCount({ note }: StatusBarContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region Attributes
|
||||||
|
function AttributesButton({ note }: StatusBarContext) {
|
||||||
|
const [ count, setCount ] = useState(note.attributes.length);
|
||||||
|
|
||||||
|
// React to changes in count.
|
||||||
|
useTriliumEvent("entitiesReloaded", (({loadResults}) => {
|
||||||
|
if (loadResults.getAttributeRows().some(attr => attributes.isAffecting(attr, note))) {
|
||||||
|
setCount(note.attributes.length);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StatusBarButton
|
||||||
|
className="attributes-button"
|
||||||
|
icon="bx bx-list-check"
|
||||||
|
title={t("status_bar.attributes_title")}
|
||||||
|
text={t("status_bar.attributes", { count })}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user