domma-cms 0.80.0 → 0.81.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/CLAUDE.md +6 -1
- package/admin/index.html +2 -2
- package/admin/js/lib/action-editor-arrange.js +1 -1
- package/admin/js/templates/action-editor.html +1 -0
- package/admin/js/templates/docs/usage-actions.html +5 -0
- package/admin/js/templates/form-editor.html +72 -0
- package/admin/js/views/form-editor.js +7 -7
- package/package.json +1 -1
- package/public/css/forms.css +1 -1
- package/public/js/form-logic-engine.js +1 -1
- package/public/js/forms.js +2 -2
- package/public/js/site.js +1 -1
- package/server/routes/api/forms.js +36 -10
- package/server/services/actions.js +28 -0
- package/server/services/collections.js +10 -4
- package/server/services/notification-sources.js +40 -0
- package/server/templates/page.html +4 -4
|
@@ -224,6 +224,12 @@ export async function registerCoreSources() {
|
|
|
224
224
|
description: 'A form\'s email, webhook or action failed after a submission. At most once a day per form.'},
|
|
225
225
|
{id: 'core:form-submitted', label: 'Form submitted', severity: 'info', defaultOn: false,
|
|
226
226
|
description: 'Every form submission. Off by default - busy forms would fill the inbox.'},
|
|
227
|
+
// On, and to every admin: the author asked for it answer by answer, so
|
|
228
|
+
// it is not noise, and fleet sites have no Super Admin to receive it.
|
|
229
|
+
{id: 'core:form-triggers', label: 'Form triggers', severity: 'info', audience: 'admins',
|
|
230
|
+
description: 'A form trigger set to "Notify the admins" fired when a form was submitted.'},
|
|
231
|
+
{id: 'core:actions', label: 'Actions', severity: 'info', audience: 'admins',
|
|
232
|
+
description: 'An Action with a "Notify the admins" step ran.'},
|
|
227
233
|
{id: 'core:users', label: 'Users added or removed', severity: 'info', defaultOn: false,
|
|
228
234
|
description: 'A user account was created or deleted.'}
|
|
229
235
|
];
|
|
@@ -302,6 +308,40 @@ export function formActionFailed(slug, title, what, message) {
|
|
|
302
308
|
body: `After a submission to "${title || slug}", its ${what} failed: ${String(message || '').slice(0, 300)}\n\nThe submission itself was saved.`});
|
|
303
309
|
}
|
|
304
310
|
|
|
311
|
+
/** What a trigger's level means to a notification: `error` is the one word they do not share. */
|
|
312
|
+
const TRIGGER_SEVERITY = {info: 'info', success: 'success', warning: 'warning', error: 'critical'};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* The notice a form trigger's "Notify the admins" raises. Pure, for the tests.
|
|
316
|
+
*
|
|
317
|
+
* @param {object} o
|
|
318
|
+
* @param {string} o.slug
|
|
319
|
+
* @param {string} [o.formTitle]
|
|
320
|
+
* @param {object} o.action - the trigger action: {message, level}
|
|
321
|
+
* @param {string} [o.field] - label of the field the trigger hangs off
|
|
322
|
+
* @param {*} [o.answer] - that field's answer
|
|
323
|
+
* @param {boolean} [o.ended] - an end-form cut the form short
|
|
324
|
+
* @param {boolean} [o.recorded] - the submission was stored
|
|
325
|
+
*/
|
|
326
|
+
export function formTriggerPayload({slug, formTitle, action = {}, field, answer, ended, recorded}) {
|
|
327
|
+
const form = formTitle || slug;
|
|
328
|
+
const said = Array.isArray(answer) ? answer.join(', ') : String(answer ?? '');
|
|
329
|
+
const lines = [`On the "${form}" form, ${field ? `"${field}" was answered "${said.slice(0, 200)}"` : 'a trigger fired'}.`];
|
|
330
|
+
if (ended) lines.push(recorded ? 'The form ended there; the answers given so far were saved.' : 'The form ended there; nothing was saved.');
|
|
331
|
+
return {
|
|
332
|
+
source: 'core:form-triggers',
|
|
333
|
+
severity: TRIGGER_SEVERITY[action.level] || 'info',
|
|
334
|
+
title: String(action.message || '').trim() || `Form "${form}": a trigger fired`,
|
|
335
|
+
body: lines.join('\n\n'),
|
|
336
|
+
link: recorded ? `#/forms/${slug}/submissions` : `#/forms/edit/${slug}`
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** forms route: a trigger's "Notify the admins" fired on a submission. */
|
|
341
|
+
export function formTriggerNotice(o) {
|
|
342
|
+
return notify(formTriggerPayload(o));
|
|
343
|
+
}
|
|
344
|
+
|
|
305
345
|
/** adapterRegistry / connectionManager: a database connection failed. */
|
|
306
346
|
export function storageDown(name, message) {
|
|
307
347
|
return notify({source: 'core:storage', severity: 'critical', dedupeKey: `storage:${name}`,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
<!-- Site CSS -->
|
|
27
27
|
<link rel="stylesheet" href="/public/css/site.css?v=20260919-nav-hover-2">
|
|
28
|
-
<link rel="stylesheet" href="/public/css/forms.css?v=
|
|
28
|
+
<link rel="stylesheet" href="/public/css/forms.css?v=20260926-end-panel">
|
|
29
29
|
<!-- Menu item hover / current-page effects. Loaded after site.css so a
|
|
30
30
|
menu's own highlight wins over the blanket link styling there. -->
|
|
31
31
|
<link rel="stylesheet" href="/public/css/menu-highlight.css?v=20260905-menu-highlight">
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
</script>
|
|
137
137
|
|
|
138
138
|
<!-- Site initialisation -->
|
|
139
|
-
<script src="/public/js/site.js?v=
|
|
139
|
+
<script src="/public/js/site.js?v=20260926-form-end-embed" type="module"></script>
|
|
140
140
|
<script src="/public/js/collection-context.js?v=20260919-ctx-tokens" type="module"></script>
|
|
141
141
|
{{ctxMenusModule}}
|
|
142
142
|
|
|
@@ -150,8 +150,8 @@
|
|
|
150
150
|
<script src="/public/js/collection-browser.js?v=20260523-browser"></script>
|
|
151
151
|
|
|
152
152
|
<!-- Core Forms (logic engine must load before renderer) -->
|
|
153
|
-
<script src="/public/js/form-logic-engine.js?v=
|
|
154
|
-
<script src="/public/js/forms.js?v=
|
|
153
|
+
<script src="/public/js/form-logic-engine.js?v=20260926-end-no-finish"></script>
|
|
154
|
+
<script src="/public/js/forms.js?v=20260926-form-end" type="module"></script>
|
|
155
155
|
|
|
156
156
|
<!-- Core effects runtime -->
|
|
157
157
|
<script src="/public/js/effects.js"></script>
|