File

src/ui/lookup/services/smart-lookup-binding.service.ts

Description

Component-scoped service that holds the lookup binding context and value-resolution helpers consumed by SmartLookupComponent. Provided per-component via providers: [SmartLookupBindingService] so each lookup instance has its own state.

Index

Properties
Methods

Methods

getModelField
getModelField()

Returns the lookup field whose value mirrors smartModel. Display side when the binding is the display side, value side when bound to the value side. Used both to read the model value from a record and to filter the datasource by it.

Returns : string
isBoundToValueField
isBoundToValueField()

True when the bound viewer field corresponds to the value side of the lookup (i.e. keyValueField or its alternate binding) rather than the display side. Used by restore/sync logic that needs to decide between keyValueModel and smartModel as the source of truth.

Returns : boolean
readBoundFieldValue
readBoundFieldValue(record: any, field: string)

Reads a value from a lookup record honoring the same fallbacks the legacy syncBoundFieldValuesFromData used: direct property, _.get for dotted paths, then last-token short-name on the record.

Parameters :
Name Type Optional
record any No
field string No
Returns : any
resolveDisplayValueAfterSelection
resolveDisplayValueAfterSelection(selected: any, datasourceSelected: any, fallback: any)

Resolves the text written to the Kendo input after key-value navigation (selectByKeyValue).

Parameters :
Name Type Optional Description
selected any No
  • the parent viewer-bound record.
datasourceSelected any No
  • the lookup datasource's selected row.
fallback any No
Returns : string
resolveInputDisplayText
resolveInputDisplayText(sourceSelection: any, selected: any, fallback: any)

Resolves the text written to the Kendo input after a live selection synchronization (autocomplete, dialog OK).

Parameters :
Name Type Optional Description
sourceSelection any No
  • the freshly selected lookup record.
selected any No
  • the parent viewer-bound record.
fallback any No
  • last-resort value (typically smartModel).
Returns : any
resolveKeyValueModel
resolveKeyValueModel(sourceSelection: any, fallback?: any)

Resolves the value to assign to keyValueModel from a record. Differs from resolveModelValue only in that an explicit 0 / empty string from the record is preferred over the fallback.

Parameters :
Name Type Optional
sourceSelection any No
fallback any Yes
Returns : any
resolveModelValue
resolveModelValue(sourceSelection: any, fallback?: any)

Resolves the value to assign to smartModel from a record. The bound viewer field dictates which lookup field provides the value: when the binding is the value side (keyValueField / keyValueFieldBinding) the model tracks the value field; otherwise it tracks the display field. This preserves the legacy modelValueField semantics used by display-bound lookups such as ManagerUserName (display=UserName, value=UserGuid).

Parameters :
Name Type Optional
sourceSelection any No
fallback any Yes
Returns : any
resolveRestoreDisplayText
resolveRestoreDisplayText(selected: any, fallback: any, displayFallback?: any)

Resolves the text written to the Kendo input when restoring after cancel / no autocomplete match. Falls back to the previous model value supplied by the caller.

Parameters :
Name Type Optional
selected any No
fallback any No
displayFallback any Yes
Returns : string
resolveViewerFieldReference
resolveViewerFieldReference(fieldName: string, viewerFields: T[])
Type parameters :
  • T

Locates a viewer field by exact or short-name match. Mirrors the old SmartLookupComponent.getViewerFieldReference helper.

Parameters :
Name Type Optional
fieldName string No
viewerFields T[] No
Returns : T | undefined
setInputs
setInputs(inputs: SmartLookupBindingInputs)

Push the latest input values into the service. Only the keys present on inputs are updated, so callers can update a single field without resetting the others.

Parameters :
Name Type Optional
inputs SmartLookupBindingInputs No
Returns : void

Properties

Readonly context
Type : Signal<LookupBindingContext>
Default value : computed(() => { const tokens = (this._name() || '').split('.'); const boundFieldName = this.resolveBoundFieldName(tokens); const keyField = this._keyField(); const keyValueField = this._keyValueField(); const keyValueFieldBinding = this._keyValueFieldBinding(); return { boundFieldName, displayField: keyField || keyValueField, effectiveKeyValueField: keyValueField || keyField, keyValueFieldBinding }; })

Reactive lookup binding context. Recomputes whenever any of the underlying inputs (name, keyField, keyValueField, keyValueFieldBinding) change.

results matching ""

    No results matching ""