Parsware
All articles

Model-driven apps

Tidy command bars

A command bar can use your organisation's words and follow the order people work in. Rename the platform's own commands, hide the ones a list doesn't need, drag everything into place, and divide it into groups.

An asset list in dark mode whose command bar reads Record a purchase, Due for review, then a divider, Edit, Delete and Refresh, next to the title "Tidy command bars"

Every list starts with the same bar. That's a good default, but it's not always what people call things, and it's not always the order they work in. Here is the Purchases view of an Asset table, as the platform draws it:

The Assets list's command bar: New, Import data, Edit, Delete and Refresh

The people using this list record new purchases and check which assets are due for review. They never import a spreadsheet here. So we'll:

  1. rename New to Record a purchase,
  2. hide Import data,
  3. add a Due for review button beside it,
  4. and put a divider between those two and the commands that act on ticked rows.

The Asset table is in our own unmanaged solution, and you can do the same on any table of yours. Every picture is the real product.

The strip holds every command

Open the view in the View Designer. The Commands strip shows the whole bar: the platform's commands with a dashed outline, and your own with a solid one. You can select any of them.

Rename one

Select New and type into Label:

The Commands strip with the New chip selected and now reading Record a purchase, and the Properties panel showing Comes from The platform, Label, Icon No icon, Starts hidden and Starts disabled

Comes from: The platform says what you can change on a built-in command: its words, its icon, where it sits and how it starts. What it does stays the platform's.

Leave Label empty to use the platform's own word. That word is translated, so an empty label reads New in English, جدید in Persian and جديد in Arabic, with nothing for you to maintain. Once you type a word, that word is shown in every language.

Hide one

Select Import data and tick Starts hidden:

The Import data chip faded with an eye-slash glyph, and its properties with Starts hidden ticked

The chip fades and picks up an eye-slash glyph. It stays in the strip, because that's where you'd turn it back on. Starts disabled greys a command out instead.

"Starts" matters. This is the state the bar opens in, and a business rule or a command's own script can show it again later. It is not a permission. A command someone must never use is taken away on their security role, where the server enforces it. Hiding it on the bar only tidies the screen.

Your settings add to what the platform already does. The bar hides New from someone who may not create records and greys out Delete until a row is ticked, and unticking Starts disabled can't undo that.

Add yours, and drag it into place

Add command puts a new chip at the end of the strip. We called it Due for review, gave it an icon, and set When pressed to Open a view on the table's Due for Review view:

The new Due for review command selected: Label Due for review, Type Button, Placement Action bar, When pressed Open a view, Table This table, View Due for Review

Now drag it. The platform's commands and yours are one list, so you can put your button between any two of them. Drop it onto Edit and it goes before Edit. With the keyboard: Tab to a chip, Space to pick it up, the arrow keys to move it, and Space again to drop it.

Add separator adds a divider chip. Drag it onto Edit as well:

The finished strip: Pin, Record a purchase, Import data faded, Due for review, a separator, Edit, Delete and Refresh

A separator is only a line. It has no label and no action, and it only goes in the bar, never in the ⋯ menu. The bar drops a separator that would divide nothing: one at the start, one at the end, or the second of two in a row. So a divider you placed next to Delete simply disappears for someone who can't delete, instead of hanging off the end of their bar.

The result

Save the view and open the app:

The Assets list's command bar after saving: Record a purchase, Due for review, a divider, then Edit, Delete and Refresh

While writing this we found that the designer and the app disagreed about where Import data sits. The designer showed it after Delete; the app drew it right after New. A command dragged next to it in the designer could land somewhere else in the app. Both now read the order from the same list, with Import data beside New.

What the view stores

The tidied Purchases bar is three lists in the view's document, and each holds only what you changed:

{
  "logicalName": "con_asset_purchases",
  "commandOverrides": [
    { "command": "new", "label": "Record a purchase" },
    { "command": "import", "initiallyHidden": true }
  ],
  "actions": [
    { "id": "act-due-for-review", "label": "Due for review", "icon": "CalendarClock", "kind": "button",
      "placement": "bar", "run": { "kind": "OpenView", "view": "con_asset_dueforreview" } },
    { "id": "act-sep-1", "kind": "separator", "placement": "bar" }
  ],
  "commandOrder": ["new", "import", "act-due-for-review", "act-sep-1", "edit", "delete", "refresh"]
}
  • commandOverrides changes the platform's own commands, by their fixed ids: new, import, edit, delete, refresh, and on forms save, saveAndClose, activate and deactivate. The id never changes, so an override can't come loose when somebody renames a label.
  • actions are your own commands, as in Buttons that do something.
  • commandOrder is the one order of both, by id. A command it doesn't mention, such as one the platform adds next year, keeps its natural place at the end rather than vanishing.

Hiding is not removing

The rule behind every setting on this page: a maker may hide and disable, never show or enable. The bar already hides New from somebody who can't create records and greys out Delete until a row is ticked, and nothing in a view can undo that. Your settings narrow the bar further; they can't make it offer something the server would refuse.

So there are two different tools, and it matters which one you reach for:

You want Use Who enforces it
A tidier bar for people who don't need a command Starts hidden on the view or form Nobody: it is presentation
A command nobody in a group may use Remove the permission from their security role The server, on every request

If Import data is hidden only because the purchasing team never imports, Starts hidden is right. If the purchasing team must never import, take Create on the table away from them, and Import data, which needs it, disappears by itself. Security roles in practice shows how.

Commands that follow a record's state

On a form, a platform command can be limited to some of the table's states. The order form in one of the platform's sample solutions offers Delete only while an order is still a draft:

"commandOverrides": [
  { "command": "delete", "states": [0] },
  { "command": "deactivate", "initiallyHidden": true }
]

"states": [0] means only in state 0, the first state, which is where a draft order sits. Once the order is submitted, Delete is gone from its form. This is presentation too: the record's own rules still decide what may be written. But it saves people from offering a button that would only lead to a refusal. States and reasons explains the numbers.

Your own commands can do the same, with states on the action, so a Submit button shows only on drafts and a Reopen button only on closed records.

Words in every language

A platform command you haven't renamed reads in the person's own language: New, جدید, جديد. That is worth keeping wherever you can, because the moment you type a label, that exact word is shown in every language. For an application used in more than one language, rename only where the platform's word is genuinely wrong for the job, and choose words your other languages' readers will understand. Building for more than one language discusses the trade-off.

A tidy bar, table by table

What a bar needs depends on what people do with the table. A few typical shapes:

Table Keep Rename Hide Add
Purchases (assets) New, Edit, Delete, Refresh New → Record a purchase Import data Due for review
Reference data (countries, rates) Edit, Refresh New, Delete, Import data
Support tickets New, Edit, Refresh New → Log a ticket Delete Urgent only
Orders, on the form Save Delete except on drafts Submit, Print delivery note

The reference-data row deserves a comment. When a table is maintained by a solution's seed data or by one team, hiding New and Delete on the everyday view stops casual edits, and the team that owns the data keeps a view of its own with everything on it.

The order people expect

Whatever you add, the platform keeps one convention across every bar: the primary command first, then the other commands, then the destructive ones, then your own. On a list the primary command is New; on a form, Save. Keep your most important custom command near the start of your own group, and put anything that deletes or cancels after the others, so nobody presses it by mistake while reaching for something else.

What's stored

Only what you changed. A bar you never rearranged stores no order, so when the platform adds a command later, it appears in its natural place. A bar you did arrange keeps your order, and a new command goes at the end, where you can drag it.

The same strip is on a form, in the Form Designer, with Save and Save & Close as the platform's commands.

Next: a dashboard in an app.