@crombolo/backoffice-host 0.54.1 → 0.55.0

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.
@@ -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.54.1",
5
+ "version": "0.55.0",
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",
4
4
  "id": "Crombolo.Core",
5
- "version": "0.54.1",
5
+ "version": "0.55.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -864,6 +864,21 @@
864
864
  }
865
865
  ]
866
866
  },
867
+ {
868
+ "type": "workspaceInfoApp",
869
+ "alias": "Crombolo.WorkspaceInfoApp.Document.History",
870
+ "name": "Crombolo Page History",
871
+ "element": "/crombolo-plugin/page-history.js",
872
+ "overwrites": ["Umb.WorkspaceInfoApp.Document.History"],
873
+ "weight": 20,
874
+ "conditions": [{ "alias": "Umb.Condition.WorkspaceAlias", "match": "Umb.Workspace.Document" }]
875
+ },
876
+ {
877
+ "type": "modal",
878
+ "alias": "Crombolo.Modal.PageHistory",
879
+ "name": "Crombolo Page History Panel",
880
+ "element": "/crombolo-plugin/page-history-modal.js"
881
+ },
867
882
  {
868
883
  "type": "condition",
869
884
  "alias": "Crombolo.Condition.Document.MaySendForApproval",
@@ -8,6 +8,8 @@
8
8
  * the file to the same rules on save, so this only spares a round trip.
9
9
  */
10
10
  // For its side effect: registers `umb-input-document`, which the shell loads lazily.
11
+ import './alias-input.js'
12
+ import { kebabAlias } from './alias-model.js'
11
13
  import '@umbraco-cms/backoffice/document'
12
14
  import { css, html, nothing, unsafeCSS } from '@umbraco-cms/backoffice/external/lit'
13
15
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
@@ -114,6 +116,9 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
114
116
  if (named) this.#edit(named)
115
117
  else if (asked.has('new')) {
116
118
  this.#edit(blank())
119
+ // New: its alias, and its stages', follow their names until saved or written by hand.
120
+ this.#freshWorkflow = true
121
+ for (const stage of this._editing.stages) this.#fresh.add(stage)
117
122
  this.#folder = asked.get('new') || undefined
118
123
  } else this._editing = undefined
119
124
  }
@@ -148,7 +153,34 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
148
153
  this.#follow()
149
154
  }
150
155
 
156
+ /**
157
+ * What is new and not saved yet, whose alias follows its name until it is
158
+ * written by hand. Stages by the object, which an edit keeps; the workflow by
159
+ * a flag, since every edit copies it.
160
+ */
161
+ #fresh = new WeakSet()
162
+ #own = new WeakSet()
163
+ #freshWorkflow = false
164
+ #ownWorkflowAlias = false
165
+
166
+ #followsStage(stage) {
167
+ return this.#fresh.has(stage) && !this.#own.has(stage)
168
+ }
169
+
170
+ /** A stage alias made from its name, unlike every other stage's. */
171
+ #stageAliasFor(stage, name) {
172
+ const base = kebabAlias(name) || 'stage'
173
+ let alias = base
174
+ for (let n = 2; this._editing.stages.some((s) => s !== stage && s.alias === alias); n++)
175
+ alias = `${base}-${n}`
176
+ return alias
177
+ }
178
+
151
179
  #edit(workflow) {
180
+ this.#freshWorkflow = false
181
+ this.#ownWorkflowAlias = false
182
+ this.#fresh = new WeakSet()
183
+ this.#own = new WeakSet()
152
184
  this.#folder = undefined
153
185
  const copy = structuredClone(workflow)
154
186
  // Every stage gets the place the canvas would draw it, so dragging starts from there.
@@ -176,7 +208,7 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
176
208
  let n = this._editing.stages.length + 1
177
209
  while (this.#stage(`stage-${n}`)) n++
178
210
  const xs = this._editing.stages.map((s) => s.position?.x ?? 0)
179
- this._editing.stages.push({
211
+ const stage = {
180
212
  alias: `stage-${n}`,
181
213
  name: `Stage ${n}`,
182
214
  approvers: [],
@@ -184,7 +216,9 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
184
216
  next: [],
185
217
  sendBack: 'editor',
186
218
  position: { x: Math.max(0, ...xs) + BOX.width + 80, y: 0 },
187
- })
219
+ }
220
+ this.#fresh.add(stage)
221
+ this._editing.stages.push(stage)
188
222
  this._selected = `stage-${n}`
189
223
  this.#touch()
190
224
  }
@@ -310,6 +344,9 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
310
344
  // The green toast every workspace shows on a save.
311
345
  this.#notifications?.peek('positive', { data: { message: 'Workflow saved' } })
312
346
  this._originalAlias = this._editing.alias
347
+ // Saved, its aliases are what requests and files name: no longer following names.
348
+ this.#freshWorkflow = false
349
+ this.#fresh = new WeakSet()
313
350
  this.#folder = undefined
314
351
  approvalsChanged()
315
352
  window.dispatchEvent(new Event('crombolo:definitions-changed'))
@@ -500,18 +537,28 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
500
537
  ${property(
501
538
  'Name',
502
539
  undefined,
503
- html`<uui-input label="Name" ?readonly=${!editable} .value=${stage.name ?? ''} @change=${(
540
+ html`<uui-input label="Name" ?readonly=${!editable} .value=${stage.name ?? ''} @input=${(
504
541
  e,
505
542
  ) => {
506
543
  stage.name = e.target.value
507
- this.#touch()
544
+ if (this.#followsStage(stage))
545
+ this.#renameStage(stage, this.#stageAliasFor(stage, stage.name))
546
+ else this.#touch()
508
547
  }}></uui-input>`,
509
548
  'vertical',
510
549
  )}
511
550
  ${property(
512
551
  'Alias',
513
552
  'How the stage is named in the file and in other stages',
514
- html`<uui-input label="Alias" ?readonly=${!editable} .value=${stage.alias} @change=${(e) => this.#renameStage(stage, e.target.value)}></uui-input>`,
553
+ html`<crombolo-alias-input
554
+ ?readonly=${!editable}
555
+ ?saved=${!this.#fresh.has(stage)}
556
+ .value=${stage.alias}
557
+ @change=${(e) => {
558
+ this.#own.add(stage)
559
+ this.#renameStage(stage, e.target.value)
560
+ }}
561
+ ></crombolo-alias-input>`,
515
562
  'vertical',
516
563
  )}
517
564
  ${property(
@@ -593,12 +640,24 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
593
640
  ${property(
594
641
  'Name',
595
642
  undefined,
596
- html`<uui-input label="Name" ?readonly=${!editable} .value=${w.name} @change=${(e) => set('name')(e.target.value)}></uui-input>`,
643
+ html`<uui-input label="Name" ?readonly=${!editable} .value=${w.name} @input=${(e) => {
644
+ if (this.#freshWorkflow && !this.#ownWorkflowAlias)
645
+ w.alias = kebabAlias(e.target.value) || 'new-workflow'
646
+ set('name')(e.target.value)
647
+ }}></uui-input>`,
597
648
  )}
598
649
  ${property(
599
650
  'Alias',
600
651
  'The name of its file',
601
- html`<uui-input label="Alias" ?readonly=${!editable} .value=${w.alias} @change=${(e) => set('alias')(e.target.value.trim())}></uui-input>`,
652
+ html`<crombolo-alias-input
653
+ ?readonly=${!editable}
654
+ ?saved=${!this.#freshWorkflow}
655
+ .value=${w.alias}
656
+ @change=${(e) => {
657
+ this.#ownWorkflowAlias = true
658
+ set('alias')(e.target.value)
659
+ }}
660
+ ></crombolo-alias-input>`,
602
661
  )}
603
662
  ${property(
604
663
  'Covers the pages under',