@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
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sending a page for approval from the bottom bar (story 028): "Send for approval"
|
|
3
|
+
* beside "Save and publish", and "Request unpublish" in its menu. Each shows only
|
|
4
|
+
* while the page's workflow lets this user send it, saves the page first, as
|
|
5
|
+
* publishing does, and asks for a note and, where the workflow allows, the times.
|
|
6
|
+
*/
|
|
7
|
+
import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/document'
|
|
8
|
+
import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry'
|
|
9
|
+
import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
10
|
+
import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'
|
|
11
|
+
import {
|
|
12
|
+
UmbWorkspaceActionBase,
|
|
13
|
+
UmbWorkspaceActionMenuItemBase,
|
|
14
|
+
} from '@umbraco-cms/backoffice/workspace'
|
|
15
|
+
import { pageApproval, sendForApproval } from './workflow-client.js'
|
|
16
|
+
import { maySend, scheduleFor } from './workflow-send-model.js'
|
|
17
|
+
|
|
18
|
+
/** Sent on `window` when a page's request changes, so its tab and buttons catch up. */
|
|
19
|
+
export const APPROVAL_CHANGED = 'crombolo:approval-changed'
|
|
20
|
+
|
|
21
|
+
/** `Crombolo.Condition.Document.MaySendForApproval`, with `action` in its config. */
|
|
22
|
+
export class CromboloMaySendCondition extends UmbConditionBase {
|
|
23
|
+
#key
|
|
24
|
+
#isNew = true
|
|
25
|
+
#check = async () => {
|
|
26
|
+
// A page not saved yet has no request to send, and the server does not know it.
|
|
27
|
+
if (!this.#key || this.#isNew) {
|
|
28
|
+
this.permitted = false
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
const key = this.#key
|
|
32
|
+
const approval = await pageApproval(key).catch(() => undefined)
|
|
33
|
+
if (key === this.#key) this.permitted = maySend(approval, this.config.action ?? 'publish')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
constructor(host, args) {
|
|
37
|
+
super(host, args)
|
|
38
|
+
this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (context) => {
|
|
39
|
+
this.observe(context?.isNew, (isNew) => {
|
|
40
|
+
this.#isNew = isNew !== false
|
|
41
|
+
this.#check()
|
|
42
|
+
})
|
|
43
|
+
this.observe(context?.unique, (unique) => {
|
|
44
|
+
this.#key = unique ?? undefined
|
|
45
|
+
this.#check()
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
window.addEventListener(APPROVAL_CHANGED, this.#check)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
destroy() {
|
|
52
|
+
window.removeEventListener(APPROVAL_CHANGED, this.#check)
|
|
53
|
+
super.destroy()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The note and the times, in a dialog; resolves to what was given, or undefined when cancelled. */
|
|
58
|
+
function askForRequest(action, scheduling) {
|
|
59
|
+
return new Promise((resolve) => {
|
|
60
|
+
const dialog = document.createElement('crombolo-send-for-approval-dialog')
|
|
61
|
+
dialog.action = action
|
|
62
|
+
dialog.scheduling = scheduling
|
|
63
|
+
dialog.addEventListener('done', (event) => {
|
|
64
|
+
dialog.remove()
|
|
65
|
+
resolve(event.detail)
|
|
66
|
+
})
|
|
67
|
+
document.body.append(dialog)
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function send(host, action) {
|
|
72
|
+
const workspace = await host.getContext(UMB_DOCUMENT_WORKSPACE_CONTEXT)
|
|
73
|
+
const notifications = await host.getContext(UMB_NOTIFICATION_CONTEXT)
|
|
74
|
+
const key = workspace?.getUnique?.()
|
|
75
|
+
if (!key) return
|
|
76
|
+
const approval = await pageApproval(key)
|
|
77
|
+
const given = await askForRequest(action, approval.workflow?.scheduling === true)
|
|
78
|
+
if (!given) return
|
|
79
|
+
// What is sent is what is saved, so the editor's changes go first.
|
|
80
|
+
await workspace.requestSubmit()
|
|
81
|
+
const result = await sendForApproval(
|
|
82
|
+
key,
|
|
83
|
+
action,
|
|
84
|
+
given.comment,
|
|
85
|
+
scheduleFor(action, given.publishAt, given.unpublishAt),
|
|
86
|
+
)
|
|
87
|
+
window.dispatchEvent(new CustomEvent(APPROVAL_CHANGED, { detail: { key } }))
|
|
88
|
+
if (result.ok)
|
|
89
|
+
notifications?.peek('positive', {
|
|
90
|
+
data: {
|
|
91
|
+
message:
|
|
92
|
+
action === 'unpublish' ? 'Asked for approval to take it down' : 'Sent for approval',
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
else
|
|
96
|
+
notifications?.peek('danger', {
|
|
97
|
+
data: { message: result.message ?? 'The page could not be sent for approval.' },
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class CromboloSendForApprovalAction extends UmbWorkspaceActionBase {
|
|
102
|
+
async execute() {
|
|
103
|
+
await send(this, 'publish')
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class CromboloRequestUnpublishAction extends UmbWorkspaceActionMenuItemBase {
|
|
108
|
+
async execute() {
|
|
109
|
+
await send(this, 'unpublish')
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
class CromboloSendForApprovalDialogElement extends LitElement {
|
|
114
|
+
static properties = {
|
|
115
|
+
action: { type: String },
|
|
116
|
+
scheduling: { type: Boolean },
|
|
117
|
+
_comment: { state: true },
|
|
118
|
+
_publishAt: { state: true },
|
|
119
|
+
_unpublishAt: { state: true },
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
constructor() {
|
|
123
|
+
super()
|
|
124
|
+
this._comment = ''
|
|
125
|
+
this._publishAt = ''
|
|
126
|
+
this._unpublishAt = ''
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
firstUpdated() {
|
|
130
|
+
this.renderRoot.querySelector('dialog')?.showModal()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#done(detail) {
|
|
134
|
+
this.renderRoot.querySelector('dialog')?.close()
|
|
135
|
+
this.dispatchEvent(new CustomEvent('done', { detail }))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
render() {
|
|
139
|
+
const unpublish = this.action === 'unpublish'
|
|
140
|
+
const title = unpublish ? 'Request unpublish' : 'Send for approval'
|
|
141
|
+
return html`<dialog aria-label=${title} @cancel=${() => this.#done(undefined)}>
|
|
142
|
+
<h3>${title}</h3>
|
|
143
|
+
<p>The page is saved first, and what is saved is what the approvers see.</p>
|
|
144
|
+
<uui-textarea
|
|
145
|
+
label="A note for the approvers"
|
|
146
|
+
placeholder="A note for the approvers (optional)"
|
|
147
|
+
.value=${this._comment}
|
|
148
|
+
@input=${(e) => {
|
|
149
|
+
this._comment = e.target.value
|
|
150
|
+
}}
|
|
151
|
+
></uui-textarea>
|
|
152
|
+
${
|
|
153
|
+
this.scheduling
|
|
154
|
+
? html`<div class="times">
|
|
155
|
+
${
|
|
156
|
+
unpublish
|
|
157
|
+
? nothing
|
|
158
|
+
: html`<uui-label for="publish-at">Publish at
|
|
159
|
+
<uui-input id="publish-at" type="datetime-local" label="Publish at" .value=${this._publishAt}
|
|
160
|
+
@input=${(e) => {
|
|
161
|
+
this._publishAt = e.target.value
|
|
162
|
+
}}></uui-input></uui-label>`
|
|
163
|
+
}
|
|
164
|
+
<uui-label for="unpublish-at">Take down at
|
|
165
|
+
<uui-input id="unpublish-at" type="datetime-local" label="Take down at" .value=${this._unpublishAt}
|
|
166
|
+
@input=${(e) => {
|
|
167
|
+
this._unpublishAt = e.target.value
|
|
168
|
+
}}></uui-input></uui-label>
|
|
169
|
+
<small>Leave empty to ${unpublish ? 'take it down' : 'publish'} as soon as it is approved.</small>
|
|
170
|
+
</div>`
|
|
171
|
+
: nothing
|
|
172
|
+
}
|
|
173
|
+
<div class="actions">
|
|
174
|
+
<uui-button look="secondary" label="Cancel" @click=${() => this.#done(undefined)}>Cancel</uui-button>
|
|
175
|
+
<uui-button
|
|
176
|
+
look="primary"
|
|
177
|
+
label=${title}
|
|
178
|
+
@click=${() =>
|
|
179
|
+
this.#done({
|
|
180
|
+
comment: this._comment,
|
|
181
|
+
publishAt: this._publishAt,
|
|
182
|
+
unpublishAt: this._unpublishAt,
|
|
183
|
+
})}
|
|
184
|
+
>${title}</uui-button
|
|
185
|
+
>
|
|
186
|
+
</div>
|
|
187
|
+
</dialog>`
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static styles = css`
|
|
191
|
+
dialog {
|
|
192
|
+
width: min(32rem, calc(100vw - 2rem));
|
|
193
|
+
padding: var(--uui-size-space-5);
|
|
194
|
+
border: 1px solid var(--uui-color-border);
|
|
195
|
+
border-radius: var(--uui-border-radius);
|
|
196
|
+
background: var(--uui-color-surface);
|
|
197
|
+
color: var(--uui-color-text);
|
|
198
|
+
box-shadow: var(--uui-shadow-depth-5);
|
|
199
|
+
}
|
|
200
|
+
dialog::backdrop {
|
|
201
|
+
background: rgb(0 0 0 / 0.35);
|
|
202
|
+
}
|
|
203
|
+
h3 {
|
|
204
|
+
margin: 0 0 var(--uui-size-space-3);
|
|
205
|
+
}
|
|
206
|
+
p,
|
|
207
|
+
small {
|
|
208
|
+
color: var(--uui-color-text-alt);
|
|
209
|
+
}
|
|
210
|
+
uui-textarea {
|
|
211
|
+
width: 100%;
|
|
212
|
+
}
|
|
213
|
+
.times {
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-wrap: wrap;
|
|
216
|
+
gap: var(--uui-size-space-4);
|
|
217
|
+
margin-top: var(--uui-size-space-4);
|
|
218
|
+
}
|
|
219
|
+
.actions {
|
|
220
|
+
display: flex;
|
|
221
|
+
justify-content: flex-end;
|
|
222
|
+
gap: var(--uui-size-space-3);
|
|
223
|
+
margin-top: var(--uui-size-space-5);
|
|
224
|
+
}
|
|
225
|
+
`
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (!customElements.get('crombolo-send-for-approval-dialog'))
|
|
229
|
+
customElements.define('crombolo-send-for-approval-dialog', CromboloSendForApprovalDialogElement)
|
|
230
|
+
|
|
231
|
+
export { CromboloSendForApprovalAction as api }
|
package/plugin/workflow-tab.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A page's Workflow tab (story 028): which workflow covers it, where a request
|
|
3
|
-
* stands in its graph, what
|
|
4
|
-
*
|
|
5
|
-
* Sending for approval sends what is saved: the editor saves first, as they
|
|
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.
|
|
3
|
+
* stands in its graph, what an approver may do about it, and its history. A page
|
|
4
|
+
* is sent for approval from the bottom bar (`workflow-send.js`).
|
|
8
5
|
*/
|
|
9
6
|
import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/document'
|
|
10
7
|
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api'
|
|
11
8
|
import { css, html, LitElement, nothing, unsafeCSS } from '@umbraco-cms/backoffice/external/lit'
|
|
12
|
-
import { decide, pageApproval
|
|
9
|
+
import { decide, pageApproval } from './workflow-client.js'
|
|
13
10
|
import { drawGraph, GRAPH_STYLES } from './workflow-graph.js'
|
|
14
|
-
import {
|
|
11
|
+
import { APPROVAL_CHANGED } from './workflow-send.js'
|
|
12
|
+
import { describeWhen } from './workflow-time.js'
|
|
15
13
|
|
|
16
14
|
const KIND = {
|
|
17
15
|
sent: 'Sent for approval',
|
|
@@ -41,15 +39,25 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
41
39
|
_message: { state: true },
|
|
42
40
|
_busy: { state: true },
|
|
43
41
|
_comment: { state: true },
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#changed = (event) => {
|
|
45
|
+
if (event.detail?.key === this._key) this.#load()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
super.connectedCallback()
|
|
50
|
+
window.addEventListener(APPROVAL_CHANGED, this.#changed)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
super.disconnectedCallback()
|
|
55
|
+
window.removeEventListener(APPROVAL_CHANGED, this.#changed)
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
constructor() {
|
|
49
59
|
super()
|
|
50
60
|
this._comment = ''
|
|
51
|
-
this._publishAt = ''
|
|
52
|
-
this._unpublishAt = ''
|
|
53
61
|
this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (context) => {
|
|
54
62
|
if (!context) return
|
|
55
63
|
this.observe(context.unique, (unique) => {
|
|
@@ -76,9 +84,8 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
76
84
|
return
|
|
77
85
|
}
|
|
78
86
|
this._comment = ''
|
|
79
|
-
this._publishAt = ''
|
|
80
|
-
this._unpublishAt = ''
|
|
81
87
|
await this.#load()
|
|
88
|
+
window.dispatchEvent(new CustomEvent(APPROVAL_CHANGED, { detail: { key: this._key } }))
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
render() {
|
|
@@ -88,84 +95,25 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
88
95
|
return html`
|
|
89
96
|
<uui-box headline=${workflow ? `Workflow: ${workflow.name}` : 'Workflow'}>
|
|
90
97
|
${
|
|
91
|
-
workflow
|
|
92
|
-
? html`<p class="lead">
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
: 'Publishing this page goes through this workflow.'
|
|
97
|
-
}
|
|
98
|
-
</p>`
|
|
99
|
-
: html`<p class="lead">No workflow covers this page: it publishes as soon as someone who may publish does.</p>`
|
|
98
|
+
!workflow
|
|
99
|
+
? html`<p class="lead">No workflow covers this page: it publishes as soon as someone who may publish does.</p>`
|
|
100
|
+
: can.publishDirectly
|
|
101
|
+
? nothing
|
|
102
|
+
: html`<p class="lead">Publishing this page goes through this workflow.</p>`
|
|
100
103
|
}
|
|
101
104
|
${this._message ? html`<p class="message">${this._message}</p>` : nothing}
|
|
102
|
-
${request ? this.#renderRequest(request) : workflow ? this.#renderSend(workflow, can) : nothing}
|
|
103
|
-
</uui-box>
|
|
104
|
-
${past.length > 0 ? html`<uui-box headline="Earlier requests">${past.map((r) => this.#renderPast(r))}</uui-box>` : nothing}
|
|
105
|
-
`
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
#renderSend(workflow, can) {
|
|
109
|
-
if (!can.send && !can.requestUnpublish) return nothing
|
|
110
|
-
return html`
|
|
111
|
-
<div class="graph-wrap">${drawGraph(workflow.stages)}</div>
|
|
112
|
-
<uui-textarea
|
|
113
|
-
label="A note for the approvers"
|
|
114
|
-
placeholder="A note for the approvers (optional)"
|
|
115
|
-
.value=${this._comment}
|
|
116
|
-
@input=${(e) => {
|
|
117
|
-
this._comment = e.target.value
|
|
118
|
-
}}
|
|
119
|
-
></uui-textarea>
|
|
120
|
-
${workflow.scheduling ? this.#renderTimes(can) : nothing}
|
|
121
|
-
<div class="actions">
|
|
122
|
-
${
|
|
123
|
-
can.send
|
|
124
|
-
? html`<uui-button look="primary" ?disabled=${this._busy} label="Send for approval"
|
|
125
|
-
@click=${() => this.#act(() => sendForApproval(this._key, 'publish', this._comment, this.#schedule('publish')))}
|
|
126
|
-
>Send for approval</uui-button>`
|
|
127
|
-
: nothing
|
|
128
|
-
}
|
|
129
105
|
${
|
|
130
|
-
|
|
131
|
-
?
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
106
|
+
request
|
|
107
|
+
? this.#renderRequest(request)
|
|
108
|
+
: workflow
|
|
109
|
+
? html`<div class="graph-wrap">${drawGraph(workflow.stages)}</div>`
|
|
110
|
+
: nothing
|
|
135
111
|
}
|
|
136
|
-
</
|
|
112
|
+
</uui-box>
|
|
113
|
+
${past.length > 0 ? html`<uui-box headline="Earlier requests">${past.map((r) => this.#renderPast(r))}</uui-box>` : nothing}
|
|
137
114
|
`
|
|
138
115
|
}
|
|
139
116
|
|
|
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
|
-
|
|
169
117
|
#renderRequest(request) {
|
|
170
118
|
const states = Object.fromEntries(request.stages.map((s) => [s.alias, s.state]))
|
|
171
119
|
const progress = request.stages
|
|
@@ -250,8 +198,6 @@ export default class CromboloWorkflowTabElement extends UmbElementMixin(LitEleme
|
|
|
250
198
|
.message { color: var(--uui-color-danger); }
|
|
251
199
|
.graph-wrap { overflow-x: auto; margin: var(--uui-size-space-4) 0; }
|
|
252
200
|
.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); }
|
|
255
201
|
.actions { display: flex; gap: var(--uui-size-space-3); margin: var(--uui-size-space-3) 0; }
|
|
256
202
|
uui-textarea { width: 100%; }
|
|
257
203
|
.history { padding-left: var(--uui-size-space-5); }
|