Skip to content

Commit d720be2

Browse files
committed
Updated sign with custom logic to add a sign.
1 parent c368931 commit d720be2

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

16/umbraco-cms/customizing/back-office-signs.md

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ Using this binding lets the server determine which signs are present in the resp
3434

3535
## Displaying a Sign
3636

37-
To display a Sign in the backoffice, you register an entitySign extension and bind it to one or more flags using the forEntityFlags property. If you're using an icon variant, you must set kind: "icon" and provide both meta.iconName and meta.label, so the UI has the necessary visual and accessible information to render.
37+
To display a Sign in the backoffice, you register an entitySign extension.
3838

39-
Example:
39+
Typically, you’ll bind it to one or more flags returned in the server response using the `forEntityFlags` property. However, you can also provide your own logic to determine when a Sign should appear.
40+
41+
If you're using an icon variant, set kind to "icon" and provide both meta.iconName and meta.label.This ensures the user interface has the necessary visual and accessible information to render the Sign correctly.
42+
43+
### Example: Rendering an Entity Sign from a Server Flag
4044

4145
```typescript
4246
import type { UmbExtensionManifest } from "@umbraco-cms/backoffice/extension-registry";
@@ -58,8 +62,60 @@ export const manifests: UmbExtensionManifest = {
5862
};
5963
```
6064

61-
When an entity includes the Umb.IsProtected flag, this Sign appears next to it in the UI, indicating that the item is protected.
65+
When an entity includes the `Umb.IsProtected` flag, this Sign appears next to it in the UI, indicating that the item is protected.
66+
67+
![Screenshot of Recently Created sign](../reference/images/protected-entity-sign.png)
68+
69+
### Example: Rendering an Entity Sign with Custom Logic
70+
71+
The following Sign appears next to any document created within the past week. This Sign isn’t controlled by server flags.
72+
73+
```typescript
74+
import type { UmbExtensionManifest } from "@umbraco-cms/backoffice/extension-registry";
75+
import { UMB_DOCUMENT_ENTITY_TYPE } from "@umbraco-cms/backoffice/document";
76+
77+
export const manifests: UmbExtensionManifest = {
78+
type: "entitySign",
79+
kind: "icon",
80+
alias: "Umb.EntitySign.Document.RecentlyCreated",
81+
name: "Recently Created Document Sign",
82+
forEntityTypes: [UMB_DOCUMENT_ENTITY_TYPE],
83+
element: () => import("./recently-created-sign.element.ts"),
84+
meta: {
85+
iconName: "icon-umbraco",
86+
label: "Recently Created",
87+
},
88+
};
89+
```
90+
91+
And in `recently-created-sign.element.ts`:
92+
93+
```typescript
94+
@customElement("umb-recently-created-sign")
95+
export class UmbRecentlyCreatedSignElement extends UmbLitElement {
96+
@state() private _createDate?: string;
97+
98+
override connectedCallback(): void {
99+
super.connectedCallback();
100+
this.consumeContext(UMB_TREE_ITEM_CONTEXT, (ctx) => {
101+
const item = ctx?.getTreeItem?.() ?? (ctx as any).item;
102+
this._createDate = item?.createDate;
103+
this.requestUpdate();
104+
});
105+
}
106+
107+
protected override render() {
108+
if (!this._createDate) return null;
109+
const created = new Date(this._createDate);
110+
const weekAgo = new Date();
111+
weekAgo.setDate(weekAgo.getDate() - 7);
112+
return created > weekAgo ? html`<div>New</div>` : null;
113+
}
114+
}
115+
```
116+
117+
![Screenshot of Recently Created sign](../reference/images/custom-entity-sign.png)
62118

63119
{% hint style="info" %}
64-
The client extension for backoffice signs will be available in Umbraco 16.4 / 17.0.
120+
The client extension for backoffice signs are available in Umbraco 16.4.
65121
{% endhint %}
27.3 KB
Loading
26.1 KB
Loading

0 commit comments

Comments
 (0)