Build a board where dragging a card saves its column
Use this for an order board, a task board or any list of records sorted into columns, where moving a card from one column to another changes a field on the record.
A dnd-list block saves a drop by itself. No rule, form or service is involved.
Who can drag
Section titled “Who can drag”By default only a signed-in user of the application can drag. The save goes through the reorder route, and a request with no sign-in is refused with 401.
A model can opt in to dragging by visitors who are not signed in. Add "allow_anonymous": true to its public_record_reorder setting:
{ "anonymous_access": { "read": true, "create": true }, "public_record_reorder": { "enabled": true, "allow_anonymous": true, "allowed_group_fields": ["status"] }}A signed-out drop is then saved when all of these hold:
public_record_reorder.enabledandallow_anonymousare bothtrue- the model allows anonymous read (
anonymous_access.read: true) - the model is published, with no unpublished schema changes pending
- the application is live and does not serve an uploaded site
- the field the drop writes is listed in
allowed_group_fields
Choose deliberately. With the opt-in, anyone who can open the board can move any card, and the change is recorded without a user. That suits a kiosk or a demo. For a board only the owner’s people should change, leave the opt-in off, build a sign-in (see Add a staff sign-in to an application) and make the board page require it, while any customer-facing page, such as an order form, stays public.
Signed-out drops are rate limited per visitor address (100 in 15 minutes).
The record model
Section titled “The record model”The model the cards come from needs two fields besides its own:
- the column field, which says which column a card is in. A plain text field with a fixed set of values such as
New,BakingandReadyis enough. No separate column model is needed. - an integer field for the order inside a column, for example
position.
And these settings, so signed-in users may read the cards and move them (for a board without sign-in, use the opt-in shown above instead):
{ "consumer_reads": "any_authenticated", "consumer_writes": "any_authenticated", "public_record_reorder": { "enabled": true, "allowed_group_fields": ["status"] }}The key names are exact: public_record_reorder holds enabled and allowed_group_fields (and optionally allow_ungrouped and allow_anonymous). A key the platform does not know, such as group_fields, is refused when the settings are saved, with a message listing the allowed keys.
public_record_reorder is what allows the move. Without it a drop is refused with 403. allowed_group_fields lists the fields a drop may write; name the column field there. Model settings are replaced as a whole on update, so send them merged with the settings the model already has, including anonymous_access.
One list per column
Section titled “One list per column”Put one dnd-list in each column. Each list shows the records whose column field has that column’s value, and writes that value to any card dropped into it.
{ "id": "board", "type": "container", "display": { "layout": "grid", "columns": 3, "gap": 16, "full_width": true }, "blocks": [ { "id": "column-new", "type": "container", "display": { "layout": "flex", "direction": "column", "gap": 8 }, "blocks": [ { "id": "column-new-title", "type": "heading", "content": { "text": "New", "level": "h2" } }, { "id": "column-new-cards", "type": "dnd-list", "source": { "model_id": "<order model id>", "fields": ["customer_name", "items", "status", "position"], "filter": { "status": "New" }, "group_field": "status", "group_id": "New", "sort_field": "position", "dnd_group": "order-board", "live": true }, "display": { "item_var": "item", "orientation": "vertical" }, "blocks": [ { "id": "order-card", "type": "container", "style": { "class": "rounded-lg border p-3" }, "blocks": [ { "id": "order-card-name", "type": "heading", "content": { "text": "{{ item.customer_name }}", "level": "h3" } }, { "id": "order-card-items", "type": "text", "content": { "text": "{{ item.items }}" } } ] } ] } ] } ]}Repeat the column container for each column, changing only the title, the ids, filter.status and group_id.
What each source setting does:
group_fieldandgroup_id: a card dropped into this list getsgroup_fieldset togroup_id. Here,statusbecomesNew.filter: which records this list shows. Keep it equal to thegroup_fieldandgroup_idpair, or a dropped card disappears from the list it was dropped into.sort_field: the integer field the drop rewrites to keep the new order.dnd_group: lists with the same value exchange cards. Give every column the same one.live: withtrue, a record created or changed somewhere else, for example a new order from the public form, appears without a reload. Without it only changes made in the same tab appear. It must be a JSON boolean.
Check it
Section titled “Check it”Sign in as a user of the application, open the published board, and drag one card to another column. Reload the page: the card must still be in the new column. Then create a record from another browser and confirm it appears on the open board without a reload.
