@crombolo/backoffice-host 0.53.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/content-strip-items.js +20 -10
- package/plugin/definition-tree.js +157 -126
- 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-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 +43 -18
- 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 +96 -41
- 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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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.
|
|
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
|
|
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.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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,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,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 }
|