domma-cms 1.47.2 → 1.47.4
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/CHANGELOG.md +10 -0
- package/admin/js/lib/form-submissions-arrange.js +1 -1
- package/admin/js/lib/private-files.js +1 -0
- package/admin/js/templates/docs/api-forms.html +10 -1
- package/admin/js/templates/docs/tutorial-forms.html +6 -0
- package/admin/js/views/collection-entries.js +7 -7
- package/admin/js/views/form-submissions.js +2 -2
- package/docs/DommaFeatures.md +44 -6
- package/package.json +1 -1
- package/plugins/free-tier.lock.json +9 -9
- package/plugins/shopping-cart/CHANGELOG.md +4 -0
- package/plugins/shopping-cart/CLAUDE.md +3 -0
- package/plugins/shopping-cart/admin/views/products.js +2 -2
- package/plugins/shopping-cart/plugin.json +1 -1
- package/plugins/shopping-cart/public/lib/products.js +14 -0
- package/plugins/shopping-cart/public/shop.css +21 -2
- package/plugins/shopping-cart/tests/pure.test.js +12 -1
- package/public/js/form-answers.mjs +1 -0
- package/server/routes/api/forms.js +161 -16
- package/server/server.js +15 -1
- package/server/services/email.js +30 -11
- package/server/services/form-uploads-migration.js +254 -0
- package/server/services/formUploads.js +161 -0
- package/server/services/markdown.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.47.4] - 2026-11-08
|
|
4
|
+
|
|
5
|
+
- **Security: files visitors send with a form are private.** They were saved to content/media/, served to anyone at `/media/<name>` and listed in the Media library - CVs and right-to-work documents among them. New uploads go to `content/form-uploads/<form>/<upload id>/` (kept out of the site repo by its own `.gitignore`) and are served only by `GET /api/forms/:slug/uploads/:id/:name`, to a signed-in user with the submissions inbox's permission (`collections` read) who can see the form, while a submission links to the file. Only PNG, JPEG, GIF, WebP and PDF are shown inline; everything else is a download, always with nosniff, `private, no-store` and a CSP that runs nothing. The submission panel shows pictures and opens files with the admin's sign-in; the notification email links to them and says to sign in (files are not attached). On first start a one-off migration moves the files existing submissions reference into the private store and rewrites the references - only real submissions (`meta.source: form:<slug>`) and only regular files (a link or folder is skipped); a file a page or other content also links to is copied and left in Media. The file route's CSP also has `frame-ancestors 'none'`. Webhooks, Actions and plugins that fetched a submission's file URL without signing in can no longer do so.
|
|
6
|
+
- Forms: the submission panel and the notification email show answers as the visitor saw them, not as stored. A dropdown, radio, checkbox group or chooser (picture choices) shows the option's label ("Faulty", not `faulty`), a single checkbox Yes or No (not `true`), a date 03/11/2026 (not `2026-11-03`), a time 14:05, and a file field its file names. A value the form no longer offers is shown as stored. The row summary, Copy and search use the same words. One helper does it for both (`answerLabel()`, `public/js/form-answers.mjs`), reading labels the way trigger messages do; the email escapes all of it. CSV and JSON exports still carry the stored values.
|
|
7
|
+
- Forms: deleting a submission (one, or Clear all) now deletes the files it uploaded. Only the files the form saved for that submission in its private store are touched - a reference in one of the form's file fields to `/api/forms/<this form>/uploads/...`, resolved through `fileIn` inside the store - and a file another entry still links to is kept. Nothing under /media is ever deleted this way, so a reference planted in an entry (a public create, a token, an editor) cannot remove a file a page uses, and a tampered reference such as `../../config/server.json` is refused.
|
|
8
|
+
|
|
9
|
+
## [1.47.3] - 2026-11-08
|
|
10
|
+
|
|
11
|
+
- **Security: `{{field}}` in a block template escapes `'` as well**, so a value printed inside a single-quoted attribute cannot end it (`escapeHtmlText()` in markdown.js escaped `"` only).
|
|
12
|
+
|
|
3
13
|
## [1.47.2] - 2026-11-08
|
|
4
14
|
|
|
5
15
|
- **Security: a shortcode parameter can no longer close the attribute it is written into.** `[card class=…]` (and `[box]`, which builds on it) was pushed into `class="…"` unescaped, and `[animate]`, `[ambient]`, `[grid]`/`[col]` and the hero's blobs built class names from parameters as written (`animate-${type}`, `gap-${gap}`, `grid-cols-${cols}`, `col-span-${span}`). A quote in one added attributes of its own - a `data-config` that site.js acts on, for one. The class is now escaped and class-building parameters keep to letters, digits, `_` and `-` (`classToken()` in markdown.js).
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const FILTERS=["inbox","new","spam"],WEEK_MS=
|
|
1
|
+
import{answerLabel as g}from"../../../public/js/form-answers.mjs";export const FILTERS=["inbox","new","spam"],WEEK_MS=7*864e5;const y=new Set(["page-break","heading","paragraph","html","divider","spacer","banner"]);export function answerFields(e){return(e?.fields||[]).filter(t=>t&&t.name&&!y.has(t.type)).map(t=>({name:String(t.name),label:String(t.label||t.name),type:String(t.type||"text"),...Array.isArray(t.options)&&{options:t.options},...t.logic?.cascade&&{logic:{cascade:t.logic.cascade}}}))}export const isFileRef=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.url=="string"&&(typeof e.name=="string"||e.name===void 0),fileRefsOf=e=>(Array.isArray(e)?e:[e]).filter(isFileRef),safeFileHref=e=>/^(https?:\/\/|\/(?!\/))/i.test(String(e||""))?String(e):"";export function answerText(e){return e==null?"":Array.isArray(e)?e.map(answerText).filter(Boolean).join(", "):typeof e=="boolean"?e?"Yes":"No":isFileRef(e)?e.name||e.url.split("/").pop()||"file":typeof e=="object"?JSON.stringify(e):String(e).trim()}export const fieldText=(e,t)=>g(e,t),isSpam=e=>e?.data?.spam===!0,createdAt=e=>e?.meta?.createdAt||"",isNew=(e,t=Date.now())=>{const n=Date.parse(createdAt(e));return Number.isFinite(n)&&t-n<WEEK_MS};const d=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;export function emailOf(e,t){const n=e?.data||{},r=t.find(i=>i.type==="email"&&d.test(answerText(n[i.name])));if(r)return answerText(n[r.name]);const a=t.find(i=>/e-?mail/i.test(i.name)&&d.test(answerText(n[i.name])));if(a)return answerText(n[a.name]);const m=t.find(i=>d.test(answerText(n[i.name])));return m?answerText(n[m.name]):""}const f=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e;export function submissionRow(e,t,n=Date.now()){const r=e?.data||{},a=t.filter(c=>fieldText(c,r[c.name])!==""),m=a.find(c=>/(^|_|-)(full[-_ ]?)?name$|^name/i.test(c.name)&&c.type!=="email"),i=emailOf(e,t),s=m||a.find(c=>answerText(r[c.name])===i&&i)||a[0],p=s?f(fieldText(s,r[s.name]),80):"Empty submission",u=a.filter(c=>c!==s).slice(0,3).map(c=>`${c.label}: ${f(fieldText(c,r[c.name]),60)}`),o=isSpam(e),l=isNew(e,n);return{id:String(e?.id??""),title:p,meta:u.join(" \xB7 ")||"No other answers",email:i,at:createdAt(e),spam:o,fresh:l&&!o,rowCls:[o&&"is-spam",l&&!o&&"is-new"].filter(Boolean).join(" ")}}export function arrangeSubmissions(e,{filter:t="inbox",query:n="",from:r="",to:a="",now:m=Date.now(),fields:i=[]}={}){const s=String(n).trim().toLowerCase(),p=r?Date.parse(`${r}T00:00:00`):null,u=a?Date.parse(`${a}T23:59:59.999`):null;return[...e||[]].filter(o=>t==="spam"?isSpam(o):!isSpam(o)).filter(o=>t!=="new"||isNew(o,m)).filter(o=>!s||Object.values(o?.data||{}).some(l=>answerText(l).toLowerCase().includes(s))||i.some(l=>fieldText(l,o?.data?.[l.name]).toLowerCase().includes(s))).filter(o=>{if(p===null&&u===null)return!0;const l=Date.parse(createdAt(o));return Number.isFinite(l)?(p===null||l>=p)&&(u===null||l<=u):!1}).sort((o,l)=>String(createdAt(l)).localeCompare(String(createdAt(o))))}export function submissionCounts(e,t=Date.now()){const n=e||[],r=n.filter(isSpam).length;return{inbox:n.length-r,new:n.filter(a=>!isSpam(a)&&isNew(a,t)).length,spam:r,all:n.length}}export function submissionText(e,t,{formTitle:n="",when:r=""}={}){const a=e?.data||{},m=t.filter(s=>fieldText(s,a[s.name])!=="").map(s=>`${s.label}: ${fieldText(s,a[s.name])}`),i=[n&&`${n} - submission`,r&&`Submitted ${r}`].filter(Boolean);return[...i,...i.length?[""]:[],...m].join(`
|
|
2
2
|
`)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getToken as c,refreshAccessToken as s}from"/admin/js/api.js";export const isPrivateUpload=r=>/^\/api\/forms\/[^/?#]+\/uploads\/[^/?#]+\/[^/?#]+$/.test(String(r||""));const o=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf"]),l=/\.(png|jpe?g|gif|webp)$/i;export async function fetchPrivateFile(r){const t=n=>fetch(r,{headers:n?{Authorization:`Bearer ${n}`}:{}});let e=await t(c());if(e.status===401)try{e=await t(await s())}catch{}if(!e.ok)throw new Error(e.status===404?"That file is no longer there.":`Could not open the file (${e.status}).`);return e.blob()}export async function openPrivateFile(r,t="file"){const e=window.open("","_blank");try{const n=await fetchPrivateFile(r),a=URL.createObjectURL(n);if(o.has(n.type)&&e)e.opener=null,e.location.href=a;else{e?.close();const i=document.createElement("a");i.href=a,i.download=t,document.body.appendChild(i),i.click(),i.remove()}setTimeout(()=>URL.revokeObjectURL(a),6e4)}catch(n){e?.close(),E.toast(n.message,{type:"error"})}}export function wirePrivateLink(r,t){isPrivateUpload(t?.url)&&r.addEventListener("click",e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),openPrivateFile(t.url,t.name||"file"))})}export function privateThumbnail(r){if(!isPrivateUpload(r?.url)||!(l.test(r.url)||/^image\/(png|jpeg|gif|webp)$/.test(String(r.mime||""))))return null;const t=document.createElement("img");return t.alt=r.name||"",t.className="fsx-thumb",t.style.cssText="display:block;max-width:220px;max-height:160px;margin-top:4px;border-radius:4px;",fetchPrivateFile(r.url).then(e=>{if(!o.has(e.type)||e.type==="application/pdf"){t.remove();return}t.src=URL.createObjectURL(e),t.addEventListener("load",()=>URL.revokeObjectURL(t.src),{once:!0})}).catch(()=>t.remove()),t}
|
|
@@ -212,10 +212,19 @@
|
|
|
212
212
|
<h3>File uploads</h3>
|
|
213
213
|
<p>Send <code>multipart/form-data</code>. A file part whose name matches a <code>type: "file"</code> field is checked
|
|
214
214
|
against that field's <code>file.maxSize</code> (bytes, default 5 MB) and <code>file.accept</code> (comma-separated
|
|
215
|
-
MIME types, wildcards such as <code>image/*</code> allowed), saved to
|
|
215
|
+
MIME types, wildcards such as <code>image/*</code> allowed), saved to a private store
|
|
216
|
+
(<code>content/form-uploads/<form>/<upload id>/</code>, never the media library) under a prefixed safe name,
|
|
216
217
|
and stored on the entry as <code>{ "url", "name", "size", "mime" }</code>. A file part for an unknown field is
|
|
217
218
|
ignored; an empty file input is skipped. The server-wide upload limit (<code>uploads.maxFileSize</code> in
|
|
218
219
|
<code>config/server.json</code>) still applies.</p>
|
|
220
|
+
<p>The <code>url</code> is <code>/api/forms/<slug>/uploads/<upload id>/<name></code>. It answers only a
|
|
221
|
+
signed-in user with the <code>collections</code> read permission (the one that opens the submissions inbox) who can
|
|
222
|
+
see the form, and only while a submission of the form links to the file: a Bearer token, or the admin's sign-in
|
|
223
|
+
cookie for a link opened in the browser. Anyone else gets <code>401</code> or <code>403</code>. PNG, JPEG, GIF, WebP
|
|
224
|
+
and PDF are sent inline; everything else as an <code>attachment</code> of type
|
|
225
|
+
<code>application/octet-stream</code>, always with <code>X-Content-Type-Options: nosniff</code>,
|
|
226
|
+
<code>Cache-Control: private, no-store</code> and a Content-Security-Policy that runs nothing. Deleting a submission
|
|
227
|
+
deletes its files.</p>
|
|
219
228
|
<pre class="code-block"><code class="language-bash">curl -X POST https://example.com/api/forms/submit/apply \
|
|
220
229
|
-F name='Ada Lovelace' \
|
|
221
230
|
-F email=ada@example.com \
|
|
@@ -134,6 +134,12 @@ Subject Prefix: [Contact Form]</code></pre>
|
|
|
134
134
|
<li>Forms accept pictures (not SVG), audio, video, PDFs, Office and OpenDocument files, text and CSV, and
|
|
135
135
|
archives. Web pages, SVG files and scripts are always refused. Files are only saved once the submission
|
|
136
136
|
has passed its spam and validation checks.</li>
|
|
137
|
+
<li>Files visitors send are <strong>private</strong>. They are not in Media and have no public address: they
|
|
138
|
+
open from the submission (pictures show there) for someone signed in who can read the form's submissions.
|
|
139
|
+
The email notification links to them; the link asks you to sign in first. Files are never attached to the
|
|
140
|
+
email. Deleting a submission deletes its files.</li>
|
|
141
|
+
<li>Files sent before this change were in Media. They are moved to the private store when the site first
|
|
142
|
+
starts on this version - or copied, and left in Media too, if a page or other content links to one.</li>
|
|
137
143
|
</ul>
|
|
138
144
|
|
|
139
145
|
<h3>Copying a form to another site</h3>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{api as k,apiRequest as
|
|
1
|
+
import{wirePrivateLink as ft}from"/admin/js/lib/private-files.js";import{api as k,apiRequest as mt}from"../api.js";import{addBannerAction as j}from"../lib/plugin-chrome.js";import{SHAPES as ht,showLoading as yt}from"../lib/loading.js";import{helpPopovers as ze}from"../lib/help-popover.js";import{onceClosed as vt,openMenuAt as je,sidebarCount as P,viewLifetime as bt}from"../lib/tool-kit.js";import{PAGE_SIZE as ce,SHOW_STEP as X,arrangeEntries as gt,listColumns as Et,canClear as kt,cellText as Pe,countText as xt,draftable as wt,fileRefsOf as St,filterChoices as Ct,filterText as $t,hasForm as At,isFileValue as ve,safeFileHref as Mt,shownValue as be,snapshot as _e,typedValue as Lt,valueText as ge}from"../lib/collection-entries-arrange.js";import{fmtDate as qt,fmtDateTime as _}from"../lib/dates.js";const Be=/^#\/collections\/[^/?#]+\/entries\/?(\?.*)?$/,B=p=>`collection-entries.draft.${p}`,U=p=>String(p??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function le(p){const m=document.createElement("template");return m.innerHTML=p.trim(),m.content.firstElementChild}const Tt='<span class="cex-chip">{{text}}<button type="button" data-idx="{{idx}}" title="Remove this filter" aria-label="Remove filter {{text}}">\xD7</button></span>';function Nt(p){return`
|
|
2
2
|
<tr class="cex-row" data-id="{{id}}" tabindex="0" data-bind-class="rowCls">
|
|
3
3
|
<td class="cex-check"><input type="checkbox" class="cex-sel" aria-label="Select this entry" data-bind-checked="sel"></td>
|
|
4
|
-
${Array.from({length:p},(
|
|
4
|
+
${Array.from({length:p},(v,a)=>`<td data-col="${a}" title="{{t${a}}}">{{c${a}}}</td>`).join("")}
|
|
5
5
|
<td class="cex-when" title="{{whenFull}}">{{when}}</td>
|
|
6
6
|
<td class="cex-tools"><button type="button" class="cex-run" data-bind-hidden="!runs" title="Run one of this collection's actions">\u26A1 {{runs}}</button><button type="button" class="cex-kebab" aria-label="Actions for this entry" title="Actions">\u22EE</button></td>
|
|
7
|
-
</tr>`}const
|
|
7
|
+
</tr>`}const It=(p,m)=>p?.type==="file"||ve(m?.[p?.name]);function He(p){const m=document.createElement("ul");m.className="cex-files";for(const v of St(p)){const a=document.createElement("li"),l=Mt(v.url),c=document.createElement(l?"a":"span");l&&(c.href=l,c.target="_blank",c.rel="noopener",ft(c,v)),c.textContent=ge(v),a.appendChild(c),m.appendChild(a)}return m}function Dt(p,m){const v={};return p.forEach(a=>{const l={};a.fullWidth?l.span=m:a.span>1&&(l.span=a.span),a.placeholder&&(l.placeholder=a.placeholder),a.helper&&(l.hint=a.helper),a.prefix&&(l.prefix=a.prefix),a.suffix&&(l.suffix=a.suffix);for(const u of["clear","stepper","counter"])a[u]===!0&&(l[u]=!0);const c=a.type==="checkbox"?"boolean":a.type==="date"?"string":a.type;v[a.name]={type:c,label:a.label,required:a.required,options:a.options,...Object.keys(l).length?{formConfig:l}:{}}}),v}function Ve(p,m){const v=CSS.escape(m);return[...p.querySelectorAll(`[name="${v}"], [name="${v}[]"]`)]}function ie(p,m){const v={};for(const a of m){const l=Ve(p,a.name);if(!l.length)continue;const c=l[0];c.type==="radio"?v[a.name]=l.find(u=>u.checked)?.value??"":c.type==="checkbox"&&(l.length>1||c.name.endsWith("[]"))?v[a.name]=l.filter(u=>u.checked).map(u=>u.value):c.type==="checkbox"?v[a.name]=c.checked:c.tagName==="SELECT"&&c.multiple?v[a.name]=[...c.selectedOptions].map(u=>u.value):v[a.name]=Lt(a,c.value)}return v}function Je(p,m,v){for(const a of m){if(!(a.name in v))continue;const l=v[a.name],c=Ve(p,a.name);if(!c.length)continue;const u=c[0];u.type==="radio"?c.forEach(r=>{r.checked=r.value===String(l)}):u.type==="checkbox"&&(c.length>1||u.name.endsWith("[]"))?c.forEach(r=>{r.checked=Array.isArray(l)&&l.includes(r.value)}):u.type==="checkbox"?u.checked=l===!0:u.tagName==="SELECT"&&u.multiple?[...u.options].forEach(r=>{r.selected=Array.isArray(l)&&l.includes(r.value)}):u.value=l??"",c.forEach(r=>r.dispatchEvent(new Event("input",{bubbles:!0})))}}const Ke=bt(Be);export const collectionEntriesView={templateUrl:"/admin/js/templates/collection-entries.html",async onMount(p){Ke.reset();const m=p.get(0).querySelector(".cex")||p.get(0),v=location.hash.match(/^#\/collections\/([^/?#]+)\/entries/),a=v?decodeURIComponent(v[1]):null,l=()=>Be.test(location.hash)&&m.isConnected&&location.hash.includes(`/collections/${encodeURIComponent(a)}/entries`),c=e=>(Ke.add(e),e);if(!a){E.toast("No collection selected.",{type:"error"});return}const u=M.observable(null),r=M.observable([]),x=M.observable(0),Y=M.observable(!0),H=M.observable(""),We=M.computed(()=>u.value!==null),re=M.observable(""),w=M.observable([]),Z=M.observable({key:"created",dir:"desc"}),g=M.observable([]),N=M.observable(X),V=M.observable([]),Q=M.observable({}),L=M.observable(!1);let ee=1;const te=()=>u.peek()?.fields||[],de=M.computed(()=>Et(u.value?.fields)),J=e=>r.peek().find(t=>t.id===e),Ee=e=>V.peek().filter(t=>{const n=Q.peek()[t.slug];return n==null||n.has(e)}),D=M.observable([]),ke=M.observable([]);c(M.effect(()=>{const e=gt(r.value,{filters:w.value,query:re.value,sort:Z.value});D.value=e})),c(M.effect(()=>{const e=de.value,t=new Set(g.value);Q.value,V.value,ke.value=D.value.slice(0,N.value).map(n=>{const o={id:n.id,sel:t.has(n.id),rowCls:t.has(n.id)?"is-selected":""};e.forEach((i,h)=>{const d=be(i,n.data?.[i.name]);o[`c${h}`]=Pe(d),o[`t${h}`]=ge(d)});const s=n.meta?.createdAt;o.when=s?qt(s):"",o.whenFull=s?`Created ${_(s)}${n.meta?.updatedAt?` \xB7 changed ${_(n.meta.updatedAt)}`:""}`:"";const f=Ee(n.id).length;return o.runs=f?String(f):"",o})}));const Ge=M.computed(()=>w.value.map((e,t)=>({key:`${t}:${e.field}:${e.op}:${e.value}`,idx:t,text:$t(e)}))),Xe=M.computed(()=>g.value.length),Ye={schema:u,loaded:r,loading:Y,loadError:H,ready:We,query:re,rows:ke,chips:Ge,busy:L,selectedCount:Xe,countLine:M.computed(()=>xt(D.value.length,r.value.length,x.value)),selectedText:M.computed(()=>`${g.value.length} selected`),canClear:M.computed(()=>kt(a)),introText:M.computed(()=>{const e=u.value;return e?`${e.description?`${e.description} - `:""}${(e.fields||[]).length} field${(e.fields||[]).length===1?"":"s"}${e.storage?.adapter==="mongodb"?", on MongoDB":""}.`:""}),emptyText:M.computed(()=>r.value.length?"No entries match the search or filters.":"No entries yet - Add entry in the banner makes one, or Import brings many."),moreText:M.computed(()=>{const e=D.value.length-N.value;if(e>0)return`Show ${Math.min(X,e)} more (${e} not shown)`;const t=x.value-r.value.length;return t>0?`Load the next ${Math.min(ce,t)} from the server`:""})};async function K({reset:e=!0,pending:t=null}={}){Y.value=!0;try{const n=e?Math.max(ce,r.peek().length):ce;e&&(ee=1);const o=await k.collections.listEntries(a,{limit:n,page:ee});if(t&&await t.done(),!l())return;const s=o?.entries||(Array.isArray(o)?o:[]);r.value=e?s:[...r.peek(),...s.filter(i=>!J(i.id))],x.value=Number(o?.total)||r.peek().length,e&&(ee=Math.max(1,Math.ceil(r.peek().length/ce)));const f=new Set(r.peek().map(i=>i.id));g.value=g.peek().filter(i=>f.has(i)),H.value="",await et()}catch(n){H.value=`Could not load the entries: ${n.message||n}`}finally{t&&await t.done(),Y.value=!1}}async function Ze(){ee+=1,await K({reset:!1})}async function Qe(){try{if((await mt("/actions/_count",{method:"GET"}).catch(()=>null))?.available===!1)return;const t=await k.actions.forCollection(a);V.value=Array.isArray(t)?t.filter(n=>n.canRun!==!1):[]}catch{V.value=[]}}async function et(){const e=V.peek().filter(o=>o.access?.rowLevel);if(!e.length||!r.peek().length)return;const t=r.peek().map(o=>o.id),n={...Q.peek()};await Promise.all(e.map(async o=>{try{n[o.slug]=new Set((await k.actions.checkAccess(o.slug,t)).allowed)}catch{n[o.slug]=null}})),Q.value=n}const W=e=>{const t=te()[0];return(t?Pe(be(t,e?.data?.[t.name]),40):"")||`Entry ${String(e?.id||"").slice(0,8)}`};async function xe(e){if(await E.confirm(`Delete \u201C${U(W(e))}\u201D? This cannot be undone.`))try{await k.collections.deleteEntry(a,e.id),r.value=r.peek().filter(t=>t.id!==e.id),x.value=Math.max(0,x.peek()-1),g.value=g.peek().filter(t=>t!==e.id),P("#/collections"),E.toast("Entry deleted.",{type:"success"})}catch(t){E.toast(`Not deleted: ${t.message||t}`,{type:"error"})}}async function tt(){const e=[...g.peek()];if(!e.length||!await E.confirm(`Delete ${e.length} entr${e.length===1?"y":"ies"}? This cannot be undone.`))return;L.value=!0;let t=0;const n=[];for(const o of e)try{await k.collections.deleteEntry(a,o),t++}catch(s){n.push(s.message||String(s))}L.value=!1,g.value=[],P("#/collections"),E.toast(n.length?`Deleted ${t}; ${n.length} refused (${n[0]}).`:`Deleted ${t} entr${t===1?"y":"ies"}.`,{type:n.length?"warning":"success",duration:n.length?7e3:4e3}),l()&&await K()}async function nt(){const e=u.peek();if(await E.confirm(`Delete ALL ${x.peek()} entries in \u201C${U(e?.title||a)}\u201D? This cannot be undone.`)){L.value=!0;try{await k.collections.clearEntries(a),r.value=[],x.value=0,g.value=[],P("#/collections"),E.toast("All entries deleted.",{type:"success"})}catch(t){E.toast(`Not cleared: ${t.message||t}`,{type:"error"})}finally{L.value=!1}}}async function at(e){try{const t=await k.collections.createEntry(a,{...e.data||{}});r.value=[t,...r.peek()],x.value=x.peek()+1,P("#/collections"),E.toast("Duplicated - the copy is at the top.",{type:"success"})}catch(t){E.toast(`Not duplicated: ${t.message||t}`,{type:"error"})}}async function st(e,t){const n=e.trigger?.confirmMessage;if(!(n&&!await E.confirm(U(n)))){L.value=!0;try{const o=await k.actions.execute(e.slug,t.id);if(o?.success){const s=o.stepsCompleted??0;E.toast(`${e.trigger?.label||e.title||"Action"} done (${s} step${s===1?"":"s"}).`,{type:"success"}),l()&&await K()}else E.toast(o?.results?.find(s=>!s.success)?.error||"The action failed.",{type:"error"})}catch(o){E.toast(o.message||"The action failed.",{type:"error"})}finally{L.value=!1}}}async function we(e){try{await navigator.clipboard.writeText(e),E.toast("Copied.",{type:"success",duration:1500})}catch{E.toast("Copy failed - your browser refused the clipboard.",{type:"error"})}}function ue(e){const t=g.peek();g.value=t.includes(e)?t.filter(n=>n!==e):[...t,e]}function Se(e,t,n){w.value=[...w.peek(),{field:e.name,label:e.label||e.name,op:t,value:n}],N.value=X}const pe=new Set;let O=null,Ce=!1;function $e(e,t,n){const o=e.close.bind(e);let s=!1,f=!1;e.close=async i=>{if(!s&&i!==!0&&!Ce&&t()){if(f)return;f=!0;const h=await E.confirm(n);if(f=!1,!h)return}return s=!0,o()}}function ne(e,t=()=>{}){pe.add(e),vt(e,()=>{pe.delete(e),t()})}function z(e,t=null){const n=u.peek(),o=te().filter(y=>It(y,e?.data)),s=te().filter(y=>!o.includes(y)),f=Object.fromEntries(o.filter(y=>e?.data&&y.name in e.data).map(y=>[y.name,e.data[y.name]])),i=!!e,h=E.slideover({title:i?`Edit ${U(W(e))}`:"New entry",size:"md",position:"right"}),d=le(`
|
|
8
8
|
<div class="cex-form">
|
|
9
9
|
<div class="cex-fields"></div>
|
|
10
10
|
<small class="cex-hint cex-when-line"></small>
|
|
@@ -15,7 +15,7 @@ import{api as k,apiRequest as ft}from"../api.js";import{addBannerAction as j}fro
|
|
|
15
15
|
<button type="button" class="btn btn-sm btn-ghost" data-act="cancel">Cancel</button>
|
|
16
16
|
<button type="button" class="btn btn-sm btn-primary" data-act="save"><span data-icon="check" data-icon-size="13"></span> <span class="cex-save-text"></span></button>
|
|
17
17
|
</div>
|
|
18
|
-
</div>`);d.querySelector(".cex-save-text").textContent=i?"Save":"Add entry";const
|
|
18
|
+
</div>`);d.querySelector(".cex-save-text").textContent=i?"Save":"Add entry";const b=d.querySelector(".cex-fields");for(const y of o){if(!ve(f[y.name]))continue;const $=document.createElement("div");$.className="cex-files-field";const T=document.createElement("span");T.textContent=y.label||y.name,$.append(T,He(f[y.name])),b.before($)}F.create(Dt(s,n?.columns||2),e?.data||{},{layout:n?.layout||"stacked",columns:n?.columns||2,showSubmitButton:!1}).renderTo(b),s.forEach(y=>{if(y.type!=="date"||!y.name)return;const $=b.querySelector(`[name="${CSS.escape(y.name)}"]`);$&&$.type!=="date"&&($.type="date")}),e?.data&&Je(b,s,e.data),i&&e.meta?.createdAt&&(d.querySelector(".cex-when-line").textContent=`Created ${_(e.meta.createdAt)}${e.meta.updatedAt?`, last changed ${_(e.meta.updatedAt)}`:""}${e.meta.source?` \xB7 via ${e.meta.source}`:""}.`),h.element.appendChild(d);const ut=_e(ie(b,s));t&&Je(b,s,t);const me=()=>_e(ie(b,s))!==ut,pt=d.querySelector(".cex-dirty"),he=()=>{pt.hidden=!me()};b.addEventListener("input",he),b.addEventListener("change",he),he();let ye=!1;async function Re(){if(ye)return;document.activeElement?.dispatchEvent?.(new Event("change",{bubbles:!0}));const y={...i?e.data:{},...ie(b,s),...f};ye=!0;const $=d.querySelector('[data-act="save"]');$.disabled=!0;try{if(i){const T=await k.collections.updateEntry(a,e.id,y);r.value=r.peek().map(Ue=>Ue.id===e.id?T:Ue),E.toast("Entry saved.",{type:"success"})}else{const T=await k.collections.createEntry(a,y);r.value=[T,...r.peek()],x.value=x.peek()+1,P("#/collections"),E.toast("Entry added.",{type:"success"})}try{S.remove?S.remove(B(a)):S.set(B(a),null)}catch{}h.close(!0)}catch(T){E.toast(T.message||"Not saved.",{type:"error"})}finally{ye=!1,$.disabled=!1}}d.querySelector('[data-act="save"]').addEventListener("click",Re),d.querySelector('[data-act="cancel"]').addEventListener("click",()=>h.close()),d.addEventListener("keydown",y=>{(y.ctrlKey||y.metaKey)&&(y.key==="Enter"||y.key==="s")&&(y.preventDefault(),Re())});const Fe={id:e?.id??null,dirty:me,values:()=>wt(ie(b,s),s)};O=Fe,ne(h,()=>{O===Fe&&(O=null)}),$e(h,me,"Discard the changes you have not saved?"),I.scan(d),h.open(),b.querySelector("input, select, textarea")?.focus()}function ot(e){const t=E.slideover({title:U(W(e)),size:"md",position:"right"}),n=le(`
|
|
19
19
|
<div class="cex-form">
|
|
20
20
|
<dl class="cex-detail"></dl>
|
|
21
21
|
<div class="cex-meta"></div>
|
|
@@ -24,7 +24,7 @@ import{api as k,apiRequest as ft}from"../api.js";import{addBannerAction as j}fro
|
|
|
24
24
|
<span class="cex-spacer"></span>
|
|
25
25
|
<button type="button" class="btn btn-sm btn-primary" data-act="edit"><span data-icon="edit" data-icon-size="13"></span> Edit</button>
|
|
26
26
|
</div>
|
|
27
|
-
</div>`),o=n.querySelector(".cex-detail");for(const i of te()){const h=ge(be(i,e.data?.[i.name])),d=document.createElement("dt");d.textContent=i.label||i.name;const
|
|
27
|
+
</div>`),o=n.querySelector(".cex-detail");for(const i of te()){const h=ge(be(i,e.data?.[i.name])),d=document.createElement("dt");d.textContent=i.label||i.name;const b=document.createElement("dd");ve(e.data?.[i.name])?b.appendChild(He(e.data[i.name])):b.textContent=h===""?"-":h,o.append(d,b)}const s=n.querySelector(".cex-meta"),f=i=>{const h=document.createElement("span");h.textContent=i,s.appendChild(h)};f(`Id: ${e.id}`),e.meta?.createdAt&&f(`Created: ${_(e.meta.createdAt)}`),e.meta?.updatedAt&&f(`Changed: ${_(e.meta.updatedAt)}`),e.meta?.source&&f(`Source: ${e.meta.source}`),n.querySelector('[data-act="copy"]').addEventListener("click",()=>we(JSON.stringify(e,null,2))),n.querySelector('[data-act="edit"]').addEventListener("click",()=>{t.close(!0),z(e)}),t.element.appendChild(n),ne(t),I.scan(n),t.open()}function ct(){const e=E.slideover({title:"Import entries",size:"md",position:"right"}),t=le(`
|
|
28
28
|
<div class="cex-form">
|
|
29
29
|
<p class="cex-hint">A JSON array of entries, each with a "data" object of field values - what Export gives you.
|
|
30
30
|
<span data-help="Each entry is added as new, with a new id and today's date (the Data Transfer plugin from the Marketplace keeps ids and dates). Entries are checked like any other save - one that fails, or points a reference at an entry that does not exist, is skipped and reported. Values are stored as given, including fields the collection does not have."></span></p>
|
|
@@ -40,11 +40,11 @@ import{api as k,apiRequest as ft}from"../api.js";import{addBannerAction as j}fro
|
|
|
40
40
|
<button type="button" class="btn btn-sm btn-ghost" data-act="cancel">Cancel</button>
|
|
41
41
|
<button type="button" class="btn btn-sm btn-primary" data-act="import"><span data-icon="upload" data-icon-size="13"></span> Import</button>
|
|
42
42
|
</div>
|
|
43
|
-
</div>`),n=t.querySelector("textarea"),o=t.querySelector(".cex-err"),s=t.querySelector(".cex-ok"),f=t.querySelector('input[type="file"]');t.querySelector('[data-act="file"]').addEventListener("click",()=>f.click()),f.addEventListener("change",async()=>{const h=f.files?.[0];f.value="",h&&(n.value=await h.text())}),t.querySelector('[data-act="cancel"]').addEventListener("click",()=>e.close());let i=!1;t.querySelector('[data-act="import"]').addEventListener("click",async()=>{o.hidden=!0,s.hidden=!0;let h;try{if(h=JSON.parse(n.value),!Array.isArray(h))throw new Error("it must be a JSON array")}catch(
|
|
43
|
+
</div>`),n=t.querySelector("textarea"),o=t.querySelector(".cex-err"),s=t.querySelector(".cex-ok"),f=t.querySelector('input[type="file"]');t.querySelector('[data-act="file"]').addEventListener("click",()=>f.click()),f.addEventListener("change",async()=>{const h=f.files?.[0];f.value="",h&&(n.value=await h.text())}),t.querySelector('[data-act="cancel"]').addEventListener("click",()=>e.close());let i=!1;t.querySelector('[data-act="import"]').addEventListener("click",async()=>{o.hidden=!0,s.hidden=!0;let h;try{if(h=JSON.parse(n.value),!Array.isArray(h))throw new Error("it must be a JSON array")}catch(b){o.textContent=`Not valid: ${b.message}`,o.hidden=!1;return}const d=t.querySelector('[data-act="import"]');d.disabled=!0;try{const b=await k.collections.import(a,h);s.textContent=`Imported ${b.imported}; skipped ${b.skipped}.`,s.hidden=!1,i=!0,P("#/collections"),l()&&await K(),setTimeout(()=>e.close(!0),1200)}catch(b){o.textContent=b.message||"Import failed.",o.hidden=!1}finally{d.disabled=!1}}),e.element.appendChild(t),ne(e),$e(e,()=>!i&&n.value.trim()!=="","Discard the entries you pasted?"),ze(t),I.scan(t),e.open(),n.focus()}function lt(){const e=E.slideover({title:"Export entries",size:"sm",position:"right"}),t=le(`
|
|
44
44
|
<div class="cex-form">
|
|
45
45
|
<p class="cex-hint">Every entry in the collection - not only the ones shown.</p>
|
|
46
46
|
<div class="cex-export">
|
|
47
47
|
<button type="button" class="btn btn-ghost" data-fmt="json"><span data-icon="download" data-icon-size="14"></span> Export as JSON</button>
|
|
48
48
|
<button type="button" class="btn btn-ghost" data-fmt="csv"><span data-icon="download" data-icon-size="14"></span> Export as CSV</button>
|
|
49
49
|
</div>
|
|
50
|
-
</div>`);t.querySelectorAll("[data-fmt]").forEach(n=>n.addEventListener("click",async()=>{const o=n.dataset.fmt;try{const s=await fetch(`/api/collections/${encodeURIComponent(a)}/export?format=${o}`,{headers:{Authorization:`Bearer ${S.get("auth_token")||""}`}});if(!s.ok)throw new Error(`${s.status}`);const f=await s.blob(),i=document.createElement("a");i.href=URL.createObjectURL(f),i.download=`${a}-entries.${o}`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(i.href),1e3),e.close(!0)}catch(s){E.toast(`Export failed (${s.message}).`,{type:"error"})}})),e.element.appendChild(t),ne(e),I.scan(t),e.open()}function it(e,t){const n=J(e.dataset.id);if(!n)return[];const o=t?.event?.target?.closest?.("td[data-col]"),s=o?de.peek()[Number(o.dataset.col)]:null,f=Ee(n.id),i=g.peek().includes(n.id),h=s?
|
|
50
|
+
</div>`);t.querySelectorAll("[data-fmt]").forEach(n=>n.addEventListener("click",async()=>{const o=n.dataset.fmt;try{const s=await fetch(`/api/collections/${encodeURIComponent(a)}/export?format=${o}`,{headers:{Authorization:`Bearer ${S.get("auth_token")||""}`}});if(!s.ok)throw new Error(`${s.status}`);const f=await s.blob(),i=document.createElement("a");i.href=URL.createObjectURL(f),i.download=`${a}-entries.${o}`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(i.href),1e3),e.close(!0)}catch(s){E.toast(`Export failed (${s.message}).`,{type:"error"})}})),e.element.appendChild(t),ne(e),I.scan(t),e.open()}function it(e,t){const n=J(e.dataset.id);if(!n)return[];const o=t?.event?.target?.closest?.("td[data-col]"),s=o?de.peek()[Number(o.dataset.col)]:null,f=Ee(n.id),i=g.peek().includes(n.id),h=s?Ct(s,n.data?.[s.name]):[];return[{header:W(n)},{label:"Edit\u2026",icon:"edit",action:()=>z(n)},{label:"See all of it\u2026",icon:"eye",action:()=>ot(n)},{label:"Duplicate",icon:"copy",action:()=>at(n)},{label:"Copy id",icon:"hash",action:()=>we(n.id)},{label:i?"Deselect":"Select",icon:"check",action:()=>ue(n.id)},...f.length?[{type:"divider"},...f.map(d=>({label:`${d.trigger?.label||d.title||d.slug}\u2026`,icon:d.trigger?.icon||"zap",disabled:L.peek(),action:()=>st(d,n)}))]:[],...s?[{type:"divider"},{label:`Filter by ${s.label||s.name}`,icon:"filter",submenu:[...h.map(d=>({label:d.label,action:()=>Se(s,d.op,d.value)})),{label:`${s.label||s.name} contains\u2026`,action:async()=>{const d=await E.prompt(`Show entries whose ${U(s.label||s.name)} contains`,{inputPlaceholder:"text"});d&&String(d).trim()&&Se(s,"contains",String(d).trim())}}]}]:[],...w.peek().length?[{label:`Clear filters (${w.peek().length})`,icon:"x",action:()=>{w.value=[]}}]:[],{type:"divider"},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>xe(n)}]}const q=m.querySelector(".cex-rows"),G=m.querySelector(".cex-head"),fe=m.querySelector(".cex-chips-list");fe.innerHTML=Tt;const ae=yt(m.querySelector(".dm-loading-slot"),ht.table);try{u.value=await k.collections.get(a)}catch(e){H.value=`Could not load the collection: ${e.message||e}`}if(!l()){ae.done();return}if(!u.peek()&&(await ae.done(),!H.peek())){E.toast("Collection not found.",{type:"error"}),R.navigate("/collections");return}const Ae=de.peek();q.innerHTML=Nt(Ae.length),G.replaceChildren();const se=(e,t)=>{const n=document.createElement("th");return e&&(n.className=e),t&&n.append(t),G.appendChild(n),n},A=document.createElement("input");A.type="checkbox",A.title="Select every entry shown",A.setAttribute("aria-label","Select every entry shown"),se("cex-check",A);const Me=(e,t)=>{const n=document.createElement("button");return n.type="button",n.dataset.sort=e,n.append(document.createTextNode(t),Object.assign(document.createElement("span"),{className:"cex-sort"})),n};Ae.forEach(e=>se("",Me(e.name,e.label||e.name))),se("cex-when",Me("created","Created")),se("cex-tools"),c(M.effect(()=>{const e=Z.value;G.querySelectorAll("[data-sort]").forEach(t=>{t.querySelector(".cex-sort").textContent=t.dataset.sort===e.key?e.dir==="asc"?"\u25B2":"\u25BC":"",t.parentElement.setAttribute("aria-sort",t.dataset.sort===e.key?e.dir==="asc"?"ascending":"descending":"none")})})),c(M.effect(()=>{const e=D.value.map(n=>n.id),t=new Set(g.value);A.checked=e.length>0&&e.every(n=>t.has(n)),A.indeterminate=!A.checked&&e.some(n=>t.has(n))}));const Le=e=>{const t=e.target.closest("[data-sort]");if(!t)return;const n=Z.peek();Z.value={key:t.dataset.sort,dir:n.key===t.dataset.sort&&n.dir==="asc"?"desc":"asc"}};G.addEventListener("click",Le),A.addEventListener("change",()=>{const e=D.peek().map(t=>t.id);g.value=A.checked?[...new Set([...g.peek(),...e])]:g.peek().filter(t=>!e.includes(t))}),c(()=>G.removeEventListener("click",Le));const rt=M.applyBindings(Ye,m,{methods:{clearSelection:()=>{g.value=[]},deleteSelected:()=>tt(),clearAll:()=>nt(),clearFilters:()=>{w.value=[]},showMore:()=>{D.peek().length>N.peek()?N.value=N.peek()+X:Ze()}}});c(()=>rt.dispose()),c(ze(m,{position:"bottom"})),c(M.effect(()=>{re.value,w.value,N.value=X}));const qe=e=>{const t=e.target.closest("button[data-idx]");if(!t)return;const n=Number(t.dataset.idx);w.value=w.peek().filter((o,s)=>s!==n)};fe.addEventListener("click",qe),c(()=>fe.removeEventListener("click",qe));const dt=E.contextMenu(q,{cursor:"glyph",match:".cex-row",inherit:!1,density:"compact",items:(e,t)=>it(e,t)});c(()=>dt?.destroy?.());const Te=e=>{const t=e.target.closest(".cex-row");if(!t)return;if(e.target.closest(".cex-kebab, .cex-run")){je(e.target.closest(".cex-kebab, .cex-run"));return}if(e.target.closest(".cex-check"))return;const n=J(t.dataset.id);n&&z(n)},Ne=e=>{if(!e.target.matches(".cex-sel"))return;const t=e.target.closest(".cex-row");t&&ue(t.dataset.id)},Ie=e=>{const t=e.target.closest(".cex-row");if(!t||e.target!==t)return;const n=J(t.dataset.id);n&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),je(t)):e.key==="Enter"?(e.preventDefault(),z(n)):e.key===" "?(e.preventDefault(),ue(n.id)):e.key==="Delete"&&(e.preventDefault(),xe(n)))};q.addEventListener("click",Te),q.addEventListener("change",Ne),q.addEventListener("keydown",Ie),c(()=>{q.removeEventListener("click",Te),q.removeEventListener("change",Ne),q.removeEventListener("keydown",Ie)});const De=u.peek(),oe=p.get(0).querySelector(".dm-plugin-banner-name")?.querySelector(".dm-plugin-banner-sep");if(oe&&De?.title){for(;oe.nextSibling;)oe.nextSibling.remove();oe.after(document.createTextNode(De.title))}j(p,{id:"entries-back",icon:"arrow-left",title:"All collections",onClick:()=>{location.hash="#/collections"}}),j(p,{id:"entries-fields",icon:"edit-3",title:"Edit its fields and settings",onClick:()=>{location.hash=`#/collections/edit/${encodeURIComponent(a)}`}}),At(a)&&j(p,{id:"entries-form",icon:"layout",title:"Open its form",onClick:()=>{location.hash=`#/forms/edit/${encodeURIComponent(a)}`}}),j(p,{id:"entries-export",icon:"download",title:"Export",onClick:()=>lt()}),j(p,{id:"entries-import",icon:"upload",title:"Import",onClick:()=>ct()}),j(p,{id:"entries-add",icon:"plus",title:"Add entry",onClick:()=>z(null)});const Oe=e=>{O?.dirty()&&(e.preventDefault(),e.returnValue="")};if(window.addEventListener("beforeunload",Oe),c(()=>window.removeEventListener("beforeunload",Oe)),c(()=>{if(O?.dirty())try{S.set(B(a),{id:O.id,values:O.values(),at:new Date().toISOString()})}catch{}Ce=!0,[...pe].forEach(e=>{try{e.close(!0)}catch{}})}),I.scan(m),!u.peek()){Y.value=!1;return}if(await Qe(),!l()){ae.done();return}if(await K({pending:ae}),!l())return;let C=null;try{C=S.get(B(a))}catch{}if(C?.values){try{S.remove?S.remove(B(a)):S.set(B(a),null)}catch{}let e=C.id?J(C.id):null;if(C.id&&!e&&(e=await k.collections.getEntry(a,C.id).catch(()=>null)),!l()||C.id&&!e)return;const t=e?`your changes to \u201C${U(W(e))}\u201D`:"a new entry",n=e?.meta?.updatedAt&&C.at&&e.meta.updatedAt>C.at?" It has been changed since - check before saving.":"";await E.confirm(`You left ${t} unsaved.${n} Pick up where you left off?`)&&l()&&z(e,C.values)}}};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{apiRequest as
|
|
1
|
+
import{apiRequest as O}from"/admin/js/api.js";import{addBannerAction as Q}from"/admin/js/lib/plugin-chrome.js";import{SHAPES as Re,whileLoading as Oe}from"/admin/js/lib/loading.js";import{helpPopovers as me}from"/admin/js/lib/help-popover.js";import{onceClosed as Ie,openMenuAt as pe,sidebarCount as Z,viewLifetime as qe}from"/admin/js/lib/tool-kit.js";import{FILTERS as Ue,answerFields as Fe,answerText as ee,arrangeSubmissions as Pe,fieldText as ue,fileRefsOf as je,safeFileHref as ze,submissionCounts as Be,submissionRow as q,submissionText as Ke}from"/admin/js/lib/form-submissions-arrange.js";import{fmtDateTime as _e}from"../lib/dates.js";import{openEmail as He}from"../lib/mail-compose.js";import{privateThumbnail as We,wirePrivateLink as Je}from"/admin/js/lib/private-files.js";const fe=/^#\/forms\/[^/?#]+\/submissions\/?(\?.*)?$/,te="form-submissions.filter",Ve=`
|
|
2
2
|
<div class="fsx-row" data-id="{{id}}" tabindex="0" data-bind-class="rowCls">
|
|
3
3
|
<span class="fsx-dot" aria-hidden="true"></span>
|
|
4
4
|
<span class="fsx-main"><strong>{{title}}</strong><small>{{meta}}</small></span>
|
|
@@ -8,4 +8,4 @@ import{apiRequest as R}from"/admin/js/api.js";import{addBannerAction as Q}from"/
|
|
|
8
8
|
</span>
|
|
9
9
|
<span class="fsx-when" title="{{whenFull}}">{{when}}</span>
|
|
10
10
|
<button type="button" class="fsx-kebab" aria-label="Actions for this submission" title="Actions">\u22EE</button>
|
|
11
|
-
</div>`,te=a=>String(a??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),j=(a,i,p=`${i}s`)=>`${a} ${a===1?i:p}`,ne=a=>a?Ke(a):"";async function fe(a){try{return await navigator.clipboard.writeText(a),!0}catch{}try{const i=document.createElement("textarea");i.value=a,i.style.cssText="position:fixed;opacity:0;",document.body.appendChild(i),i.select();const p=document.execCommand("copy");return i.remove(),p}catch{return!1}}function he(a,i){const p=je(i);if(!p.length||p.length!==(Array.isArray(i)?i.length:1)){a.textContent=F(i);return}const m=document.createElement("ul");m.className="fsx-files";for(const d of p){const u=document.createElement("li"),c=ze(d.url),y=document.createElement(c?"a":"span");if(c&&(y.href=c,y.target="_blank",y.rel="noopener"),y.textContent=F(d),u.appendChild(y),Number(d.size)>0){const N=document.createElement("small");N.textContent=` ${Number(d.size)<1024?`${d.size} B`:`${Math.round(Number(d.size)/1024)} KB`}`,u.appendChild(N)}m.appendChild(u)}a.appendChild(m)}const x=Ie(ue);export const formSubmissionsView={templateUrl:"/admin/js/templates/form-submissions.html",async onMount(a){x.reset();const i=a.get(0).querySelector(".fsx")||a.get(0),p=()=>ue.test(location.hash)&&i.isConnected,m=decodeURIComponent((location.hash.match(/^#\/forms\/([^/?#]+)\/submissions/)||[])[1]||"");if(!m){E.toast("No form selected.",{type:"error"});return}const d=encodeURIComponent(m),u=M.observable(null),c=M.observable([]),y=M.observable(!0),N=M.observable("");let se="inbox";try{se=qe.includes(S.get(ee))?S.get(ee):"inbox"}catch{}const v=M.observable(se),oe=M.observable(""),z=M.observable(""),B=M.observable("");x.add(M.effect(()=>{const e=v.value;try{S.set(ee,e)}catch{}}));const T=M.computed(()=>Ue(u.value||{})),P=M.observable([]);x.add(M.effect(()=>{const e=Date.now(),t=Fe(c.value,{filter:v.value,query:oe.value,from:z.value,to:B.value,now:e}),n=T.value;P.value=t.map(r=>{const s=O(r,n,e);return{...s,when:s.at?D(s.at).fromNow():"",whenFull:ne(s.at)}})}));const be=M.computed(()=>Be(c.value)),ye=M.computed(()=>{const e=P.value.length,t=c.value.length;return t?e===t?j(t,"submission"):`${e} of ${j(t,"submission")}`:""}),Ee=M.computed(()=>c.value.length?v.value==="spam"?"Nothing marked as spam.":"No submissions match.":"No submissions yet - they appear here as people send the form."),we=M.computed(()=>u.value?`What people sent through "${u.value.title||m}".`:"What people sent through this form."),q=e=>c.peek().find(t=>String(t.id)===String(e));async function ge(){try{const[e,t]=await Re(i.querySelector(".dm-loading-slot"),Promise.all([R(`/forms/${d}`),R(`/forms/${d}/submissions`)]),Le.rows);if(!p())return;u.value=e||null,c.value=Array.isArray(t)?t:[],N.value="",xe(e?.title||m)}catch(e){if(!p())return;N.value=`Could not load the submissions: ${e.message||e}`}finally{y.value=!1}}function xe(e){const t=a.get(0).querySelector(".dm-plugin-banner-name"),n=t?.lastChild;n&&n.nodeType===Node.TEXT_NODE&&t.querySelector(".dm-plugin-banner-sep")&&(n.textContent=`${e} submissions`),document.title=`${e} - Submissions - Domma CMS`}const K=(e,t)=>ce(e.id,()=>ve(e,t)),_=e=>ce(e.id,()=>Ce(e));async function ve(e,t){try{const n=await R(`/forms/${d}/submissions/${encodeURIComponent(e.id)}/spam`,{method:"POST",body:JSON.stringify({spam:t})});return c.value=c.peek().map(r=>String(r.id)===String(e.id)?{...r,data:n?.entry?.data||{...r.data,spam:t}}:r),E.toast(t?"Marked as spam - it is under Spam now.":"Back in the inbox.",{type:"success"}),Z("#/forms"),!0}catch(n){return E.toast(`Not changed: ${n.message||n}`,{type:"error"}),!1}}async function Ce(e){const t=O(e,T.peek()).title;if(!await E.confirm(`Delete the submission from "${te(t)}"? This cannot be undone.`,{confirmText:"Delete"}))return!1;try{return await R(`/forms/${d}/submissions/${encodeURIComponent(e.id)}`,{method:"DELETE"}),c.value=c.peek().filter(n=>String(n.id)!==String(e.id)),E.toast("Submission deleted.",{type:"success"}),Z("#/forms"),!0}catch(n){return E.toast(`Not deleted: ${n.message||n}`,{type:"error"}),!1}}let H=!1;async function ke(){if(!H){H=!0;try{await Se()}finally{H=!1}}}async function Se(){const e=c.peek().length;if(!e){E.toast("There are no submissions to clear.",{type:"info"});return}const t=u.peek()?.title||m;if(await E.confirm(`Delete all ${j(e,"submission")} to "${te(t)}", spam included? This cannot be undone - Export them first if you may need them.`))try{await R(`/forms/${d}/submissions`,{method:"DELETE"}),c.value=[],E.toast("All submissions cleared.",{type:"success"}),Z("#/forms")}catch(n){E.toast(`Not cleared: ${n.message||n}`,{type:"error"})}}const ae=async e=>{const t=Pe(e,T.peek(),{formTitle:u.peek()?.title||m,when:ne(e.meta?.createdAt)});E.toast(await fe(t)?"Copied.":"Copy failed.",{type:"info"})},$e=async e=>{E.toast(await fe(e)?`Copied ${e}.`:"Copy failed.",{type:"info"})},ie=e=>{const t=O(e,T.peek()).email;t&&_e({to:[t],subject:`Re: ${u.peek()?.title||m}`})};async function Ne(e,t){try{const n=await fetch(`/api/forms/${d}/submissions/${e}`,{headers:{Authorization:`Bearer ${S.get("auth_token")||""}`}});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);const r=await n.blob(),s=document.createElement("a");return s.href=URL.createObjectURL(r),s.download=t,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(s.href),1e3),!0}catch(n){return E.toast(`Export failed: ${n.message||n}`,{type:"error"}),!1}}const W=new Set,U=new Set;function re(e,t,n,r="md"){if(U.has(e))return null;U.add(e);let s;try{s=E.slideover({title:te(t),size:r,position:"right"}),s.element.appendChild(n);const h=me(n);return W.add(s),Oe(s,()=>{U.delete(e),W.delete(s),h()}),I.scan(n),s.open(),s}catch(h){U.delete(e);try{s?.destroy?.(),s?.element?.remove()}catch{}return E.toast(`Could not open it: ${h.message||h}`,{type:"error"}),null}}const J=new Set;async function ce(e,t){const n=String(e);if(J.has(n))return!1;J.add(n);try{return await t()}finally{J.delete(n)}}function Te(){const e=c.peek().length,t=document.createElement("div");t.className="fsx-export";const n=document.createElement("p");n.className="fsx-note",n.textContent=e?`All ${j(e,"submission")}, spam included.`:"There are no submissions yet - the file will be empty.",t.appendChild(n);let r;const s=(h,C,G,X,A)=>{const l=document.createElement("button");l.type="button",l.className="btn btn-ghost";const k=document.createElement("span");k.setAttribute("data-icon",C),l.append(k,document.createTextNode(` ${h}`));const L=document.createElement("span");L.setAttribute("data-help",A),l.addEventListener("click",async()=>{if(!l.disabled){l.disabled=!0;try{await Ne(G,`${m}-submissions.${X}`)&&r?.close()}finally{l.disabled=!1}}});const o=document.createElement("div");o.append(l,L),t.appendChild(o)};s("Export as CSV","file-text","export","csv","One row per submission, one column per question - opens in Excel, Numbers or Google Sheets."),s("Export as JSON","code","export/json","json","Every submission exactly as stored, with its id and dates - for importing elsewhere or keeping a full copy."),r=re("export","Export submissions",t,"sm")}function V(e){if(!e)return;const t=T.peek(),n=O(e,t),r=document.createElement("div");r.className="fsx-detail";const s=document.createElement("div");s.className="fsx-facts";const h=o=>{const f=document.createElement("span");f.textContent=o,s.appendChild(f)};e.meta?.createdAt&&h(`Sent ${ne(e.meta.createdAt)} (${D(e.meta.createdAt).fromNow()})`),e.meta?.ip&&h(`IP ${e.meta.ip}`),n.spam&&h("Marked as spam"),r.appendChild(s);const C=document.createElement("dl");C.className="fsx-answers";const G=t.filter(o=>F(e.data?.[o.name])!=="");for(const o of G){const f=document.createElement("div");f.className="fsx-answer";const g=document.createElement("dt");g.textContent=o.label;const $=document.createElement("dd");he($,e.data[o.name]),f.append(g,$),C.appendChild(f)}const X=new Set(t.map(o=>o.name));for(const[o,f]of Object.entries(e.data||{})){if(X.has(o)||o==="spam"||F(f)==="")continue;const g=document.createElement("div");g.className="fsx-answer";const $=document.createElement("dt");$.textContent=`${o} (no longer on the form)`;const b=document.createElement("dd");he(b,f),g.append($,b),C.appendChild(g)}if(C.children.length)r.appendChild(C);else{const o=document.createElement("p");o.className="fsx-note",o.textContent="Nothing was filled in.",r.appendChild(o)}const A=document.createElement("div");A.className="fsx-actions";const l=(o,f,g,$)=>{const b=document.createElement("button");b.type="button",b.className=`btn btn-sm ${g}`;const Y=document.createElement("span");return Y.setAttribute("data-icon",f),Y.setAttribute("data-icon-size","13"),b.append(Y,document.createTextNode(` ${o}`)),b.addEventListener("click",$),A.appendChild(b),b};let k;l("Copy","copy","btn-ghost",()=>ae(e)),n.email&&l("Email them","mail","btn-ghost",()=>ie(e)),l(n.spam?"Not spam":"Mark as spam",n.spam?"inbox":"alert-triangle","btn-ghost",async()=>{await K(e,!n.spam)&&k?.close()});const L=document.createElement("span");L.className="fsx-spacer",A.appendChild(L),l("Delete","trash","btn-ghost text-danger",async()=>{await _(e)&&k?.close()}),l("Close","x","btn-ghost",()=>k?.close()),r.appendChild(A),k=re(`sub:${e.id}`,n.title,r)}function Me(e){const t=q(e);if(!t)return[];const n=O(t,T.peek());return[{header:n.title},{label:"Open\u2026",icon:"eye",action:()=>V(t)},{label:"Copy submission",icon:"copy",action:()=>ae(t)},{type:"divider"},{label:n.email?`Copy ${n.email}`:"Copy email",icon:"at-sign",disabled:!n.email,action:()=>$e(n.email)},{label:"Email them\u2026",icon:"mail",disabled:!n.email,action:()=>ie(t)},{type:"divider"},n.spam?{label:"Not spam - back to the inbox",icon:"inbox",action:()=>K(t,!1)}:{label:"Mark as spam",icon:"alert-triangle",action:()=>K(t,!0)},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>_(t)}]}const w=i.querySelector(".fsx-list");w.innerHTML=He;const Ae=M.applyBindings({loading:y,loadError:N,filter:v,query:oe,from:z,to:B,rows:P,counts:be,summary:ye,emptyText:Ee,intro:we},i,{methods:{showInbox:()=>{v.value="inbox"},showNew:()=>{v.value="new"},showSpam:()=>{v.value="spam"},clearDates:()=>{z.value="",B.value=""}}});x.add(()=>Ae.dispose()),x.add(me(i,{position:"bottom"}));const De=E.contextMenu(w,{cursor:"glyph",match:".fsx-row",inherit:!1,density:"compact",items:e=>Me(e.dataset.id)});x.add(()=>De?.destroy?.());const le=e=>{const t=e.target.closest(".fsx-row");if(!t)return;const n=e.target.closest(".fsx-kebab");if(n){pe(n);return}V(q(t.dataset.id))},de=e=>{const t=e.target.closest(".fsx-row");if(!(!t||e.target!==t)){if(e.key==="F10"&&e.shiftKey)e.preventDefault(),pe(t);else if(e.key==="Enter")V(q(t.dataset.id));else if(e.key==="Delete"){e.preventDefault();const n=q(t.dataset.id);n&&_(n)}}};w.addEventListener("click",le),w.addEventListener("keydown",de),x.add(()=>{w.removeEventListener("click",le),w.removeEventListener("keydown",de)}),Q(a,{id:"form-submissions-back",icon:"arrow-left",title:"All forms",onClick:()=>{location.hash="#/forms"}}),Q(a,{id:"form-submissions-export",icon:"download",title:"Export (CSV or JSON)",onClick:Te}),Q(a,{id:"form-submissions-clear",icon:"trash",title:"Clear all submissions",onClick:ke}),x.add(()=>{[...W].forEach(e=>{try{e.close()}catch{}})}),I.scan(i),await ge(),p()&&requestAnimationFrame(()=>{w.isConnected&&I.scan(w)})}};
|
|
11
|
+
</div>`,ne=i=>String(i??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),P=(i,a,u=`${a}s`)=>`${i} ${i===1?a:u}`,se=i=>i?_e(i):"";async function he(i){try{return await navigator.clipboard.writeText(i),!0}catch{}try{const a=document.createElement("textarea");a.value=i,a.style.cssText="position:fixed;opacity:0;",document.body.appendChild(a),a.select();const u=document.execCommand("copy");return a.remove(),u}catch{return!1}}function be(i,a,u=null){const m=je(a);if(!m.length||m.length!==(Array.isArray(a)?a.length:1)){i.textContent=u?ue(u,a):ee(a);return}const f=document.createElement("ul");f.className="fsx-files";for(const l of m){const c=document.createElement("li"),T=ze(l.url),h=document.createElement(T?"a":"span");if(T&&(h.href=T,h.target="_blank",h.rel="noopener",Je(h,l)),h.textContent=ee(l),c.appendChild(h),Number(l.size)>0){const b=document.createElement("small");b.textContent=` ${Number(l.size)<1024?`${l.size} B`:`${Math.round(Number(l.size)/1024)} KB`}`,c.appendChild(b)}const L=We(l);L&&c.appendChild(L),f.appendChild(c)}i.appendChild(f)}const v=qe(fe);export const formSubmissionsView={templateUrl:"/admin/js/templates/form-submissions.html",async onMount(i){v.reset();const a=i.get(0).querySelector(".fsx")||i.get(0),u=()=>fe.test(location.hash)&&a.isConnected,m=decodeURIComponent((location.hash.match(/^#\/forms\/([^/?#]+)\/submissions/)||[])[1]||"");if(!m){E.toast("No form selected.",{type:"error"});return}const f=encodeURIComponent(m),l=M.observable(null),c=M.observable([]),T=M.observable(!0),h=M.observable("");let L="inbox";try{L=Ue.includes(S.get(te))?S.get(te):"inbox"}catch{}const b=M.observable(L),oe=M.observable(""),j=M.observable(""),z=M.observable("");v.add(M.effect(()=>{const e=b.value;try{S.set(te,e)}catch{}}));const C=M.computed(()=>Fe(l.value||{})),B=M.observable([]);v.add(M.effect(()=>{const e=Date.now(),t=Pe(c.value,{filter:b.value,query:oe.value,from:j.value,to:z.value,now:e,fields:C.value}),n=C.value;B.value=t.map(r=>{const s=q(r,n,e);return{...s,when:s.at?D(s.at).fromNow():"",whenFull:se(s.at)}})}));const ye=M.computed(()=>Be(c.value)),Ee=M.computed(()=>{const e=B.value.length,t=c.value.length;return t?e===t?P(t,"submission"):`${e} of ${P(t,"submission")}`:""}),we=M.computed(()=>c.value.length?b.value==="spam"?"Nothing marked as spam.":"No submissions match.":"No submissions yet - they appear here as people send the form."),ge=M.computed(()=>l.value?`What people sent through "${l.value.title||m}".`:"What people sent through this form."),U=e=>c.peek().find(t=>String(t.id)===String(e));async function xe(){try{const[e,t]=await Oe(a.querySelector(".dm-loading-slot"),Promise.all([O(`/forms/${f}`),O(`/forms/${f}/submissions`)]),Re.rows);if(!u())return;l.value=e||null,c.value=Array.isArray(t)?t:[],h.value="",ve(e?.title||m)}catch(e){if(!u())return;h.value=`Could not load the submissions: ${e.message||e}`}finally{T.value=!1}}function ve(e){const t=i.get(0).querySelector(".dm-plugin-banner-name"),n=t?.lastChild;n&&n.nodeType===Node.TEXT_NODE&&t.querySelector(".dm-plugin-banner-sep")&&(n.textContent=`${e} submissions`),document.title=`${e} - Submissions - Domma CMS`}const K=(e,t)=>ce(e.id,()=>Ce(e,t)),_=e=>ce(e.id,()=>ke(e));async function Ce(e,t){try{const n=await O(`/forms/${f}/submissions/${encodeURIComponent(e.id)}/spam`,{method:"POST",body:JSON.stringify({spam:t})});return c.value=c.peek().map(r=>String(r.id)===String(e.id)?{...r,data:n?.entry?.data||{...r.data,spam:t}}:r),E.toast(t?"Marked as spam - it is under Spam now.":"Back in the inbox.",{type:"success"}),Z("#/forms"),!0}catch(n){return E.toast(`Not changed: ${n.message||n}`,{type:"error"}),!1}}async function ke(e){const t=q(e,C.peek()).title;if(!await E.confirm(`Delete the submission from "${ne(t)}"? This cannot be undone.`,{confirmText:"Delete"}))return!1;try{return await O(`/forms/${f}/submissions/${encodeURIComponent(e.id)}`,{method:"DELETE"}),c.value=c.peek().filter(n=>String(n.id)!==String(e.id)),E.toast("Submission deleted.",{type:"success"}),Z("#/forms"),!0}catch(n){return E.toast(`Not deleted: ${n.message||n}`,{type:"error"}),!1}}let H=!1;async function Se(){if(!H){H=!0;try{await $e()}finally{H=!1}}}async function $e(){const e=c.peek().length;if(!e){E.toast("There are no submissions to clear.",{type:"info"});return}const t=l.peek()?.title||m;if(await E.confirm(`Delete all ${P(e,"submission")} to "${ne(t)}", spam included? This cannot be undone - Export them first if you may need them.`))try{await O(`/forms/${f}/submissions`,{method:"DELETE"}),c.value=[],E.toast("All submissions cleared.",{type:"success"}),Z("#/forms")}catch(n){E.toast(`Not cleared: ${n.message||n}`,{type:"error"})}}const ae=async e=>{const t=Ke(e,C.peek(),{formTitle:l.peek()?.title||m,when:se(e.meta?.createdAt)});E.toast(await he(t)?"Copied.":"Copy failed.",{type:"info"})},Ne=async e=>{E.toast(await he(e)?`Copied ${e}.`:"Copy failed.",{type:"info"})},ie=e=>{const t=q(e,C.peek()).email;t&&He({to:[t],subject:`Re: ${l.peek()?.title||m}`})};async function Te(e,t){try{const n=await fetch(`/api/forms/${f}/submissions/${e}`,{headers:{Authorization:`Bearer ${S.get("auth_token")||""}`}});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);const r=await n.blob(),s=document.createElement("a");return s.href=URL.createObjectURL(r),s.download=t,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(s.href),1e3),!0}catch(n){return E.toast(`Export failed: ${n.message||n}`,{type:"error"}),!1}}const W=new Set,F=new Set;function re(e,t,n,r="md"){if(F.has(e))return null;F.add(e);let s;try{s=E.slideover({title:ne(t),size:r,position:"right"}),s.element.appendChild(n);const y=me(n);return W.add(s),Ie(s,()=>{F.delete(e),W.delete(s),y()}),I.scan(n),s.open(),s}catch(y){F.delete(e);try{s?.destroy?.(),s?.element?.remove()}catch{}return E.toast(`Could not open it: ${y.message||y}`,{type:"error"}),null}}const J=new Set;async function ce(e,t){const n=String(e);if(J.has(n))return!1;J.add(n);try{return await t()}finally{J.delete(n)}}function Me(){const e=c.peek().length,t=document.createElement("div");t.className="fsx-export";const n=document.createElement("p");n.className="fsx-note",n.textContent=e?`All ${P(e,"submission")}, spam included.`:"There are no submissions yet - the file will be empty.",t.appendChild(n);let r;const s=(y,k,G,X,A)=>{const d=document.createElement("button");d.type="button",d.className="btn btn-ghost";const $=document.createElement("span");$.setAttribute("data-icon",k),d.append($,document.createTextNode(` ${y}`));const R=document.createElement("span");R.setAttribute("data-help",A),d.addEventListener("click",async()=>{if(!d.disabled){d.disabled=!0;try{await Te(G,`${m}-submissions.${X}`)&&r?.close()}finally{d.disabled=!1}}});const o=document.createElement("div");o.append(d,R),t.appendChild(o)};s("Export as CSV","file-text","export","csv","One row per submission, one column per question - opens in Excel, Numbers or Google Sheets."),s("Export as JSON","code","export/json","json","Every submission exactly as stored, with its id and dates - for importing elsewhere or keeping a full copy."),r=re("export","Export submissions",t,"sm")}function V(e){if(!e)return;const t=C.peek(),n=q(e,t),r=document.createElement("div");r.className="fsx-detail";const s=document.createElement("div");s.className="fsx-facts";const y=o=>{const p=document.createElement("span");p.textContent=o,s.appendChild(p)};e.meta?.createdAt&&y(`Sent ${se(e.meta.createdAt)} (${D(e.meta.createdAt).fromNow()})`),e.meta?.ip&&y(`IP ${e.meta.ip}`),n.spam&&y("Marked as spam"),r.appendChild(s);const k=document.createElement("dl");k.className="fsx-answers";const G=t.filter(o=>ue(o,e.data?.[o.name])!=="");for(const o of G){const p=document.createElement("div");p.className="fsx-answer";const x=document.createElement("dt");x.textContent=o.label;const N=document.createElement("dd");be(N,e.data[o.name],o),p.append(x,N),k.appendChild(p)}const X=new Set(t.map(o=>o.name));for(const[o,p]of Object.entries(e.data||{})){if(X.has(o)||o==="spam"||ee(p)==="")continue;const x=document.createElement("div");x.className="fsx-answer";const N=document.createElement("dt");N.textContent=`${o} (no longer on the form)`;const w=document.createElement("dd");be(w,p),x.append(N,w),k.appendChild(x)}if(k.children.length)r.appendChild(k);else{const o=document.createElement("p");o.className="fsx-note",o.textContent="Nothing was filled in.",r.appendChild(o)}const A=document.createElement("div");A.className="fsx-actions";const d=(o,p,x,N)=>{const w=document.createElement("button");w.type="button",w.className=`btn btn-sm ${x}`;const Y=document.createElement("span");return Y.setAttribute("data-icon",p),Y.setAttribute("data-icon-size","13"),w.append(Y,document.createTextNode(` ${o}`)),w.addEventListener("click",N),A.appendChild(w),w};let $;d("Copy","copy","btn-ghost",()=>ae(e)),n.email&&d("Email them","mail","btn-ghost",()=>ie(e)),d(n.spam?"Not spam":"Mark as spam",n.spam?"inbox":"alert-triangle","btn-ghost",async()=>{await K(e,!n.spam)&&$?.close()});const R=document.createElement("span");R.className="fsx-spacer",A.appendChild(R),d("Delete","trash","btn-ghost text-danger",async()=>{await _(e)&&$?.close()}),d("Close","x","btn-ghost",()=>$?.close()),r.appendChild(A),$=re(`sub:${e.id}`,n.title,r)}function Ae(e){const t=U(e);if(!t)return[];const n=q(t,C.peek());return[{header:n.title},{label:"Open\u2026",icon:"eye",action:()=>V(t)},{label:"Copy submission",icon:"copy",action:()=>ae(t)},{type:"divider"},{label:n.email?`Copy ${n.email}`:"Copy email",icon:"at-sign",disabled:!n.email,action:()=>Ne(n.email)},{label:"Email them\u2026",icon:"mail",disabled:!n.email,action:()=>ie(t)},{type:"divider"},n.spam?{label:"Not spam - back to the inbox",icon:"inbox",action:()=>K(t,!1)}:{label:"Mark as spam",icon:"alert-triangle",action:()=>K(t,!0)},{label:"Delete\u2026",icon:"trash",danger:!0,action:()=>_(t)}]}const g=a.querySelector(".fsx-list");g.innerHTML=Ve;const Le=M.applyBindings({loading:T,loadError:h,filter:b,query:oe,from:j,to:z,rows:B,counts:ye,summary:Ee,emptyText:we,intro:ge},a,{methods:{showInbox:()=>{b.value="inbox"},showNew:()=>{b.value="new"},showSpam:()=>{b.value="spam"},clearDates:()=>{j.value="",z.value=""}}});v.add(()=>Le.dispose()),v.add(me(a,{position:"bottom"}));const De=E.contextMenu(g,{cursor:"glyph",match:".fsx-row",inherit:!1,density:"compact",items:e=>Ae(e.dataset.id)});v.add(()=>De?.destroy?.());const le=e=>{const t=e.target.closest(".fsx-row");if(!t)return;const n=e.target.closest(".fsx-kebab");if(n){pe(n);return}V(U(t.dataset.id))},de=e=>{const t=e.target.closest(".fsx-row");if(!(!t||e.target!==t)){if(e.key==="F10"&&e.shiftKey)e.preventDefault(),pe(t);else if(e.key==="Enter")V(U(t.dataset.id));else if(e.key==="Delete"){e.preventDefault();const n=U(t.dataset.id);n&&_(n)}}};g.addEventListener("click",le),g.addEventListener("keydown",de),v.add(()=>{g.removeEventListener("click",le),g.removeEventListener("keydown",de)}),Q(i,{id:"form-submissions-back",icon:"arrow-left",title:"All forms",onClick:()=>{location.hash="#/forms"}}),Q(i,{id:"form-submissions-export",icon:"download",title:"Export (CSV or JSON)",onClick:Me}),Q(i,{id:"form-submissions-clear",icon:"trash",title:"Clear all submissions",onClick:Se}),v.add(()=>{[...W].forEach(e=>{try{e.close()}catch{}})}),I.scan(a),await xe(),u()&&requestAnimationFrame(()=>{g.isConnected&&I.scan(g)})}};
|
package/docs/DommaFeatures.md
CHANGED
|
@@ -30,6 +30,8 @@ Code was treated as the truth. Where docs disagree with it, the disagreement is
|
|
|
30
30
|
| Plugin | Tier | Version | In one line |
|
|
31
31
|
|---|---|---|---|
|
|
32
32
|
| `advent-calendar` | paid (giftable) | 1.0.0 | A calendar of 1 to 31 doors, one opening each day: an advent calendar or a countdown to a launch or event. Behind each door a message, picture, link and a code (shared, unique from a list, or a single-use Shop code), never sent before its day; codes limited per visitor and per connection. |
|
|
33
|
+
| `ai-site-builder` | paid (hosted sites only, in the Pro plan) | 0.6.2 | Site Builder - "Dot": build and change a site by asking in plain words, with the site's own pages, blocks, menus, forms, collections and theme; every change a draft to preview, publish or undo. Never on self-hosted sites. |
|
|
34
|
+
| `ai-tool-builder` | paid (hosted sites only, £59 a month) | 0.1.4 | Tool Builder - "Daisy": describe a Tool and it is written, checked on a test copy of a site, shown as a picture, then reviewed by a person at Domma before it reaches the site. Never a copy of a Tool Domma has. Never on self-hosted sites. |
|
|
33
35
|
| `anagram` | paid (giftable) | 1.0.0 | Word puzzles against the clock: unscramble the letters (any other real word of the same letters counts too) or climb a word ladder one letter at a time. Random rounds each go, or a daily set everyone shares. Skip and hints for a time penalty, leaderboards, personal best, Share, export and import. |
|
|
34
36
|
| `analytics-pro` | paid | 2.3.4 | Visitors, visits and page views: where visitors came from (sources, campaigns, channels, country and city by GeoIP), IP addresses, each visit's pages in order, devices and browsers, busiest times and a live view. Cookieless. Several display styles, CSV/JSON export and a printable report. |
|
|
35
37
|
| `backup-pro` | paid | 0.1.4 | A site's own view of the backups Domma keeps of it: how they stand, every backup, Back up now, restore of the whole site or chosen collections, pages or media after a safety backup, downloads without secrets, and Activity - every backup, restore and change, including Domma's own, named and never hidden. Needs a site run by Domma. |
|
|
@@ -544,10 +546,13 @@ Examples of where they appear: `projects` uses `boolean`, `notifications` uses `
|
|
|
544
546
|
- **File uploads**. A form `file` field switches the submission to `multipart/form-data`.
|
|
545
547
|
- The server checks each file against the field's `file.accept` (MIME list, wildcards such as `image/*` allowed) and `file.maxSize` (default 5 MB).
|
|
546
548
|
- `multiple: true` takes several files, up to `file.maxFiles` (default 5, at most 20; the form editor's Several files / Most files). One bad file or one too many refuses the submission.
|
|
547
|
-
- The filename is cleaned and given a uuid prefix, and the file is saved
|
|
548
|
-
- The entry stores `{url, name, size, mime}`, or a list of them for a `multiple` field.
|
|
549
|
-
-
|
|
550
|
-
|
|
549
|
+
- The filename is cleaned and given a uuid prefix, and the file is saved - only after every other check has passed - to a **private store**, `content/form-uploads/<form slug>/<upload id>/<name>` (one uuid folder per submission; never `content/media/`, so not public and not in the Media library). The store writes its own `*` `.gitignore`, so a site repo never commits a visitor's file. Every path goes through `fileIn` (`server/services/formUploads.js`).
|
|
550
|
+
- The entry stores `{url, name, size, mime}`, or a list of them for a `multiple` field. `url` is `/api/forms/<slug>/uploads/<upload id>/<name>`.
|
|
551
|
+
- **Served only to a signed-in user** with `collections` read (the inbox's permission, checked by `requirePermission`) who can see the form (project scope), and only while a submission of that form links to the file. Credentials: Bearer, or the `dm_session` cookie for a browser following a link (a side-effect-free read, the one kind of route that cookie may serve). PNG, JPEG, GIF, WebP and PDF go inline; everything else is an `attachment` as `application/octet-stream`; always `nosniff`, `Cache-Control: private, no-store` and a CSP with `default-src 'none'` and `frame-ancestors 'none'` (plus `sandbox` for all but PDF). An anonymous browser gets a "Sign in to view this file" page.
|
|
552
|
+
- The admin's submission panel and collection entries open a file with the Bearer token (`admin/js/lib/private-files.js`) and show image thumbnails. The notification email links to the route and says sign-in is needed; files are never attached.
|
|
553
|
+
- Deleting a submission (or Clear all) deletes its files in the private store, unless another entry still links to one (`submissionUploads()` / `removeSubmissionUploads()`). Nothing under `/media/` is ever deleted this way: an old reference is the migration's to move, and a planted one may be a file a page uses.
|
|
554
|
+
- **Migration** (`server/services/form-uploads-migration.js`, once per site, marker `form-uploads-private` in `content/.migrations.json`): files that existing submissions (entries with `meta.source: form:<slug>` only) reference as `/media/<8 hex>-<name>` in one of the form's file fields - regular files only, never a link or folder (`lstat`) - are copied into the store and the references rewritten; the Media copy is then removed unless the name appears anywhere else in `content/` or `config/` text (a page, block, other collection), in which case it is left (copied, not moved). Never overwrites; a missing file keeps its reference; progress in `content/form-uploads/.migration.json`; logs counts.
|
|
555
|
+
Where: `parseMultipartForm()` / `saveFormFiles()` in `server/routes/api/forms.js`; `server/services/formUploads.js`; `docs/configuration.md`. Since: 0.20.0; private since [Unreleased].
|
|
551
556
|
|
|
552
557
|
### Entries screen
|
|
553
558
|
|
|
@@ -893,7 +898,7 @@ Where: `server/services/presetCollections.js` (`PRESETS`, `seedAll()`), `server/
|
|
|
893
898
|
Settings: `settings.honeypot`, `settings.rateLimitPerMinute`.
|
|
894
899
|
- **What happens on submit**:
|
|
895
900
|
- **Store**: to the form's own collection, or to another collection chosen in `actions.collection`. Several forms can share one collection, and each submission is stamped `source: form:<slug>`.
|
|
896
|
-
- **Email notification**: to recipients with a subject prefix, using the site's SMTP settings. **Forms > Test email** sends a test message.
|
|
901
|
+
- **Email notification**: to recipients with a subject prefix, using the site's SMTP settings, with each answer as its label (as the submissions view shows it), escaped. **Forms > Test email** sends a test message.
|
|
897
902
|
- **Webhook**: POST (or another method) of `{form, data}`.
|
|
898
903
|
- **CMS Action**: `settings.actionSlug`, which receives the signed-in submitter as `{{user.*}}`.
|
|
899
904
|
- **Success message or redirect**: `successRedirect` supports `{{entryId}}`.
|
|
@@ -904,7 +909,7 @@ Where: `server/services/presetCollections.js` (`PRESETS`, `seedAll()`), `server/
|
|
|
904
909
|
- **Submissions view**.
|
|
905
910
|
- One row per submission, named after the sender.
|
|
906
911
|
- Filters: Inbox, New this week, Spam, plus search across every answer and a date range.
|
|
907
|
-
- Click a row to see everything that was sent.
|
|
912
|
+
- Click a row to see everything that was sent. Answers read as the visitor saw them: an option's label (dropdown, radio, checkbox group, chooser), Yes/No for a single checkbox, dd/mm/yyyy dates, HH:mm times, file names. A value the form no longer offers shows as stored. The notification email shows the same (`answerLabel()` in `public/js/form-answers.mjs`); CSV and JSON exports keep the stored values.
|
|
908
913
|
- Right-click to copy it, copy or email the sender, mark it as spam or delete it.
|
|
909
914
|
- Banner: Export (CSV or JSON), Clear all.
|
|
910
915
|
- The Forms list badge shows submissions in the last 7 days.
|
|
@@ -1724,6 +1729,37 @@ From `dcms-marketplace/docs/security-plan.md` (2026-09-26; all phases built and
|
|
|
1724
1729
|
|
|
1725
1730
|
## Marketplace Plugins
|
|
1726
1731
|
|
|
1732
|
+
### Site Builder (`ai-site-builder`) - "Dot"
|
|
1733
|
+
|
|
1734
|
+
Tier: paid (closed source), **hosted sites only** (`hostedOnly: true`; a self-hosted site refuses to install or load it) · Included in the **Pro** plan, not sold alone · Version: 0.6.2 · Permission: `ai-builder`
|
|
1735
|
+
|
|
1736
|
+
The AI in Site Builder is called **Dot** ("Dot, your Site Builder"). A site owner asks for changes in plain words and Dot makes them with the site's own content types. Dot says plainly that it is AI, never claims to be a person, and only works on the website: general questions, emails and other writing are politely turned down, and nothing in the conversation can change those rules.
|
|
1737
|
+
|
|
1738
|
+
**Features**
|
|
1739
|
+
- Plain-word requests: new pages, rewrites, a warmer look, menu changes, forms, collections, blocks, blog posts and products (where the site has them). One short question when something that matters is unclear.
|
|
1740
|
+
- Drafts first: every change waits under **Changes** to preview, publish or undo; Dot never claims something is live.
|
|
1741
|
+
- Build a whole site: a few questions (business, audience, feel) and a plan shown before anything is built.
|
|
1742
|
+
- Conversations with their own changes, saved prompts, site memory and references; a monthly allowance of words (25,000 on Pro), shown on the screen.
|
|
1743
|
+
- Missing Tools: Dot says which Tool would do it rather than faking it with pages, and points to Tool Builder for Tools Domma does not have.
|
|
1744
|
+
- Works through the person's own permissions: what they may not edit, Dot may not edit for them.
|
|
1745
|
+
|
|
1746
|
+
**Where:** Admin sidebar **Site Builder** (`#/plugins/ai-site-builder`); the model runs on the Manager (`site-manager/services/aiBuilder.js`, system prompt in `aiBuilderTools.js`). Guide: Documentation > Tools > Site Builder; manual chapter `/spaces/domma-cms-user-manual/site-builder`; tutorial `/tutorials/build-a-page-by-asking-dot`.
|
|
1747
|
+
|
|
1748
|
+
### Tool Builder (`ai-tool-builder`) - "Daisy"
|
|
1749
|
+
|
|
1750
|
+
Tier: paid (closed source), **hosted sites only** (`hostedOnly: true`) · **£59 a month**, a separate Tool (not in a plan) · Version: 0.1.4 · Permission: `tool-builder`
|
|
1751
|
+
|
|
1752
|
+
The AI in Tool Builder is called **Daisy** ("Daisy, your Tool Builder"). A site owner describes a Tool and Daisy writes it as a walled-off plugin (`tb-<site>-<name>`), checks it and sends it to Domma for review. Daisy says plainly that it is AI, only builds Tools, and never builds a Tool Domma already has: it names the Tool that does the job instead.
|
|
1753
|
+
|
|
1754
|
+
**Features**
|
|
1755
|
+
- New Tool: a name and a description in plain words; one short question when something that matters is unclear. Two new Tools a month; changes to a site's Tools are included.
|
|
1756
|
+
- Checks on every change: code rules, a real boot of a test copy of a site, its screen opened in a browser and its tests run; a picture of how it looks.
|
|
1757
|
+
- Review by a person at Domma (by the next working day) before release; approved versions are kept and an earlier one can be put back.
|
|
1758
|
+
- Never a copy: a name matching a Tool Domma has (or one the site already built) is refused before any build is counted, with the reason in the New Tool form ("Domma already has Invoices…", 0.1.4); the model is given the list of every Tool Domma has, rescanned every 10 minutes.
|
|
1759
|
+
- Ownership: the idea and the Tool's data are the client's; Domma writes, holds and licenses the code.
|
|
1760
|
+
|
|
1761
|
+
**Where:** Admin sidebar **Tool Builder** (`#/plugins/ai-tool-builder`); the build loop, checks and release run on the Manager (`tools/ai-tool-builder/`, `site-manager/services/toolBuilder.js`); staff review at Site Manager > Tool reviews. Guide: Documentation > Tools > Tool Builder; manual chapter `/spaces/domma-cms-user-manual/tool-builder`; tutorial `/tutorials/make-a-tool-of-your-own-with-daisy`.
|
|
1762
|
+
|
|
1727
1763
|
### Analytics Pro (`analytics-pro`)
|
|
1728
1764
|
|
|
1729
1765
|
Tier: paid (closed source) · Version: 2.3.2 · Requires: no MongoDB (hits kept in `data/hits.jsonl`); no `minCmsVersion` declared; no `requires` · Uses: none declared · Permission: `analytics-pro` (View), granted to `admin` (2.3.0)
|
|
@@ -1840,6 +1876,8 @@ Everything in the free Blog, plus several separate blogs on one site - each with
|
|
|
1840
1876
|
- `align`: wide, full, center, left, right. Admin "Insert media" slideover builds these.
|
|
1841
1877
|
- Post editor **Insert shortcode** (0.7.0): a searchable picker over the admin's own shortcode registry (`insertMenuGroups()` / `insertShortcodeByName()` from `admin/js/lib/shortcode-insert.js`), so posts get the page editor's forms and builders (card, timeline, scribe, image); Blog Pro's media group leads and opens Insert media. The content box also gets the page editor's right-click menu (edit the shortcode under the cursor, Insert…).
|
|
1842
1878
|
- Featured media on posts: a video/audio link leads the post in place of its picture; cards borrow the provider thumbnail.
|
|
1879
|
+
- **Pin to the top** (Blog Pro 0.8.0): a post editor box puts a post first on a blog's front page and makes it the Featured header's post (and `[blog-featured]` with no slug); archives stay in date order; publishers only.
|
|
1880
|
+
- **After every post** (Blog Pro 0.8.1): a per-blog or default setting (`postFooter`, Markdown and shortcodes, up to 8,000 characters) shown under every post in every layout; admin-only.
|
|
1843
1881
|
- Link metadata and thumbnails fetched once server-side (SSRF-guarded), cached in `data/media/` (30 days; failures retried after 6 hours).
|
|
1844
1882
|
- Per-blog settings: posts per page, RSS length, comments, hold for approval, post layout, listing display, readers can switch display, in-page search/filter, related posts, author pages, authors index, index header, author page header, authors index style, transition, reveal, hover.
|
|
1845
1883
|
- Sitemap source `blog-pro` (every blog's index and public posts).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"note": "Written by `make sync-free-tier` in dcms-marketplace. Do not edit these plugins here - edit them there and sync.",
|
|
3
|
-
"source": "dcms-marketplace@
|
|
3
|
+
"source": "dcms-marketplace@2611cf2",
|
|
4
4
|
"plugins": {
|
|
5
5
|
"blog": {
|
|
6
6
|
"version": "1.10.3",
|
|
@@ -234,10 +234,10 @@
|
|
|
234
234
|
}
|
|
235
235
|
},
|
|
236
236
|
"shopping-cart": {
|
|
237
|
-
"version": "1.7.
|
|
237
|
+
"version": "1.7.4",
|
|
238
238
|
"files": {
|
|
239
|
-
"CHANGELOG.md": "
|
|
240
|
-
"CLAUDE.md": "
|
|
239
|
+
"CHANGELOG.md": "0dd30ec7fde5f4b1c5a5743852d925eb849f764e7de8971b3fc2e2e34b948983",
|
|
240
|
+
"CLAUDE.md": "9e62730419a01b05e70559fea238b8334a6f46ebed27a5943d7b477abfcce9a1",
|
|
241
241
|
"admin/css/index.css": "cdd7790511deef162ad30e299b4512d289583e978ba3b87d65945cdf1da3cdda",
|
|
242
242
|
"admin/lib/chart.js": "b01ce5cfac773c8df8efccab50b67d3dfa99fbead0037d817553db4a6688d4d6",
|
|
243
243
|
"admin/lib/drafts.js": "9e71b939f6c98d5c25875f35b02c367a5e89e0d2c6d084d6a4de0c71128930a2",
|
|
@@ -246,7 +246,7 @@
|
|
|
246
246
|
"admin/templates/shop.html": "c5bb03f1f7cbabfbd8202f3533783eb1848103755b1ba25fdcf1fd8e9478cb8e",
|
|
247
247
|
"admin/views/orders.js": "11a4f9d1db5b6c849b136d97b97e44821bcac21b617281dda58809b442c8645e",
|
|
248
248
|
"admin/views/overview.js": "02241e75976cfa759d6ba738dd13ca0bd2bcb760d66a5f184becc2e472807efc",
|
|
249
|
-
"admin/views/products.js": "
|
|
249
|
+
"admin/views/products.js": "8944645e5e264b0bce5fbd483fbc694ba9df0999db288f2ee202b513ba619c99",
|
|
250
250
|
"admin/views/sales.js": "001c08963e26df72f43d2357bbcc5a0f54f74f9d22bca319c23a28a50f40c124",
|
|
251
251
|
"admin/views/settings.js": "5bec0fc307abe935858e24697acb5cfae7f4dcac945afc1f6185da982c121e22",
|
|
252
252
|
"admin/views/shop.js": "b28390b8aacde1c2d395cdf92902ec655075061bbd8dd5ca0df53db851f5051c",
|
|
@@ -267,13 +267,13 @@
|
|
|
267
267
|
"lib/shop.js": "baa5dfc4e410210e8ba13678997ee5752eb2ebe72fc4d3e449465d29b60b458d",
|
|
268
268
|
"lib/summary.js": "ff947ccf0f63cc3095946612460f3ea7ff742803395802179b3ccd66fe961dfa",
|
|
269
269
|
"plugin.js": "650025fefd7426ffc8334807c3e88c6496067350479e2551efcf61d53c74b630",
|
|
270
|
-
"plugin.json": "
|
|
270
|
+
"plugin.json": "ed9dd04c57e12d722fe6ea0d8642c9ea2c07b785b0ac6a18ca64f6408893fbcb",
|
|
271
271
|
"plugin.public.js": "d4304e85895f7e8e2397e64cc7a8e118e94b65c2f271369f880d92e7d32f83f8",
|
|
272
272
|
"public/account.js": "5f644016c098c7879c59948d662f5997cb61680996204ecb7897baab8945d434",
|
|
273
273
|
"public/cart.js": "7338141392ec653ff616eb75688d2a2ad08cff8427d7020d381f540be0037b73",
|
|
274
274
|
"public/lib/money.js": "d22b2b6f80dde6f7887b69e24188c05ea93c02217aba639b5331aa3bd616f4fc",
|
|
275
275
|
"public/lib/orders.js": "e18d054bf385e9c15544628c81ad7746179eea74c33dbcce42dd2525f3fa210e",
|
|
276
|
-
"public/lib/products.js": "
|
|
276
|
+
"public/lib/products.js": "ace3b66b3a5033c061c01bef86c8529ba91449bcb47f7be4fbada072a9c63e1e",
|
|
277
277
|
"public/lib/session.js": "4f71e98818a52cf2321c8dc57e33e5591deb04ebb2c0bea19dd6758827719a08",
|
|
278
278
|
"public/samples/candle-2.svg": "aca5691b9168467caf6feb7622ab154ee92504be8b887ac6c818db22476e7bed",
|
|
279
279
|
"public/samples/candle.svg": "ef75e95a53ce13e88928004c6f1290c45a1094765e2ba741ae1fc55d404b881f",
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
"public/samples/tee.svg": "287a82d7fc00acb1543b3209927ae20dcbe3d4b2a2b3de03574ab0c463385f3c",
|
|
288
288
|
"public/samples/tote-2.svg": "9c7f41cc57866e71973e413a6c87f46be48f7488d3490ceea58e24559c334813",
|
|
289
289
|
"public/samples/tote.svg": "01de817a32c8d3d8ea47ff491049f439ca3e4d4fce943dbdc62a4187139e016c",
|
|
290
|
-
"public/shop.css": "
|
|
290
|
+
"public/shop.css": "ac42d386b014556e175b12164cf4ff2fbdcf7b273c32ed7f55da7cc1f43c103b",
|
|
291
291
|
"roles/shop-customer.json": "3f3366c536c9fbf2b2ce146bb3090b008d5fbfe22752e764eb8e5a1de9cd611c",
|
|
292
292
|
"templates/shop.html": "4649e57d23458833a157799dc80141824eb0f658d96734bd1859c68e0ba9a8b9",
|
|
293
293
|
"tests/accounts.test.js": "79b0e91e4310d076960b2a768ada02185b6cf05cab83052ee825b13978e0a9dc",
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
"tests/commission.test.js": "fbc4cf83e0ed6446a09e57e4ff37a9608c81947c633c78ac6049eb0aedf6cb58",
|
|
296
296
|
"tests/drafts.test.js": "2dec0cfeadd6df1d3b90f3fd8bce1f33762811eb6e94cd7325bcb8ec31edac42",
|
|
297
297
|
"tests/email.test.js": "2190b6dd7cc9afad99d2170f002343fe3dad306aa14ac718428e5df0be54ded1",
|
|
298
|
-
"tests/pure.test.js": "
|
|
298
|
+
"tests/pure.test.js": "d124ed192b0148965558c563dce87acfd84d6c63fc475bc1e4ff2313dab62db8",
|
|
299
299
|
"tests/refunds.test.js": "0ae06afca3cf9fd1fe89f1fbc63b3676216c79e174dbcb83788180c01d078366",
|
|
300
300
|
"tests/sales.test.js": "9025bc608b04bcc14f5bb2c98b4f7c35de99f3ddab4ffa59772d045795bf2cb7",
|
|
301
301
|
"tests/seo.test.js": "1d0b77409bd65faf803af303531c7653a151b4ffd615bab4fb1708efabd670de"
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.7.4] - 2026-11-08
|
|
4
|
+
- The product list counts options without pluralising their name: "Units: 2 options", not "2 unitss" (`optionsText` in public/lib/products.js).
|
|
5
|
+
- The receipt's Download buttons (and [buy-button] links) are readable on every theme: their text is the theme's own on-primary colour (`--dm-primary-text`), and the site's content-link colour no longer paints over it (it made them primary text on a primary button).
|
|
6
|
+
|
|
3
7
|
## [1.7.3] - 2026-11-08
|
|
4
8
|
- An order's extension facts show only words and numbers, with readable names ("keys short: 2"): Shop Pro's bookkeeping (counted, granted) showed raw.
|
|
5
9
|
- Needs you says an option is sold out ("Imperial sold out") rather than ": 0".
|
|
@@ -93,6 +93,9 @@ A cached page can show a stale stock flag until it is re-rendered; checkout re-p
|
|
|
93
93
|
|
|
94
94
|
- Storefront CSS tokens are defined on `body`, not `:root`: themes set --dm-* on body's dm-theme-* class.
|
|
95
95
|
- The site's own input/link styles reach the storefront: see the "reach in here" block at the end of shop.css.
|
|
96
|
+
- Text on the accent is `--shop-accent-ink` = the theme's `--dm-primary-text` (never a fixed #fff). A link drawn as a button
|
|
97
|
+
needs its colour in the `@layer shop-ink` block: core site.css colours content links with an !important rule of
|
|
98
|
+
specificity 0,8,5, and only a layered !important beats it without a selector arms race.
|
|
96
99
|
- `siteBase()` uses `request.host` (with the port); `request.hostname` drops it under Fastify 5.
|
|
97
100
|
- A test site on a non-standard port needs `site.baseUrl` for Stripe/PayPal return addresses behind a proxy, and
|
|
98
101
|
emails have no links to the order until it (or a real sign-in) gives the site a trusted address (1.6.1).
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import {api, ask, claims, entriesOf, soon, esc, getCurrency, money, moneyIn, moneyOut, mountPanels, openPanel, refreshBadge, store, wireRows} from '../lib/kit.js';
|
|
21
21
|
import {NEW_KEY, PRODUCT_DRAFTS_KEY, adoptAsNew, draftDiffers, draftKey, draftValues, productDraftQuestion, readMap, replaceNewDraftQuestion,
|
|
22
22
|
stableJson, withDraft} from '../lib/drafts.js';
|
|
23
|
-
import {STATUS_LABEL, cleanProduct, priceRange, slugify, totalStock} from '/plugins/shopping-cart/public/lib/products.js';
|
|
23
|
+
import {STATUS_LABEL, cleanProduct, optionsText, priceRange, slugify, totalStock} from '/plugins/shopping-cart/public/lib/products.js';
|
|
24
24
|
|
|
25
25
|
const FILTERS = [
|
|
26
26
|
{key: 'all', label: 'All', match: (p) => p.status !== 'archived'},
|
|
@@ -90,7 +90,7 @@ export async function mount(root, ctx) {
|
|
|
90
90
|
img: p.images?.[0] || '',
|
|
91
91
|
featured: Boolean(p.featured),
|
|
92
92
|
unsaved: kept.has(e.id),
|
|
93
|
-
meta: [p.category,
|
|
93
|
+
meta: [p.category, optionsText(p), p.sku].filter(Boolean).join(' · ') || ' ',
|
|
94
94
|
stockText: stock === null ? '∞' : `${stock} in stock`,
|
|
95
95
|
stockTone: stock === null ? 'is-muted' : stock === 0 ? 'is-danger' : stock <= low ? 'is-warning' : '',
|
|
96
96
|
statusLabel: STATUS_LABEL[p.status],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shopping-cart",
|
|
3
3
|
"displayName": "Shopping Cart",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.4",
|
|
5
5
|
"tier": "free",
|
|
6
6
|
"description": "Sell from your site: products with options, stock and pictures, a storefront and a cart that follows shoppers from page to page, and checkout with Stripe, PayPal or payment offline. Orders to fulfil in the sidebar, refunds from the order.",
|
|
7
7
|
"author": "Domma CMS",
|