Skip to content

Commit dc27f58

Browse files
authored
Merge pull request #2069 from umbraco/v14/bugfix/document-media-tree-item-collection-icon
Bugfix: Render collection icon for document/media tree items
2 parents aedc0a8 + 5f4125e commit dc27f58

File tree

2 files changed

+85
-31
lines changed

2 files changed

+85
-31
lines changed

src/packages/documents/documents/tree/tree-item/document-tree-item.element.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { UmbDocumentTreeItemModel, UmbDocumentTreeItemVariantModel } from '../types.js';
21
import { css, html, nothing, customElement, state, classMap } from '@umbraco-cms/backoffice/external/lit';
32
import type { UmbAppLanguageContext } from '@umbraco-cms/backoffice/language';
43
import { UMB_APP_LANGUAGE_CONTEXT } from '@umbraco-cms/backoffice/language';
54
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
65
import { UmbTreeItemElementBase } from '@umbraco-cms/backoffice/tree';
6+
import type { UmbDocumentTreeItemModel, UmbDocumentTreeItemVariantModel } from '../types.js';
77

88
@customElement('umb-document-tree-item')
99
export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocumentTreeItemModel> {
@@ -74,11 +74,7 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
7474
${this.item?.documentType.icon
7575
? html`
7676
<umb-icon id="icon" slot="icon" name="${this.item.documentType.icon}"></umb-icon>
77-
${this.item.isProtected ? this.#renderIsProtectedIcon() : nothing}
78-
<!--
79-
// TODO: implement correct status symbol
80-
<span id="status-symbol"></span>
81-
-->
77+
${this.#renderStateIcon()}
8278
`
8379
: nothing}
8480
</span>
@@ -91,8 +87,24 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
9187
> `;
9288
}
9389

90+
#renderStateIcon() {
91+
if (this.item?.isProtected) {
92+
return this.#renderIsProtectedIcon();
93+
}
94+
95+
if (this.item?.documentType.collection) {
96+
return this.#renderIsCollectionIcon();
97+
}
98+
99+
return nothing;
100+
}
101+
102+
#renderIsCollectionIcon() {
103+
return html`<umb-icon id="state-icon" slot="icon" name="icon-grid" title="Collection"></umb-icon>`;
104+
}
105+
94106
#renderIsProtectedIcon() {
95-
return html`<umb-icon id="icon-lock" slot="icon" name="icon-lock" title="Protected"></umb-icon>`;
107+
return html`<umb-icon id="state-icon" slot="icon" name="icon-lock" title="Protected"></umb-icon>`;
96108
}
97109

98110
static override styles = [
@@ -106,19 +118,13 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
106118
vertical-align: middle;
107119
}
108120
109-
#status-symbol {
110-
width: 5px;
111-
height: 5px;
112-
border: 1px solid white;
113-
background-color: blue;
114-
display: block;
115-
position: absolute;
116-
bottom: 0;
117-
right: 0;
118-
border-radius: 100%;
121+
#label {
122+
white-space: nowrap;
123+
overflow: hidden;
124+
text-overflow: ellipsis;
119125
}
120126
121-
#icon-lock {
127+
#state-icon {
122128
position: absolute;
123129
bottom: -5px;
124130
right: -5px;
@@ -130,36 +136,30 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
130136
line-height: 14px;
131137
}
132138
133-
#label {
134-
white-space: nowrap;
135-
overflow: hidden;
136-
text-overflow: ellipsis;
137-
}
138-
139-
:hover #icon-lock {
139+
:hover #state-icon {
140140
background: var(--uui-color-surface-emphasis);
141141
}
142142
143143
/** Active */
144-
[active] #icon-lock {
144+
[active] #state-icon {
145145
background: var(--uui-color-current);
146146
}
147147
148-
[active]:hover #icon-lock {
148+
[active]:hover #state-icon {
149149
background: var(--uui-color-current-emphasis);
150150
}
151151
152152
/** Selected */
153-
[selected] #icon-lock {
153+
[selected] #state-icon {
154154
background-color: var(--uui-color-selected);
155155
}
156156
157-
[selected]:hover #icon-lock {
157+
[selected]:hover #state-icon {
158158
background-color: var(--uui-color-selected-emphasis);
159159
}
160160
161161
/** Disabled */
162-
[disabled] #icon-lock {
162+
[disabled] #state-icon {
163163
background-color: var(--uui-color-disabled);
164164
}
165165

src/packages/media/media/tree/tree-item/media-tree-item.element.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
1010
return html`
1111
<span id="icon-container" slot="icon">
1212
${this.item?.mediaType.icon
13-
? html` <umb-icon id="icon" slot="icon" name="${this.item.mediaType.icon}"></umb-icon> `
13+
? html`
14+
<umb-icon id="icon" slot="icon" name="${this.item.mediaType.icon}"></umb-icon>
15+
${this.#renderStateIcon()}
16+
`
1417
: nothing}
1518
</span>
1619
`;
@@ -20,6 +23,18 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
2023
return html`<span id="label" slot="label">${this._item?.variants[0].name}</span> `;
2124
}
2225

26+
#renderStateIcon() {
27+
if (this.item?.mediaType.collection) {
28+
return this.#renderIsCollectionIcon();
29+
}
30+
31+
return nothing;
32+
}
33+
34+
#renderIsCollectionIcon() {
35+
return html`<umb-icon id="state-icon" slot="icon" name="icon-grid" title="Collection"></umb-icon>`;
36+
}
37+
2338
static override styles = [
2439
UmbTextStyles,
2540
css`
@@ -36,6 +51,45 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
3651
overflow: hidden;
3752
text-overflow: ellipsis;
3853
}
54+
55+
#state-icon {
56+
position: absolute;
57+
bottom: -5px;
58+
right: -5px;
59+
font-size: 10px;
60+
background: var(--uui-color-surface);
61+
width: 14px;
62+
height: 14px;
63+
border-radius: 100%;
64+
line-height: 14px;
65+
}
66+
67+
:hover #state-icon {
68+
background: var(--uui-color-surface-emphasis);
69+
}
70+
71+
/** Active */
72+
[active] #state-icon {
73+
background: var(--uui-color-current);
74+
}
75+
76+
[active]:hover #state-icon {
77+
background: var(--uui-color-current-emphasis);
78+
}
79+
80+
/** Selected */
81+
[selected] #state-icon {
82+
background-color: var(--uui-color-selected);
83+
}
84+
85+
[selected]:hover #state-icon {
86+
background-color: var(--uui-color-selected-emphasis);
87+
}
88+
89+
/** Disabled */
90+
[disabled] #state-icon {
91+
background-color: var(--uui-color-disabled);
92+
}
3993
`,
4094
];
4195
}

0 commit comments

Comments
 (0)