@crombolo/backoffice-host 0.19.0 → 0.20.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.
- package/package.json +2 -2
- package/plugin/assistant/umbraco-package.json +1 -1
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/umbraco-package.json +1 -1
- package/plugin/workflow-client.js +2 -2
- package/plugin/workflow-designer.js +5 -0
- package/plugin/workflow-requests.js +6 -1
- package/plugin/workflow-tab.js +49 -3
- package/plugin/workflow-time.js +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Serves the Umbraco backoffice SPA: shell HTML, import map and package manifests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@crombolo/core": "0.
|
|
34
|
+
"@crombolo/core": "0.20.0",
|
|
35
35
|
"@crombolo/backoffice-dist": "18.2.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -21,8 +21,8 @@ async function call(path, init = {}) {
|
|
|
21
21
|
const post = (path, body = {}) => call(path, { method: 'POST', body: JSON.stringify(body) })
|
|
22
22
|
|
|
23
23
|
export const pageApproval = (key) => call(`page/${encodeURIComponent(key)}`)
|
|
24
|
-
export const sendForApproval = (key, action, comment) =>
|
|
25
|
-
post(`page/${encodeURIComponent(key)}/send`, { action, comment })
|
|
24
|
+
export const sendForApproval = (key, action, comment, schedule) =>
|
|
25
|
+
post(`page/${encodeURIComponent(key)}/send`, { action, comment, schedule })
|
|
26
26
|
export const decide = (requestKey, verb, body) =>
|
|
27
27
|
post(`request/${encodeURIComponent(requestKey)}/${verb}`, body)
|
|
28
28
|
export const waitingForMe = () => call('waiting')
|
|
@@ -590,6 +590,11 @@ export default class CromboloWorkflowDesignerElement extends UmbLitElement {
|
|
|
590
590
|
'Taking a page down goes through the workflow too',
|
|
591
591
|
html`<uui-toggle label="Unpublishing needs approval" ?disabled=${!editable} ?checked=${w.unpublish} @change=${(e) => set('unpublish')(e.target.checked)}></uui-toggle>`,
|
|
592
592
|
)}
|
|
593
|
+
${property(
|
|
594
|
+
'Requests can say when to publish',
|
|
595
|
+
'The editor may give a time to publish or take the page down; approval schedules it',
|
|
596
|
+
html`<uui-toggle label="Requests can say when to publish" ?disabled=${!editable} ?checked=${w.scheduling === true} @change=${(e) => set('scheduling')(e.target.checked)}></uui-toggle>`,
|
|
597
|
+
)}
|
|
593
598
|
${property('When a waiting page is changed', undefined, select('When a waiting page is changed', w.onEdit, ON_EDIT, set('onEdit'), !editable))}
|
|
594
599
|
${property(
|
|
595
600
|
'When the person who made the change could approve it',
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
7
7
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
8
8
|
import { finished, inFlight, waitingForMe } from './workflow-client.js'
|
|
9
|
+
import { describeWhen } from './workflow-time.js'
|
|
9
10
|
|
|
10
11
|
const STATE = {
|
|
11
12
|
waiting: ['warning', 'Waiting'],
|
|
13
|
+
scheduled: ['positive', 'Approved, waiting for its time'],
|
|
12
14
|
approved: ['positive', 'Approved'],
|
|
13
15
|
'sent-back': ['danger', 'Sent back'],
|
|
14
16
|
withdrawn: ['default', 'Withdrawn'],
|
|
17
|
+
superseded: ['default', 'Replaced by a direct publish'],
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
/** The page's Workflow tab: the editor's route is `edit/<key>/<variant>/view/<tab>`. */
|
|
@@ -82,6 +85,7 @@ class CromboloWorkflowListElement extends UmbLitElement {
|
|
|
82
85
|
<uui-table-head-cell>Page</uui-table-head-cell>
|
|
83
86
|
<uui-table-head-cell>Workflow</uui-table-head-cell>
|
|
84
87
|
<uui-table-head-cell>Asked for</uui-table-head-cell>
|
|
88
|
+
<uui-table-head-cell>When</uui-table-head-cell>
|
|
85
89
|
<uui-table-head-cell>Where it stands</uui-table-head-cell>
|
|
86
90
|
<uui-table-head-cell>Sent</uui-table-head-cell>
|
|
87
91
|
</uui-table-head>
|
|
@@ -92,6 +96,7 @@ class CromboloWorkflowListElement extends UmbLitElement {
|
|
|
92
96
|
<uui-table-cell><a href=${pageLink(item)} @click=${(e) => openInBackoffice(e, pageLink(item))}>${item.nodeName}</a></uui-table-cell>
|
|
93
97
|
<uui-table-cell>${item.workflow.name}</uui-table-cell>
|
|
94
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>
|
|
95
100
|
<uui-table-cell>
|
|
96
101
|
<uui-tag color=${color}>${label}</uui-tag>
|
|
97
102
|
${waiting.length > 0 ? html`<small>at ${waiting.join(', ')}</small>` : nothing}
|
|
@@ -140,7 +145,7 @@ customElements.define(
|
|
|
140
145
|
return 'In flight'
|
|
141
146
|
}
|
|
142
147
|
get empty() {
|
|
143
|
-
return 'No page is waiting for approval.'
|
|
148
|
+
return 'No page is waiting for approval or for its time.'
|
|
144
149
|
}
|
|
145
150
|
fetch() {
|
|
146
151
|
return inFlight()
|
package/plugin/workflow-tab.js
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
* stands in its graph, what the reader may do about it, and its history.
|
|
4
4
|
*
|
|
5
5
|
* Sending for approval sends what is saved: the editor saves first, as they
|
|
6
|
-
* would before publishing.
|
|
6
|
+
* would before publishing. A workflow that allows it lets the request say when
|
|
7
|
+
* to publish or take the page down (story 029): one time for the whole page.
|
|
7
8
|
*/
|
|
8
9
|
import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/document'
|
|
9
10
|
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api'
|
|
10
11
|
import { css, html, LitElement, nothing, unsafeCSS } from '@umbraco-cms/backoffice/external/lit'
|
|
11
12
|
import { decide, pageApproval, sendForApproval } from './workflow-client.js'
|
|
12
13
|
import { drawGraph, GRAPH_STYLES } from './workflow-graph.js'
|
|
14
|
+
import { describeWhen, fromLocalInput } from './workflow-time.js'
|
|
13
15
|
|
|
14
16
|
const KIND = {
|
|
15
17
|
sent: 'Sent for approval',
|
|
@@ -20,12 +22,16 @@ const KIND = {
|
|
|
20
22
|
restarted: 'Started again',
|
|
21
23
|
published: 'Published',
|
|
22
24
|
unpublished: 'Taken down',
|
|
25
|
+
scheduled: 'Approved, waiting for its time',
|
|
26
|
+
superseded: 'Replaced by a direct publish',
|
|
23
27
|
}
|
|
24
28
|
const STATE = {
|
|
25
29
|
waiting: 'Waiting for approval',
|
|
30
|
+
scheduled: 'Approved, waiting for its time',
|
|
26
31
|
approved: 'Approved',
|
|
27
32
|
'sent-back': 'Sent back',
|
|
28
33
|
withdrawn: 'Withdrawn',
|
|
34
|
+
superseded: 'Replaced by a direct publish',
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
export default class CromboloWorkflowTabElement extends UmbElementMixin(LitElement) {
|
|
@@ -35,11 +41,15 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
35
41
|
_message: { state: true },
|
|
36
42
|
_busy: { state: true },
|
|
37
43
|
_comment: { state: true },
|
|
44
|
+
_publishAt: { state: true },
|
|
45
|
+
_unpublishAt: { state: true },
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
constructor() {
|
|
41
49
|
super()
|
|
42
50
|
this._comment = ''
|
|
51
|
+
this._publishAt = ''
|
|
52
|
+
this._unpublishAt = ''
|
|
43
53
|
this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (context) => {
|
|
44
54
|
if (!context) return
|
|
45
55
|
this.observe(context.unique, (unique) => {
|
|
@@ -66,6 +76,8 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
66
76
|
return
|
|
67
77
|
}
|
|
68
78
|
this._comment = ''
|
|
79
|
+
this._publishAt = ''
|
|
80
|
+
this._unpublishAt = ''
|
|
69
81
|
await this.#load()
|
|
70
82
|
}
|
|
71
83
|
|
|
@@ -105,18 +117,19 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
105
117
|
this._comment = e.target.value
|
|
106
118
|
}}
|
|
107
119
|
></uui-textarea>
|
|
120
|
+
${workflow.scheduling ? this.#renderTimes(can) : nothing}
|
|
108
121
|
<div class="actions">
|
|
109
122
|
${
|
|
110
123
|
can.send
|
|
111
124
|
? html`<uui-button look="primary" ?disabled=${this._busy} label="Send for approval"
|
|
112
|
-
@click=${() => this.#act(() => sendForApproval(this._key, 'publish', this._comment))}
|
|
125
|
+
@click=${() => this.#act(() => sendForApproval(this._key, 'publish', this._comment, this.#schedule('publish')))}
|
|
113
126
|
>Send for approval</uui-button>`
|
|
114
127
|
: nothing
|
|
115
128
|
}
|
|
116
129
|
${
|
|
117
130
|
can.requestUnpublish
|
|
118
131
|
? html`<uui-button look="secondary" ?disabled=${this._busy} label="Request unpublish"
|
|
119
|
-
@click=${() => this.#act(() => sendForApproval(this._key, 'unpublish', this._comment))}
|
|
132
|
+
@click=${() => this.#act(() => sendForApproval(this._key, 'unpublish', this._comment, this.#schedule('unpublish')))}
|
|
120
133
|
>Request unpublish</uui-button>`
|
|
121
134
|
: nothing
|
|
122
135
|
}
|
|
@@ -124,6 +137,35 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
124
137
|
`
|
|
125
138
|
}
|
|
126
139
|
|
|
140
|
+
/** Optional times, both for the whole page; left empty, approval publishes at once. */
|
|
141
|
+
#renderTimes(can) {
|
|
142
|
+
return html`<div class="times">
|
|
143
|
+
${
|
|
144
|
+
can.send
|
|
145
|
+
? html`<uui-label for="publish-at">Publish at
|
|
146
|
+
<uui-input id="publish-at" type="datetime-local" label="Publish at" .value=${this._publishAt}
|
|
147
|
+
@input=${(e) => {
|
|
148
|
+
this._publishAt = e.target.value
|
|
149
|
+
}}></uui-input></uui-label>`
|
|
150
|
+
: nothing
|
|
151
|
+
}
|
|
152
|
+
<uui-label for="unpublish-at">Take down at
|
|
153
|
+
<uui-input id="unpublish-at" type="datetime-local" label="Take down at" .value=${this._unpublishAt}
|
|
154
|
+
@input=${(e) => {
|
|
155
|
+
this._unpublishAt = e.target.value
|
|
156
|
+
}}></uui-input></uui-label>
|
|
157
|
+
<small>Leave empty to publish as soon as it is approved.</small>
|
|
158
|
+
</div>`
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
#schedule(action) {
|
|
162
|
+
const publishTime = action === 'publish' ? fromLocalInput(this._publishAt) : null
|
|
163
|
+
const unpublishTime = fromLocalInput(this._unpublishAt)
|
|
164
|
+
return publishTime || unpublishTime
|
|
165
|
+
? [{ culture: null, publishTime, unpublishTime }]
|
|
166
|
+
: undefined
|
|
167
|
+
}
|
|
168
|
+
|
|
127
169
|
#renderRequest(request) {
|
|
128
170
|
const states = Object.fromEntries(request.stages.map((s) => [s.alias, s.state]))
|
|
129
171
|
const progress = request.stages
|
|
@@ -136,6 +178,7 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
136
178
|
${request.action === 'unpublish' ? 'To take this page down.' : 'To publish this page.'}
|
|
137
179
|
${progress ? html`<small>${progress}</small>` : nothing}
|
|
138
180
|
</p>
|
|
181
|
+
${request.schedule ? html`<p class="when">${describeWhen(request.action, request.schedule)}</p>` : nothing}
|
|
139
182
|
<div class="graph-wrap">${drawGraph(request.workflow.stages, { states })}</div>
|
|
140
183
|
${
|
|
141
184
|
request.can.approve.length > 0 || request.can.sendBack.length > 0 || request.can.withdraw
|
|
@@ -206,6 +249,9 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
206
249
|
.lead { margin-top: 0; }
|
|
207
250
|
.message { color: var(--uui-color-danger); }
|
|
208
251
|
.graph-wrap { overflow-x: auto; margin: var(--uui-size-space-4) 0; }
|
|
252
|
+
.when { font-weight: 600; }
|
|
253
|
+
.times { display: flex; flex-wrap: wrap; align-items: end; gap: var(--uui-size-space-4); margin: var(--uui-size-space-3) 0; }
|
|
254
|
+
.times uui-label { display: flex; flex-direction: column; gap: var(--uui-size-space-1); }
|
|
209
255
|
.actions { display: flex; gap: var(--uui-size-space-3); margin: var(--uui-size-space-3) 0; }
|
|
210
256
|
uui-textarea { width: 100%; }
|
|
211
257
|
.history { padding-left: var(--uui-size-space-5); }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When an approval request asked to publish or take its page down (story 029),
|
|
3
|
+
* in the reader's own time, with the time zone named.
|
|
4
|
+
*/
|
|
5
|
+
const zone = () =>
|
|
6
|
+
new Intl.DateTimeFormat(undefined, { timeZoneName: 'short' })
|
|
7
|
+
.formatToParts(new Date())
|
|
8
|
+
.find((p) => p.type === 'timeZoneName')?.value ?? ''
|
|
9
|
+
|
|
10
|
+
export const formatTime = (iso) =>
|
|
11
|
+
`${new Date(iso).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' })} ${zone()}`.trim()
|
|
12
|
+
|
|
13
|
+
/** "Publishes 3 Nov 2026, 09:00 AEDT", one phrase per time; empty when it asked for none. */
|
|
14
|
+
export function describeWhen(action, schedule) {
|
|
15
|
+
if (!schedule) return ''
|
|
16
|
+
return schedule
|
|
17
|
+
.flatMap((e) => {
|
|
18
|
+
const culture = e.culture ? ` (${e.culture})` : ''
|
|
19
|
+
return [
|
|
20
|
+
...(action === 'publish' && e.publishTime
|
|
21
|
+
? [`Publishes ${formatTime(e.publishTime)}${culture}`]
|
|
22
|
+
: []),
|
|
23
|
+
...(e.unpublishTime ? [`Comes down ${formatTime(e.unpublishTime)}${culture}`] : []),
|
|
24
|
+
]
|
|
25
|
+
})
|
|
26
|
+
.join(' · ')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A `datetime-local` input's value, read as the reader's local time, in ISO form; null when empty. */
|
|
30
|
+
export const fromLocalInput = (value) => (value ? new Date(value).toISOString() : null)
|