tool_qr
A base/build sample tool that renders the current section selection as a printable A4 sheet of QR codes — one per record, each linking back to its Dédalo page. Not for production use; ships as a reference implementation.
Sample, not a production tool
tool_qr is a worked example of a UI-only tool with a ddo_map-driven render, not a supported feature. It ships no server/ package. tool_dev_template is the production-shaped scaffold to copy when building a real tool (see Creating new tools).
What it does / why & when to use it
tool_qr takes the records currently selected in a section list and draws each one on an A4 print canvas as a QR code plus a small info card (an identifying image, the section_id, and a label). The QR encodes the record's own Dédalo page URL (…/page/?tipo=<section_tipo>§ion_id=<section_id>), so scanning it reopens that exact record. The canvas can be flipped between portrait and landscape and is styled for printing (the tool header, info bar and footer are hidden under @media print, each card avoids page breaks).
Concrete heritage scenario: a museum stores numismatic objects in trays in a warehouse. A cataloguer filters the Inventory section down to a tray's worth of coins, opens the QR tool from a configured button, prints the A4 sheet, and cuts out the labels. Each physical coin slot now carries a QR sticker showing a thumbnail and inventory number; scanning it on a phone jumps straight to that coin's record for easy location and verification. This is exactly the use the tool's own registration description records: "Creates QR codes for records. Used to print labels with item information for easy location in the warehouse."
Use it as: a starting skeleton when you need a tool that reads a section's selection and renders something custom client-side, or as a demonstration of the ddo_map button-trigger surfacing pattern. Do not depend on it as shipped functionality.
How it works (server + client)
Server. tools/tool_qr/ ships no server/ package — confirmed: there is no tools/tool_qr/server/ directory. All behavior is client-side; the tool never calls tool_request.
Client (tools/tool_qr/js/):
index.jsre-exports the tool;tool_qr.jsis the instance, wired to the standardtool_commonlifecycle (init/build/render,editfromrender_tool_qr).init()callstool_common.prototype.initand then dynamically imports the QR library from the client-lib registry,/dedalo/lib/qrcode/dist/easy.qrcode.min.js— the pinnedeasyqrcodejspackage (EasyQRCodeJS), registered insrc/core/client_libs/registry.ts.build()callstool_common.prototype.build(which loads theddo_map) and thenload_section(): it resolves the caller's element context viadata_manager.get_element_context, takes thededalo-enginerequest_config, overwrites itsshow.ddo_mapwith the tool'sddo_map, and forcessqo.limit = 0/sqo.offset = 0so the whole selection is loaded (no pagination). It then builds asectioninstance inlistmode and recordssection.total. Theddo_mapsource is'button_triger'by default — i.e. the map comes from the button'stool_configrather than the section-list properties, so per-section user access can be controlled by the button.render_tool_qr.jsbuilds the DOM: aninfo_container(section label, total records, a portrait/landscape<select>) and aqr_canvasofqr_wrappercards. For each record it composes the page URL, draws the QR withgenerate_qr()(an EasyQRCodeJSQRCoderendered throughdd_request_idle_callback), and fills the info card from theddo_map: entries withrole:'image'render the image component, entries withrole:'label'render the label component (both pulled fromsection.datum.databytipo+row_section_id). Optionalconfig.options.hostoverrides the URL host andconfig.options.entity_logoadds a logo image.worker_qr.jsis a commented-out Web Worker variant of the QR generation (kept as a reference; not used by the active code path, which renders on the main thread).css/tool_qr.lessstyles the A4 canvas (21cm × 29.7cm, landscape 29.7cm wide) and the print media query.
Actions & options
tool_qr has no API actions — it is UI-only.
| Action | Permission gate | Background | Reads from options |
|---|---|---|---|
| (none) | — | — | — |
(no server module). Any attempt to call an action on this tool through dd_tools_api is refused at dispatch gate 5 (tool has no server module) — there is nothing to dispatch to.
What the client reads instead of action options:
| Source | Field | Meaning |
|---|---|---|
| caller | caller.tipo, caller.section_tipo, caller.model, caller.lang |
the element the tool was opened from; used to load the section selection |
tool_config (from the button / section properties) |
ddo_map |
the columns to render. Entries flagged role:'image' become the card image; role:'label' become the card label |
tool config |
options.host |
overrides the host in the generated page URL (default: window.location.origin) |
tool config |
options.entity_logo |
optional logo image URL drawn on each card |
properties |
open_as, windowFeatures |
UI hint: opens in its own window |
How it is registered & surfaced
tools/tool_qr/register.json is a column-keyed dump (string/relation/misc/… keyed by component tipo — a seeded matrix-row snapshot, not a hand-authored file); importTools() passes it through as-is (see register.json reference). The essentials it carries:
dd1326name =tool_qr;dd1327version (1.0.1);dd1328minimum Dédalo version (6.2.8);dd1644developer = Dédalo team;dd799label =QR.dd1335properties ={ "open_as": "window", "windowFeatures": null }→ opens in its own window.dd612description anddd1362implementation notes (the implementation field documents thetool_config/ddo_mapbutton-trigger pattern in detail).
Surfacing. tool_qr is not attached by affected_models / affected_tipos. It surfaces through the properties->tool_config path in the section/component tool filter: an element (typically a section, via a button trigger under tch350-style config) names the tool in its properties.tool_config.tool_qr and supplies the ddo_map there. Because the trigger lives on a button, access can be scoped per section; placing the button on a parent virtual section (e.g. as a child of tch7) makes it operative for all that section's virtual children (tch100, tch200, tch300, …). The tool is therefore opened from a section list, not from the inspector or inline on a component.
Examples
There is no tool_request to show (no server actions). The tool is enabled by declaring it in an element's properties.tool_config, e.g. on a button trigger for section tch1:
{
"tool_config": {
"tool_qr": {
"ddo_map": [
{
"mode": "list",
"tipo": "tch66",
"typo": "ddo",
"view": "mosaic",
"label": "Identifying images",
"model": "component_portal",
"parent": "tch1",
"section_tipo": "tch1"
},
{
"mode": "list",
"role": "image",
"tipo": "rsc29",
"typo": "ddo",
"view": "list",
"label": "Image",
"model": "component_image",
"parent": "tch66",
"section_tipo": "rsc170"
},
{
"mode": "list",
"role": "label",
"tipo": "tch63",
"typo": "ddo",
"view": "list",
"label": "Title",
"model": "component_input_text",
"parent": "tch1",
"section_tipo": "tch1"
}
]
}
}
}
role:'image' flags the ddo the card renders as its thumbnail; role:'label' flags the ddo rendered as the card title. For a button shared across virtual sections, use "parent": "self" and "section_tipo": "self" on the section-owned entries so the same config works for tch1, tch100, tch200, tch300, … (children of tch7).
Optional per-tool config (dd996 / register default_config) to override the QR URL host and add a logo:
{
"options": {
"host": "https://my.museum.org/",
"entity_logo": "https://my.museum.org/logo.svg"
}
}
Related
- Creating new tools —
tool_qris a hand-on skeleton for this tutorial; the production-shaped scaffold istool_dev_template. - Server contract · Security — why a UI-only tool is refused cleanly at dispatch even with no
server/package at all. - JS lifecycle — the
init/build/render/editflowtool_qrfollows and theddo_mapit consumes. - tool_export — the other section-selection tool; if you actually need to get section data out (CSV/TSV/XLSX/round-trip), use export, not QR. See Exporting data.
- Tools catalog — full list of shipped tools.
- Source:
tools/tool_qr/register.json(noserver/package),tools/tool_qr/js/{index,tool_qr,render_tool_qr,worker_qr}.js,tools/tool_qr/css/tool_qr.less; the QR library is the pinnedeasyqrcodejspackage (client-lib idqrcode).