Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UIObject

Represents a object used to customize the application layout.

Can be used for menus, forms, items in lists etc.

You can change propeties on the UIObject and it's fields to dynamicaly control the Application Layout.

This is done by intercepting the 'RecalculateUIObject' event, and modifying the UIObject found on the data.UIObject.

example

pepperi.events.intercept('RecalculateUIObject', {
    UIObject: {
        context: {
            Name: 'UserHomePage' // intercept events that data.UIObject.context.Name === 'UserHomePage'
        }
    }
}, async (data) => {
    // randomly hide fields in the home screen for fun
    for (const field of data.UIObject?.fields ?? []) {
        field.visible = Math.random() < 0.5;
    }
})

Hierarchy

  • UIObject

Accessors

backgroundColor

  • get backgroundColor(): string
  • set backgroundColor(value: string): void
  • If the UIObject is mark as {@link UIObject.highlighted | highlighted} - this property defines the color in hexadecimal eg. #A5EBFF (The blue color for campaign item in the cart)

    Returns string

  • If the UIObject is mark as {@link UIObject.highlighted | highlighted} - this property defines the color in hexadecimal eg. #A5EBFF (The blue color for campaign item in the cart)

    Parameters

    • value: string

    Returns void

context

  • Get the UIObject dataView context.

    info

    This is substantially faster than calling dataView.Context

    Returns DataViewContext

dataObject

  • Get the UIObject's dataObject This will return undefined for UIObject that don't have a dataObject (eg. UserHomePage)

    Returns undefined | DataObject

dataView

  • Get the UIObject dataView

    Returns DataView

fields

  • Get the UIObject fields.

    Returns UIField[]

key

  • get key(): string
  • The UIObject Key

    Returns string

readonly

  • get readonly(): boolean
  • set readonly(value: boolean): void
  • Should the UIObject be editable

    info

    if this returns true, then the readonly field on each UIField is irrelevant

    Returns boolean

  • Should the UIObject be editable

    Parameters

    • value: boolean

    Returns void

Methods

getField

  • getField(fieldID: string): Promise<undefined | UIField>
  • Get UIField by FieldID

    Parameters

    • fieldID: string

      the FieldID of the UIField you want to get

    Returns Promise<undefined | UIField>

    the UIFeild or undefined if none such exists

recalculate

  • recalculate(): Promise<void>
  • Recalculate the UIObject

    This passes over all the UIField's and sets their values from the DataObject.

    Emits the RecalculateUIObject event

    Returns Promise<void>

reloadDataObject

  • reloadDataObject(): Promise<void>
  • Reload the dataObject from the DB Only applies to changes that haven't been saved to the DB yet

    Returns Promise<void>

setFieldValue

  • setFieldValue(fieldID: string, value: string, save?: boolean): Promise<undefined | UIField>
  • Set a field's value

    This is different than setting the field value directly on the dataObject using DataObject.setFieldValue because this function involves the application logic.

    For example: if {@link Field.readonly | readonly} is true, the set will not work (no error is thrown). Additionaly if this field is not customized on the UIObject the set will not work (on error is thrown - undefined will be returned)

    Parameters

    • fieldID: string

      The field ID

    • value: string

      The value to set

    • save: boolean = true

      Should the object be saved in the DB, if set to true UIObject.reloadDataObject will not undo this change

    Returns Promise<undefined | UIField>

    The field or undefined if it is not customized

toJSON

  • toJSON(): object
  • Override the toJSON function This will be called when calling JSON.stringify function

    Returns object

    • DataObject: any
    • DataView: DataView
    • Fields: object[]
    • Key: string
    • Readonly: boolean

Static Create

Generated using TypeDoc