@eclipse-scout/core
Version:
Eclipse Scout runtime
90 lines • 3.94 kB
TypeScript
/// <reference types="jquery" />
import { AjaxCall, DoEntity, LookupCall, LookupResult, LookupRow, RestLookupCallModel } from '../index';
import Deferred = JQuery.Deferred;
/**
* A lookup call that can load lookup rows from a REST service.
*
* API:
* ----
* By default, the REST service is expected to listen for POST requests at the URL defined by
* this.resourceUrl. It receives a restriction object and must return a list of matching lookup rows.
* The serialization format is JSON.
*
* Lookup rows:
* ------------
* The standard lookup row properties defined by Scout are usually sufficient (see AbstractLookupRowDo.java).
*
* Restriction:
* ------------
* The restriction object consists of a number of 'well-known' properties (e.g. 'text' in {@link QueryBy.TEXT}
* mode, see AbstractLookupRestrictionDo.java for details) and additional, service-dependent properties
* that can either be predefined in the model or added programmatically at runtime. Since all of those
* properties are sent in the same restriction object, some care must be taken to prevent accidental
* overwriting of properties.
*
* Order of precedence (lowest to highest):
* 1. Restrictions automatically applied to all clones after their creation in the respective cloneFor method.
* These are: 'active' (ALL, TEXT, REC) and 'maxRowCount' (ALL, TEXT, REC)
* 2. Restrictions predefined in the model property 'restriction', shared by all clones.
* 3. Restrictions applied to clones programmatically, e.g. during a 'prepareLookupCall' event.
* 4. Hard-coded properties that are fundamental to the respective queryBy mode (cannot be overridden).
* These are: 'ids' (KEY, KEYS) and 'text' (TEXT)
*/
export declare class RestLookupCall<TKey> extends LookupCall<TKey> implements RestLookupCallModel<TKey> {
model: RestLookupCallModel<TKey>;
resourceUrl: string;
maxTextLength: number;
restriction: Record<string, any>;
protected _restriction: Record<string, any>;
protected _ajaxCall: AjaxCall;
protected _deferred: Deferred<LookupResult<TKey>, {
abort: boolean;
}>;
constructor();
/**
* Use this function with caution! Added restrictions will be shared among cloned instances
* and the current instance if this function was also called before cloning!
*/
addRestriction(key: string, value: any): void;
/**
* Adds the given key-value pair to 'this._restriction', but only if there is no predefined
* value for this key in 'this.restriction'. This prevents unintentional overriding of
* user-defined model restrictions.
*/
protected _addRestrictionIfAbsent(key: string, value: any): void;
protected _getAll(): JQuery.Promise<LookupResult<TKey>>;
protected _getByText(text: string): JQuery.Promise<LookupResult<TKey>>;
protected _getByKey(key: TKey): JQuery.Promise<LookupResult<TKey>>;
protected _getByKeys(keys: TKey[]): JQuery.Promise<LookupResult<TKey>>;
cloneForAll(): this;
cloneForText(text: string): this;
cloneForRec(parentKey: TKey): this;
protected _acceptLookupRow(lookupRowDo: LookupRowDo<TKey>): boolean;
protected _createLookupRowFromDo(lookupRowDo: LookupRowDo<TKey>): LookupRow<TKey>;
protected _call(): JQuery.Promise<LookupResult<TKey>>;
abort(): void;
protected _getCallUrl(): string;
protected _getRestrictionForAjaxCall(): Record<string, any>;
protected _createAjaxCall(): AjaxCall;
}
/**
* @see "AbstractLookupRowDo.java"
*/
export interface LookupRowDo<Key> extends DoEntity {
id: Key;
parentId: Key;
text: string;
tooltipText: string;
enabled: boolean;
active: boolean;
iconId: string;
cssClass: string;
additionalTableRowData: any;
}
/**
* @see "LookupResponse.java"
*/
export interface LookupResponse<TLookupRow = LookupRowDo<any>> extends DoEntity {
rows: TLookupRow[];
}
//# sourceMappingURL=RestLookupCall.d.ts.map