@crombolo/backoffice-host 0.52.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/branding/localization-en.js +4 -0
- package/plugin/content-strip-items.js +41 -16
- package/plugin/content-strip.js +4 -2
- package/plugin/definition-tree-model.js +1 -1
- package/plugin/definition-tree.js +169 -128
- 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-create-option.js +13 -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 +86 -8
- 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 +136 -42
- 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 }
|
|
@@ -32,6 +32,8 @@ export default {
|
|
|
32
32
|
'Welcome to Crombolo! Unfortunately your invite has expired. Please contact your administrator to get a new one.',
|
|
33
33
|
},
|
|
34
34
|
user: {
|
|
35
|
+
sectionsHelp:
|
|
36
|
+
'Pages needs Content. Structure, Components and Workflow setup change the whole site, so give them with care.',
|
|
35
37
|
changePasswordDescription:
|
|
36
38
|
"You can change your password for accessing the Crombolo backoffice by filling out the form below and click the 'Change Password' button",
|
|
37
39
|
createUserHelp:
|
|
@@ -90,6 +92,8 @@ export default {
|
|
|
90
92
|
newPartialViewFromSnippet: 'Component from snippet',
|
|
91
93
|
},
|
|
92
94
|
treeHeaders: {
|
|
95
|
+
// Components, modules, stylesheets and scripts: more than templates.
|
|
96
|
+
templatingGroup: 'Code',
|
|
93
97
|
// One tree over one directory: templates and partial views are the same
|
|
94
98
|
// kind of file here, and what makes one a template is that a content type
|
|
95
99
|
// names it, not where it sits.
|
|
@@ -1,33 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What the menu under Content offers (story 289), and which item a page belongs
|
|
3
|
-
* to. Pure, so each is tested on its own. Structure and
|
|
4
|
-
* Settings
|
|
5
|
-
*
|
|
3
|
+
* to. Pure, so each is tested on its own. Structure and Code stay in
|
|
4
|
+
* Settings: the client links to them there, and the menu is what puts them
|
|
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
|
-
const
|
|
10
|
+
const STRUCTURE = 'Crombolo.Section.Structure'
|
|
11
|
+
const COMPONENTS = 'Crombolo.Section.Components'
|
|
12
|
+
const WORKFLOW_SETUP = 'Crombolo.Section.WorkflowSetup'
|
|
13
|
+
const APPROVALS = 'Crombolo.Section.Workflow'
|
|
14
|
+
/** Reading forms, which is what a group's Forms comes to. */
|
|
15
|
+
const FORM_READ = 'Crombolo.Form.Read'
|
|
10
16
|
const FORMS = 'Crombolo.Section.Forms'
|
|
11
17
|
const CONTENT = 'Umb.Section.Content'
|
|
12
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
|
+
]
|
|
27
|
+
|
|
13
28
|
const ITEMS = [
|
|
14
29
|
{ label: 'Pages', path: 'section/content', section: CONTENT },
|
|
15
|
-
{ label: '
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
30
|
+
{ label: 'Approvals', path: 'section/workflow', section: APPROVALS },
|
|
31
|
+
{
|
|
32
|
+
label: 'Structure',
|
|
33
|
+
path: 'section/settings/structure',
|
|
34
|
+
section: STRUCTURE,
|
|
35
|
+
or: STRUCTURE_ELSE,
|
|
36
|
+
},
|
|
37
|
+
{ label: 'Code', path: 'section/settings/code', section: COMPONENTS },
|
|
19
38
|
]
|
|
20
39
|
|
|
21
40
|
/**
|
|
22
41
|
* The items this user may open. One alone is no menu, so it offers none.
|
|
23
42
|
*
|
|
24
|
-
* @param {{ allowedSections?: string[], isAdmin?: boolean } | undefined} user
|
|
43
|
+
* @param {{ allowedSections?: string[], fallbackPermissions?: string[], isAdmin?: boolean } | undefined} user
|
|
25
44
|
*/
|
|
26
45
|
export function stripItems(user) {
|
|
27
46
|
const allowed = user?.allowedSections ?? []
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
const may = (verb) => user?.isAdmin === true || (user?.fallbackPermissions ?? []).includes(verb)
|
|
48
|
+
const items = ITEMS.flatMap((item) => {
|
|
49
|
+
if (allowed.includes(item.section)) return [item]
|
|
50
|
+
const other = (item.or ?? []).find(
|
|
51
|
+
(or) => allowed.includes(or.section) && (!or.verb || may(or.verb)),
|
|
52
|
+
)
|
|
53
|
+
return other ? [{ ...item, ...other }] : []
|
|
54
|
+
})
|
|
31
55
|
return items.length > 1 ? items : []
|
|
32
56
|
}
|
|
33
57
|
|
|
@@ -41,10 +65,11 @@ export function activeItem(path) {
|
|
|
41
65
|
if (!section) return undefined
|
|
42
66
|
const [, name, rest = ''] = section
|
|
43
67
|
if (name === 'content') return 'Pages'
|
|
44
|
-
if (name === 'forms') return
|
|
68
|
+
if (name === 'forms') return 'Structure'
|
|
69
|
+
if (name === 'workflow') return 'Approvals'
|
|
45
70
|
if (name !== 'settings') return undefined
|
|
46
|
-
if (rest.startsWith(
|
|
47
|
-
if (rest.startsWith('code')) return '
|
|
71
|
+
if (['structure', 'forms', 'workflows'].some((tree) => rest.startsWith(tree))) return 'Structure'
|
|
72
|
+
if (rest.startsWith('code')) return 'Code'
|
|
48
73
|
const tree = treeFor(/^workspace\/([^/]+)/.exec(rest)?.[1])
|
|
49
|
-
return tree === 'structure' ? 'Structure' : tree === 'code' ? '
|
|
74
|
+
return tree === 'structure' ? 'Structure' : tree === 'code' ? 'Code' : undefined
|
|
50
75
|
}
|
package/plugin/content-strip.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The menu under Content (story 289): Pages, Structure,
|
|
3
|
-
* Workflows, for whoever may open them. A row of its own under the header, shown
|
|
2
|
+
* The menu under Content (story 289): Pages, Structure, Code and Workflows, for whoever may open them. A row of its own under the header, shown
|
|
4
3
|
* wherever one of them is open, and it keeps Content's tab marked while it shows.
|
|
5
4
|
*/
|
|
6
5
|
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
|
|
@@ -58,12 +57,15 @@ export default class CromboloContentStripElement extends UmbLitElement {
|
|
|
58
57
|
this.#follow()
|
|
59
58
|
window.addEventListener('changestate', this.#follow)
|
|
60
59
|
window.addEventListener('popstate', this.#follow)
|
|
60
|
+
// A route the router settles on without a state change of its own, such as Home.
|
|
61
|
+
window.addEventListener('navigationend', this.#follow)
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
disconnectedCallback() {
|
|
64
65
|
super.disconnectedCallback()
|
|
65
66
|
window.removeEventListener('changestate', this.#follow)
|
|
66
67
|
window.removeEventListener('popstate', this.#follow)
|
|
68
|
+
window.removeEventListener('navigationend', this.#follow)
|
|
67
69
|
mark(undefined)
|
|
68
70
|
document.documentElement.style.removeProperty(ROW_HEIGHT)
|
|
69
71
|
}
|
|
@@ -38,6 +38,6 @@ export function definitionTree(items, folders) {
|
|
|
38
38
|
export function readOnlyWords(kind, because) {
|
|
39
39
|
if (because === 'site')
|
|
40
40
|
return `${kind} are kept with this site's files, so they can't be changed here. To change one, edit it in the site's code and deploy it.`
|
|
41
|
-
if (because === 'permission') return `
|
|
41
|
+
if (because === 'permission') return `Your group can't change ${kind.toLowerCase()}.`
|
|
42
42
|
return undefined
|
|
43
43
|
}
|
|
@@ -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'
|
|
@@ -15,23 +15,41 @@ const here = () => {
|
|
|
15
15
|
return location.pathname.startsWith(base) ? location.pathname.slice(base.length) : ''
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** A form's screens, in Structure for those who have it, else in the Forms section. */
|
|
19
|
+
const formsAt = (view) =>
|
|
20
|
+
here().startsWith('section/settings')
|
|
21
|
+
? `section/settings/forms${view === 'entries' ? '/entries' : ''}`
|
|
22
|
+
: `section/forms/view/${view}`
|
|
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
|
+
|
|
18
28
|
const KINDS = {
|
|
19
29
|
Forms: {
|
|
20
30
|
label: 'Forms',
|
|
21
|
-
root
|
|
31
|
+
get root() {
|
|
32
|
+
return formsAt('entries')
|
|
33
|
+
},
|
|
22
34
|
rootLabel: 'Forms',
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
itemNoun: 'form',
|
|
36
|
+
icon: 'icon-autofill',
|
|
37
|
+
open: (item) => `${formsAt('forms')}?form=${encodeURIComponent(item.key)}`,
|
|
38
|
+
create: (folder) => `${formsAt('forms')}?new=${encodeURIComponent(folder)}`,
|
|
25
39
|
load: formsTree,
|
|
26
40
|
folder: sendFormFolder,
|
|
27
41
|
move: moveForm,
|
|
28
42
|
},
|
|
29
43
|
Workflows: {
|
|
30
44
|
label: 'Workflows',
|
|
31
|
-
root
|
|
45
|
+
get root() {
|
|
46
|
+
return workflowsAt()
|
|
47
|
+
},
|
|
32
48
|
rootLabel: 'Workflows',
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
itemNoun: 'workflow',
|
|
50
|
+
icon: 'icon-mindmap',
|
|
51
|
+
open: (item) => workflowsAt(`?workflow=${encodeURIComponent(item.alias)}`),
|
|
52
|
+
create: (folder) => workflowsAt(`?new=${encodeURIComponent(folder)}`),
|
|
35
53
|
load: async () => {
|
|
36
54
|
const list = await listWorkflows()
|
|
37
55
|
return {
|
|
@@ -50,6 +68,10 @@ const url = (path) =>
|
|
|
50
68
|
|
|
51
69
|
export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
52
70
|
static properties = {
|
|
71
|
+
/** The tree to show; without it, the menu item's, else whichever the address belongs to. */
|
|
72
|
+
kind: { type: String },
|
|
73
|
+
/** Set by the menu, as for any menu item: its `meta.kind` names the tree. */
|
|
74
|
+
manifest: { attribute: false },
|
|
53
75
|
_kind: { state: true },
|
|
54
76
|
_tree: { state: true },
|
|
55
77
|
_because: { state: true },
|
|
@@ -58,7 +80,10 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
58
80
|
}
|
|
59
81
|
|
|
60
82
|
#follow = () => {
|
|
61
|
-
const kind =
|
|
83
|
+
const kind =
|
|
84
|
+
this.kind ??
|
|
85
|
+
this.manifest?.meta?.kind ??
|
|
86
|
+
(/^section\/forms\/view\/workflows/.test(here()) ? 'Workflows' : 'Forms')
|
|
62
87
|
if (kind === this._kind) return
|
|
63
88
|
this._kind = kind
|
|
64
89
|
this.#load()
|
|
@@ -66,6 +91,10 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
66
91
|
|
|
67
92
|
#reload = () => this.#load()
|
|
68
93
|
|
|
94
|
+
willUpdate(changed) {
|
|
95
|
+
if (changed.has('manifest')) this.#follow()
|
|
96
|
+
}
|
|
97
|
+
|
|
69
98
|
connectedCallback() {
|
|
70
99
|
super.connectedCallback()
|
|
71
100
|
this.#follow()
|
|
@@ -86,7 +115,10 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
86
115
|
}
|
|
87
116
|
|
|
88
117
|
async #load() {
|
|
118
|
+
const kind = this._kind
|
|
89
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
|
|
90
122
|
this._tree = definitionTree(items, folders)
|
|
91
123
|
this._folders = folders
|
|
92
124
|
this._because = readOnlyBecause
|
|
@@ -137,156 +169,164 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
137
169
|
</form>`
|
|
138
170
|
}
|
|
139
171
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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>
|
|
152
209
|
${
|
|
153
|
-
|
|
154
|
-
? html`<button
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
aria-label="Rename"
|
|
158
|
-
@click=${() => {
|
|
159
|
-
this._asking = { verb: 'rename', path }
|
|
160
|
-
}}
|
|
161
|
-
>✎</button>
|
|
162
|
-
<button
|
|
163
|
-
type="button"
|
|
164
|
-
title="Delete"
|
|
165
|
-
aria-label="Delete"
|
|
166
|
-
@click=${() => this.#send(() => this.#config.folder('DELETE', { path }))}
|
|
167
|
-
>×</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>`
|
|
168
214
|
: nothing
|
|
169
215
|
}
|
|
170
|
-
</
|
|
216
|
+
</uui-action-bar>`
|
|
171
217
|
}
|
|
172
218
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
+
}))
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
#idFor(kind, key) {
|
|
269
|
+
return `${kind}-${key.replace(/[^a-z0-9]/gi, '-')}`
|
|
186
270
|
}
|
|
187
271
|
|
|
188
|
-
#
|
|
189
|
-
|
|
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))}
|
|
190
286
|
${repeat(
|
|
191
287
|
node.folders,
|
|
192
288
|
(folder) => folder.path,
|
|
193
|
-
(folder) =>
|
|
194
|
-
<details open>
|
|
195
|
-
<summary><span>${folder.name}</span>${this.#folderActions(folder.path)}</summary>
|
|
196
|
-
${this.#items(folder)}
|
|
197
|
-
</details>
|
|
198
|
-
</li>`,
|
|
289
|
+
(folder) => this.#folder(folder, folder.name),
|
|
199
290
|
)}
|
|
200
291
|
${repeat(
|
|
201
292
|
node.items,
|
|
202
293
|
(item) => item.alias,
|
|
203
|
-
(item) =>
|
|
204
|
-
|
|
205
|
-
|
|
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
|
+
},
|
|
206
305
|
)}
|
|
207
|
-
</
|
|
306
|
+
</uui-menu-item>`
|
|
208
307
|
}
|
|
209
308
|
|
|
210
309
|
render() {
|
|
211
310
|
if (!this._tree) return html`<uui-loader></uui-loader>`
|
|
212
311
|
const words = readOnlyWords(this.#config.label, this._because)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
</div>
|
|
217
|
-
${this.#asking()}
|
|
312
|
+
this.#popovers = []
|
|
313
|
+
const tree = this.#folder(this._tree, this.#config.rootLabel, url(this.#config.root))
|
|
314
|
+
return html`${this.#asking()}
|
|
218
315
|
${this._problem ? html`<p class="problem" role="alert">${this._problem}</p>` : nothing}
|
|
219
316
|
${words ? html`<p class="note" role="status">${words}</p>` : nothing}
|
|
220
|
-
|
|
317
|
+
<uui-menu-item-list>${tree}</uui-menu-item-list>
|
|
318
|
+
${this.#popovers}`
|
|
221
319
|
}
|
|
222
320
|
|
|
223
321
|
static styles = css`
|
|
224
322
|
:host {
|
|
225
323
|
display: block;
|
|
226
|
-
padding: var(--uui-size-space-3) var(--uui-size-space-4);
|
|
227
|
-
}
|
|
228
|
-
a {
|
|
229
|
-
color: var(--uui-color-text);
|
|
230
|
-
text-decoration: none;
|
|
231
|
-
}
|
|
232
|
-
a:hover {
|
|
233
|
-
text-decoration: underline;
|
|
234
|
-
}
|
|
235
|
-
.root {
|
|
236
|
-
display: flex;
|
|
237
|
-
justify-content: space-between;
|
|
238
|
-
align-items: center;
|
|
239
|
-
font-weight: 700;
|
|
240
|
-
padding-bottom: var(--uui-size-space-2);
|
|
241
|
-
}
|
|
242
|
-
ul {
|
|
243
|
-
list-style: none;
|
|
244
|
-
margin: 0;
|
|
245
|
-
padding: 0 0 0 var(--uui-size-space-4);
|
|
246
|
-
}
|
|
247
|
-
:host > ul {
|
|
248
|
-
padding-left: 0;
|
|
249
|
-
}
|
|
250
|
-
li {
|
|
251
|
-
padding: var(--uui-size-space-1) 0;
|
|
252
|
-
}
|
|
253
|
-
.item {
|
|
254
|
-
display: flex;
|
|
255
|
-
justify-content: space-between;
|
|
256
|
-
gap: var(--uui-size-space-2);
|
|
257
|
-
}
|
|
258
|
-
summary {
|
|
259
|
-
display: flex;
|
|
260
|
-
justify-content: space-between;
|
|
261
|
-
cursor: pointer;
|
|
262
|
-
list-style-position: inside;
|
|
263
|
-
}
|
|
264
|
-
.actions {
|
|
265
|
-
display: inline-flex;
|
|
266
|
-
gap: var(--uui-size-space-1);
|
|
267
|
-
}
|
|
268
|
-
.actions button,
|
|
269
|
-
.actions a {
|
|
270
|
-
background: none;
|
|
271
|
-
border: 0;
|
|
272
|
-
padding: 0 var(--uui-size-space-1);
|
|
273
|
-
cursor: pointer;
|
|
274
|
-
color: var(--uui-color-text-alt);
|
|
275
|
-
font: inherit;
|
|
276
|
-
}
|
|
277
|
-
select {
|
|
278
|
-
max-width: 5rem;
|
|
279
|
-
font: inherit;
|
|
280
|
-
font-size: var(--uui-type-small-size);
|
|
281
|
-
color: var(--uui-color-text-alt);
|
|
282
|
-
background: none;
|
|
283
|
-
border: 0;
|
|
284
324
|
}
|
|
285
325
|
.ask {
|
|
286
326
|
display: flex;
|
|
287
327
|
flex-wrap: wrap;
|
|
288
328
|
gap: var(--uui-size-space-2);
|
|
289
|
-
padding
|
|
329
|
+
padding: var(--uui-size-space-2) var(--uui-size-space-4);
|
|
290
330
|
}
|
|
291
331
|
.ask input {
|
|
292
332
|
flex: 1 1 100%;
|
|
@@ -294,7 +334,8 @@ export default class CromboloDefinitionTreeElement extends UmbLitElement {
|
|
|
294
334
|
}
|
|
295
335
|
.note,
|
|
296
336
|
.problem {
|
|
297
|
-
margin: 0
|
|
337
|
+
margin: 0;
|
|
338
|
+
padding: var(--uui-size-space-2) var(--uui-size-space-4);
|
|
298
339
|
font-size: var(--uui-type-small-size);
|
|
299
340
|
line-height: 1.5;
|
|
300
341
|
color: var(--uui-color-text-alt);
|