UI Element Visibility Control

Overview

The shortToFullMap mechanism provides a flexible way to control the visibility of UI elements through URL parameters, allowing both short and full identifiers for precise element hiding.

The parameter removes buttons from the top toolbar, entries from the Shape menu, the events column in the pricing modes and the canvas context menu. An action whose tool is hidden also leaves the context menu and the selection actions on the canvas: ?hidden=seatRows, for example, removes Add Rows and Duplicate for sections.

The canvas bar (the Layers menu with its Show check boxes for seats and the other layers, the View menu, snapping and the level filter), the buttons at the bottom right of the canvas, the Structure and Inspector tabs and the Properties panel are not controlled by the parameter.

menu

Key Components

shortToFullMap

A mapping object that translates short identifiers to their full, canonical names for UI elements.

const shortToFullMap: Record<string, string> = {
  schema: 'mode.schema',
  visual: 'mode.visual',
  edit: 'mode.edit',
  pricingZones: 'mode.pricingZones',
  pricing: 'mode.pricing',
  section: 'mode.section',

  select: 'tool.select',
  seatRows: 'tool.seatRows',
  table: 'tool.table',
  roundTable: 'tool.roundTable',

  shape: 'tool.shape',
  rect: 'tool.shape.rect',
  circle: 'tool.shape.circle',
  line: 'tool.shape.line',
  polygon: 'tool.shape.polygon',
  exit: 'tool.shape.exit',
  stairs: 'tool.shape.stairs',

  label: 'tool.label',
  selectSeats: 'tool.selectSeats',
  selectRows: 'tool.selectRows',
  addSeat: 'tool.addSeat',
  numberSeats: 'tool.numberSeats',
  selectSections: 'tool.selectSections',
  underlay: 'tool.underlay',
  venueShape: 'tool.venueShape',
  viewbox: 'tool.viewbox',
  binding: 'tool.binding',
  inspector: 'tool.inspector',
  events: 'tool.events',
  save: 'tool.save',
  contextMenu: 'tool.contextMenu',
};

Mapping Categories

Mode Elements

Control the two mode buttons at the left of the toolbar:

  • edit: Edit button
  • pricing: Prices button

The identifiers schema, visual, section and pricingZones are still accepted but match no control, so they hide nothing. The editor now switches between the layers of the map in the Layers menu on the canvas bar, and between pricing and pricing zones in the bar at the bottom of the canvas in the pricing modes.

Tool Elements

Control the tools in the toolbar:

  • select: Select tool
  • seatRows: Seat Rows tool
  • table: Table tool
  • roundTable: Round Table tool
  • shape: Shape menu and all its drawing tools
    • rect: Rectangle shape
    • circle: Circle shape
    • line: Line drawing
    • polygon: Polygon drawing
    • exit: Exit, in the Venue elements gallery of the Shape menu
    • stairs: Stairs, in the Venue elements gallery of the Shape menu

Additional Tools

  • label: Label tool
  • selectSeats: Select Seats tool
  • selectRows: Select Rows tool
  • addSeat: Add Seat tool
  • numberSeats: Number Seats tool
  • selectSections: Select Sections tool in the pricing modes
  • binding: Binding tool on the Venue artwork layer
  • inspector: the button at the right of the toolbar, labeled Layers, that opens the Inspector tab. The Structure and Inspector tabs and the I key stay available
  • events: Events button, events column in Pricing mode and the preview modal event tabs
  • save: Save button
  • contextMenu: the canvas context menu

The Combine and References buttons have no short identifier. Hide them with the full identifiers tool.combineSections and tool.references.

The identifiers underlay, venueShape and viewbox are still accepted but match no control. The Venue artwork layer, the venue shape and the view area are edited from the Layers menu, the Structure tab and the Crop frame button.

Utility Functions

isHidden(title: string, hiddenItems: string[]): boolean

Determines whether a specific UI element should be hidden based on provided parameters.

Parameters

  • title: Full identifier of the UI element (e.g., ‘mode.pricing’)
  • hiddenItems: Array of items to potentially hide

Example

const hiddenItems = ['pricing', 'select'];

getHiddenItemsFromURL(): string[]

Extracts hidden items directly from the current page’s URL query string.

Return Value

An array of item identifiers to be hidden.

Example URL

https://example.com/app?hidden=pricing,select,label

Usage Scenarios

URL-Based Element Hiding

  • Control UI element visibility by adding a hidden parameter to the URL.

Supported Formats

  • Short Identifiers: ?hidden=pricing,select
  • Full Identifiers: ?hidden=mode.pricing,tool.select
  • Mixed Identifiers: ?hidden=pricing,tool.select

Example URLs

  • Hide pricing and selection tools:
    • /app/venues/42/schemas/295?hidden=pricing,select
  • Hide specific shape tools:
    • /app/design?hidden=line,polygon
  • Remove the canvas context menu:
    • /app/venues/42/schemas/295?hidden=contextMenu

Best Practices

  • Use consistent naming in shortToFullMap
  • Prefer full identifiers for clarity
  • Validate and sanitize URL parameters
  • Handle cases where identifiers might not exist in the map

Advanced Configuration

  • Extend the shortToFullMap to include more UI elements as your application grows.

Potential Improvements

  • Add type safety with a predefined enum of allowed identifiers
  • Implement more sophisticated visibility logic
  • Add logging or debugging tools

Security Considerations

  • Sanitize URL parameters
  • Validate incoming hidden item lists
  • Prevent potential abuse of the hiding mechanism

Type a feature, setting, endpoint or SDK method.