OPX//77
opx_infinitypanel

Client

Last updated on

The panel contract on the client — open, patch, fill and close the drawer.

local panel = OPX.Api.Get('panel')

From client code inside opx_infinity. Every function answers a Result. None yields. Messages written before the page is ready are queued (max 256), then sent once it reports ready.

Open

Opens a panel from a spec. An unknown field refuses it (unknown_field).

panel.Open(spec)

Parameters

Returns

  • Result — { handle, id }; panel_busy if another owner's panel is open, unless spec.steal = true
Example
local opened = panel.Open({
  owner = 'mymodule', id = 'stock', title = 'STOCK', search = true,
  actions = { { id = 'buy', label = 'Buy', primary = true } },
  on = function(p)
    if p.action == 'select' then panel.Update(p.handle, { selected = { [p.tab] = p.item } }) end
  end,
})
if opened.ok then panel.Append(opened.value.handle, { { id = 'a', label = 'Item A' } }, true) end

Close

Closes it; the callback gets close with reason.

panel.Close(handle, reason)

Parameters

  • handle: integer
  • reason?: string
    • Default caller, max 32 characters.

Returns

  • Result — true

Update

Changes any patchable field. selected is merged per tab.

panel.Update(handle, patch)

Parameters

  • handle?: integer
    • nil targets the open panel; an old handle answers stale_handle.
  • patch: table
    • Patchable fields, plus clearItems = true to empty the item list first.

Returns

  • Result — true

Append

Adds items. An item with an existing id replaces it. Large batches are split to fit the host's 1024-node payload limit.

panel.Append(handle, items, done)

Parameters

  • handle?: integer
  • items: table[]
    • Up to 200 per call, 5000 per panel.
  • done?: boolean
    • true ends the loading state.

Returns

  • Result — true

Confirm

Shows a confirm dialog. The answer arrives as a confirm action.

panel.Confirm(handle, question)

Parameters

  • handle?: integer
  • question: table|false|nil
    • { id, title?, text?, yes?, no? } — title max 60, text max 240, buttons max 40. nil or false withdraws it.

Returns

  • Result — true
Example
panel.Confirm(handle, { id = 'buy', title = 'Buy it?', text = '250 eddies' })

State

Whether a panel is open, and whose.

panel.State()

Returns

  • Result
    • { open = false }
    • or { open, handle, owner, id, tab, items, busy, dialog } — items is the item count

The panel spec

Spec-only fields (cannot be patched):

FieldTypeMeaning
ownerstringRequired. Your module id, max 64. Closes with owner_stopped if that module stops.
idstringRequired. Panel id, max 64, echoed as payload.panel.
onfunctionRequired. on(payload) for every action.
hoverbooleanReport hover/leave on items. Default false.
dismiss'close' or 'ask'Escape on the page: close closes; ask raises a dismiss action and leaves the panel open. Default close.
columns1 or 2Item columns. Default COLUMNS.
stealbooleanReplace another owner's panel.

Patchable fields

Allowed in Open and Update.

FieldShapeMeaning
eyebrow, title, subtitlestring (max 60, 60, 40)Header text.
introstring (max 240)Paragraph under the header.
tabslist of { id, label, marked?, disabled? }, max 12Tab strip.
tabstringThe active tab id.
searchtrue, string, or falseShow the search box (string = initial text). Absent at open = no search box.
summary{ label, value, action? }A summary plate; action is one button.
actionslist of buttons, max 4The commit row.
toolslist of buttons, max 8Buttons that adjust the view.
groupslist of buttons, max 8Other screens reachable from this one.
sliderslist of { id, label, count, index, value?, disabled? }, max 12Ranges the caller owns. index is 0..count; 0 means "none". Replaces the item column with the rail.
tiles{ slot, from, entries, labels?, images? }A window of up to 60 names for the picture grid of slider slot, starting at position from. See below.
selected{ [tabId] = itemId or false }The selected item per tab.
statusstring, or { text, kind = 'info'/'error' }Status line, max 160.
busybooleanWhile true, select, slide and button clicks are ignored.
loadingbooleanShows the loading label.
labelstableOverrides the words count, empty, loading, search, nothing, confirmYes, confirmNo.
clearItemsbooleanUpdate only.
  • A button is { id, label, icon?, primary?, disabled? }: id max 64, label max 40, icon a name from OPX.Glyphs.
  • tiles.entries are the keys of the boxes (record names). labels (optional) is the caption under each box; images (optional) the picture in it: a bare file name under the page's images/clothing/ (letters, digits, _, -, .; at most 64 characters), never a path.
  • labels and images are parallel to entries and must have the same length, or the whole tiles is refused (invalid_tiles). '' means no caption or no picture; with no caption the box shows the entry name.

Items

FieldMeaning
idRequired, max 160 characters, no control characters.
labelRequired, max 80.
tabTab id the item belongs to.
detailSecond line, max 120.
disabledDrawn greyed.

The action payload

on(payload) and opx:on:panel:action receive { panel, handle, owner, action, … } plus:

actionExtra fieldsRaised when
selectitem, tabAn item was clicked (not while busy). The page does not select it itself: send selected back.
hover, leaveitem, tab / nonePointer over an item, with hover = true.
tabtabA tab was clicked.
actionidAn actions, tools, groups or summary button was clicked (not while busy).
slideid, index, commitA slider moved; commit = false is a preview, true the release.
tilesslot, fromThe grid wants the window starting at from. Answer with Update({ tiles = … }).
confirmitem, valueThe dialog item was answered; value is true for yes.
dismissnoneEscape with dismiss = 'ask'.
closereasoncaller, dismissed, pause, reopened, superseded, owner_stopped, player_down, stopped.

The pause key behaves like Escape: with dismiss = 'ask' it raises dismiss and leaves the panel open (a dialog up swallows it); otherwise it closes with reason pause.

On this page