Skip to content

Latest commit

 

History

History
641 lines (570 loc) · 54.3 KB

Practices-App-Dev.md

File metadata and controls

641 lines (570 loc) · 54.3 KB

MR Moqui application development practices

A guide for agents and people building business applications on MR Moqui: the IronStone BOSS apps (Projects, Products and those that follow) over Mantle, and apps like them. It covers how the artifacts are organized and the practices that keep an app's code and screens good. The reference guides for each tool (entities, services, screens, forms, the facades) are separate; they are being ported from the Moqui Java documentation and extended.

Most of these practices come from reviews of the Products app (runtime/components/addon/mr-boss/plan/impl-products.md, section "R — Review" and findings F43–F46), of Accounting P0–P3 (impl-accounting.md "R — Review", F61 on) and of Accounting P4–P5 (impl-accounting.md "R2 — Review"), measured against the Projects app, which is the reference implementation of the screen archetypes. They cover code quality, organization and UI quality, not individual bugs.

Contents: 1 tools and artifacts · 2 references · 3 where logic goes · 4 services and scripts · 5 screens · 6 vue single-file screens · 7 tests · 8 formatting and mechanical changes · 9 checklist

1. Tools and artifacts

The layers

Layer Repository and directory What belongs there
Framework mr-moqui: crates/*, runtime/components/base/{framework,webroot,tools}, runtime/components/dev/{example,dev-aide,template} The facades, the screen renderers (framework/template/screen/Screen*.js), the browser client (webroot/screen/webroot/js/WebrootVue.qvt*.js), the XSDs (framework/xsd). No business data model.
Mantle mr-mantle: runtime/components/addon/mr-mantle The business data model (entities, seed data) and the business services. It stands alone: no Mantle service, script, data file or spec names a BOSS group, service, screen or setting. It checks Moqui permissions itself (for example PRODUCT_CATALOG_EDIT, PRICE_VIEW).
Apps mr-boss: runtime/components/addon/mr-boss The apps: screens, the app's access check, screen context (options, names, capabilities), settings forms, app-specific services.

Each component is its own git repository. Commit in each repository that a change touches, with its own message.

A component's directories

Path Contents
component.xml, MoquiConf.xml The component and its conf: screen mounts (screen-facade), tool factories, its own settings element (Conf settings).
entity/*.xml, entity/<domain>/*.xml Entity definitions, view entities and extensions (extend-entity). Mantle groups these by domain, with separate *Entities.xml, *Views.xml and *Extensions.xml files.
data/ XML data files, in name order in each directory, followed by its subdirectories in name order, depth first. Seed, initial settings, install and demo data (type="seed", "seed-initial", "install", "demo"): enumerations, status flows, security (ArtifactGroup, ArtifactAuthz, UserGroupPermission), demo records the walks use.
service/<package path>/*.xml Service definitions: verb and noun, parameters, <description>, and the implementation, inline XML Actions in <actions> (§4). SECAs in *.secas.xml, EECAs in entity/*.eecas.xml.
service/<package path>/*.js Script modules for logic too involved for XML Actions: one module per area (Prices.js, Methods.js), plus a shared library (ProductsLib.js).
screen/<App>.xml, screen/<App>/**/*.xml XML Screens: the app root, its sections and subscreens. screen/Shared/*.xml holds screens mounted in several apps.
screen/**/*.qvue Vue single-file screens and widgets for the browser (§6), each beside an XML screen.
screen-extend/ Extensions of another component's screens.
template/*.xml Shared screen parts: transition-include files (CatalogChoiceTransitions.xml, FilePickerTransitions.xml), section includes; *.fancy text templates.
build/js-build.json, build/<project>/ Browser libraries from npm: the locked projects and the build script that ./moq build-js runs. Its output is under screen/, ignored by git apart from its MANIFEST.json (Build-Test, Browser libraries of a component).
test/*.spec.js Server specs, run by moqui test inside the server's script engine.
test/client/*.spec.js, test/client/suite.js Client specs (HTTP, WebSocket, headless Chromium), run by moqui test-client; suite.js orders them and names the server specs that load their fixtures.
plan/, docs/ In mr-boss: research, design and implementation plans per app, the style guide; reference notes for built apps.

Languages and render modes

  • Services are XML Actions first. A service's implementation is inline XML Actions in its definition; JavaScript is for logic XML Actions do not express well (§4).
  • Scripts are JavaScript (quickjs-oxide, a QuickJS-compatible engine), not Groovy. XML action expressions, <script> bodies, conditions, ${} template text and service scripts are all JavaScript. Groovy's ?: and ?. habits do not all carry over: use || or ??. moqui lint --groovy <dir> reports Groovy left in a component; moqui lint --screens reports idioms and hazards in screen expressions.
  • A service script module is a file whose last expression is its value, by convention ;({execute: run}). A service calls it with ec.resource.script(location).execute(op, context). A module whose top level only declares (functions, constants of literals or tables of them, other modules by ec.resource.script("...")) gives the same value for the rest of the outermost script run (the request, job or call on the thread), made once; any other top level (a let, a loop, a call, a change to a table) is evaluated afresh in its own scope on each load. So module-level state lasts at most the run, never into the next request; a cache kept in a module constant lasts the whole run, and a per-call cache belongs in the call (§4).
  • Screens render in qvt (the browser: Vue 3 and Quasar), tui (the terminal, as a JSON node document; see TUI "For screen authors"), html and html-print (print and PDF). Every screen must work in qvt and tui. A render-mode text for one mode needs its twin for the other.
  • Decimals are not JavaScript numbers. A BigDecimal from an entity or service supports add, subtract, multiply, divide, compare, eq, isZero and toNumber; toDecimal(x) makes one. String concatenation calls valueOf and throws: write String(quantity).

Commands

Command Use
./moq run Start the server on the dev conf.
./moq test <component> [--spec S] [--feature F] Server specs on a fresh database (Testing).
./moq test-client <component> --serve -- --spec S Client specs against a started server (JS-Test-Client).
./moq test-apps The regression suite of every app component, before a commit (The two suites).
./moq accept <component> [--spec S] The acceptance suite (test/acceptance/), only when asked or when you add or change an acceptance test.
target/release/moqui lint --screens [report-file] Screen expression lint. The argument is the report's output file, not a screen to check: passing a screen path overwrites that screen.
moqui lint [service-file], moqui lint --groovy <dir> Service expression lint; leftover Groovy.
moqui tui, moqui tui --server The terminal UI, to see a screen's tui rendering.

2. References

  • Style guide: runtime/components/addon/mr-boss/plan/style-guide.md. The shell (§2), the screen archetypes (§3: landing, list, detail, 360, task, board, wizard, report, settings and more), the widget guide (§4), color and status display (§5), states and feedback (§6), devices and breakpoints (§7), and the checklist for a new XML element (§8.1).
  • Archetype gallery: runtime/components/dev/example/screen/Gallery*.xml and its .qvue files, at /qapps/gallery once signed in on a dev instance. One screen per archetype; its README lists them.
  • Reference implementation: the Projects app, runtime/components/addon/mr-boss/screen/Projects/. For record headers and actions see Projects/Projects/ProjectDetail.xml (the m-record-header block); for a landing see Projects/Home.xml.
  • Design documents: plan/design-doc-guide.md (what a design contains), plan/design-crosscut.md (shared screens, cross-app contracts, posting rules), and the per-app design-*.md, impl-*.md and research-*.md. plan/initial-design.md holds the decided app set.
  • Products notes: runtime/components/addon/mr-boss/docs/ProductsSharedScreens.md (shared mounts and the shared context) and ProductsImplementation.md.
  • Framework guides in docs/: Services (errors, transactions, probe calls), Testing, JS-Test-Client, TUI, Moqui-Java-Migration (with the deliberate differences listed in Parity-Diffs), Native-Components, Web-Scripts.
  • Schemas: runtime/components/base/framework/xsd/mr-xml-screen.xsd, mr-xml-form.xsd, mr-service-definition.xsd, mr-entity-definition.xsd. Their documentation elements describe MR Moqui's behavior where it differs.
  • Building: .agents/skills/building/SKILL.md, and the rules in AGENTS.md (failure tolerance, no Node dependency).

3. Where logic goes

  • Use Mantle before adding to it. Mantle was ported from Moqui Java's mantle-usl, much of it used in production for years (/moqui/runtime/components/addon/mantle-usl in a Java checkout is the original). Before writing a service, find the one that already does it and use it, or extend it with a parameter: payments are created, changed and posted through create#/update#Payment and post#Payment (so their SECAs run), applied through the apply#* services, refunded through create#RefundPayment; gateway operations go through the *#SinglePayment services and their gateway interfaces; invoices print over get#InvoicePrintInfo and send through an EmailTemplate. Accounting P4–P5 first rebuilt each of these beside Mantle, with its own entities and guards, and the review removed the copies.
  • Business rules lean to Mantle. A rule about the records (validation, effective dating, rounding, policy, totals) is a Mantle service in the package of the records it changes, with its own rule test in Mantle, passing under ./moq test mr-mantle alone; an app's specs do not test it again. The app keeps its access check, its screen context and its settings forms. Products' review moved catalog settings writers, bulk price changes, stock totals and cost subtotals from BOSS scripts into Mantle (CatalogSettings.js, PriceChanges.js, get#ProductStockTotals).
  • No pass-throughs. A BOSS service that only renames a Mantle service adds nothing. A screen calls the Mantle service after the app's access check (for example in always-actions after get#SharedContext).
  • Check access in services, from permissions. The check runs where the data is read or written, so it holds for imports, exports, search, shared mounts and direct requests. Derive capabilities from Moqui permissions (ec.user.hasPermission, UserGroupPermission rows in setup data), not from a map of BOSS group names, and not from ec.user.isInGroup in a service, the palette or a record link. Grant permissions to groups in data.
  • Reads come from view permissions. Do not make an app's read capability "holds any of its permissions": another app's group is given an edit permission for its own work (Projects' managers hold RECEIVABLE_EDIT to bill), and it then opens this app's lists, search and links. Give each kind of record a view permission (RECEIVABLE_VIEW, PAYABLE_VIEW), let an edit permission alone open nothing, and spec what a neighboring app's group can reach.
  • Restricted values stay on the server. A service leaves out of its answer what the user may not read (costs, supplier prices, margins); nothing is fetched and then hidden by the screen. Declare a service's out-parameters: an XML-action or script service returns only the declared ones, read by name (JS-Service-Scripts).
  • Compare reason codes, not message text. A policy that refuses returns a code (denied(reason, message) in mantle/product/PricePolicy.js), and callers test the code. Matching on an error's wording breaks when the wording changes. A new policy module starts with codes, as Accounting's AccountingPolicy.js does through mantle/ledger/EntityLib.js (denied, reasonCode).
  • Shared screens (screen/Shared/*.xml) take appRoot and compute capabilities on the server through the app's shared-context service; the mounting app's context adds tabs and filters, never authority (design-crosscut §1.1). sharedLinks gives the paths to other shared screens under the current app.
  • One route per screen. Do not keep hidden alias routes for an old path. When a screen moves, change the links and specs.

4. Services and scripts

References: JS-Service-Scripts (what a service body sees and returns), JS-XML-Actions (actions and expressions as JavaScript), JS-Core-API (ec.*), JS-Globals (decimals, dates, the helper objects) and JS-Framework-Services (the services the framework ships).

Definitions

  • Give each service a <description>: what it does and what it refuses.
  • Share parameter lists through an interface: a type="interface" service (define#MethodParameters) and <implements service="..."/> in each service that uses it. Products had service files of thousands of lines of copied parameter unions before this. An interface holds the in-parameters its services share; each service declares its own out-parameters. An interface that lists every service's outputs is the copied union again, and copying the interface into a second file to reuse it is a copy too: implement the first.
  • Undeclared in-parameters are dropped before the service runs. A screen that passes context passes only what the service declares.

Service implementations

  • Inline XML Actions in the service definition: entity-find, entity-find-one, entity-find-count, entity-make-value, entity-create/update/delete, service-call, set, if, iterate, return, message. A Mantle service that checks its own permission and organization scope reads and writes with disable-authz="true" on these actions (and on service-call), as its script would with .disableAuthz(). A short JavaScript expression in a set from or a condition is fine.
  • A script module only for logic that XML Actions do not express well: paging over several kinds of record, allocation planning, a posting preview, hashing, CSV, date arithmetic. Accounting P4–P5 first had nearly every service as a one-line <script> into a module of 1,000 to 1,600 lines, most of it entity and service calls.
  • No authorization by caller. A service does not read ec.artifactExecution.getStackNameString() to decide whether its caller may write; it checks permissions. Status rules are StatusFlowTransition data that update# checks.
  • A change reason is the audit row's. Pass <field>_changeReason with an entity-auto create#, update# or store# (implicit or declared) and the audit row of that field (enable-audit-log) records it; no changeReason field of the app's own. A message staged until someone commits it is SmsgStaged (the framework's, with Consuming and Cancelled), so no consume job takes it.
  • Writing as the system. A service that has checked its caller and must write what the caller may not (a page space with restrictUpdate) uses ec.artifactExecution.runAsSystem(() => ...): no user, authorization off, the same transaction. Only a service's own code may call it (The system scope); never grant the user a row for the write. Records written inside have no user, so pass the acting user where the write takes one (update#WikiPage historyUserId).
  • No EECA guarding an entity that only its own module writes, and no EECA or SECA on a hot path (every Payment or AcctgTrans write, a framework entity, service=".*") without a narrow <condition>.
  • Nothing for tests in production files. Test entities, services, SECAs and scripts under test/ are not loaded by entity/ or service/ files; a spec makes its own data and faults.
  • Sequenced ids (entity-sequenced-id-primary, the create# services), not ec.user.randomString; status and kind fields are StatusItem or Enumeration ids with relationships, not free text.

Heavy work: scripts or Rust

The script engine interprets its bytecode, with no JIT, by design (Build-Test). A typical service or screen spends its time in entity finds, service calls, the conversions between script and framework values, and rendering, not in its own loops, so XML Actions and scripts stay the default. Heavy work goes to Rust:

Work Where
Finds, service calls, conditions; screen and template logic; per-request work over tens to hundreds of records XML Actions, or a script module where they do not express it well
Work many apps repeat: serializing, sorting, filtering, grouping and totaling lists, escaping, formatting, parsing The framework's helpers: JSON.stringify and JSON.parse, orderMapList, filterMapList, CollectionUtilities, StringUtilities. A missing one is a framework API to add, not a loop in each app
Loops over thousands of rows or more; numeric work (MRP, costing, scheduling, allocation); reading or writing formats such as EDI, CSV or binary files; work that runs hot across many requests A native service in Rust (Native-Components)
  • Keep the loop on one side. Every call between a script and the framework converts its values. A helper that takes the whole list and loops in Rust is fast; one called once per element can be slower than plain JavaScript.
  • A timing decides. A script is a file the server loads; a Rust service is compiled into the binary, so it needs ./moq build, a new binary for the set of components, and a license and advisory check of any crates it adds. Move the part a timing shows is hot, not a whole service by default.

Script modules

  • One module per area, with named functions and an explicit table of operations. An unknown operation throws:

    const operations = {context, stock, projection, policy, storeFacility, storeTracking}
    if (!operations[op]) throw new Error("Unknown stock operation " + op)
    return operations[op](parameters)
  • Put shared helpers in one library module (ProductsLib.js: find/one/rows/rowsIn, ms, dateText, blankToNull, enumOptions, page), not a copy in each file. Copies drift: Products had three versions of the empty-value check and two date conversions with different results.

  • Per-call state (the app route, cached access, record reads) lives in an object made for the call (lib.forCall(appRoot)), not in module variables.

  • Write code people read: real names for variables and functions, short lines. Products' first scripts averaged 150–300 characters a line with one-letter names; the review rewrote them as named functions and ran Prettier (§8).

  • Separate authorizing a write from building a screen's context. A write that builds the whole screen context to check access does every read twice.

Queries

  • Put conditions, ordering, limit/offset and count() in the entity find. Do not list a whole table and filter it in JavaScript.
  • Read names and related rows for a list in one in query (rowsIn), not one one() per row. Check the visibility of many records in one call, not one call per row.
  • Use .selectField(...) and .distinct(true) when only a few values are needed.
  • Cap lists that could grow without bound (a dropdown of every product capped at 200 is not a dropdown; use a server-search choice, §5) and paginate long lists.
  • Search ignoring case, in the query, before the limit: makeCondition(field, "like", "%" + term + "%").ignoreCase() on the record's names as well as its id. Filtering in JavaScript after limit finds nothing past the first page, and a plain like misses "Cash" for "cash".
  • makeCondition takes three arguments for a value: (field, "equals", value). With two, the second is read as the operator. And not-equals "Y" leaves out rows where the field is null; add an is-null alternative when null means "not Y".
  • Files through ec.resource, never their storage entities. DbResource*, ContentBlob*, GitObject, GitRef and GitLfsObject are the content group, in a database of its own (Run-Deploy): no view-entity, relationship with a foreign key, or find may join them to an application's entities. Keep a file's location on the row (contentLocation) and read and write the file with ec.resource.getLocationReference(location). A test fails when a service, screen or script names them.

Failure tolerance and errors

  • As AGENTS.md says: when one independent item fails (a row, a facility, a record of a list), log an error naming it and go on with the rest. Wrap each item in try/catch.
  • A call whose failure the caller expects and gets past runs as a probe, in its own transaction, with ec.message.pushErrors()/popErrors() around it (Services "A probe call"). Clearing the errors does not clear the transaction's rollback mark.
  • Check concurrency: pass lastUpdatedStamp or the service's expectedRevision back on update so a stale write is refused.

Conf settings

A setting an operator sets per deployment is an attribute of a conf element, with its default written literally there; there is no default-property and no ${name} in a conf attribute (the boot refuses both). Its name everywhere else is its selector, chat@view-once-days or chat/stickers@max-bytes, and the environment sets it by the name built from the same path, moqui_conf__chat__view_once_days (Run-Deploy).

  • A component's setting goes on the component's own top-level element in its MoquiConf.xml, named for the component and holding every setting of it, with the defaults and a comment saying what each does: mr-pass's pass, mr-mantle's mantle, basic-comms' comms. Another component that reads it gets null when that one is absent. Group a set of related settings as a child element (chat/stickers), not as prefixes on one element's attributes.
  • A framework setting goes on the framework element it belongs to in MoquiDefaultConf.xml (a new element when no existing one fits), with its attribute in mr-moqui-conf.xsd and its element in the conf schema (crates/moqui-core/src/context/conf_schema.rs: its reload class, its key when it repeats, a secret's mark), and a merge rule in conf.rs for a new top-level element or a new child.
  • Reading it: a script reads ec.factory.getConfValue('chat@view-once-days') (null for a secret; a secret is named to a host function such as RestClient.addPropertyHeader); Rust reads conf_env::setting("...") or the factory's conf_setting. A spec sets one with setConf or withConf, never setProperty. System.getProperty is for process properties that are not configuration: a test run's switch, the state the server sets as it runs.

Readiness, refresh and settings registrations

A component shows in System › Operations › Health, the System home's attention list, the support summary and the settings index (and in an app that shows those screens, such as IronStone Admin) by seed rows of three framework entities, read by org.moqui.admin.ReadinessServices (JS-Framework-Services; the rules a hand-made request meets are in Attack-Surface). The fields are described in runtime/components/base/framework/entity/ServerEntities.xml; the framework's own rows are in framework/data/AdminConfigurationData.xml.

  • A readiness provider (moqui.server.ReadinessProvider): a key, an owner, a title, a group, the permission a reader needs and a service. The service takes providerKey and the scope parameters the row names (scopeParameters, such as organizationPartyId), changes nothing, and returns checks: each {checkKey, title, state (ready, warning, failed or unavailable), reasonCode, message} and, where it applies, subject (whom or what it is for, in words), scope (the scope parameters that narrow a request to it), watermark and coverage (a data source's freshness, with the row's expectedFrequencyMinutes and maxLagMinutes). It checks the caller's permission and scope itself and refuses with a reason code (PERMISSION_DENIED, RECORD_UNAVAILABLE), which leaves the provider out for that caller; any other failure shows it as not checked. A row whose registration names a scope is an organization's or a store's check: Health shows it, the System home does not.
  • A place is a key, never a path. A row's fixRoute and fixId, a check's own fixRoute, fixId and fixParameters, and a settings entry's destinationRoute name a route the application showing them resolves (Mounting the administration screens): the framework's keys are in tools/template/AdminMount.js, an app's own are in its mount (mr-boss Admin.js mountRoutes). A key with no route where it is shown is no link.
  • A refresh operation (moqui.server.RefreshOperation): a key, the permission that runs it, the provider whose source it refreshes and a service, called with refreshKey, operationKey, reason and the scope parameters the row names.
  • A settings entry (moqui.server.SettingsEntry): a key, a title, a group, destinationRoute and screenLocation, the screen whose authorization decides who is shown the entry (the caller's own grants, counted down the component's screen directory), with an optional viewPermission and the providerKey of what it configures. An app that shows a framework settings screen under its own root seeds the entry again, under the same key, with its own screenLocation.
  • The registration adds no right. A registered service is called as the user, and the registry's own grant is not inheritable: outside an app's screens a caller needs a grant of the service itself, which the component's setup data gives to the groups that should read it.

Values

  • No hard-coded defaults for currency ('USD'), units ('OTH_ea'), languages ('es') or purposes. Take them from the organization's settings, then the user's preferences, else leave the choice empty for the user.
  • Dates in the user's zone: ec.l10n.format(date, pattern), not toISOString() and a UTC label. This holds in specs too: a day computed with toISOString().slice(0, 10) is tomorrow's from evening on in the Americas, and a spec that locks "yesterday" that way fails every evening.
  • Display values come from the service. A row for a screen carries its display text: dates as text in the user's zone (Accounting's AccountingPolicy.display adds a <field>Text for each date and stamp), names for ids, status names. JSON drops date types, and a screen that loads a script module to format dates evaluates the whole module on every render.
  • Amounts round to their currency (ec.l10n.roundCurrency), not a fixed setScale(6).
  • Changes by effective date: a policy, price or setting change starts a dated row and ends the one in effect; history stays readable.

5. Screens

References: JS-Screen-Scripts (actions, transitions and widget expressions) and JS-Templates-Macros (render modes and sri).

Structure

  • Element order follows the XSD: parameter, always-actions, transition/transition-include, subscreens, pre-actions, condition, actions, widgets, fail-widgets. In a form-list: the fields, then columns (including columns type="mobile"), then view-board.
  • always-actions stay small: the shared-context check and what every subscreen needs. A subscreen rendered on its own (a standalone tab render, a TUI tab) runs its parents' always-actions but not their actions, so data a tab needs from its parent goes in always-actions; everything else goes in the tab's own actions. A screen path rendered with a trailing / renders the default subscreen's widgets, not the parent's.
  • A detail screen reads its record in actions, not always-actions. always-actions also run for each request to a transition, so a read there runs on every drop-down keystroke of the screen's choices. Read it with transaction="force-new" ignore-error="true", set recordFound, and show a "Not available" state that links back to the list (ProjectDetail), instead of failing the page.
  • Do not repeat the access check in every transition and section. Check once in always-actions and read sharedMountContext.capabilities where a widget depends on a capability.
  • A server-static screen sends only what its template reads. Its GET {screen}/actions holds the context names the compiled template reads, and a form-list's rows its fields and what the template reads; a name kept is sent whole, so keep a value the browser must not see out of a map the template reads. A name the template reads by a computed name, or a client component reads by itself, goes in the actions element's client-context (JS-Screen-Scripts).
  • Shared transitions go in a transition-include file (template/CatalogChoiceTransitions.xml), not copied into each screen. A transition-include copies one transition by its name: a template with several needs one include per transition, and a form whose transition is not on its own screen posts to nothing. Shared widgets go in a section-include of the same file (template/AccountingParts.xml: the organization picker, a list's find form, report options).
  • Screens that differ only by record kind share one template. Accounting's invoice and bill screens were 5-line diffs of each other; now each route screen sets the kind in its actions and includes template/AccountingDocuments.xml's sections. Look for such pairs in the diff before calling a phase done.
  • Declare only the parameters a screen reads. A transition's response adds every declared parameter of its target that is in the context, so a copied block of parameters carries stale values to other screens (Accounting's delete of a draft went back to a list filtered by the deleted id). A response then needs no parameter list beyond what the target lacks.
  • A form's map falls back to the context. A field missing or empty in the map takes the context's value, so an empty map does not keep a form blank, and an Edit form that extends an Add form in a list row reads the row's values. Do not keep a page variable named like a field of a form on the page unless the form should show it.
  • The screen context holds data, not functions. A set of an arrow function fails when the context is converted; compute the values instead.
  • A transition with no actions is a link. The form that targets it renders as a GET link form (m-form-link), which does not post a row-selection's checked rows. A row-selection action that opens another screen with the selection needs at least one action in its transition (Products' bulkPrice normalizes the id list).
  • Open a dialog after a reload with the _openDialog=<dialog id> parameter, for "edit this row" links that reload the page with the row selected.
  • Links: target-window="_blank", not target. Other screens of the app through sharedLinks, not literal paths.

A framework screen under an app's root

An app shows a framework screen (System's administration screens, the Dashboards screens) under its own root instead of copying it, as IronStone Admin and Insights do. The two contracts are Mounting the administration screens and Mounting the report screens; the record of the two moves, with the findings behind these rules, is plans/archive/Admin-Screens-Down.md.

  • Three ways, chosen by what the app's authorization rows name, what the framework screen has and what the app adds:
    • By location: a subscreens-item of the app's area names the framework file, and the app has no file. Only when no grant of the app names the screen or a transition of it, the screen has no transition that is the instance administrator's alone, and the app adds nothing.
    • A thin wrapper at the app's own location: include-screen share-scope="true" and one transition-include for each transition the app offers. A transition that is not taken in does not exist on the app's route. This is the way when a grant of the app names the screen or its transitions, and when the framework screen has transitions the app must not offer.
    • A screen of the app's own, with its own actions and transitions, around the framework screen's named sections and forms (section-include, form extends). This is the way when the app adds something inside the screen: an organization as a filter or a scope, a column, a box, a check before an action.
  • A grant names the app's own screen, never a framework location. A grant on a framework location opens it under the framework's own app too, past that app's check. An app's inheritable always-allow on its area skips every check below it (transition, service, entity), so a transition the app must not offer is kept off its route, not refused on it.
  • Mount context is data, never authority. The app's root sets the map (adminMount; reportLinks and reportPolicy) in its always-actions, so that transitions read it too, and the framework's own roots set it to null, so a request parameter never supplies one. It says where links go and which values of the app's policy apply. What a value allows is enforced by the transition, which reads the map and never a parameter, or by the service it calls; a list of what is offered gives no right. A service's context is its own: a module function an app calls from a service sees no mount, so the service passes it what it needs (a range, fixed variables).
  • What the engine does that an author of such a screen meets:
    • A form nested in a field of an extended form is the other screen's and is not found: override that field with a form of the app's own. A field of an extended form-list is replaced whole by a field of the same name, and section-include reaches a section nested in another.
    • Two paginated lists on one page share pageIndex. Show the second in place of the first, by a parameter, not beside it.
    • A link carries every parameter its target declares that is in the linking screen's context (a page index, a range of dates, a find value), and a screen mounted by location declares all of its parameters on the app's route. An empty value in the link's own parameters leaves one out: a list that links another screen's record sends its own find values empty, as a link that leaves a mode does. A menu entry or tab carries them too, but one for a screen other than the one shown leaves out the list's page, page size and sort (pageIndex, pageSize, pageNoLimit, orderByField).
    • A screen path that names the app's root (//Admin/...) does not resolve where a spec renders with the app's root file as the root. A mount's routes are relative to a screen of an area, which holds under any root.

The archetypes

Follow the style guide's archetype for each screen, as the Projects app does. In particular:

  • Record header on detail and 360 screens (style-guide §3.3, §3.4), as in Projects/Projects/ProjectDetail.xml: m-record-header holding m-record-title (a key chip, an h5 name and a caption of facts), m-record-status (a status-bar or a state chip), m-record-foot (tags, links) and m-record-actions. Readers see the same header with fewer actions, not a separate label stack.
  • One primary action, chosen by status (Approve, Publish, Activate; New when there is no record yet): btn-type="primary" on a link, type="primary" on a container-dialog. The other actions go in a button-menu "More" with icon="more_horiz".
  • An action the user lacks the authority for is shown disabled, not hidden (disable-condition with a disable-message in the user's words, on a link or a container-dialog), so they see it exists and can ask for it: "Exchange rates are maintained by a finance administrator of every organization" on Currencies' Add exchange rate. A screen's actions read the authority from the service (a may* or capability flag), never decide it, and the service still refuses. Keep hidden (condition) what makes no sense in the record's state, row actions and More-menu items that would crowd every row or the menu, phone and terminal-only compact screens, and links into an app the user does not have.
  • Ends and deletes use btn-type="danger" and a confirmation that names the record. Activate, publish and generate confirm too.
  • Landing screens use number-cards in a dashboard, each linking to a filtered list, shortcut buttons with one primary, and an empty state that offers the first steps (Create, Import). The screens an app home features are nav-cards in a dashboard: an icon, a title, one line of text and up to three child links.
  • Tabs use subscreens-panel type="tab" (or subscreens-menu type="tab" with subscreens-active inside a tab) with an explicit menu-index on each item, in the design's order.
  • Do not wrap one button in a box. A box whose body is a single dialog button belongs in the header's actions or in the box-toolbar of the box it acts on (Add component on the Draft changes box).
  • Hide empty boxes with a section condition, and show an empty state where the user needs to know why there is nothing ("This product has no manufacturing method yet. Start one with New method.").
  • "Not available" states link back to the list.

Lists

  • Phone columns on every list a phone sees: columns type="mobile" with two columns. The first holds the record link and its name; the second the amount or state and the row actions. Products' first pass gave many lists only an ID and a state, so phone users could not see a product's name or a price's amount.
  • The first column is the record link.
  • Names, not IDs: display-entity (mantle.party.PartyDetail with text="PartyNameTemplate", moqui.basic.Enumeration, moqui.basic.Uom, moqui.basic.StatusItem), or a *Name/*Text the service returns.
  • Amounts with currency-unit-field and align="right"; quantities with display format="#,##0.###" and align="right".
  • States as chips: a render-mode with a qvt text <q-chip dense square class="q-ma-none m-tonal text-${color}"> and a tui text built with JSON.stringify. A tui text must be JSON produced by JSON.stringify({t: "text", text: ...}), never JSON with ${} pasted into it.
  • Row actions in the row (style-guide §4.4): inline container-dialogs for the common actions (Schedule, Correct, End), and a "More" menu for the rest; not a box of per-row forms below the list.
  • Bulk actions are row-selection actions on the list, not a separate screen where the user types IDs.
  • paginate long lists; select-columns on main lists.
  • Pagination comes from the service. A list a service pages returns its <list>PageIndex, PageSize, PageMaxIndex, PageRangeLow and PageRangeHigh (ProductsLib.page, Accounting's find#Records). A short, bounded list (a preview's findings, an audit trail, a document's lines) is paginate="false". Never set the page fields by hand to fake one page: Accounting P2 had sixty such lines.
  • A row action's dialog id carries the row's key (EditLine_${acctgTransEntrySeqId}); a fixed id repeats on every row.

Inputs

  • Choose records with server-search drop-downs: drop-down with dynamic-options transition="choices" server-search="true" min-length="0", through the shared choices transition, which also returns the label of the selected value. No text inputs for IDs, and no drop-downs that load every record. The choices service is a table of named sources, like an operations table: each finds its authorized rows, searches its fields in the query (§4), and reads a selected value outside the page on its own; an unknown choice throws. A spec calls every choice once with a selected value that is not in the page.
  • Closed lists (languages, currencies, units, types) are drop-downs from the server's options.
  • Wording: dialog titles and buttons in the user's words, saying what they do ("Edit category membership", "Review price changes"), not form names. Hints go in tooltip, not in the field title ("Through", not "Through (exclusive)"). Option labels are words, not code tokens (financialType). Titles in sentence case.
  • No implementation words in the UI: "phase", "later", "scheduled", "placeholder". An area that is not built is left out of the menu, and its page says what it is not yet, in the user's terms.
  • Group related fields with field-layout, field-row and field-row-big; a wide dialog uses two columns.

Hygiene

  • The XML declaration, the component's full license header (copy it from a neighboring file; a one-line "See LICENSE.md" is not it) and a final newline in every file; one element per line; 4-space indentation. A rewrite of a placeholder keeps its header and its section's menu-image.
  • Lint every changed screen (moqui lint --screens with a report file) and keep its idiom count from growing.

6. Vue single-file screens (.qvue)

  • Use one only when the XML widgets cannot express the screen (the variant builder's matrix, a board or calendar beyond view-board/view-calendar). Prefer extending a widget (style-guide §8.1) when several screens need it.
  • A .qvue sits beside an XML screen that declares render-modes and server-static, and keeps its transitions, parameters and authorization in that XML. It has a tui twin: a <Name>.tui.json beside it (usually one component node registered by name, as the gallery's Board.tui.json), or a separate XML screen (VariantBuilderTui.xml).
  • Use the m-* inputs and the shell's feedback (moqui.notifyMessages, a $q.dialog confirm) so it looks and behaves like the XML screens: one primary button at a time, a count in the confirmation of a bulk action, result boxes only when there are results.
  • The gallery's Board.qvue, Calendar.qvue and QuickTask.qvue (runtime/components/dev/example/screen/Gallery/) are the patterns.

7. Tests

There are two suites (The two suites, the testing skill): the regression suite (test/), small rule tests run while working and before every commit, and the acceptance suite (test/acceptance/), complete scenarios run on a schedule, before a release or when asked. Say which suite a new test goes in, and why. Regression tests check rules, not pages: write one for a business rule you add or change (its result and its refusals) and for a bug you fix. What to run before a commit, by what changed, is the pre-commit skill: ./moq test-apps for application work, and the Rust checks as well when the change reaches a crate.

Server specs (test/*.spec.js)

  • Each expression statement directly in then or expect is a condition. A comparison inside an if, a loop or a helper function is not checked. Products' first shots specs had their page checks in if blocks, and those checks never ran (F46). Use assert(condition, message) for a nested check, or compute a problem string and compare it at the top level.
  • No full walks. No regression spec walks every screen of an app or of all apps, or renders every screen in every mode; these have been deleted before and keep coming back. Rendering as such is the framework's (its goldens and moqui lint --screens); a sweep is an acceptance test, one per app per mode. A screen is rendered at most once in each mode across the regression suite, and that one render carries all of its checks (content, access, a value that must not show). Render a screen in a second mode only where the modes differ, that is, where it has its own qvt or tui template (.qvue, .tui.json, a render-mode section); say which template the check covers. A screen whose content depends on data needs a check text present whatever the data.
  • A widget that fails renders its error into the output, not into errorMessages: a check of status 200 and no error messages passes a broken page. Check the output for Error rendering and Exception in render, and check a text the page shows. List rows are in the html render; a qvt render needs withStaticData() and the app root with lastStandalone: "-2", and a chip that has only qvt and tui texts is in neither html nor print.
  • Access is checked per rule, not per service or route. An access rule gets one holder and one non-holder on one verb of the rule, and another organization's record refused, in the app's one access spec (about seven features, with authorization on; no where: doubling of authorization on and off). An access or isolation walk over every route and group is an acceptance test. The negative case must fail for the permission: use the same parameters as a positive case that succeeds, or compare a reason code. A helper that counts any error as a refusal passes on a validation error (Accounting's store#DraftEntry without its fields was "refused" for everyone).
  • A spec of a control's absence also checks its presence for a user who has it: Accounting checked that readers do not see "New batch", a button that was named "New journal batch".
  • Spec helpers an app's specs share (sign in as a user, the demo record ids) go in one place, not a copy in each spec; four copies of Accounting's demo ids disagreed about an account.
  • A spec line that begins with ( or [ continues the line before it (no semicolons): compute the value in when and compare it in then.
  • A Mantle spec creates its own data and does not depend on BOSS.
  • Run the specs of the screens and services you touched while working (./moq test <component> --spec ...), and ./moq test-apps before a commit. Run an acceptance test only when the user asks, or when you add or change one.
  • Keep a spec fast. A regression spec runs in well under a second as a rule; one over 15 seconds fails the run, and a component over 1.5 times its budget (test/budget) fails it too (The regression budget). Cut duplicates or move the scenario to acceptance rather than raise the budget, which needs the user's agreement.
  • A test earns its place by the regression it catches. Do not add a feature that repeats another with a different user, mode or flag (where: both doubling, every role of a group) unless that difference is the rule under test.

Client specs (test/client/*.spec.js)

  • No screenshot specs. A spec asserts what a page shows; it does not save images that no one compares or looks at. To look at a screen, take a screenshot while working (the browser tools, or page.screenshot in a spec run by hand) and do not keep it in the suite. A failed browser feature still writes its own failed-*.png for debugging. A phone-width (390 px) check is an acceptance test; a theme is checked only where a feature depends on it.
  • Open the browser pages in setupSpec, one per user and width. Module variables are not shared between cases.
  • Walks. The regression suite has one golden-path client walk per app (test/client/), kept current. Every other walk is an acceptance test (test/acceptance/client/): a plan's "usable when" scenario, server side through the screens' transitions or in a browser, a phone-width check, an access or isolation walk. A walk has a user with only the needed grants, every click a user makes, and an assertion of the result.
  • Click what the user clicks. A menu item that holds a dialog or link is a q-item around a button: click the button (.q-menu button, .q-menu a), not the q-item, which does nothing (F43 was this test mistake). Scope a header menu to its own actions container: a 360 screen has more than one "More".
  • Find rows by the record they show (a link with the record's id), not by position.
  • Do not run client specs while editing the screens they cover: the run loads the spec files at its start and the screens as they change.
  • A client failure that also fails at the commit before your change (for example a PDF without Chromium) is recorded as such, not "fixed" by changing the test.

8. Formatting and mechanical changes

  • JavaScript (service scripts and specs) is formatted with Prettier, used as a one-off tool, not a dependency, with the repository's .prettierrc.json: {"semi": false, "tabWidth": 4, "printWidth": 130, "bracketSpacing": false, "trailingComma": "none", "arrowParens": "avoid", "singleQuote": false} with --parser babel. Prettier finds the file from the formatted file's directory; Prettier run with its defaults (width 80, { a }, trailing commas) is the wrong style, as Accounting P1–P3's scripts and specs were. Spec conditions are found by syntax, so formatting a spec is safe. After formatting a service script, check that its module value is still the last expression.
  • XML: only XMLLINT_INDENT=" " xmllint --format, then confirm with a canonical comparison (xmllint --c14n of both versions with blank text removed) that only whitespace changed before replacing the file. Another formatter writes " /> and reorders attributes.
  • Scripted edits assert that each old text is present exactly once before replacing it; a replacement that matched nothing looks like a passing change. Re-indent a moved block to its new depth.
  • Commit per phase and per repository, with the tests run named in the record (plan/impl-<app>.md).

9. Checklist before calling a phase done

  • Business rules in Mantle with Mantle specs; the app keeps access, context and settings; no pass-throughs.
  • Access checked in services from permissions; restricted values left out of answers; out-parameters declared.
  • Scripts: one module per area, named functions, the shared library, bounded queries, failure tolerance per item.
  • No hard-coded currency, unit or language; dates in the user's zone; amounts rounded to their currency.
  • Screens follow their archetype: record header, one primary, More menu, danger and confirmation on ends.
  • Every list has phone columns with name and amount or state, names not IDs, amounts with currency, states as chips.
  • Records chosen with server-search drop-downs; no typed IDs.
  • Empty boxes hidden, empty states explained, user wording in titles and buttons.
  • tui texts built with JSON.stringify.
  • Every detail screen has the record header and a not-available state; every ending, bulk or irreversible action confirms, naming the record or the count.
  • Screens that differ by record kind share a template; each screen declares only the parameters it reads.
  • Mantle's services used or extended, not rebuilt beside them; service implementations in inline XML Actions, script modules only for complex logic; no caller-name guards, no self-guarding EECAs, nothing for tests in production files.
  • The phase's regression tests for the rules it added pass, ./moq test-apps passes within budget, and moqui lint --screens has no new idiom sites. The plan's "usable when" scenarios are acceptance tests to write, named in the plan; running them is not part of done.
  • A mechanical pass over the changed files:
    • isInGroup( in a service or script;
    • PageRangeHigh set in a screen;
    • toISOString in a script or spec;
    • getStackNameString, ec.user.randomString for an id, ec.context.putAll(ec.resource.script(, and a component://.../test/ location in a service/ or entity/ file;
    • like without ignoreCase, and a limit before a JavaScript filter;
    • a form whose transition is not on its screen;
    • more than one type="primary"/btn-type="primary" on a screen at a time;
    • " /> and the one-line license header in XML, and a long parameter-map or expression that could be named once in actions (report options, a record's link parameters);
    • Prettier with the repository's config shows no change.
  • The design and implementation records updated: what was built, the commits, the findings, and what is left for later.
  • What the phase made reachable is recorded in the attack surface map, in the application's file: Attack-Surface-Apps-BOSS for mr-boss and the Mantle services staff reach, Attack-Surface-Apps-PASS and its two companion files (Commerce, and Forum and Smithy) for mr-pass and the Mantle services its operations reach. A framework hook the phase added goes in that area's framework file (index), never in the index. Commands in a record name no machine's paths (/Applications/..., /tmp/...): point to Build-Test for the Chromium setting, and to a report file of the reader's choosing.