Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DataInstanceStore<T>

Retrieves an entity instance using Generic REST API.

Type parameters

  • T

    entity type.

Hierarchy

  • DataInstanceStore

Implements

Index

Constructors

constructor

  • new DataInstanceStore(mainStore: MainStore, entityName: string, viewName?: string, stringIdName?: undefined | string): DataInstanceStore

Properties

changedItems

changedItems: IObservableArray<never> = observable([])
inheritdoc

entityName

entityName: string

Optional item

item: T & Partial<SerializedEntityProps> & WithId

Retrieved entity instance.

Optional lastError

inheritdoc

Private mainStore

mainStore: MainStore

status

status: DataContainerStatus = "CLEAN"
inheritdoc

Optional stringIdName

stringIdName: undefined | string

Name of the ID attribute of a String ID entity. Mandatory for String ID entities, shall be omitted otherwise.

viewName

viewName: string

Name of the view used to limit the entity graph.

Methods

commit

  • commit(commitMode?: CommitMode): Promise<Partial<T>>
  • Sends a request to the REST API to persist the changes made to the item.

    Parameters

    • Optional commitMode: CommitMode

      see update

    Returns Promise<Partial<T>>

    a promise that resolves to the update result returned by the REST API.

getFieldValues

  • getFieldValues(properties: string[]): Partial<object>
  • Transforms the item into the format expected by Ant Design Form fields.

    Parameters

    • properties: string[]

      entity properties that should be included in the result.

    Returns Partial<object>

    entity instance transformed into the format expected by Ant Design Form fields.

load

  • load(id: string): void
  • Retrieves an entity instance using the given id and view by sending a request to the REST API.

    Parameters

    • id: string

      id of an entity instance to be retrieved.

    Returns void

setItem

  • setItem(item: this["item"]): void

setItemToFormFields

  • setItemToFormFields(formFields: Partial<T>): void
  • Sets the item based on provided values of Ant Design Form fields.

    Parameters

    • formFields: Partial<T>

      a object representing the values of Ant Design Form fields.

    Returns void

update

  • update(entityPatch: Record<string, any>, commitMode?: CommitMode): Promise<any>
  • Updates the item using a provided entityPatch, then sends a request to the REST API to persist the changes.

    Parameters

    • entityPatch: Record<string, any>

      a Partial representing the changes to be made.

    • Optional commitMode: CommitMode

      'create' when creating a new entity or 'edit' when editing an existing one. Different REST API endpoints and HTTP methods will be used depending on whether the entity is new. IMPORTANT: If this parameter is omitted, then the entity will be considered new if it lacks the id attribute. This will produce incorrect results for String ID entities. Therefore using this parameter is mandatory for String ID entities.

    Returns Promise<any>

    a promise that resolves to the update result returned by the REST API.

Generated using TypeDoc