@crombolo/backoffice-host 0.51.1 → 0.53.2
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/branding/localization-en.js +6 -8
- package/plugin/breadcrumb.js +6 -2
- package/plugin/content-home-dashboard.js +115 -0
- package/plugin/content-strip-items.js +65 -0
- package/plugin/content-strip.js +120 -0
- package/plugin/definition-tree-model.js +43 -0
- package/plugin/definition-tree.js +318 -0
- package/plugin/document-links.js +19 -0
- package/plugin/form-create-option.js +13 -0
- package/plugin/form-word-input-model.js +45 -0
- package/plugin/form-word-input.js +170 -0
- package/plugin/forms-client.js +21 -2
- package/plugin/forms-entries.js +77 -32
- package/plugin/forms-layout.js +6 -0
- package/plugin/forms-overview.js +200 -42
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/overview-dashboard.js +77 -7
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/session-guard-model.js +54 -0
- package/plugin/session-guard.js +50 -0
- package/plugin/settings-cards.js +14 -31
- package/plugin/settings-section.js +157 -16
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/theme-sync.js +69 -0
- package/plugin/tsx-editors.js +8 -5
- package/plugin/umbraco-package.json +132 -18
- package/plugin/view-parts.js +24 -0
- package/plugin/workflow-client.js +7 -2
- package/plugin/workflow-designer.js +44 -4
- package/src/paths.ts +1 -0
- package/plugin/theme-switch.js +0 -135
package/plugin/forms-entries.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Entries: every form's, under the Forms root of the tree, or one form's, as a tab
|
|
3
|
+
* on that form when `form` is given (story 289).
|
|
3
4
|
*
|
|
4
5
|
* What a person actually does here: read what was submitted, approve or reject
|
|
5
6
|
* it, delete it, and take the lot away as CSV.
|
|
@@ -20,8 +21,12 @@ import {
|
|
|
20
21
|
setEntryState,
|
|
21
22
|
} from './forms-client.js'
|
|
22
23
|
|
|
24
|
+
/** The filter's value for every form together. */
|
|
25
|
+
const ALL = ''
|
|
26
|
+
|
|
23
27
|
export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
24
28
|
static properties = {
|
|
29
|
+
form: { attribute: false },
|
|
25
30
|
_forms: { state: true },
|
|
26
31
|
_selected: { state: true },
|
|
27
32
|
_libraryForms: { state: true },
|
|
@@ -29,6 +34,8 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
29
34
|
_entries: { state: true },
|
|
30
35
|
_total: { state: true },
|
|
31
36
|
_state: { state: true },
|
|
37
|
+
_language: { state: true },
|
|
38
|
+
_languages: { state: true },
|
|
32
39
|
_search: { state: true },
|
|
33
40
|
_includeSpam: { state: true },
|
|
34
41
|
_notice: { state: true },
|
|
@@ -43,6 +50,8 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
43
50
|
this._entries = []
|
|
44
51
|
this._total = 0
|
|
45
52
|
this._state = ''
|
|
53
|
+
this._language = ''
|
|
54
|
+
this._languages = []
|
|
46
55
|
this._search = ''
|
|
47
56
|
this._includeSpam = false
|
|
48
57
|
this._notice = ''
|
|
@@ -60,8 +69,8 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
60
69
|
listForms().then(
|
|
61
70
|
(forms) => {
|
|
62
71
|
this._forms = forms
|
|
63
|
-
this._selected =
|
|
64
|
-
if (
|
|
72
|
+
this._selected = this.form ?? ALL
|
|
73
|
+
if (forms.length > 0) this.#load()
|
|
65
74
|
},
|
|
66
75
|
(error) => {
|
|
67
76
|
this._forms = []
|
|
@@ -73,15 +82,23 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
73
82
|
async #load() {
|
|
74
83
|
this._notice = ''
|
|
75
84
|
try {
|
|
76
|
-
const
|
|
85
|
+
const query = {
|
|
77
86
|
state: this._state,
|
|
87
|
+
language: this._language,
|
|
78
88
|
library: this._library,
|
|
79
89
|
search: this._search,
|
|
80
90
|
includeSpam: this._includeSpam ? 'true' : '',
|
|
81
91
|
take: 200,
|
|
82
|
-
}
|
|
83
|
-
this.
|
|
84
|
-
|
|
92
|
+
}
|
|
93
|
+
const forms = this._selected === ALL ? this._forms : [{ key: this._selected }]
|
|
94
|
+
const pages = await Promise.all(forms.map((form) => listEntries(form.key, query)))
|
|
95
|
+
this._languages = [...new Set(pages.flatMap((page) => page.languages ?? []))]
|
|
96
|
+
this._entries = pages
|
|
97
|
+
.flatMap((page, index) =>
|
|
98
|
+
(page.items ?? []).map((entry) => ({ ...entry, formName: forms[index].name })),
|
|
99
|
+
)
|
|
100
|
+
.sort((a, b) => new Date(b.createDate) - new Date(a.createDate))
|
|
101
|
+
this._total = pages.reduce((total, page) => total + (page.total ?? 0), 0)
|
|
85
102
|
} catch (error) {
|
|
86
103
|
this._entries = []
|
|
87
104
|
this._notice = error.message
|
|
@@ -133,19 +150,23 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
133
150
|
return html`
|
|
134
151
|
<uui-box headline="Entries">
|
|
135
152
|
<div class="filters">
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
${
|
|
154
|
+
this.form
|
|
155
|
+
? nothing
|
|
156
|
+
: html`<uui-select
|
|
157
|
+
label="Form"
|
|
158
|
+
.options=${[{ name: 'All forms', key: ALL }, ...this._forms].map((form) => ({
|
|
159
|
+
name: form.name,
|
|
160
|
+
value: form.key,
|
|
161
|
+
selected: form.key === this._selected,
|
|
162
|
+
}))}
|
|
163
|
+
@change=${(event) => {
|
|
164
|
+
this._selected = event.target.value
|
|
165
|
+
this._library = ''
|
|
166
|
+
this.#load()
|
|
167
|
+
}}
|
|
168
|
+
></uui-select>`
|
|
169
|
+
}
|
|
149
170
|
${this.#libraryFilter()}
|
|
150
171
|
<uui-select
|
|
151
172
|
label="State"
|
|
@@ -160,6 +181,20 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
160
181
|
this.#load()
|
|
161
182
|
}}
|
|
162
183
|
></uui-select>
|
|
184
|
+
${
|
|
185
|
+
this._languages.length > 1
|
|
186
|
+
? html`<uui-select
|
|
187
|
+
label="Language"
|
|
188
|
+
.options=${[['', 'Any language'], ...this._languages.map((l) => [l, l])].map(
|
|
189
|
+
([value, name]) => ({ name, value, selected: value === this._language }),
|
|
190
|
+
)}
|
|
191
|
+
@change=${(event) => {
|
|
192
|
+
this._language = event.target.value
|
|
193
|
+
this.#load()
|
|
194
|
+
}}
|
|
195
|
+
></uui-select>`
|
|
196
|
+
: nothing
|
|
197
|
+
}
|
|
163
198
|
<uui-input
|
|
164
199
|
placeholder="Search the answers"
|
|
165
200
|
.value=${this._search}
|
|
@@ -176,18 +211,22 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
176
211
|
this.#load()
|
|
177
212
|
}}
|
|
178
213
|
></uui-toggle>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
214
|
+
${
|
|
215
|
+
this._selected === ALL
|
|
216
|
+
? nothing
|
|
217
|
+
: html`<uui-button
|
|
218
|
+
class="csv"
|
|
219
|
+
look="secondary"
|
|
220
|
+
label="Export CSV"
|
|
221
|
+
@click=${async () => {
|
|
222
|
+
try {
|
|
223
|
+
await downloadEntriesCsv(this._selected)
|
|
224
|
+
} catch (error) {
|
|
225
|
+
this._notice = error.message
|
|
226
|
+
}
|
|
227
|
+
}}
|
|
228
|
+
></uui-button>`
|
|
229
|
+
}
|
|
191
230
|
</div>
|
|
192
231
|
|
|
193
232
|
${this._notice ? html`<p class="notice" role="alert">${this._notice}</p>` : nothing}
|
|
@@ -203,7 +242,13 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
203
242
|
<div class="entry">
|
|
204
243
|
<div class="meta">
|
|
205
244
|
<strong>${new Date(entry.createDate).toLocaleString()}</strong>
|
|
245
|
+
${this._selected === ALL ? html`<span class="form">${entry.formName}</span>` : nothing}
|
|
206
246
|
<span class="state">${entry.state}</span>
|
|
247
|
+
${
|
|
248
|
+
this._languages.length > 1 && entry.culture
|
|
249
|
+
? html`<span class="language">${entry.culture}</span>`
|
|
250
|
+
: nothing
|
|
251
|
+
}
|
|
207
252
|
${entry.spam ? html`<span class="spam">spam</span>` : nothing}
|
|
208
253
|
${
|
|
209
254
|
entry.libraryKey
|
package/plugin/forms-layout.js
CHANGED
|
@@ -47,6 +47,12 @@ export function removePage(form, index) {
|
|
|
47
47
|
return next
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/** Sets a field's text, or takes it away when empty, so the file doesn't hold an empty value. */
|
|
51
|
+
export function setFieldText(field, key, value) {
|
|
52
|
+
if (value.trim()) field[key] = value
|
|
53
|
+
else delete field[key]
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
export function setPageCaption(form, index, caption) {
|
|
51
57
|
const next = copy(form)
|
|
52
58
|
if (caption.trim()) next.pages[index].caption = caption
|
package/plugin/forms-overview.js
CHANGED
|
@@ -12,14 +12,18 @@
|
|
|
12
12
|
*/
|
|
13
13
|
// For its side effect: registers `umb-input-document`, which the shell loads lazily.
|
|
14
14
|
import '@umbraco-cms/backoffice/document'
|
|
15
|
+
import './form-word-input.js'
|
|
16
|
+
import './forms-entries.js'
|
|
15
17
|
import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
|
|
16
18
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
17
19
|
import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'
|
|
20
|
+
import { readOnlyWords } from './definition-tree-model.js'
|
|
18
21
|
import {
|
|
19
22
|
deleteForm,
|
|
23
|
+
formsTree,
|
|
20
24
|
listEmailTemplates,
|
|
21
|
-
listForms,
|
|
22
25
|
listFormTypes,
|
|
26
|
+
listWords,
|
|
23
27
|
previewChoices,
|
|
24
28
|
readForm,
|
|
25
29
|
saveForm,
|
|
@@ -37,6 +41,7 @@ import {
|
|
|
37
41
|
removeGroup,
|
|
38
42
|
removePage,
|
|
39
43
|
setColumns,
|
|
44
|
+
setFieldText,
|
|
40
45
|
setGroupCaption,
|
|
41
46
|
setPageCaption,
|
|
42
47
|
withLayout,
|
|
@@ -53,6 +58,20 @@ import {
|
|
|
53
58
|
workflowSettings,
|
|
54
59
|
} from './forms-workflows.js'
|
|
55
60
|
|
|
61
|
+
/** The form's own texts that can name a dictionary item. */
|
|
62
|
+
const WORD_SETTINGS = ['messageOnSubmit', 'submitLabel', 'nextLabel', 'previousLabel']
|
|
63
|
+
|
|
64
|
+
/** The settings of a field's type that can name one. */
|
|
65
|
+
const WORD_FIELD_SETTINGS = ['placeholder', 'content']
|
|
66
|
+
|
|
67
|
+
/** The tree beside the list hears of a change this way. */
|
|
68
|
+
const definitionsChanged = () => window.dispatchEvent(new Event('crombolo:definitions-changed'))
|
|
69
|
+
|
|
70
|
+
/** Back to the list, which the tree's links leave by their query. */
|
|
71
|
+
const clearQuery = () => {
|
|
72
|
+
if (location.search) history.replaceState(null, '', location.pathname)
|
|
73
|
+
}
|
|
74
|
+
|
|
56
75
|
/** What a preview depends on, so it survives a layout change that copies the field. */
|
|
57
76
|
const sourceKey = (source) => `${source.kind}|${source.parent}`
|
|
58
77
|
|
|
@@ -71,12 +90,27 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
71
90
|
_notice: { state: true },
|
|
72
91
|
_busy: { state: true },
|
|
73
92
|
_choices: { state: true },
|
|
93
|
+
_words: { state: true },
|
|
74
94
|
_types: { state: true },
|
|
75
95
|
_workflowTypes: { state: true },
|
|
76
96
|
_designs: { state: true },
|
|
97
|
+
_because: { state: true },
|
|
98
|
+
_tab: { state: true },
|
|
77
99
|
}
|
|
78
100
|
|
|
79
101
|
#notifications
|
|
102
|
+
/** The folder a new form goes in, from the tree's link. */
|
|
103
|
+
#folder
|
|
104
|
+
#query
|
|
105
|
+
|
|
106
|
+
#follow = () => {
|
|
107
|
+
if (location.search === this.#query) return
|
|
108
|
+
this.#query = location.search
|
|
109
|
+
const asked = new URLSearchParams(location.search)
|
|
110
|
+
if (asked.has('form')) this.#edit(asked.get('form'))
|
|
111
|
+
else if (asked.has('new')) this.#new(asked.get('new'))
|
|
112
|
+
else this._editing = undefined
|
|
113
|
+
}
|
|
80
114
|
|
|
81
115
|
constructor() {
|
|
82
116
|
super()
|
|
@@ -101,17 +135,34 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
101
135
|
connectedCallback() {
|
|
102
136
|
super.connectedCallback()
|
|
103
137
|
this.#load()
|
|
138
|
+
this.#follow()
|
|
139
|
+
window.addEventListener('changestate', this.#follow)
|
|
140
|
+
window.addEventListener('popstate', this.#follow)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
disconnectedCallback() {
|
|
144
|
+
super.disconnectedCallback()
|
|
145
|
+
window.removeEventListener('changestate', this.#follow)
|
|
146
|
+
window.removeEventListener('popstate', this.#follow)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#changed() {
|
|
150
|
+
this.#folder = undefined
|
|
151
|
+
definitionsChanged()
|
|
152
|
+
clearQuery()
|
|
104
153
|
}
|
|
105
154
|
|
|
106
155
|
async #load() {
|
|
107
156
|
try {
|
|
108
|
-
const [
|
|
109
|
-
|
|
157
|
+
const [tree, types, designs] = await Promise.all([
|
|
158
|
+
formsTree(),
|
|
110
159
|
listFormTypes(),
|
|
111
160
|
// The picker can still offer Standard without them.
|
|
112
161
|
listEmailTemplates().catch(() => []),
|
|
113
162
|
])
|
|
114
|
-
this.
|
|
163
|
+
this._words = await listWords().catch(() => [])
|
|
164
|
+
this._forms = tree.items ?? []
|
|
165
|
+
this._because = tree.readOnlyBecause
|
|
115
166
|
this._types = new Map(types.fields.map((info) => [info.type, info]))
|
|
116
167
|
this._workflowTypes = new Map(types.workflows.map((info) => [info.type, info]))
|
|
117
168
|
this._designs = designs
|
|
@@ -124,6 +175,7 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
124
175
|
async #edit(key) {
|
|
125
176
|
this._problems = []
|
|
126
177
|
this._notice = ''
|
|
178
|
+
this._tab = 'design'
|
|
127
179
|
const detail = await readForm(key)
|
|
128
180
|
this._editing = withLayout(detail.definition)
|
|
129
181
|
this._choices = new Map()
|
|
@@ -157,6 +209,47 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
157
209
|
}
|
|
158
210
|
}
|
|
159
211
|
|
|
212
|
+
/** The words a field keeps out of the table: its help, and what it says when refused. */
|
|
213
|
+
#fieldDetails(field) {
|
|
214
|
+
const readonly = Boolean(this._because)
|
|
215
|
+
const box = (key, label) => html`<label>
|
|
216
|
+
<span>${label}</span>
|
|
217
|
+
<crombolo-form-word-input
|
|
218
|
+
label=${label}
|
|
219
|
+
.value=${field[key] ?? ''}
|
|
220
|
+
.words=${this._words}
|
|
221
|
+
?readonly=${readonly}
|
|
222
|
+
@change=${(event) => {
|
|
223
|
+
setFieldText(field, key, event.target.value)
|
|
224
|
+
this.#touch()
|
|
225
|
+
}}
|
|
226
|
+
></crombolo-form-word-input>
|
|
227
|
+
</label>`
|
|
228
|
+
const textual = this._types.get(field.type)?.settings.some((s) => s.key === 'placeholder')
|
|
229
|
+
return html`<details class="field-details">
|
|
230
|
+
<summary>Help and messages</summary>
|
|
231
|
+
${box('helpText', 'Help text')}
|
|
232
|
+
${box('mandatoryMessage', 'When left empty')}
|
|
233
|
+
${
|
|
234
|
+
textual
|
|
235
|
+
? html`<label>
|
|
236
|
+
<span>Must match (a regular expression)</span>
|
|
237
|
+
<uui-input
|
|
238
|
+
label="Must match"
|
|
239
|
+
.value=${field.pattern ?? ''}
|
|
240
|
+
?readonly=${readonly}
|
|
241
|
+
@change=${(event) => {
|
|
242
|
+
setFieldText(field, 'pattern', event.target.value)
|
|
243
|
+
this.#touch()
|
|
244
|
+
}}
|
|
245
|
+
></uui-input>
|
|
246
|
+
</label>
|
|
247
|
+
${box('patternMessage', 'When it does not match')}`
|
|
248
|
+
: nothing
|
|
249
|
+
}
|
|
250
|
+
</details>`
|
|
251
|
+
}
|
|
252
|
+
|
|
160
253
|
/**
|
|
161
254
|
* One input per setting the type declares. A built-in type keeps them on the
|
|
162
255
|
* field; a bundle's type keeps them in the field's own settings.
|
|
@@ -188,6 +281,17 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
188
281
|
.checked=${value === true}
|
|
189
282
|
@change=${(event) => write(setting.key, event.target.checked || undefined)}
|
|
190
283
|
></uui-toggle>`
|
|
284
|
+
if (WORD_FIELD_SETTINGS.includes(setting.key))
|
|
285
|
+
return html`<label>
|
|
286
|
+
<span>${label}</span>
|
|
287
|
+
<crombolo-form-word-input
|
|
288
|
+
label=${label}
|
|
289
|
+
.value=${value ?? ''}
|
|
290
|
+
.words=${this._words}
|
|
291
|
+
?readonly=${Boolean(this._because)}
|
|
292
|
+
@change=${(event) => write(setting.key, event.target.value.trim() || undefined)}
|
|
293
|
+
></crombolo-form-word-input>
|
|
294
|
+
</label>`
|
|
191
295
|
return html`<label>
|
|
192
296
|
<span>${label}</span>
|
|
193
297
|
<uui-input
|
|
@@ -282,9 +386,11 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
282
386
|
`
|
|
283
387
|
}
|
|
284
388
|
|
|
285
|
-
#new() {
|
|
389
|
+
#new(folder) {
|
|
286
390
|
this._problems = []
|
|
287
391
|
this._notice = ''
|
|
392
|
+
this._tab = 'design'
|
|
393
|
+
this.#folder = folder || undefined
|
|
288
394
|
this._editing = {
|
|
289
395
|
key: crypto.randomUUID(),
|
|
290
396
|
alias: '',
|
|
@@ -313,12 +419,14 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
313
419
|
const pages = this._editing.pages
|
|
314
420
|
return html`<section class="page" aria-label=${page.caption || `Page ${p + 1}`}>
|
|
315
421
|
<div class="bar">
|
|
316
|
-
<
|
|
422
|
+
<crombolo-form-word-input
|
|
317
423
|
label="Page title"
|
|
318
424
|
placeholder=${`Page ${p + 1}`}
|
|
319
425
|
.value=${page.caption ?? ''}
|
|
426
|
+
.words=${this._words}
|
|
427
|
+
?readonly=${Boolean(this._because)}
|
|
320
428
|
@change=${(event) => this.#apply(setPageCaption, p, event.target.value)}
|
|
321
|
-
></
|
|
429
|
+
></crombolo-form-word-input>
|
|
322
430
|
<uui-button compact look="secondary" label="Move page up" ?disabled=${p === 0}
|
|
323
431
|
@click=${() => this.#apply(movePage, p, p - 1)}>↑</uui-button>
|
|
324
432
|
<uui-button compact look="secondary" label="Move page down" ?disabled=${p === pages.length - 1}
|
|
@@ -341,12 +449,14 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
341
449
|
@drop=${(event) => this.#drop(event, { page: p, group: g, index: group.fields.length })}
|
|
342
450
|
>
|
|
343
451
|
<div class="bar">
|
|
344
|
-
<
|
|
452
|
+
<crombolo-form-word-input
|
|
345
453
|
label="Group title"
|
|
346
454
|
placeholder="Untitled group"
|
|
347
455
|
.value=${group.caption ?? ''}
|
|
456
|
+
.words=${this._words}
|
|
457
|
+
?readonly=${Boolean(this._because)}
|
|
348
458
|
@change=${(event) => this.#apply(setGroupCaption, p, g, event.target.value)}
|
|
349
|
-
></
|
|
459
|
+
></crombolo-form-word-input>
|
|
350
460
|
<label class="columns">
|
|
351
461
|
Columns
|
|
352
462
|
<select @change=${(event) => this.#apply(setColumns, p, g, Number(event.target.value))}>
|
|
@@ -435,14 +545,17 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
435
545
|
@click=${() => this.#apply(nudgeField, { page: p, group: g, index }, 1)}>↓</uui-button>
|
|
436
546
|
</uui-table-cell>
|
|
437
547
|
<uui-table-cell>
|
|
438
|
-
<
|
|
548
|
+
<crombolo-form-word-input
|
|
439
549
|
label="Caption"
|
|
440
550
|
.value=${field.caption ?? ''}
|
|
551
|
+
.words=${this._words}
|
|
552
|
+
?readonly=${Boolean(this._because)}
|
|
441
553
|
@change=${(event) => {
|
|
442
554
|
field.caption = event.target.value
|
|
443
555
|
this.#touch()
|
|
444
556
|
}}
|
|
445
|
-
></
|
|
557
|
+
></crombolo-form-word-input>
|
|
558
|
+
${this.#fieldDetails(field)}
|
|
446
559
|
</uui-table-cell>
|
|
447
560
|
<uui-table-cell>
|
|
448
561
|
<uui-input
|
|
@@ -650,18 +763,15 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
650
763
|
this._problems = []
|
|
651
764
|
this._notice = ''
|
|
652
765
|
try {
|
|
653
|
-
const result = await saveForm(this._editing)
|
|
766
|
+
const result = await saveForm(this._editing, this.#folder)
|
|
654
767
|
if (result.ok) {
|
|
655
768
|
// The green toast every workspace shows on a save.
|
|
656
769
|
this.#notifications?.peek('positive', { data: { message: 'Form saved' } })
|
|
657
770
|
this._editing = undefined
|
|
771
|
+
this.#changed()
|
|
658
772
|
await this.#load()
|
|
659
773
|
} else {
|
|
660
774
|
this._problems = result.body.problems ?? []
|
|
661
|
-
if (result.body.status === 'readOnly' && this._problems.length === 0)
|
|
662
|
-
this._problems = [
|
|
663
|
-
{ path: '', message: 'The schema directory is read-only on this node.' },
|
|
664
|
-
]
|
|
665
775
|
}
|
|
666
776
|
} catch (error) {
|
|
667
777
|
this._problems = [{ path: '', message: error.message }]
|
|
@@ -675,6 +785,7 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
675
785
|
try {
|
|
676
786
|
const result = await deleteForm(form.key)
|
|
677
787
|
if (!result.ok) this._notice = 'That form could not be deleted.'
|
|
788
|
+
this.#changed()
|
|
678
789
|
await this.#load()
|
|
679
790
|
} catch (error) {
|
|
680
791
|
this._notice = error.message
|
|
@@ -685,15 +796,21 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
685
796
|
if (this._forms === undefined) return html`<div class="list"><uui-loader></uui-loader></div>`
|
|
686
797
|
if (this._editing) return this.#editor()
|
|
687
798
|
return html`<div class="list">
|
|
799
|
+
${this.#readOnly()}
|
|
688
800
|
${this._notice ? html`<uui-box><p>${this._notice}</p></uui-box>` : nothing}
|
|
689
801
|
${this.#list()}
|
|
690
802
|
</div>`
|
|
691
803
|
}
|
|
692
804
|
|
|
805
|
+
#readOnly() {
|
|
806
|
+
const words = readOnlyWords('Forms', this._because)
|
|
807
|
+
return words ? html`<uui-box><p role="status">${words}</p></uui-box>` : nothing
|
|
808
|
+
}
|
|
809
|
+
|
|
693
810
|
#list() {
|
|
694
811
|
// The create button above the list, as the workflows list has it.
|
|
695
812
|
return html`
|
|
696
|
-
|
|
813
|
+
${this._because ? nothing : html`<uui-button class="create" color="default" look="outline" label="Create" @click=${() => this.#new()}></uui-button>`}
|
|
697
814
|
<uui-box headline="Forms">
|
|
698
815
|
${
|
|
699
816
|
this._forms.length === 0
|
|
@@ -718,7 +835,7 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
718
835
|
<uui-table-cell>${form.storeEntries ? 'stored' : 'not stored'}</uui-table-cell>
|
|
719
836
|
<uui-table-cell>
|
|
720
837
|
<uui-button look="secondary" label="Edit" @click=${() => this.#edit(form.key)}></uui-button>
|
|
721
|
-
|
|
838
|
+
${this._because ? nothing : html`<uui-button look="secondary" color="danger" label="Delete" @click=${() => this.#remove(form)}></uui-button>`}
|
|
722
839
|
</uui-table-cell>
|
|
723
840
|
</uui-table-row>
|
|
724
841
|
`,
|
|
@@ -730,29 +847,9 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
730
847
|
`
|
|
731
848
|
}
|
|
732
849
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
<uui-form-layout-item>
|
|
737
|
-
<uui-label slot="label">${label}</uui-label>
|
|
738
|
-
${hint ? html`<span slot="description">${hint}</span>` : nothing}
|
|
739
|
-
<uui-input
|
|
740
|
-
.value=${form[key] ?? ''}
|
|
741
|
-
@change=${(event) => {
|
|
742
|
-
form[key] = event.target.value
|
|
743
|
-
this.#touch()
|
|
744
|
-
}}
|
|
745
|
-
></uui-input>
|
|
746
|
-
</uui-form-layout-item>
|
|
747
|
-
`
|
|
748
|
-
const leave = () => {
|
|
749
|
-
this._editing = undefined
|
|
750
|
-
this._problems = []
|
|
751
|
-
}
|
|
752
|
-
// Umbraco's own layout, as the workflow designer has it: Save bottom right,
|
|
753
|
-
// and what stopped a save listed just above it.
|
|
754
|
-
return html`<umb-body-layout headline=${form.alias ? `Form: ${form.name || form.alias}` : 'A new form'}>
|
|
755
|
-
<uui-box>
|
|
850
|
+
/** The form's own settings and layout, which is what its Design tab shows. */
|
|
851
|
+
#design(form, text) {
|
|
852
|
+
return html` <uui-box>
|
|
756
853
|
${text('name', 'Name')}
|
|
757
854
|
${text('alias', 'Alias', 'Letters and numbers, starting with a letter. The file is named after it.')}
|
|
758
855
|
${text('messageOnSubmit', 'Message on submit')}
|
|
@@ -811,6 +908,63 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
811
908
|
</ul>
|
|
812
909
|
</div>`
|
|
813
910
|
: nothing
|
|
911
|
+
}`
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
#editor() {
|
|
915
|
+
const form = this._editing
|
|
916
|
+
const text = (key, label, hint) => {
|
|
917
|
+
const change = (event) => {
|
|
918
|
+
form[key] = event.target.value
|
|
919
|
+
this.#touch()
|
|
920
|
+
}
|
|
921
|
+
return html`
|
|
922
|
+
<uui-form-layout-item>
|
|
923
|
+
<uui-label slot="label">${label}</uui-label>
|
|
924
|
+
${hint ? html`<span slot="description">${hint}</span>` : nothing}
|
|
925
|
+
${
|
|
926
|
+
WORD_SETTINGS.includes(key)
|
|
927
|
+
? html`<crombolo-form-word-input
|
|
928
|
+
label=${label}
|
|
929
|
+
.value=${form[key] ?? ''}
|
|
930
|
+
.words=${this._words}
|
|
931
|
+
?readonly=${Boolean(this._because)}
|
|
932
|
+
@change=${change}
|
|
933
|
+
></crombolo-form-word-input>`
|
|
934
|
+
: html`<uui-input .value=${form[key] ?? ''} @change=${change}></uui-input>`
|
|
935
|
+
}
|
|
936
|
+
</uui-form-layout-item>
|
|
937
|
+
`
|
|
938
|
+
}
|
|
939
|
+
const leave = () => {
|
|
940
|
+
this._editing = undefined
|
|
941
|
+
this._problems = []
|
|
942
|
+
clearQuery()
|
|
943
|
+
}
|
|
944
|
+
const tab = (id, label, icon) => html`<uui-tab
|
|
945
|
+
label=${label}
|
|
946
|
+
?active=${this._tab === id}
|
|
947
|
+
@click=${() => {
|
|
948
|
+
this._tab = id
|
|
949
|
+
}}
|
|
950
|
+
><umb-icon slot="icon" name=${icon}></umb-icon>${label}</uui-tab>`
|
|
951
|
+
const saved = this._forms.some((known) => known.key === form.key)
|
|
952
|
+
// Umbraco's own layout, as the workflow designer has it: Save bottom right,
|
|
953
|
+
// and what stopped a save listed just above it.
|
|
954
|
+
return html`<umb-body-layout headline=${form.alias ? `Form: ${form.name || form.alias}` : 'A new form'}>
|
|
955
|
+
${
|
|
956
|
+
saved
|
|
957
|
+
? html`<uui-tab-group slot="navigation">
|
|
958
|
+
${tab('design', 'Design', 'icon-edit')}
|
|
959
|
+
${tab('entries', 'Entries', 'icon-inbox')}
|
|
960
|
+
</uui-tab-group>`
|
|
961
|
+
: nothing
|
|
962
|
+
}
|
|
963
|
+
${this.#readOnly()}
|
|
964
|
+
${
|
|
965
|
+
this._tab === 'entries'
|
|
966
|
+
? html`<crombolo-forms-entries .form=${form.key}></crombolo-forms-entries>`
|
|
967
|
+
: this.#design(form, text)
|
|
814
968
|
}
|
|
815
969
|
${
|
|
816
970
|
this._problems.length > 0
|
|
@@ -818,11 +972,15 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
818
972
|
: nothing
|
|
819
973
|
}
|
|
820
974
|
<uui-button slot="actions" look="secondary" label="Back to the list" @click=${leave}>Back to the list</uui-button>
|
|
821
|
-
|
|
975
|
+
${this._because ? nothing : html`<uui-button slot="actions" look="primary" color="positive" label="Save" ?disabled=${this._busy} @click=${() => this.#save()}>Save</uui-button>`}
|
|
822
976
|
</umb-body-layout>`
|
|
823
977
|
}
|
|
824
978
|
|
|
825
979
|
static styles = css`
|
|
980
|
+
.field-details { margin-top: var(--uui-size-space-2); }
|
|
981
|
+
.field-details summary { cursor: pointer; color: var(--uui-color-text-alt); font-size: var(--uui-type-small-size); }
|
|
982
|
+
.field-details label { display: block; margin-top: var(--uui-size-space-2); }
|
|
983
|
+
.field-details span { display: block; font-size: var(--uui-type-small-size); }
|
|
826
984
|
.page {
|
|
827
985
|
border: 1px solid var(--uui-color-border, #ddd);
|
|
828
986
|
border-radius: var(--uui-border-radius, 3px);
|