///
import { IComponentController } from 'angular';
/** A single entry in a metadata schema. */
export interface MetadataDefinition {
description?: string;
endpoint?: string;
enum?: (string | {
id: string;
label: string;
})[];
format: 'color' | 'date-time' | 'dropdown' | 'password' | 'lookup' | 'multiline' | 'tag' | 'unit-list' | null;
isArray?: boolean;
isGenAIPopulated?: boolean;
label: string;
lookupCallback?: (field: string, term: string) => ng.IPromise;
name: string;
objectDefinition?: MetadataDefinition[];
placeholder?: string;
readOnly?: boolean;
required: boolean;
type: 'boolean' | 'date' | 'datetime' | 'int' | 'object' | 'string';
}
/** A match returned by api query against a lookup field. */
export interface MetadataFieldRecord {
id: string;
name: string;
[key: string]: any;
}
export default class MetadataFormController implements IComponentController {
private $element;
private $http;
private $timeout;
private translateFactory;
/** Whether the first field in the form should be auto-focused. */
autoFocus: boolean;
/** Whether the component should show toggles for bulk editing. */
isBulkEdit: boolean;
/** Whether the entire form should be disabled. */
isDisabled: boolean;
/** The actual key/value pairs to display in the controls. */
metadata: {
[key: string]: any;
};
/** Called when any field value changes. Not implemented for DTZ picker. */
onChange?: (change: {
[key: string]: any;
}) => void;
/** The metadata schema describing what type of controls to render in the form. */
schema: MetadataDefinition[];
/** Key/boolean pairs indicating whether a field should be enabled for bulk editing. */
bulkEnabled: {
[key: string]: boolean;
};
/** Collection of validation forms; each field in the metadata form has one. */
forms: {
[key: string]: ng.IFormController;
};
/** Stores ng-model values for lookup fields */
lookupName: {
[key: string]: any;
};
/** Indicates which lookup fields are currently loading */
lookupLoading: {
[key: string]: boolean;
};
addAnotherText: string;
changeText: string;
leaveUnchangedText: string;
noText: string;
yesText: string;
constructor($element: ng.IAugmentedJQuery, $http: ng.IHttpService, $timeout: ng.ITimeoutService, translateFactory: any);
$onChanges(changes: {
metadata: ng.IChangesObject>;
}): void;
$onInit(): void;
addArrayMetadata(property: MetadataDefinition): void;
addTagFromAutoComplete(value: {
[key: string]: unknown;
}, origin: string): void;
/**
* Passes changes from the child components up to the parent and handles
* internal transforms for the array and object models.
*/
change(value: any): void;
changeBulkEditBool(name: string, value: boolean): void;
enableField(name: string): void;
disableField(name: string): void;
getFieldForAttribute(schemaField: MetadataDefinition): string;
inputClick(name: string): void;
initLookup(property: MetadataDefinition, value: string): void;
lookupFieldValue(property: MetadataDefinition, term?: string): import("angular").IPromise;
/** Used for tag lookups to pass to auto-complete-match-renderer. */
tagLookupFieldValue(input: string, origin: string): import("angular").IPromise;
removeArrayMetadata(property: MetadataDefinition, index: number): void;
selectLookupRecord(name: string, record: MetadataFieldRecord): void;
private setFocusInField;
}