Protect route drafts and refine keyboard, responsive, and primary button behavior. Add CURD workspace examples with tests and bilingual documentation.
14 KiB
CURD interaction conventions
Use these conventions when adding or changing business lists and record workflows in Ray Template. Keep short actions close to the list, give work that needs independent access or more space a dedicated page, and return users to a predictable place when the task ends. Create, Edit, and Detail each have an action container and can share the same layout.
Try the runnable examples for a short tag form and a routed project workflow with milestones.
Choose the surface
| Surface | Choose it when | Examples |
|---|---|---|
| Dedicated page | The task needs its own URL for direct access, refresh, sharing, or browser history. Also use it for multistep flows, long or wide content, and editing related records or working across sections. | Configure a project, manage an order with line items, open a linked record from a notification. |
| Drawer | A row-level task benefits from keeping its place in the list and fits in a single side-panel flow. Use it by default for list-bound detail previews and for short edits where the surrounding list provides context. | Preview a member's details or update a record's basic settings. |
| Modal | A brief, focused task needs the user's attention and fits comfortably in one view at the intended sizes. Use it for confirmations and short forms that need little source context. | Create a tag, rename a record, confirm deletion. |
| Inline or split view | Use inline for a small, local change that is easy to reverse. Use a split view when the user needs to interact with the list and record at the same time. | Toggle a reversible preference, inspect several rows in a master–detail view. |
Check for a dedicated-page requirement first. A modal drawer preserves visual context and blocks interaction with the background. Use the same surface for Create and Edit when their workflows are comparable. A drawer preview can offer a link to the full Detail page. Carbon form variants
Start and finish in context
- Put Create in the list toolbar. Give each record a clear Detail entry, such as a linked name for a route or a View button for a drawer. Place Edit and less frequent actions in the row action area. Put destructive actions in its overflow menu when space or prominence calls for it.
- Use distinct verbs for different outcomes. Create makes a new record, Add attaches an existing one, Save changes applies an edit, Cancel exits a form, and Close dismisses a read-only overlay. Use an object name in the title or confirmation when it helps identify the target. Carbon common actions
- When Edit starts from Detail, return to Detail on cancel or after a successful save. If both fit in a drawer, replace its Detail content with the Edit container and reuse the same drawer. When editing needs a page, navigate to its route. After a save, show the updated record.
- For Create or Edit launched from the list, return to the same list context on cancel or save. Preserve the applied filters, sort, page, and scroll position as far as the updated results allow. Open the saved record's Detail when the user has a clear next step there. Keep a successful save visible through feedback even when the current filter excludes the saved record.
- Return focus to an overlay's opener. If the opener is gone, focus a logical surviving row or the list toolbar. After deleting a record from its Detail page, return to the list. WAI-ARIA modal dialog pattern
Compose the action containers
The surface renders the title, content, and actions, manages scrolling, and forwards close requests. The action container owns record identity, access checks, data loading and mapping, the write command, and the destination after saving or cancelling. A shared editor owns the working draft, field validation, and the submit interaction. Expose its dirty and pending state to the action container for exit checks.
| Container | Data and behavior | Visible actions |
|---|---|---|
| Create | Initialize a fresh draft from defaults and explicit context, such as the current department. Bind the create command. | Create, Cancel |
| Edit | Load the record by ID, capture its revision when supported, and map the response into a fresh draft. Bind the update command to that ID and revision. | Save changes, Cancel |
| Detail | Load by ID and render readable values, labels, and sections with a description component. Offer Edit only when permitted and applicable. | Back on a page or Close in an overlay, plus Edit when available |
Each project action container can render the same workspace, whether users enter from a route or a list action.
ProjectCreate → ProjectWorkspace → ProjectEditor (defaults, create command)
ProjectEdit → ProjectWorkspace → ProjectEditor (mapped record, bound update command)
ProjectDetail → ProjectWorkspace → ProjectDescription (record)
Select the action container at the route or overlay entry point. A single page can select it from local action state such as { kind: 'edit', id }. Let the container supply the title, button copy, permissions, and action-specific fields. The shared editor receives initial values, validation rules, and a save function. Compose separate field groups when Create and Edit diverge. Share labels, section layout, and value formatters between editor and Detail. Keep the containers feature-local and extract shared pieces once their contracts match across consumers.
Reuse AppPageHeader for route pages, RModal or Naive UI's NModal for modal content, NDrawer with NDrawerContent for drawers, RForm with useForm for editors, and NDescriptions for labelled values. Import shared components from their feature entry points. Add interface copy in Simplified Chinese and English. UI entry points · Locale resources
Routes and state ownership
- Use distinct named routes for independent entries, such as
/projects,/projects/new,/projects/:id, and/projects/:id/edit. Reserve action segments such asnewfrom the ID namespace. Open routes inside the current browser tab by default. Register the views and usehiddenorsameLevelas appropriate for parameterized pages. Choose the menu, workspace tab, breadcrumbs, and cache behavior together. Routing contract - Load routed Detail and Edit from their URL identity so direct entry and reload work. Local overlays open from the list or detail page and use local state. Use an ID and the necessary shareable view state in the URL. Fetch record content through the feature API. Reset or reload when the active ID changes, including in reused route views. Vue Router route parameters
- For a page, return to the known in-app origin or use the feature's named fallback on direct entry. The fallback is the list for Create and Detail, and Detail for Edit when accessible. Use the list if Detail is unavailable. After saving, return through known history or replace the completed editing location so browser Back reaches a meaningful page.
- Keep editor routes uncached by default. Make draft retention across workspace tabs an explicit workflow decision. Let the list own its query and selection. Encode the shareable part in route query parameters when needed and account for the shell's full-URL view keys. Clear selection when the page or applied query changes unless the feature explicitly supports cross-page selection with a visible scope and count. Shell view keys
List and detail states
- Distinguish initial loading, an empty dataset, zero search matches, and load failure. Offer Create on an empty dataset when permitted, clear filters for zero matches, and a retry for failed reads. Detail and Edit also need states for a missing record and denied access. Show content and enable writes for the current, loaded record. Use list rows for summaries and IDs, and load the complete record for an editor.
- Hide actions the user lacks permission to perform. If an otherwise available action is blocked by the record's state, give an accessible reason. Enforce authorization on the server for each read and write, including direct links and batch targets.
Editing and saving
- Start each session or record change with its own draft and baseline. Determine whether the draft is dirty by comparing editable values with that baseline. Keep draft mutations local to the editor. Cancel superseded reads where supported and let only the current session's results update the editor.
- Use one submit path for keyboard and button actions. Mark required fields, use visible labels, and validate on submit or after interacting with a field. Show actionable errors near their fields and focus the first invalid control or error summary on failed submission. Map the draft to a typed API input and validate it on the server as well.
- Allow one submission at a time. Show progress on the primary action and guard repeated triggers while the write is pending. Display field errors by the affected inputs and other save failures within the editor. Preserve the draft on failure. For a revision conflict, offer a way to review the latest data before resubmitting. If a timeout leaves the outcome unknown, reconcile the result or use the API's supported idempotent retry.
- Show success after the write is confirmed. Use the saved response or re-fetch the changed record. On a remote list, call the
RTableProinstance'sreload()to preserve the current page. It handles a page that goes out of range after deletion. Usereload(true)for an intentional return to page one. If refreshing fails after a successful write, report the refresh failure and offer a refresh retry. TablePro contract - Use the same exit check for Cancel, close, Escape, navigation, and record changes. Allow clean exits directly. For dirty drafts, offer Keep editing and Discard changes. Keep the editor in place while saving and make the pending state visible. Use route leave and update guards as applicable for page editors, and include any workspace controls that refresh or close the current editor. Vue Router navigation guards
Delete and batch actions
- Use a confirmation modal for irreversible or consequential deletion and for batch deletion. Identify the record or count, state the effect on related data when relevant, and label the destructive action Delete. Focus the least destructive action first and disable accidental backdrop dismissal for the confirmation. Direct deletion is reserved for low-impact actions with a reliable undo. Carbon common actions · WAI-ARIA initial focus guidance
- Confirm and submit a snapshot of the selected IDs. Show pending feedback, refresh after confirmed changes, and remove successful targets from the selection. When the API reports partial success, report the succeeded and failed counts, keep failed eligible targets identifiable for retry, and retry only those targets. Start with current-page selection and support cross-page or all-matching selection only when its scope is explicit in both the UI and API.
Overlay and responsive behavior
- Give modal surfaces an accessible name and a visible exit. On open, focus the first field for a short editor or a heading for long read-only content. Keep keyboard focus inside modal surfaces. Use one record overlay at a time. Its own confirmation may temporarily take focus and return it to the overlay when dismissed. WAI-ARIA modal dialog pattern
- Disable backdrop dismissal on editing overlays. Give the body one scroll area when content overflows and keep the actions reachable. Let drawers use the viewport width on narrow screens while preserving the same draft and exit behavior. Use semantic theme tokens and shell dimensions for any custom styling. UI styling contract
Verify a CURD flow
- Exercise the intended list entry, permissions, loading and empty states, Create, Detail, Edit, and Delete as applicable. Check success, failure, dirty cancellation, rapid record changes, and duplicate submit protection on the affected flows.
- For a page, check direct entry, reload, Back, and return to the previous list query. For an overlay, check keyboard focus, Escape, narrow-screen scrolling, and access to actions. For bulk operations, check selection scope and the reported result.
Select the affected paths and dimensions using Harness verification.