@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.
@@ -1,10 +1,10 @@
1
1
  /**
2
- * A form text that can name a dictionary item (story 294): typing `#` offers the
3
- * items, and what one reads as shows underneath. It sends `change`, with `value`,
4
- * as `uui-input` does. The list is a popover so a table cell doesn't clip it.
2
+ * A form text that can name a dictionary item (stories 294, 297): typing `{#`,
3
+ * or `#` at the start, offers the items, and a `{#key}` shows as a chip. It sends
4
+ * `change`, with `value`, as `uui-input` does.
5
5
  */
6
- import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
7
- import { suggestions, wordLine } from './form-word-input-model.js'
6
+ import { css, html, LitElement } from '@umbraco-cms/backoffice/external/lit'
7
+ import './dictionary-words.js'
8
8
 
9
9
  export default class CromboloFormWordInputElement extends LitElement {
10
10
  static properties = {
@@ -13,107 +13,44 @@ export default class CromboloFormWordInputElement extends LitElement {
13
13
  value: { type: String },
14
14
  readonly: { type: Boolean },
15
15
  words: { attribute: false },
16
- _open: { state: true },
17
- _active: { state: true },
18
16
  }
19
17
 
20
18
  constructor() {
21
19
  super()
22
20
  this.value = ''
23
21
  this.words = []
24
- this._open = false
25
- this._active = 0
26
- }
27
-
28
- get #found() {
29
- return this.readonly ? { rows: [], more: false } : suggestions(this.words ?? [], this.value)
30
- }
31
-
32
- #choose(word) {
33
- this.value = `#${word.name}`
34
- this._open = false
35
- this.#changed()
36
22
  }
37
23
 
38
24
  #changed() {
39
25
  this.dispatchEvent(new Event('change', { bubbles: true }))
40
26
  }
41
27
 
42
- #onInput(event) {
43
- event.stopPropagation()
44
- this.value = event.target.value ?? ''
45
- this._active = 0
46
- this._open = this.#found.rows.length > 0
47
- }
48
-
49
- #onKeydown(event) {
50
- const { rows } = this.#found
51
- if (!this._open || rows.length === 0) return
52
- if (event.key === 'Escape') {
53
- event.stopPropagation()
54
- this._open = false
55
- } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
56
- event.preventDefault()
57
- const step = event.key === 'ArrowDown' ? 1 : rows.length - 1
58
- this._active = (this._active + step) % rows.length
59
- } else if (event.key === 'Enter') {
60
- event.preventDefault()
61
- this.#choose(rows[this._active] ?? rows[0])
62
- }
63
- }
64
-
65
- updated() {
66
- const list = this.renderRoot.querySelector('[popover]')
67
- if (!list) return
68
- const box = this.renderRoot.querySelector('uui-input').getBoundingClientRect()
69
- list.style.top = `${box.bottom + 2}px`
70
- list.style.left = `${box.left}px`
71
- list.style.minWidth = `${box.width}px`
72
- list.showPopover()
73
- }
74
-
75
28
  render() {
76
- const { rows, more } = this.#found
77
- const line = wordLine(this.words, this.value)
78
- const open = this._open && rows.length > 0
79
- return html`<uui-input
29
+ return html`<crombolo-dictionary-words
30
+ .value=${this.value ?? ''}
31
+ .words=${this.words}
32
+ ?readonly=${this.readonly}
33
+ @input=${(event) => event.stopPropagation()}
34
+ @crombolo-word-choose=${(event) => {
35
+ event.stopPropagation()
36
+ this.value = event.detail.value
37
+ this.#changed()
38
+ }}
39
+ >
40
+ <uui-input
80
41
  label=${this.label}
81
42
  placeholder=${this.placeholder ?? ''}
82
43
  .value=${this.value ?? ''}
83
44
  ?readonly=${this.readonly}
84
- @input=${this.#onInput}
85
- @keydown=${this.#onKeydown}
45
+ @input=${(event) => {
46
+ this.value = event.target.value ?? ''
47
+ }}
86
48
  @change=${(event) => {
87
49
  event.stopPropagation()
88
50
  this.#changed()
89
51
  }}
90
- @blur=${() => {
91
- this._open = false
92
- }}
93
52
  ></uui-input>
94
- ${line ? html`<p class="word">${line}</p>` : nothing}
95
- <span class="status" role="status"
96
- >${open ? `${rows.length} dictionary items. Use the arrow keys to choose one.` : ''}</span
97
- >
98
- ${
99
- open
100
- ? html`<div popover="manual" role="listbox" aria-label="Dictionary items">
101
- ${rows.map(
102
- (word, index) => html`<div
103
- role="option"
104
- aria-selected=${index === this._active ? 'true' : 'false'}
105
- @pointerdown=${(event) => {
106
- event.preventDefault()
107
- this.#choose(word)
108
- }}
109
- >
110
- <strong>${word.name}</strong> <span>${word.text}</span>
111
- </div>`,
112
- )}
113
- ${more ? html`<p class="more">Keep typing to narrow this down.</p>` : nothing}
114
- </div>`
115
- : nothing
116
- }`
53
+ </crombolo-dictionary-words>`
117
54
  }
118
55
 
119
56
  static styles = css`
@@ -123,47 +60,6 @@ export default class CromboloFormWordInputElement extends LitElement {
123
60
  uui-input {
124
61
  width: 100%;
125
62
  }
126
- .word {
127
- margin: var(--uui-size-space-1) 0 0;
128
- color: var(--uui-color-text-alt);
129
- font-size: var(--uui-type-small-size);
130
- }
131
- .status {
132
- position: absolute;
133
- width: 1px;
134
- height: 1px;
135
- overflow: hidden;
136
- clip-path: inset(50%);
137
- }
138
- [popover] {
139
- position: fixed;
140
- inset: auto;
141
- margin: 0;
142
- padding: var(--uui-size-space-1);
143
- max-width: 28rem;
144
- background: var(--uui-color-surface);
145
- color: var(--uui-color-text);
146
- border: 1px solid var(--uui-color-border);
147
- border-radius: var(--uui-border-radius);
148
- box-shadow: var(--uui-shadow-depth-3);
149
- }
150
- [role='option'] {
151
- padding: var(--uui-size-space-2) var(--uui-size-space-3);
152
- border-radius: var(--uui-border-radius);
153
- cursor: pointer;
154
- }
155
- [role='option'] span {
156
- color: var(--uui-color-text-alt);
157
- }
158
- [role='option'][aria-selected='true'],
159
- [role='option']:hover {
160
- background: var(--uui-color-surface-emphasis);
161
- }
162
- .more {
163
- margin: var(--uui-size-space-1) var(--uui-size-space-3);
164
- color: var(--uui-color-text-alt);
165
- font-size: var(--uui-type-small-size);
166
- }
167
63
  `
168
64
  }
169
65
 
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Localizations",
4
4
  "id": "Crombolo.Localizations",
5
- "version": "0.52.2",
5
+ "version": "0.54.1",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Search & sharing",
4
4
  "id": "Crombolo.Seo",
5
- "version": "0.52.2",
5
+ "version": "0.54.1",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -177,7 +177,14 @@ const rank = (order, alias) => {
177
177
  return at === -1 ? order.length : at
178
178
  }
179
179
 
180
- const STRUCTURE_TYPES = ['document-type', 'media-type', 'member-type', 'data-type', 'language']
180
+ const STRUCTURE_TYPES = [
181
+ 'document-type',
182
+ 'document-blueprint',
183
+ 'media-type',
184
+ 'member-type',
185
+ 'data-type',
186
+ 'language',
187
+ ]
181
188
  const CODE_TYPES = ['partial-view', 'template', 'stylesheet', 'script']
182
189
 
183
190
  /** The tree an editor for `entityType` sits beside, or undefined for none. */
@@ -6,6 +6,7 @@
6
6
  * manifest.
7
7
  */
8
8
 
9
+ import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
9
10
  import {
10
11
  createExtensionApi,
11
12
  createExtensionElement,
@@ -46,8 +47,33 @@ const emailStatus = async () => {
46
47
  return response.json()
47
48
  }
48
49
 
50
+ /** Where Umbraco's sections keep the sidebar's width, so every section shares one. */
51
+ const SPLIT_POSITION = 'umb-split-panel-position'
52
+
53
+ const savedPosition = () => {
54
+ try {
55
+ return localStorage.getItem(SPLIT_POSITION) ?? undefined
56
+ } catch {
57
+ return undefined
58
+ }
59
+ }
60
+
61
+ const savePosition = (event) => {
62
+ try {
63
+ localStorage.setItem(SPLIT_POSITION, String(event.detail.position))
64
+ } catch {
65
+ // A browser that keeps nothing starts at the default width each time.
66
+ }
67
+ }
68
+
49
69
  const menuOf = (manifest, menu) => manifest.meta?.menus?.includes(menu) === true
50
70
 
71
+ /** Each tree, and the part of Settings that opens it. */
72
+ const TREE_SECTIONS = [
73
+ ['structure', 'Crombolo.Section.Structure'],
74
+ ['code', 'Crombolo.Section.Components'],
75
+ ]
76
+
51
77
  export class CromboloSettingsSectionElement extends UmbLitElement {
52
78
  static properties = {
53
79
  _routes: { state: true },
@@ -58,6 +84,8 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
58
84
  }
59
85
 
60
86
  #dashboards = []
87
+ /** The sections the current user holds, which say how much of Settings they have. */
88
+ #held
61
89
  #menuItems = []
62
90
  #sectionRoutes = []
63
91
  #landing
@@ -66,6 +94,12 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
66
94
 
67
95
  constructor() {
68
96
  super()
97
+ this.consumeContext(UMB_CURRENT_USER_CONTEXT, (user) => {
98
+ this.observe(user?.currentUser, (current) => {
99
+ this.#held = current?.allowedSections ?? []
100
+ this.#createRoutes()
101
+ })
102
+ })
69
103
  // An explanation, not a control: a failure leaves it out.
70
104
  fetch(`${base()}/crombolo/api/site-files`, { credentials: 'include' })
71
105
  .then((response) => (response.ok ? response.json() : { writable: true }))
@@ -202,9 +236,20 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
202
236
  }
203
237
 
204
238
  #createRoutes() {
239
+ // Someone with a part of Settings has its tree, and not the cards or the tools.
240
+ const whole = this.#held?.includes('Crombolo.Section.AllSettings') ?? false
241
+ const mine = TREE_SECTIONS.filter(([, section]) => this.#held?.includes(section)).map(
242
+ ([tree]) => tree,
243
+ )
244
+ const toTree = (name) =>
245
+ history.replaceState(null, '', new URL(`section/settings/${name}`, document.baseURI).pathname)
205
246
  const landing = {
206
247
  component: () => document.createElement('crombolo-settings-landing'),
207
248
  setup: (element) => {
249
+ if (this.#held && !whole && mine[0]) {
250
+ toTree(mine[0])
251
+ return
252
+ }
208
253
  this.#landing = element
209
254
  this.#refreshLanding()
210
255
  this.#showing(undefined)
@@ -214,6 +259,10 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
214
259
  path: name,
215
260
  component: () => document.createElement('crombolo-settings-tree-start'),
216
261
  setup: (element) => {
262
+ if (this.#held && !mine.includes(name) && mine[0]) {
263
+ toTree(mine[0])
264
+ return
265
+ }
217
266
  element.tree = name
218
267
  this.#showing(name)
219
268
  },
@@ -232,12 +281,24 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
232
281
  this.#showing(undefined, { title: this.#label(manifest) })
233
282
  },
234
283
  }))
284
+ // Forms and Workflows are nodes in Structure, so its tree stays on screen beside them.
285
+ const forms = (path, tag, load) => ({
286
+ path,
287
+ component: async () => {
288
+ await load()
289
+ return document.createElement(tag)
290
+ },
291
+ setup: () => this.#showing('structure'),
292
+ })
235
293
  this._routes = [
294
+ forms('forms/entries', 'crombolo-forms-entries', () => import('./forms-entries.js')),
295
+ forms('forms', 'crombolo-forms-overview', () => import('./forms-overview.js')),
296
+ forms('workflows', 'crombolo-workflow-designer', () => import('./workflow-designer.js')),
236
297
  tree('structure'),
237
298
  tree('code'),
238
299
  // Umbraco's welcome, which this page replaces: an address people have.
239
300
  { path: 'dashboard/welcome', ...landing },
240
- // Workflows moved beside forms (story 289): an address people have.
301
+ // Workflows were a Settings card, then beside forms (story 289): an address people have.
241
302
  {
242
303
  path: 'dashboard/workflows',
243
304
  component: () => document.createElement('div'),
@@ -245,15 +306,17 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
245
306
  history.replaceState(
246
307
  null,
247
308
  '',
248
- new URL('section/forms/view/workflows', document.baseURI).pathname,
309
+ new URL('section/settings/workflows', document.baseURI).pathname,
249
310
  )
250
311
  },
251
312
  },
252
- ...dashboards,
313
+ ...(this.#held && !whole ? [] : dashboards),
253
314
  ...this.#sectionRoutes,
254
315
  { path: '', pathMatch: 'full', ...landing },
255
316
  { path: '**', component: UmbRouteNotFoundElement },
256
317
  ]
318
+ // The router keeps a page it already shows, so the cards need telling.
319
+ this.#refreshLanding()
257
320
  }
258
321
 
259
322
  #sectionPath() {
@@ -273,7 +336,7 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
273
336
  ? `${section}/${c.path}`
274
337
  : section,
275
338
  }))
276
- const main = html`<umb-section-main>
339
+ const main = html`<umb-section-main slot="end">
277
340
  ${
278
341
  crumbs.length > 0
279
342
  ? html`<crombolo-breadcrumb class="crumbs" .items=${crumbs}></crombolo-breadcrumb>`
@@ -284,7 +347,13 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
284
347
  // Both trees stay in the page, the one not in use hidden, as Umbraco's own
285
348
  // Settings keeps its menus. A tree taken out and put back breaks: the trees
286
349
  // share the section's expansion state, and a detached one still answers it.
287
- return html`<umb-section-sidebar ?hidden=${!shown}>
350
+ // Out of the split's start slot, the sidebar stays in the page but takes no room.
351
+ return html`<umb-split-panel
352
+ lock="start"
353
+ snap="300px"
354
+ .position=${savedPosition() ?? 'var(--umb-split-panel-initial-position)'}
355
+ @position-changed=${savePosition}
356
+ ><umb-section-sidebar slot=${shown ? 'start' : 'none'} ?hidden=${!shown}>
288
357
  ${
289
358
  this._tree === 'structure' && this._readOnly
290
359
  ? html`<p class="read-only" role="status">
@@ -296,7 +365,7 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
296
365
  (app) => html`<div class="tree" ?hidden=${app.alias !== shown}>${app.component}</div>`,
297
366
  )}
298
367
  </umb-section-sidebar>
299
- ${main}`
368
+ ${main}</umb-split-panel>`
300
369
  }
301
370
 
302
371
  static styles = [
@@ -307,8 +376,17 @@ export class CromboloSettingsSectionElement extends UmbLitElement {
307
376
  height: 100%;
308
377
  display: flex;
309
378
  }
310
- umb-section-sidebar {
311
- --umb-section-sidebar-width: 300px;
379
+ /* As Umbraco's own sections draw the split, so the width is the same in each. */
380
+ umb-split-panel {
381
+ --umb-split-panel-start-min-width: 200px;
382
+ --umb-split-panel-start-max-width: 400px;
383
+ --umb-split-panel-end-min-width: 600px;
384
+ --umb-split-panel-slot-overflow: visible;
385
+ }
386
+ @media only screen and (min-width: 800px) {
387
+ umb-split-panel {
388
+ --umb-split-panel-initial-position: 300px;
389
+ }
312
390
  }
313
391
  umb-section-sidebar[hidden],
314
392
  .tree[hidden] {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Sign-in Dialog",
4
4
  "id": "Crombolo.SignInDialog",
5
- "version": "0.52.2",
5
+ "version": "0.54.1",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {