UNPKG

@eclipse-scout/core

Version:
144 lines 6.77 kB
/// <reference types="jquery" /> import { ChildModelOf, InitModelOf, LookupCallModel, LookupResult, LookupRow, ObjectType, ObjectWithType, QueryBy, Session, SomeRequired } from '../index'; /** * Base class for lookup calls. A concrete implementation of LookupCall which uses resources over a network * must deal with I/O errors and set, in case of an error, the 'exception' property on the returned lookup result. * The lookup call must _always_ return a result, otherwise the SmartField cannot work properly. */ export declare class LookupCall<TKey> implements LookupCallModel<TKey>, ObjectWithType { model: LookupCallModel<TKey>; initModel: SomeRequired<this['model'], 'session'>; objectType: string; session: Session; hierarchical: boolean; loadIncremental: boolean; batch: boolean; queryBy: QueryBy; searchText: string; key: TKey; keys: TKey[]; parentKey: TKey; active: boolean; maxRowCount: number; constructor(); init(model: InitModelOf<this>): void; protected _init(model: InitModelOf<this>): void; setLoadIncremental(loadIncremental: boolean): void; setHierarchical(hierarchical: boolean): void; setBatch(batch: boolean): void; /** * @param maxRowCount - a positive number, _not_ null or undefined! */ setMaxRowCount(maxRowCount: number): void; /** * This method may be called directly on any {@link LookupCall}. For the key lookup an internal clone is created automatically. * * You should not override this function. Instead override {@link _textByKey}. * * @returns a promise which returns a text of the lookup row resolved by {@link getByKey}. */ textByKey(key: TKey): JQuery.Promise<string>; /** * Override this function to provide your own textByKey implementation. * * @returns a promise which returns a text of the lookup row resolved by {@link getByKey}. */ protected _textByKey(key: TKey): JQuery.Promise<string>; /** * This method may be called directly on any {@link LookupCall}. For the keys lookup an internal clone is created automatically. * * You should not override this function. Instead override {@link _textsByKeys}. * * @returns A promise which returns an object that maps every {@link LookupRow} key to the text of the resolved {@link LookupRow}. */ textsByKeys(keys: TKey[]): JQuery.Promise<Record<string, string>>; /** * Override this function to provide your own textsByKeys implementation. * * * @returns A promise which returns an object that maps every {@link LookupRow} key to the text of the resolved {@link LookupRow}. */ protected _textsByKeys(keys: TKey[]): JQuery.Promise<Record<string, string>>; /** * Only call this function if this LookupCall is not used again. Otherwise, use {@link cloneForAll().execute()} or {@link clone().getAll()}. * * You should not override this function. Instead override {@link _getAll}. */ getAll(): JQuery.Promise<LookupResult<TKey>>; /** * Override this method to implement. */ protected _getAll(): JQuery.Promise<LookupResult<TKey>>; /** * Only call this function if this {@link LookupCall} is not used again. Otherwise, use {@link cloneForText(text).execute()} or {@link clone().getByText(text)}. * * You should not override this function. Instead override {@link _getByText}. */ getByText(text: string): JQuery.Promise<LookupResult<TKey>>; /** * Override this method to implement. */ protected _getByText(text: string): JQuery.Promise<LookupResult<TKey>>; /** * Only call this function if this {@link LookupCall} is not used again. Otherwise, use {@link cloneForKey(key).execute()} or {@link clone().getByKey(parentKey)}. * * You should not override this function. Instead override {@link _getByKey}. */ getByKey(key: TKey): JQuery.Promise<LookupResult<TKey>>; /** * Override this method to implement. */ protected _getByKey(key: TKey): JQuery.Promise<LookupResult<TKey>>; /** * Only call this function if this {@link LookupCall} is not used again. Otherwise, use {@link cloneForKeys(keys).execute()} or {@link clone().getByKeys(keys)}. * * You should not override this function. Instead override {@link _getByKeys}. */ getByKeys(keys: TKey[]): JQuery.Promise<LookupResult<TKey>>; /** * Override this method to implement. */ protected _getByKeys(keys: TKey[]): JQuery.Promise<LookupResult<TKey>>; /** * Only call this function if this {@link LookupCall} is not used again. Otherwise, use {@link cloneForRec(parentKey).execute()} or {@link clone().getByRec(parentKey)}. * * You should not override this function. Instead override {@link _getByRec}. * * Returns a result with lookup rows for the given parent key. This is used for incremental lookups. * * @param parentKey references the parent key */ getByRec(parentKey: TKey): JQuery.Promise<LookupResult<TKey>>; protected _emptyRecResult(rec: TKey): JQuery.Promise<LookupResult<TKey>>; /** * Override this method to implement. */ protected _getByRec(rec: TKey): JQuery.Promise<LookupResult<TKey>>; /** * Executes this LookupCall. For this method to work this LookupCall must be a clone created with one of the following methods: * {@link cloneForAll()}, {@link cloneForText(text)}, {@link cloneForKey(key)}, {@link cloneForRec(parentKey)} */ execute(): JQuery.Promise<LookupResult<TKey>>; /** * @param properties Properties to add to the resulting clone instance. */ clone(properties?: object): this; cloneForAll(): this; cloneForText(text: string): this; cloneForKey(key: TKey): this; cloneForKeys(keys: TKey[]): this; cloneForRec(parentKey: TKey): this; abort(): void; /** * Creates a lookup result with the given lookup rows. If the lookup call fails, an error message (exception) should be passed. * * Can be used by concrete lookup calls if needed. */ protected _createLookupResult(lookupRows: LookupRow<TKey>[], exception?: string): LookupResult<TKey>; static ensure<TKey, TLookupCall extends LookupCall<TKey>>(lookupCall: LookupCallOrModel<TKey, TLookupCall>, session: Session): TLookupCall; static firstLookupRow<K>(result: LookupResult<K>): LookupRow<K>; } /** * A LookupCall, a LookupCallModel or a string with a LookupCall class name. */ export type LookupCallOrModel<TKey, TLookupCall extends LookupCall<TKey> = LookupCall<TKey>> = TLookupCall | ChildModelOf<TLookupCall> | ObjectType<TLookupCall>; //# sourceMappingURL=LookupCall.d.ts.map