@crombolo/backoffice-host 0.53.2 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/plugin/app-preview/umbraco-package.json +1 -1
- package/plugin/approvals-tree.js +105 -0
- package/plugin/content-strip-items.js +20 -10
- package/plugin/definition-tree.js +157 -126
- package/plugin/dictionary-chip.js +233 -0
- package/plugin/dictionary-words-client.js +52 -0
- package/plugin/dictionary-words.js +196 -0
- package/plugin/form-word-input-model.js +33 -13
- package/plugin/form-word-input.js +21 -125
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/settings-cards.js +8 -1
- package/plugin/settings-section.js +43 -18
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/template-picker-modal.js +276 -0
- package/plugin/template-picker-model.js +77 -0
- package/plugin/template-picker.js +43 -0
- package/plugin/tsx-editors.js +5 -0
- package/plugin/tsx-highlighting.js +81 -0
- package/plugin/umbraco-package.json +96 -41
- package/plugin/workflow-client.js +3 -0
- package/plugin/workflow-designer.js +0 -7
- package/plugin/workflow-requests.js +111 -105
- package/plugin/workflow-send-condition.js +2 -0
- package/plugin/workflow-send-model.js +20 -0
- package/plugin/workflow-send-unpublish.js +2 -0
- package/plugin/workflow-send.js +231 -0
- package/plugin/workflow-tab.js +32 -86
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.1",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Serves the Umbraco backoffice SPA: shell HTML, import map and package manifests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@crombolo/core": "0.
|
|
36
|
-
"@crombolo/backoffice-dist": "0.
|
|
35
|
+
"@crombolo/core": "0.54.1",
|
|
36
|
+
"@crombolo/backoffice-dist": "0.54.1"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tree beside Approvals: a folder of the requests waiting for the reader, and
|
|
3
|
+
* one of the latest decided. Each request opens its page's Workflow tab, where
|
|
4
|
+
* it is acted on.
|
|
5
|
+
*/
|
|
6
|
+
import { css, html } from '@umbraco-cms/backoffice/external/lit'
|
|
7
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
8
|
+
import { finished, waitingForMe } from './workflow-client.js'
|
|
9
|
+
import { pageLink } from './workflow-requests.js'
|
|
10
|
+
|
|
11
|
+
/** How many of the decided the tree shows: the list has the rest. */
|
|
12
|
+
const DECIDED_SHOWN = 25
|
|
13
|
+
|
|
14
|
+
const FOLDERS = [
|
|
15
|
+
{ id: 'waiting', label: 'Waiting for me', load: () => waitingForMe() },
|
|
16
|
+
{ id: 'decided', label: 'Decided', load: () => finished(0, DECIDED_SHOWN) },
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
export default class CromboloApprovalsTreeElement extends UmbLitElement {
|
|
20
|
+
static properties = {
|
|
21
|
+
_items: { state: true },
|
|
22
|
+
_closed: { state: true },
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#follow = () => {
|
|
26
|
+
if (location.pathname.includes('/section/workflow')) this.#load()
|
|
27
|
+
else this.requestUpdate()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
super.connectedCallback()
|
|
32
|
+
this._closed = new Set()
|
|
33
|
+
this.#load()
|
|
34
|
+
window.addEventListener('changestate', this.#follow)
|
|
35
|
+
window.addEventListener('popstate', this.#follow)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
disconnectedCallback() {
|
|
39
|
+
super.disconnectedCallback()
|
|
40
|
+
window.removeEventListener('changestate', this.#follow)
|
|
41
|
+
window.removeEventListener('popstate', this.#follow)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async #load() {
|
|
45
|
+
const answers = await Promise.all(FOLDERS.map((folder) => folder.load().catch(() => undefined)))
|
|
46
|
+
this._items = Object.fromEntries(
|
|
47
|
+
FOLDERS.map((folder, index) => [folder.id, answers[index]?.items ?? []]),
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#toggle(id, open) {
|
|
52
|
+
const closed = new Set(this._closed)
|
|
53
|
+
if (open) closed.delete(id)
|
|
54
|
+
else closed.add(id)
|
|
55
|
+
this._closed = closed
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render() {
|
|
59
|
+
// Headed as Umbraco's sidebar menus are, Structure's among them.
|
|
60
|
+
const header = html`<h3>Approvals</h3>`
|
|
61
|
+
if (!this._items) return html`${header}<uui-loader></uui-loader>`
|
|
62
|
+
return html`${header}<uui-menu-item-list>
|
|
63
|
+
${FOLDERS.map((folder) => {
|
|
64
|
+
const items = this._items[folder.id]
|
|
65
|
+
return html`<uui-menu-item
|
|
66
|
+
label=${folder.label}
|
|
67
|
+
.hasChildren=${items.length > 0}
|
|
68
|
+
.showChildren=${items.length > 0 && !this._closed.has(folder.id)}
|
|
69
|
+
@show-children=${() => this.#toggle(folder.id, true)}
|
|
70
|
+
@hide-children=${() => this.#toggle(folder.id, false)}
|
|
71
|
+
@click-label=${() => this.#toggle(folder.id, this._closed.has(folder.id))}
|
|
72
|
+
>
|
|
73
|
+
<umb-icon slot="icon" name="icon-folder"></umb-icon>
|
|
74
|
+
${items.map((request) => {
|
|
75
|
+
const href = pageLink(request)
|
|
76
|
+
return html`<uui-menu-item
|
|
77
|
+
label=${request.nodeName}
|
|
78
|
+
href=${href}
|
|
79
|
+
?active=${location.pathname === new URL(href, location.href).pathname}
|
|
80
|
+
title=${`${request.workflow.name}: ${request.action === 'unpublish' ? 'taking it down' : 'publishing'}`}
|
|
81
|
+
>
|
|
82
|
+
<umb-icon slot="icon" name="icon-document"></umb-icon>
|
|
83
|
+
</uui-menu-item>`
|
|
84
|
+
})}
|
|
85
|
+
</uui-menu-item>`
|
|
86
|
+
})}
|
|
87
|
+
</uui-menu-item-list>`
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static styles = css`
|
|
91
|
+
h3 {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
height: var(--umb-header-layout-height);
|
|
95
|
+
margin: 0;
|
|
96
|
+
padding: var(--uui-size-4) var(--uui-size-8);
|
|
97
|
+
box-sizing: border-box;
|
|
98
|
+
font-size: 14px;
|
|
99
|
+
}
|
|
100
|
+
`
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
customElements.define('crombolo-approvals-tree', CromboloApprovalsTreeElement)
|
|
104
|
+
|
|
105
|
+
export { CromboloApprovalsTreeElement as element }
|
|
@@ -2,31 +2,39 @@
|
|
|
2
2
|
* What the menu under Content offers (story 289), and which item a page belongs
|
|
3
3
|
* to. Pure, so each is tested on its own. Structure and Code stay in
|
|
4
4
|
* Settings: the client links to them there, and the menu is what puts them
|
|
5
|
-
* together. Forms
|
|
5
|
+
* together. Forms and Workflows are nodes in Structure; Approvals is its own section,
|
|
6
|
+
* with no tab in the header.
|
|
6
7
|
*/
|
|
7
8
|
import { treeFor } from './settings-cards.js'
|
|
8
9
|
|
|
9
10
|
const STRUCTURE = 'Crombolo.Section.Structure'
|
|
10
11
|
const COMPONENTS = 'Crombolo.Section.Components'
|
|
11
12
|
const WORKFLOW_SETUP = 'Crombolo.Section.WorkflowSetup'
|
|
13
|
+
const APPROVALS = 'Crombolo.Section.Workflow'
|
|
12
14
|
/** Reading forms, which is what a group's Forms comes to. */
|
|
13
15
|
const FORM_READ = 'Crombolo.Form.Read'
|
|
14
16
|
const FORMS = 'Crombolo.Section.Forms'
|
|
15
17
|
const CONTENT = 'Umb.Section.Content'
|
|
16
18
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Forms and Workflows are nodes in Structure; someone with either alone, and not
|
|
21
|
+
* Structure, gets it beside the other in the Forms section.
|
|
22
|
+
*/
|
|
23
|
+
const STRUCTURE_ELSE = [
|
|
24
|
+
{ path: 'section/forms', section: FORMS, verb: FORM_READ },
|
|
25
|
+
{ path: 'section/forms/view/workflows', section: WORKFLOW_SETUP },
|
|
26
|
+
]
|
|
19
27
|
|
|
20
28
|
const ITEMS = [
|
|
21
29
|
{ label: 'Pages', path: 'section/content', section: CONTENT },
|
|
30
|
+
{ label: 'Approvals', path: 'section/workflow', section: APPROVALS },
|
|
22
31
|
{
|
|
23
32
|
label: 'Structure',
|
|
24
33
|
path: 'section/settings/structure',
|
|
25
34
|
section: STRUCTURE,
|
|
26
|
-
or:
|
|
35
|
+
or: STRUCTURE_ELSE,
|
|
27
36
|
},
|
|
28
37
|
{ label: 'Code', path: 'section/settings/code', section: COMPONENTS },
|
|
29
|
-
{ label: 'Workflows', path: 'section/forms/view/workflows', section: WORKFLOW_SETUP },
|
|
30
38
|
]
|
|
31
39
|
|
|
32
40
|
/**
|
|
@@ -39,9 +47,10 @@ export function stripItems(user) {
|
|
|
39
47
|
const may = (verb) => user?.isAdmin === true || (user?.fallbackPermissions ?? []).includes(verb)
|
|
40
48
|
const items = ITEMS.flatMap((item) => {
|
|
41
49
|
if (allowed.includes(item.section)) return [item]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
const other = (item.or ?? []).find(
|
|
51
|
+
(or) => allowed.includes(or.section) && (!or.verb || may(or.verb)),
|
|
52
|
+
)
|
|
53
|
+
return other ? [{ ...item, ...other }] : []
|
|
45
54
|
})
|
|
46
55
|
return items.length > 1 ? items : []
|
|
47
56
|
}
|
|
@@ -56,9 +65,10 @@ export function activeItem(path) {
|
|
|
56
65
|
if (!section) return undefined
|
|
57
66
|
const [, name, rest = ''] = section
|
|
58
67
|
if (name === 'content') return 'Pages'
|
|
59
|
-
if (name === 'forms') return
|
|
68
|
+
if (name === 'forms') return 'Structure'
|
|
69
|
+
if (name === 'workflow') return 'Approvals'
|
|
60
70
|
if (name !== 'settings') return undefined
|
|
61
|
-
if (
|
|
71
|
+
if (['structure', 'forms', 'workflows'].some((tree) => rest.startsWith(tree))) return 'Structure'
|
|
62
72
|
if (rest.startsWith('code')) return 'Code'
|
|
63
73
|
const tree = treeFor(/^workspace\/([^/]+)/.exec(rest)?.[1])
|
|
64
74
|
return tree === 'structure' ? 'Structure' : tree === 'code' ? 'Code' : undefined
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The tree
|
|
2
|
+
* The tree of forms or of workflows (story 289), in Structure or beside them: their folders
|
|
3
|
+
* and their items,
|
|
3
4
|
* with making, renaming and moving, or a word saying why they cannot be changed.
|
|
4
5
|
* Forms' root opens every submission; a folder is a real folder of files.
|
|
5
6
|
*/
|
|
6
7
|
import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
|
|
7
8
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
8
|
-
import { activeItem } from './content-strip-items.js'
|
|
9
9
|
import { definitionTree, readOnlyWords } from './definition-tree-model.js'
|
|
10
10
|
import { formsTree, moveForm, sendFormFolder } from './forms-client.js'
|
|
11
11
|
import { listWorkflows, moveWorkflow, sendWorkflowFolder } from './workflow-client.js'
|
|
@@ -21,6 +21,10 @@ const formsAt = (view) =>
|
|
|
21
21
|
? `section/settings/forms${view === 'entries' ? '/entries' : ''}`
|
|
22
22
|
: `section/forms/view/${view}`
|
|
23
23
|
|
|
24
|
+
/** The workflow designer, in Structure for those who have it, else beside forms. */
|
|
25
|
+
const workflowsAt = (query = '') =>
|
|
26
|
+
`${here().startsWith('section/settings') ? 'section/settings/workflows' : 'section/forms/view/workflows'}${query}`
|
|
27
|
+
|
|
24
28
|
const KINDS = {
|
|
25
29
|
Forms: {
|
|
26
30
|
label: 'Forms',
|
|
@@ -28,6 +32,8 @@ const KINDS = {
|
|
|
28
32
|
return formsAt('entries')
|
|
29
33
|
},
|
|
30
34
|
rootLabel: 'Forms',
|
|
35
|
+
itemNoun: 'form',
|
|
36
|
+
icon: 'icon-autofill',
|
|
31
37
|
open: (item) => `${formsAt('forms')}?form=${encodeURIComponent(item.key)}`,
|
|
32
38
|
create: (folder) => `${formsAt('forms')}?new=${encodeURIComponent(folder)}`,
|
|
33
39
|
load: formsTree,
|
|
@@ -36,10 +42,14 @@ const KINDS = {
|
|
|
36
42
|
},
|
|
37
43
|
Workflows: {
|
|
38
44
|
label: 'Workflows',
|
|
39
|
-
root
|
|
45
|
+
get root() {
|
|
46
|
+
return workflowsAt()
|
|
47
|
+
},
|
|
40
48
|
rootLabel: 'Workflows',
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
itemNoun: 'workflow',
|
|
50
|
+
icon: 'icon-mindmap',
|
|
51
|
+
open: (item) => workflowsAt(`?workflow=${encodeURIComponent(item.alias)}`),
|
|
52
|
+
create: (folder) => workflowsAt(`?new=${encodeURIComponent(folder)}`),
|
|
43
53
|
load: async () => {
|
|
44
54
|
const list = await listWorkflows()
|
|
45
55
|
return {
|
|
@@ -58,8 +68,10 @@ const url = (path) =>
|
|
|
58
68
|
|
|
59
69
|
export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
60
70
|
static properties = {
|
|
61
|
-
/** The tree to show; without it, whichever the address belongs to. */
|
|
71
|
+
/** The tree to show; without it, the menu item's, else whichever the address belongs to. */
|
|
62
72
|
kind: { type: String },
|
|
73
|
+
/** Set by the menu, as for any menu item: its `meta.kind` names the tree. */
|
|
74
|
+
manifest: { attribute: false },
|
|
63
75
|
_kind: { state: true },
|
|
64
76
|
_tree: { state: true },
|
|
65
77
|
_because: { state: true },
|
|
@@ -68,7 +80,10 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
#follow = () => {
|
|
71
|
-
const kind =
|
|
83
|
+
const kind =
|
|
84
|
+
this.kind ??
|
|
85
|
+
this.manifest?.meta?.kind ??
|
|
86
|
+
(/^section\/forms\/view\/workflows/.test(here()) ? 'Workflows' : 'Forms')
|
|
72
87
|
if (kind === this._kind) return
|
|
73
88
|
this._kind = kind
|
|
74
89
|
this.#load()
|
|
@@ -76,6 +91,10 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
76
91
|
|
|
77
92
|
#reload = () => this.#load()
|
|
78
93
|
|
|
94
|
+
willUpdate(changed) {
|
|
95
|
+
if (changed.has('manifest')) this.#follow()
|
|
96
|
+
}
|
|
97
|
+
|
|
79
98
|
connectedCallback() {
|
|
80
99
|
super.connectedCallback()
|
|
81
100
|
this.#follow()
|
|
@@ -96,7 +115,10 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
96
115
|
}
|
|
97
116
|
|
|
98
117
|
async #load() {
|
|
118
|
+
const kind = this._kind
|
|
99
119
|
const { items, folders, readOnlyBecause } = await this.#config.load()
|
|
120
|
+
// A menu item names its tree after it is made: a load for the tree it had is dropped.
|
|
121
|
+
if (kind !== this._kind) return
|
|
100
122
|
this._tree = definitionTree(items, folders)
|
|
101
123
|
this._folders = folders
|
|
102
124
|
this._because = readOnlyBecause
|
|
@@ -147,156 +169,164 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
147
169
|
</form>`
|
|
148
170
|
}
|
|
149
171
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
/** Which folders are open, by path; the root is `''`. Everything starts open. */
|
|
173
|
+
#closed = new Set()
|
|
174
|
+
|
|
175
|
+
#toggle(path, open) {
|
|
176
|
+
if (open) this.#closed.delete(path)
|
|
177
|
+
else this.#closed.add(path)
|
|
178
|
+
this.requestUpdate()
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** The popovers this render made: drawn after the tree, since a closed folder hides its children. */
|
|
182
|
+
#popovers = []
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* A row's actions, as Umbraco's tree draws them: "…" for a popover of choices, then the
|
|
186
|
+
* first choice as a button of its own when it is marked `quick`, e.g. "+" for a new item.
|
|
187
|
+
*/
|
|
188
|
+
#menu(id, label, choices) {
|
|
189
|
+
if (choices.length === 0) return nothing
|
|
190
|
+
const pick = (run) => () => {
|
|
191
|
+
this.renderRoot.querySelector(`#${id}`)?.hidePopover?.()
|
|
192
|
+
run()
|
|
193
|
+
}
|
|
194
|
+
this.#popovers.push(html`<uui-popover-container id=${id} placement="bottom-start">
|
|
195
|
+
<umb-popover-layout>
|
|
196
|
+
${choices.map(
|
|
197
|
+
(choice) =>
|
|
198
|
+
html`<uui-menu-item label=${choice.label} @click-label=${pick(choice.run)}>
|
|
199
|
+
<umb-icon slot="icon" name=${choice.icon}></umb-icon>
|
|
200
|
+
</uui-menu-item>`,
|
|
201
|
+
)}
|
|
202
|
+
</umb-popover-layout>
|
|
203
|
+
</uui-popover-container>`)
|
|
204
|
+
const [first] = choices
|
|
205
|
+
return html`<uui-action-bar slot="actions">
|
|
206
|
+
<uui-button compact label=${`Actions for ${label}`} popovertarget=${id}
|
|
207
|
+
><uui-symbol-more></uui-symbol-more
|
|
208
|
+
></uui-button>
|
|
162
209
|
${
|
|
163
|
-
|
|
164
|
-
? html`<button
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
aria-label="Rename"
|
|
168
|
-
@click=${() => {
|
|
169
|
-
this._asking = { verb: 'rename', path }
|
|
170
|
-
}}
|
|
171
|
-
>✎</button>
|
|
172
|
-
<button
|
|
173
|
-
type="button"
|
|
174
|
-
title="Delete"
|
|
175
|
-
aria-label="Delete"
|
|
176
|
-
@click=${() => this.#send(() => this.#config.folder('DELETE', { path }))}
|
|
177
|
-
>×</button>`
|
|
210
|
+
first.quick
|
|
211
|
+
? html`<uui-button compact label=${first.label} title=${first.label} @click=${first.run}
|
|
212
|
+
><umb-icon name=${first.icon}></umb-icon
|
|
213
|
+
></uui-button>`
|
|
178
214
|
: nothing
|
|
179
215
|
}
|
|
180
|
-
</
|
|
216
|
+
</uui-action-bar>`
|
|
181
217
|
}
|
|
182
218
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
219
|
+
/** What a folder offers: a new item or folder in it, and, below the root, renaming or deleting it. */
|
|
220
|
+
#folderChoices(path) {
|
|
221
|
+
if (!this.#editable) return []
|
|
222
|
+
const go = (to) => () => window.history.pushState(null, '', url(to))
|
|
223
|
+
return [
|
|
224
|
+
{
|
|
225
|
+
label: `New ${this.#config.itemNoun}`,
|
|
226
|
+
icon: 'icon-add',
|
|
227
|
+
quick: true,
|
|
228
|
+
run: go(this.#config.create(path)),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
label: 'New folder…',
|
|
232
|
+
icon: 'icon-folder',
|
|
233
|
+
run: () => {
|
|
234
|
+
this._asking = { verb: 'new', path }
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
...(path
|
|
238
|
+
? [
|
|
239
|
+
{
|
|
240
|
+
label: 'Rename…',
|
|
241
|
+
icon: 'icon-edit',
|
|
242
|
+
run: () => {
|
|
243
|
+
this._asking = { verb: 'rename', path }
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
label: 'Delete',
|
|
248
|
+
icon: 'icon-trash',
|
|
249
|
+
run: () => this.#send(() => this.#config.folder('DELETE', { path })),
|
|
250
|
+
},
|
|
251
|
+
]
|
|
252
|
+
: []),
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** What an item offers: moving it to another folder. */
|
|
257
|
+
#itemChoices(item) {
|
|
258
|
+
if (!this.#editable || (this._folders ?? []).length === 0) return []
|
|
259
|
+
return ['', ...this._folders]
|
|
260
|
+
.filter((folder) => folder !== (item.folder ?? ''))
|
|
261
|
+
.map((folder) => ({
|
|
262
|
+
label: folder ? `Move to ${folder}` : 'Move to the top',
|
|
263
|
+
icon: 'icon-enter',
|
|
264
|
+
run: () => this.#send(() => this.#config.move(item.alias, folder)),
|
|
265
|
+
}))
|
|
196
266
|
}
|
|
197
267
|
|
|
198
|
-
#
|
|
199
|
-
return
|
|
268
|
+
#idFor(kind, key) {
|
|
269
|
+
return `${kind}-${key.replace(/[^a-z0-9]/gi, '-')}`
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
#folder(node, label, href) {
|
|
273
|
+
const children = node.folders.length + node.items.length > 0
|
|
274
|
+
return html`<uui-menu-item
|
|
275
|
+
label=${label}
|
|
276
|
+
href=${href ?? nothing}
|
|
277
|
+
.hasChildren=${children}
|
|
278
|
+
.showChildren=${children && !this.#closed.has(node.path)}
|
|
279
|
+
?active=${href !== undefined && url(this.#config.root) === location.pathname}
|
|
280
|
+
@show-children=${() => this.#toggle(node.path, true)}
|
|
281
|
+
@hide-children=${() => this.#toggle(node.path, false)}
|
|
282
|
+
@click-label=${href ? nothing : () => this.#toggle(node.path, this.#closed.has(node.path))}
|
|
283
|
+
>
|
|
284
|
+
<umb-icon slot="icon" name="icon-folder"></umb-icon>
|
|
285
|
+
${this.#menu(this.#idFor('folder', node.path || 'root'), label, this.#folderChoices(node.path))}
|
|
200
286
|
${repeat(
|
|
201
287
|
node.folders,
|
|
202
288
|
(folder) => folder.path,
|
|
203
|
-
(folder) =>
|
|
204
|
-
<details open>
|
|
205
|
-
<summary><span>${folder.name}</span>${this.#folderActions(folder.path)}</summary>
|
|
206
|
-
${this.#items(folder)}
|
|
207
|
-
</details>
|
|
208
|
-
</li>`,
|
|
289
|
+
(folder) => this.#folder(folder, folder.name),
|
|
209
290
|
)}
|
|
210
291
|
${repeat(
|
|
211
292
|
node.items,
|
|
212
293
|
(item) => item.alias,
|
|
213
|
-
(item) =>
|
|
214
|
-
|
|
215
|
-
|
|
294
|
+
(item) => {
|
|
295
|
+
const href = url(this.#config.open(item))
|
|
296
|
+
return html`<uui-menu-item
|
|
297
|
+
label=${item.name}
|
|
298
|
+
href=${href}
|
|
299
|
+
?active=${`${location.pathname}${location.search}` === href}
|
|
300
|
+
>
|
|
301
|
+
<umb-icon slot="icon" name=${this.#config.icon}></umb-icon>
|
|
302
|
+
${this.#menu(this.#idFor('item', item.alias), item.name, this.#itemChoices(item))}
|
|
303
|
+
</uui-menu-item>`
|
|
304
|
+
},
|
|
216
305
|
)}
|
|
217
|
-
</
|
|
306
|
+
</uui-menu-item>`
|
|
218
307
|
}
|
|
219
308
|
|
|
220
309
|
render() {
|
|
221
310
|
if (!this._tree) return html`<uui-loader></uui-loader>`
|
|
222
311
|
const words = readOnlyWords(this.#config.label, this._because)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
</div>
|
|
227
|
-
${this.#asking()}
|
|
312
|
+
this.#popovers = []
|
|
313
|
+
const tree = this.#folder(this._tree, this.#config.rootLabel, url(this.#config.root))
|
|
314
|
+
return html`${this.#asking()}
|
|
228
315
|
${this._problem ? html`<p class="problem" role="alert">${this._problem}</p>` : nothing}
|
|
229
316
|
${words ? html`<p class="note" role="status">${words}</p>` : nothing}
|
|
230
|
-
|
|
317
|
+
<uui-menu-item-list>${tree}</uui-menu-item-list>
|
|
318
|
+
${this.#popovers}`
|
|
231
319
|
}
|
|
232
320
|
|
|
233
321
|
static styles = css`
|
|
234
322
|
:host {
|
|
235
323
|
display: block;
|
|
236
|
-
padding: var(--uui-size-space-3) var(--uui-size-space-4);
|
|
237
|
-
}
|
|
238
|
-
a {
|
|
239
|
-
color: var(--uui-color-text);
|
|
240
|
-
text-decoration: none;
|
|
241
|
-
}
|
|
242
|
-
a:hover {
|
|
243
|
-
text-decoration: underline;
|
|
244
|
-
}
|
|
245
|
-
.root {
|
|
246
|
-
display: flex;
|
|
247
|
-
justify-content: space-between;
|
|
248
|
-
align-items: center;
|
|
249
|
-
font-weight: 700;
|
|
250
|
-
padding-bottom: var(--uui-size-space-2);
|
|
251
|
-
}
|
|
252
|
-
ul {
|
|
253
|
-
list-style: none;
|
|
254
|
-
margin: 0;
|
|
255
|
-
padding: 0 0 0 var(--uui-size-space-4);
|
|
256
|
-
}
|
|
257
|
-
:host > ul {
|
|
258
|
-
padding-left: 0;
|
|
259
|
-
}
|
|
260
|
-
li {
|
|
261
|
-
padding: var(--uui-size-space-1) 0;
|
|
262
|
-
}
|
|
263
|
-
.item {
|
|
264
|
-
display: flex;
|
|
265
|
-
justify-content: space-between;
|
|
266
|
-
gap: var(--uui-size-space-2);
|
|
267
|
-
}
|
|
268
|
-
summary {
|
|
269
|
-
display: flex;
|
|
270
|
-
justify-content: space-between;
|
|
271
|
-
cursor: pointer;
|
|
272
|
-
list-style-position: inside;
|
|
273
|
-
}
|
|
274
|
-
.actions {
|
|
275
|
-
display: inline-flex;
|
|
276
|
-
gap: var(--uui-size-space-1);
|
|
277
|
-
}
|
|
278
|
-
.actions button,
|
|
279
|
-
.actions a {
|
|
280
|
-
background: none;
|
|
281
|
-
border: 0;
|
|
282
|
-
padding: 0 var(--uui-size-space-1);
|
|
283
|
-
cursor: pointer;
|
|
284
|
-
color: var(--uui-color-text-alt);
|
|
285
|
-
font: inherit;
|
|
286
|
-
}
|
|
287
|
-
select {
|
|
288
|
-
max-width: 5rem;
|
|
289
|
-
font: inherit;
|
|
290
|
-
font-size: var(--uui-type-small-size);
|
|
291
|
-
color: var(--uui-color-text-alt);
|
|
292
|
-
background: none;
|
|
293
|
-
border: 0;
|
|
294
324
|
}
|
|
295
325
|
.ask {
|
|
296
326
|
display: flex;
|
|
297
327
|
flex-wrap: wrap;
|
|
298
328
|
gap: var(--uui-size-space-2);
|
|
299
|
-
padding
|
|
329
|
+
padding: var(--uui-size-space-2) var(--uui-size-space-4);
|
|
300
330
|
}
|
|
301
331
|
.ask input {
|
|
302
332
|
flex: 1 1 100%;
|
|
@@ -304,7 +334,8 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
304
334
|
}
|
|
305
335
|
.note,
|
|
306
336
|
.problem {
|
|
307
|
-
margin: 0
|
|
337
|
+
margin: 0;
|
|
338
|
+
padding: var(--uui-size-space-2) var(--uui-size-space-4);
|
|
308
339
|
font-size: var(--uui-type-small-size);
|
|
309
340
|
line-height: 1.5;
|
|
310
341
|
color: var(--uui-color-text-alt);
|