@crombolo/backoffice-host 0.53.2 → 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.
Files changed (38) hide show
  1. package/assets/login.js +6 -4
  2. package/package.json +3 -3
  3. package/plugin/alias-input.js +85 -0
  4. package/plugin/alias-model.js +36 -0
  5. package/plugin/app-preview/umbraco-package.json +1 -1
  6. package/plugin/approvals-tree-model.js +21 -0
  7. package/plugin/approvals-tree.js +108 -0
  8. package/plugin/content-strip-items.js +20 -10
  9. package/plugin/definition-tree.js +157 -126
  10. package/plugin/dictionary-chip.js +233 -0
  11. package/plugin/dictionary-words-client.js +52 -0
  12. package/plugin/dictionary-words.js +228 -0
  13. package/plugin/form-word-input-model.js +68 -15
  14. package/plugin/form-word-input.js +23 -125
  15. package/plugin/forms-entries.js +1 -0
  16. package/plugin/forms-overview.js +79 -9
  17. package/plugin/localizations/umbraco-package.json +1 -1
  18. package/plugin/page-history-modal.js +279 -0
  19. package/plugin/page-history-model.js +108 -0
  20. package/plugin/page-history.js +89 -0
  21. package/plugin/seo/umbraco-package.json +1 -1
  22. package/plugin/settings-cards.js +8 -1
  23. package/plugin/settings-section.js +43 -18
  24. package/plugin/sign-in/umbraco-package.json +1 -1
  25. package/plugin/template-picker-modal.js +276 -0
  26. package/plugin/template-picker-model.js +77 -0
  27. package/plugin/template-picker.js +43 -0
  28. package/plugin/tsx-editors.js +5 -0
  29. package/plugin/tsx-highlighting.js +81 -0
  30. package/plugin/umbraco-package.json +111 -41
  31. package/plugin/workflow-client.js +3 -0
  32. package/plugin/workflow-designer.js +66 -14
  33. package/plugin/workflow-requests.js +111 -105
  34. package/plugin/workflow-send-condition.js +2 -0
  35. package/plugin/workflow-send-model.js +20 -0
  36. package/plugin/workflow-send-unpublish.js +2 -0
  37. package/plugin/workflow-send.js +231 -0
  38. package/plugin/workflow-tab.js +32 -86
@@ -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.53.2",
5
+ "version": "0.55.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -613,6 +613,41 @@
613
613
  "forEntityTypes": ["document-type-root", "document-type-folder"],
614
614
  "meta": { "icon": "icon-autofill", "label": "Form" }
615
615
  },
616
+ {
617
+ "type": "menuItem",
618
+ "alias": "Crombolo.MenuItem.Forms",
619
+ "name": "Crombolo Forms In Structure",
620
+ "weight": 500,
621
+ "element": "/crombolo-plugin/definition-tree.js",
622
+ "meta": {
623
+ "menus": ["Umb.Menu.StructureSettings"],
624
+ "label": "Forms",
625
+ "icon": "icon-autofill",
626
+ "kind": "Forms"
627
+ },
628
+ "conditions": [
629
+ { "alias": "Umb.Condition.SectionUserPermission", "match": "Crombolo.Section.Forms" }
630
+ ]
631
+ },
632
+ {
633
+ "type": "menuItem",
634
+ "alias": "Crombolo.MenuItem.Workflows",
635
+ "name": "Crombolo Workflows In Structure",
636
+ "weight": 450,
637
+ "element": "/crombolo-plugin/definition-tree.js",
638
+ "meta": {
639
+ "menus": ["Umb.Menu.StructureSettings"],
640
+ "label": "Workflows",
641
+ "icon": "icon-mindmap",
642
+ "kind": "Workflows"
643
+ },
644
+ "conditions": [
645
+ {
646
+ "alias": "Umb.Condition.SectionUserPermission",
647
+ "match": "Crombolo.Section.WorkflowSetup"
648
+ }
649
+ ]
650
+ },
616
651
  {
617
652
  "type": "sectionSidebarApp",
618
653
  "alias": "Crombolo.SectionSidebarApp.DefinitionTree",
@@ -702,6 +737,18 @@
702
737
  "name": "Crombolo Sign-in Button",
703
738
  "js": "/crombolo-plugin/branding/sign-in.js"
704
739
  },
740
+ {
741
+ "type": "backofficeEntryPoint",
742
+ "alias": "Crombolo.EntryPoint.TemplatePicker",
743
+ "name": "Crombolo Template Picker In Folders",
744
+ "js": "/crombolo-plugin/template-picker.js"
745
+ },
746
+ {
747
+ "type": "backofficeEntryPoint",
748
+ "alias": "Crombolo.EntryPoint.DictionaryWords",
749
+ "name": "Crombolo Dictionary Words As Chips",
750
+ "js": "/crombolo-plugin/dictionary-words.js"
751
+ },
705
752
  {
706
753
  "type": "backofficeEntryPoint",
707
754
  "alias": "Crombolo.EntryPoint.NotificationsDialog",
@@ -759,40 +806,14 @@
759
806
  "meta": {
760
807
  "label": "Approvals",
761
808
  "pathname": "workflow"
762
- },
763
- "conditions": [{ "alias": "Crombolo.Condition.ApprovalsActive" }]
764
- },
765
- {
766
- "type": "sectionView",
767
- "alias": "Crombolo.SectionView.Workflow.Waiting",
768
- "name": "Crombolo Workflow Waiting",
769
- "element": "/crombolo-plugin/workflow-requests.js",
770
- "elementName": "crombolo-workflow-waiting",
771
- "weight": 400,
772
- "meta": {
773
- "label": "Waiting for me",
774
- "pathname": "waiting",
775
- "icon": "icon-inbox"
776
- },
777
- "conditions": [
778
- {
779
- "alias": "Umb.Condition.SectionAlias",
780
- "match": "Crombolo.Section.Workflow"
781
- }
782
- ]
809
+ }
783
810
  },
784
811
  {
785
- "type": "sectionView",
786
- "alias": "Crombolo.SectionView.Workflow.InFlight",
787
- "name": "Crombolo Workflow In Flight",
788
- "element": "/crombolo-plugin/workflow-requests.js",
789
- "elementName": "crombolo-workflow-in-flight",
790
- "weight": 300,
791
- "meta": {
792
- "label": "In flight",
793
- "pathname": "in-flight",
794
- "icon": "icon-time"
795
- },
812
+ "type": "sectionSidebarApp",
813
+ "alias": "Crombolo.SectionSidebarApp.ApprovalsTree",
814
+ "name": "Crombolo Approvals Tree",
815
+ "element": "/crombolo-plugin/approvals-tree.js",
816
+ "weight": 100,
796
817
  "conditions": [
797
818
  {
798
819
  "alias": "Umb.Condition.SectionAlias",
@@ -802,15 +823,16 @@
802
823
  },
803
824
  {
804
825
  "type": "sectionView",
805
- "alias": "Crombolo.SectionView.Workflow.History",
806
- "name": "Crombolo Workflow History",
826
+ "alias": "Crombolo.SectionView.Workflow.Requests",
827
+ "name": "Crombolo Approvals List",
807
828
  "element": "/crombolo-plugin/workflow-requests.js",
808
- "elementName": "crombolo-workflow-history",
809
- "weight": 200,
829
+ "elementName": "crombolo-approvals-list",
830
+ "weight": 400,
810
831
  "meta": {
811
- "label": "Decided",
812
- "pathname": "history",
813
- "icon": "icon-check"
832
+ "label": "Approvals",
833
+ "pathname": "approvals",
834
+ "noTab": true,
835
+ "icon": "icon-inbox"
814
836
  },
815
837
  "conditions": [
816
838
  {
@@ -837,10 +859,58 @@
837
859
  "match": "Crombolo.Section.Forms"
838
860
  },
839
861
  {
840
- "alias": "Umb.Condition.CurrentUser.IsAdmin"
862
+ "alias": "Umb.Condition.SectionUserPermission",
863
+ "match": "Crombolo.Section.WorkflowSetup"
841
864
  }
842
865
  ]
843
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
+ },
882
+ {
883
+ "type": "condition",
884
+ "alias": "Crombolo.Condition.Document.MaySendForApproval",
885
+ "name": "Crombolo May Send For Approval Condition",
886
+ "api": "/crombolo-plugin/workflow-send-condition.js"
887
+ },
888
+ {
889
+ "type": "workspaceAction",
890
+ "kind": "default",
891
+ "alias": "Crombolo.WorkspaceAction.Document.SendForApproval",
892
+ "name": "Crombolo Send For Approval",
893
+ "weight": 75,
894
+ "api": "/crombolo-plugin/workflow-send.js",
895
+ "meta": { "label": "Send for approval", "look": "secondary" },
896
+ "conditions": [
897
+ { "alias": "Umb.Condition.WorkspaceAlias", "match": "Umb.Workspace.Document" },
898
+ { "alias": "Crombolo.Condition.Document.MaySendForApproval", "action": "publish" }
899
+ ]
900
+ },
901
+ {
902
+ "type": "workspaceActionMenuItem",
903
+ "kind": "default",
904
+ "alias": "Crombolo.WorkspaceActionMenuItem.Document.RequestUnpublish",
905
+ "name": "Crombolo Request Unpublish",
906
+ "weight": 5,
907
+ "api": "/crombolo-plugin/workflow-send-unpublish.js",
908
+ "forWorkspaceActions": "Umb.WorkspaceAction.Document.SaveAndPublish",
909
+ "meta": { "label": "Request unpublish", "icon": "icon-globe" },
910
+ "conditions": [
911
+ { "alias": "Crombolo.Condition.Document.MaySendForApproval", "action": "unpublish" }
912
+ ]
913
+ },
844
914
  {
845
915
  "type": "workspaceView",
846
916
  "alias": "Crombolo.WorkspaceView.Document.Workflow",
@@ -28,6 +28,9 @@ export const decide = (requestKey, verb, body) =>
28
28
  export const waitingForMe = () => call('waiting')
29
29
  export const inFlight = () => call('in-flight')
30
30
  export const finished = (skip = 0, take = 25) => call(`history?skip=${skip}&take=${take}`)
31
+ /** A page of requests: the pending, the decided, or both. */
32
+ export const requestList = ({ pending, decided }, skip = 0, take = 25) =>
33
+ call(`requests?pending=${pending}&decided=${decided}&skip=${skip}&take=${take}`)
31
34
  export const listWorkflows = () => call('workflows')
32
35
  export const previewWorkflow = (alias, workflow) =>
33
36
  post(`workflows/${encodeURIComponent(alias)}/preview`, { workflow })
@@ -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'))
@@ -358,13 +395,7 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
358
395
 
359
396
  #renderList() {
360
397
  const { items, editable } = this._list
361
- // The create button above the list, as the Created bundles view has it.
362
398
  return html`<div class="list">
363
- ${
364
- editable
365
- ? html`<uui-button class="create" color="default" look="outline" label="Create" @click=${() => this.#edit(blank())}>Create</uui-button>`
366
- : nothing
367
- }
368
399
  ${this._message ? html`<uui-box><p class="message">${this._message}</p></uui-box>` : nothing}
369
400
  <uui-box headline="Workflows">
370
401
  ${this.#readOnly()}
@@ -506,18 +537,28 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
506
537
  ${property(
507
538
  'Name',
508
539
  undefined,
509
- html`<uui-input label="Name" ?readonly=${!editable} .value=${stage.name ?? ''} @change=${(
540
+ html`<uui-input label="Name" ?readonly=${!editable} .value=${stage.name ?? ''} @input=${(
510
541
  e,
511
542
  ) => {
512
543
  stage.name = e.target.value
513
- this.#touch()
544
+ if (this.#followsStage(stage))
545
+ this.#renameStage(stage, this.#stageAliasFor(stage, stage.name))
546
+ else this.#touch()
514
547
  }}></uui-input>`,
515
548
  'vertical',
516
549
  )}
517
550
  ${property(
518
551
  'Alias',
519
552
  'How the stage is named in the file and in other stages',
520
- 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>`,
521
562
  'vertical',
522
563
  )}
523
564
  ${property(
@@ -599,12 +640,24 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
599
640
  ${property(
600
641
  'Name',
601
642
  undefined,
602
- 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>`,
603
648
  )}
604
649
  ${property(
605
650
  'Alias',
606
651
  'The name of its file',
607
- 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>`,
608
661
  )}
609
662
  ${property(
610
663
  'Covers the pages under',
@@ -669,7 +722,6 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
669
722
  static styles = css`
670
723
  :host { display: block; height: 100%; container-type: inline-size; }
671
724
  .list { padding: var(--uui-size-layout-1); }
672
- .create { margin-bottom: var(--uui-size-space-5); }
673
725
  .actions { text-align: right; white-space: nowrap; }
674
726
  uui-tab-group { --uui-tab-divider: var(--uui-color-border); border-left: 1px solid var(--uui-color-border); border-right: 1px solid var(--uui-color-border); }
675
727
  .notice { margin-bottom: var(--uui-size-layout-1); }
@@ -1,11 +1,11 @@
1
1
  /**
2
- * The Workflows section's lists (story 028): what waits for the reader's
3
- * approval, every request in flight, and those decided. Each row links to the
4
- * page, whose Workflow tab is where a request is acted on.
2
+ * Approvals' list (story 028): the requests pending, and those decided when asked
3
+ * for, a page at a time. Each row opens the page's Workflow tab, where a request
4
+ * is acted on. With no workflow set up and no request open, it says so instead.
5
5
  */
6
6
  import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
7
7
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
8
- import { finished, inFlight, waitingForMe } from './workflow-client.js'
8
+ import { approvalsActive, requestList } from './workflow-client.js'
9
9
  import { describeWhen } from './workflow-time.js'
10
10
 
11
11
  const STATE = {
@@ -18,7 +18,7 @@ const STATE = {
18
18
  }
19
19
 
20
20
  /** The page's Workflow tab: the editor's route is `edit/<key>/<variant>/view/<tab>`. */
21
- const pageLink = (item) => {
21
+ export const pageLink = (item) => {
22
22
  const base = (document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(
23
23
  /\/$/,
24
24
  '',
@@ -37,133 +37,139 @@ function openInBackoffice(event, href) {
37
37
  history.pushState(null, '', href)
38
38
  }
39
39
 
40
- class CromboloWorkflowListElement extends UmbLitElement {
40
+ /** Rows a page of the list holds. */
41
+ export const PAGE_SIZE = 25
42
+
43
+ /** What a list of requests is called, by what it includes. Pure. */
44
+ export const listHeadline = ({ pending, decided }) =>
45
+ pending && decided ? 'Pending and decided' : decided ? 'Decided' : 'Pending'
46
+
47
+ class CromboloApprovalsListElement extends UmbLitElement {
41
48
  static properties = {
42
49
  _items: { state: true },
43
50
  _message: { state: true },
44
51
  _total: { state: true },
45
- _skip: { state: true },
46
- }
47
-
48
- /** Overridden: what this list is, and how it loads. */
49
- get headline() {
50
- return ''
51
- }
52
- get empty() {
53
- return ''
54
- }
55
- async fetch(_skip) {
56
- return { ok: true, items: [] }
52
+ _page: { state: true },
53
+ _pending: { state: true },
54
+ _decided: { state: true },
55
+ _inactive: { state: true },
57
56
  }
58
57
 
59
58
  connectedCallback() {
60
59
  super.connectedCallback()
61
- this._skip = 0
60
+ this._page = 1
61
+ this._pending = true
62
+ this._decided = false
62
63
  this.#load()
63
64
  }
64
65
 
65
66
  async #load() {
66
- const result = await this.fetch(this._skip)
67
+ const include = { pending: this._pending, decided: this._decided }
68
+ const [result, active] = await Promise.all([
69
+ requestList(include, (this._page - 1) * PAGE_SIZE, PAGE_SIZE),
70
+ approvalsActive(),
71
+ ])
72
+ this._inactive = active.ok && active.active !== true
67
73
  if (!result.ok) {
68
74
  this._message = result.message
69
75
  return
70
76
  }
77
+ this._message = undefined
71
78
  this._items = result.items
72
79
  this._total = result.total
73
80
  }
74
81
 
82
+ #include(name, checked) {
83
+ this[name] = checked
84
+ this._page = 1
85
+ this._items = undefined
86
+ this.#load()
87
+ }
88
+
89
+ #filters() {
90
+ return html`<div class="filters" role="group" aria-label="Show">
91
+ <uui-checkbox
92
+ label="Pending"
93
+ ?checked=${this._pending}
94
+ @change=${(e) => this.#include('_pending', e.target.checked)}
95
+ ></uui-checkbox>
96
+ <uui-checkbox
97
+ label="Decided"
98
+ ?checked=${this._decided}
99
+ @change=${(e) => this.#include('_decided', e.target.checked)}
100
+ ></uui-checkbox>
101
+ </div>`
102
+ }
103
+
104
+ #pages() {
105
+ const total = Math.ceil((this._total ?? 0) / PAGE_SIZE)
106
+ if (total <= 1) return nothing
107
+ return html`<uui-pagination
108
+ .current=${this._page}
109
+ .total=${total}
110
+ @change=${(e) => {
111
+ this._page = e.target.current
112
+ this.#load()
113
+ }}
114
+ ></uui-pagination>`
115
+ }
116
+
117
+ #table() {
118
+ if (!this._items) return html`<uui-loader></uui-loader>`
119
+ if (this._items.length === 0)
120
+ return html`<p>${
121
+ this._pending || this._decided
122
+ ? `No request is ${listHeadline({ pending: this._pending, decided: this._decided }).toLowerCase()}.`
123
+ : 'Choose pending or decided requests to see them.'
124
+ }</p>`
125
+ return html`<uui-table>
126
+ <uui-table-head>
127
+ <uui-table-head-cell>Page</uui-table-head-cell>
128
+ <uui-table-head-cell>Workflow</uui-table-head-cell>
129
+ <uui-table-head-cell>Asked for</uui-table-head-cell>
130
+ <uui-table-head-cell>When</uui-table-head-cell>
131
+ <uui-table-head-cell>Where it stands</uui-table-head-cell>
132
+ <uui-table-head-cell>Sent</uui-table-head-cell>
133
+ </uui-table-head>
134
+ ${this._items.map((item) => {
135
+ const [color, label] = STATE[item.state] ?? ['default', item.state]
136
+ const waiting = item.stages.filter((s) => s.state === 'waiting').map((s) => s.alias)
137
+ const href = pageLink(item)
138
+ return html`<uui-table-row class="row" @click=${(e) => openInBackoffice(e, href)}>
139
+ <uui-table-cell><a href=${href} @click=${(e) => openInBackoffice(e, href)}>${item.nodeName}</a></uui-table-cell>
140
+ <uui-table-cell>${item.workflow.name}</uui-table-cell>
141
+ <uui-table-cell>${item.action === 'unpublish' ? 'Taking it down' : 'Publishing'}</uui-table-cell>
142
+ <uui-table-cell>${describeWhen(item.action, item.schedule) || 'On approval'}</uui-table-cell>
143
+ <uui-table-cell>
144
+ <uui-tag color=${color}>${label}</uui-tag>
145
+ ${waiting.length > 0 ? html`<small>at ${waiting.join(', ')}</small>` : nothing}
146
+ </uui-table-cell>
147
+ <uui-table-cell>${new Date(item.requestedAt).toLocaleString()}</uui-table-cell>
148
+ </uui-table-row>`
149
+ })}
150
+ </uui-table>`
151
+ }
152
+
75
153
  render() {
76
- if (this._message) return html`<uui-box headline=${this.headline}>${this._message}</uui-box>`
77
- if (!this._items)
78
- return html`<uui-box headline=${this.headline}><uui-loader></uui-loader></uui-box>`
79
- return html`<uui-box headline=${this.headline}>
80
- ${
81
- this._items.length === 0
82
- ? html`<p>${this.empty}</p>`
83
- : html`<uui-table>
84
- <uui-table-head>
85
- <uui-table-head-cell>Page</uui-table-head-cell>
86
- <uui-table-head-cell>Workflow</uui-table-head-cell>
87
- <uui-table-head-cell>Asked for</uui-table-head-cell>
88
- <uui-table-head-cell>When</uui-table-head-cell>
89
- <uui-table-head-cell>Where it stands</uui-table-head-cell>
90
- <uui-table-head-cell>Sent</uui-table-head-cell>
91
- </uui-table-head>
92
- ${this._items.map((item) => {
93
- const [color, label] = STATE[item.state] ?? ['default', item.state]
94
- const waiting = item.stages.filter((s) => s.state === 'waiting').map((s) => s.alias)
95
- return html`<uui-table-row>
96
- <uui-table-cell><a href=${pageLink(item)} @click=${(e) => openInBackoffice(e, pageLink(item))}>${item.nodeName}</a></uui-table-cell>
97
- <uui-table-cell>${item.workflow.name}</uui-table-cell>
98
- <uui-table-cell>${item.action === 'unpublish' ? 'Taking it down' : 'Publishing'}</uui-table-cell>
99
- <uui-table-cell>${describeWhen(item.action, item.schedule) || 'On approval'}</uui-table-cell>
100
- <uui-table-cell>
101
- <uui-tag color=${color}>${label}</uui-tag>
102
- ${waiting.length > 0 ? html`<small>at ${waiting.join(', ')}</small>` : nothing}
103
- </uui-table-cell>
104
- <uui-table-cell>${new Date(item.requestedAt).toLocaleString()}</uui-table-cell>
105
- </uui-table-row>`
106
- })}
107
- </uui-table>`
108
- }
109
- ${
110
- this._total !== undefined && this._total > this._items.length + this._skip
111
- ? html`<uui-button look="secondary" label="Older" @click=${() => {
112
- this._skip += this._items.length
113
- this.#load()
114
- }}>Older</uui-button>`
115
- : nothing
116
- }
154
+ if (this._inactive)
155
+ return html`<uui-box headline="Approvals">
156
+ <p>No approval workflows have been set up yet, so nothing waits for approval. Workflows are set up in Structure.</p>
157
+ </uui-box>`
158
+ const headline = listHeadline({ pending: this._pending, decided: this._decided })
159
+ return html`<uui-box headline=${headline}>
160
+ ${this.#filters()}
161
+ ${this._message ? html`<p role="alert">${this._message}</p>` : this.#table()}
162
+ ${this.#pages()}
117
163
  </uui-box>`
118
164
  }
119
165
 
120
166
  static styles = css`
121
167
  :host { display: block; padding: var(--uui-size-layout-1); }
122
168
  small { margin-left: var(--uui-size-space-2); opacity: 0.8; }
169
+ .filters { display: flex; gap: var(--uui-size-space-5); margin-bottom: var(--uui-size-space-4); }
170
+ .row { cursor: pointer; }
171
+ uui-pagination { display: block; margin-top: var(--uui-size-space-4); }
123
172
  `
124
173
  }
125
174
 
126
- customElements.define(
127
- 'crombolo-workflow-waiting',
128
- class extends CromboloWorkflowListElement {
129
- get headline() {
130
- return 'Waiting for my approval'
131
- }
132
- get empty() {
133
- return 'Nothing is waiting for your approval.'
134
- }
135
- fetch() {
136
- return waitingForMe()
137
- }
138
- },
139
- )
140
-
141
- customElements.define(
142
- 'crombolo-workflow-in-flight',
143
- class extends CromboloWorkflowListElement {
144
- get headline() {
145
- return 'In flight'
146
- }
147
- get empty() {
148
- return 'No page is waiting for approval or for its time.'
149
- }
150
- fetch() {
151
- return inFlight()
152
- }
153
- },
154
- )
155
-
156
- customElements.define(
157
- 'crombolo-workflow-history',
158
- class extends CromboloWorkflowListElement {
159
- get headline() {
160
- return 'Decided'
161
- }
162
- get empty() {
163
- return 'No request has been decided yet.'
164
- }
165
- fetch(skip) {
166
- return finished(skip, 25)
167
- }
168
- },
169
- )
175
+ customElements.define('crombolo-approvals-list', CromboloApprovalsListElement)
@@ -0,0 +1,2 @@
1
+ /** `Crombolo.Condition.Document.MaySendForApproval`: `workflow-send.js`. */
2
+ export { CromboloMaySendCondition as api } from './workflow-send.js'
@@ -0,0 +1,20 @@
1
+ /**
2
+ * What the bottom bar's "Send for approval" and "Request unpublish" decide
3
+ * (`workflow-send.js`). Pure, so each is tested on its own.
4
+ */
5
+ import { fromLocalInput } from './workflow-time.js'
6
+
7
+ /** What the reader may send now: `publish`, `unpublish`, both or neither. Pure. */
8
+ export function maySend(approval, action) {
9
+ if (!approval?.ok || !approval.workflow || approval.request) return false
10
+ return action === 'unpublish'
11
+ ? approval.can?.requestUnpublish === true
12
+ : approval.can?.send === true
13
+ }
14
+
15
+ /** The schedule a request carries for the times given, or undefined for none. Pure. */
16
+ export function scheduleFor(action, publishAt, unpublishAt) {
17
+ const publishTime = action === 'publish' ? fromLocalInput(publishAt) : null
18
+ const unpublishTime = fromLocalInput(unpublishAt)
19
+ return publishTime || unpublishTime ? [{ culture: null, publishTime, unpublishTime }] : undefined
20
+ }
@@ -0,0 +1,2 @@
1
+ /** "Request unpublish" in the "Save and publish" menu: `workflow-send.js`. */
2
+ export { CromboloRequestUnpublishAction as api } from './workflow-send.js'