import {
ActionNavigation,
Link,
MultiSelectAction,
Resource,
} from "../../components/hal/hal";
import { Selectors } from "../../components/app-context/api";
import { Attribute } from "../../components/edit-attribute";
export interface Result extends Resource {
description?: string;
identifier?: string;
_actions?: {
links: ActionNavigation[];
};
}
export interface ResultResource extends Resource {
total?: number;
_embedded?: {
products: Result[];
};
_actions?: {
multiSelect: MultiSelectAction;
};
_links?: {
custom: Link;
};
}
export interface Column {
/**
* Column identifier
*/
field?: string;
/**
* Column parent, if present
*/
parent?: string;
/**
* Label for column header
*/
header: string;
/**
* Enables/Disables adding a prefix to the column header dynamically
*/
dynamicHeader?: boolean;
/**
* Column width value, will be evaluated in px (e.g 250)
*/
width: number | string;
/**
* Enables/Disables column filtering @default(false)
*/
filter?: boolean;
/**
* Column cells css class name in case column has no type or has an unsupported type
*/
name?: string;
/**
* Column type,
* currently defined types: "attribute", "widget", "boolean", "datetime", "link",
* "main-asset", "chip", "chiplist", "selector", "expander",
* "hal-actions", "interactions", "actions-and-interactions"
*/
type?: string;
/**
* Image size in case column has type "main-asset"
*/
"asset-size"?: string;
/**
* Hides/Shows image placeholder in case column has type "main-asset"
*/
hideAssetPlaceholder?: boolean;
/**
* Redirection url in case column has type "link",
* It can access any of the other columns values,
* and be used like this in the url {column-field-value}
*/
linkTemplate?: string;
/**
* Redirection link type, needed to correctly re-route the link.
* Using "internal" type will redirect the link relative to the current path.
* Can only be used in case column has type "link".
*/
linkType?: string;
/**
* Date format in case column has type "datetime"
*/
dateFormat?: string;
/**
* Tooltip date format in case column has type "datetime" @default("yyyy-MM-dd HH:mm:ss")
*/
tooltipDateFormat?: string;
/**
* Minimum column width
*/
minWidth?: number | string;
/**
* Maximum column width
*/
maxWidth?: number | string;
/**
* Enables/Disables column sorting @default(false)
*/
sortable?: boolean;
/**
* Pins/Unpins column @default(false)
*/
pinned?: boolean;
/**
* Hides/Shows column @default(false)
*/
hidden?: boolean;
/**
* Enables/Disables column editing @default(false)
*/
editable?: boolean;
/**
* Enables/Disables column grouping @default(false)
*/
groupable?: boolean;
/**
* Enables/Disables emitting cell data when it's edited @default(false)
*/
externalEditing?: boolean;
/**
* Disables/Enables column hiding @default(true)
*/
disableHiding?: boolean;
/**
* Filtering type
*/
"filter-type"?: "contains" | undefined;
/**
* Interactions that should be shown in the corresponding cell,
* needed to look up interactions in the browserContext,
* in case column has type "hal-actions", "interactions" or "actions-and-interactions"
*/
selectors?: Selectors;
/**
* Column order
*/
order?: number;
/**
* Locales map needed to update the dynamic columns headers that are shown for the table based on the selected locale.
*/
locales?: Map<string, string>;
/**
* Hides/Shows column pin icon @default(false)
*/
hidePin?: boolean;
/**
* Enables/Disables grid summary functionality per-column @default(false)
*/
hasSummary?: boolean;
/**
* Enables/Disables using customized summaries, instead of using the grid default summaries,
* both of which depend on the dataType of the column @default(false)
*/
customSummary?: boolean;
/**
* Data type of the column values
*/
dataType?: string;
/**
* Map used to set conditional css class selectors for data-list cells,
* using the css class selector as the key and a callback method identifier as the value.
* The callback method should return a boolean result and should be registered to "CellClassesCallbackRegistry" in widget.module.
* by default it already handles marking the headers of mandatory descriptions columns using this callback method "default-mandatory-attribute"
*/
cellClasses?: { [key: string]: string };
/**
* CSS class selector for column headers, can only be used when "inlineFilter" mode is enabled.
*/
headerStyle?: string;
/**
* Makes column mandatory or optional @default(false)
*/
mandatory?: boolean;
/**
* Makes column visibility configurable @default(false)
*/
visibilityConfigurable?: boolean;
/**
* Key of the column entry
*/
[key: string]: any;
/**
* "data-list-tree"-cell value is draggable @default(false)
*/
draggable?: boolean;
/**
* "data-list-tree" if draggable only tree leaves are draggable @default(false)
*/
onlyLeavesDraggable?: boolean;
/**
* cells in the column droppable/non-droppable @default(true)
*/
allowDrop?: boolean;
/**
* Enables/Disables column auto-sizing @default(false)
*/
autosize?: boolean;
/**
* Editing layout. It is used for attribute types : ['TYPE_TEXT' and 'META'].
* its possible values are : ['list' , 'textarea', 'dialog']. @default('list')
*/
editLayout?: string;
}
export type ColumnMap = { [column: string]: Column };
export interface DataListHeaderGroup {
/**
* Label for the header
*/
header?: string;
/**
* Parent of the header group, if present
*/
parent?: string;
/**
* Header group number, used for sorting
*/
order?: number;
/**
* Header group identifier,
* needed for identifying which column field to render and for sorting in case of it's a parent
*/
identifier?: any;
}
export interface DataListConfiguration {
/**
* Data-list identifier
*/
identifier?: string;
/**
* Data-list title
*/
title?: string;
/**
* List of static columns to be rendered in data-list
*/
columns?: Column[];
/**
* Deprecated: feature is now removed.
* List of data-list groups headers
*/
headers?: DataListHeaderGroup[];
/**
* Unique property key, needed to differentiate between data-list rows
*/
primaryKey?: string;
/**
* Property key, needed to get data from response
*/
dataType?: string;
/**
* CSS class selector for header component @default("primary")
*/
header?: string;
/**
* Shows/Hides the panel header @default(true)
*/
withHeader?: boolean;
/**
* Shows/Hides the border of the panel frame @default(true)
*/
withBorder?: boolean;
/**
* Adds the text in the help icon
*/
infoText?: string;
/**
* Adds the title to the text provided by the help icon
*/
infoTitle?: string;
/**
* Set autofocus on the field
*/
focusFreeTextSearch?: boolean;
/**
* Adds the link to the wiki page explaining the functionality of the content
*/
wikiLink?: string;
/**
* Deprecated: feature is now removed.
* Enables/Disables expanding/collapsing data-list panel vertically @default(false)
*/
isCollapsible?: boolean;
/**
* Deprecated: feature is now removed.
* Enables/Disables expanding/collapsing data-list panel horizontally @default(false)
*/
isSideCollapsible?: boolean;
/**
* Mode used for loading data, for eager loading use "eager",
* otherwise it will be set to lazy loading @default("eager")
*/
loadingMode?: string;
/**
* Url used to get data for "Attributes" dialog
*/
attributeUrl?: string;
/**
* Property key needed to get data from the "attributeUrl" response
*/
attributesDataType?: string;
/**
* The configuration for the filter selection dropdown used in "Attributes" dialog.
* Use an empty object (ie: {}) in order for the dropdown to be removed
*/
selectFilterParams?: SelectFilterParams;
/**
* List of property keys used to set additional information text for the attributes in the "Attributes" dialog @default(["type", "group"])
*/
selectAttributeAdditionalProperties?: string[];
/**
* Configures the maximum number of selectable attributes
*
* @default(100)
*/
selectAttributeMaxAttributes?: number;
/**
* Fallback to use, when the user explicitly removes all attributes from the dialog
*
* @default(null)
*/
selectAttributeEmptySelection?: Attribute[];
/**
* Shows/Hides the restrict to category button in the select-attributes dialog @default(false)
*/
showRestrictToCategoryButton?: boolean;
/**
* The url used to fetch/update attribute-profiles, if null no profile selection/update will be enabled
*/
profileUrl?: string;
/**
* Enables/Disables running the "restrict to category" action when the "Attributes" dialog is opened @default(false)
*/
restrictAttributesToCategoryOnAttributeDialogOpen?: boolean;
/**
* The local storage entry identifier, needed to save currently shown attributes
*/
localStorageShownAttributes?: string;
/**
* Url used to get dynamic columns on data-list initialization,
* should be embedded using type "attributes" in response
*/
dynamicColumnLink?: string;
/**
* Shows/Hides maintenance levels selection dropdown @default(false)
*/
maintenanceLevelSelection?: boolean;
/**
* Url used to get maintenance levels to be shown in maintenance levels selection dropdown,
* otherwise the default defined url will be used
*/
maintenanceLevelLink?: string;
/**
* Shows/Hides language selection dropdown @default(false)
*/
languageSelection?: boolean;
/**
* Url used to get languages to be shown in languages selection dropdown,
* otherwise the default defined url will be used
*/
languageSelectionUrl?: string;
/**
* Property key used to get the value from the response,
* to be set as the option value for the languages selection dropdown @default("id")
*/
languageSelectorValueProperty?: string;
/**
* Shows/Hides view mode selection dropdown @default(false)
*/
viewModeSelection?: boolean;
/**
* List of options to be shown in the view mode selection dropdown
*/
viewModeOptions?: ViewModeOption[];
/**
* Enables/Disables handling view mode change using the backend @default(false)
*/
handleViewModeInBackend?: boolean;
/**
* Hides/Shows reset table state button, used to clear currently applied filters and sorting state @default(false)
*/
removeAllFiltersButton?: boolean;
/**
* Deprecated: feature is now removed.
* List of row properties keys to be emitted with the edited rows output in "metadata" entry.
*/
metadataKeys?: string[];
/**
* Enables/Disables emitting the "rowData" entry with the selected rows output,
* that contains the complete row's data @default(false)
*/
emitSelectedItems?: boolean;
/**
* Enables/Disables rows selection @default(true)
*/
rowSelectable?: boolean;
/**
* Sets rows selection mode, possible values "single" or "multiple"
* can only be used when "rowSelectable" property is enabled @default("multiple")
*/
rowSelectionMode?: string;
/**
* Sets data-list height
*/
tableHeight?: number;
/**
* Enables/Disables row editting mode, otherwise cell editting mode is used @default(false)
*/
rowEditable?: boolean;
/**
* List of grouping configurations used to group the data based on a column or a combination of columns
*/
groupingExpressions?: GroupingExpression[];
/**
* List of dataTypes option, dataTypes selection dropdown,
* will only be shown when dataTypeMode is set to "choose" @default([])
*/
availableDataTypes?: string[];
/**
* The dataType to be selected initially by default, when there is no previous selection stored
*/
initialDataType?: string;
/**
* Set to true, to get columns defined in response,
* otherwise alternatively "Attributes" dialog can be used to add dynamic columns @default(false)
*/
dynamicColumnsFromData?: boolean;
/**
* Defines how dynamic columns are added to the existing statically configured columns list,
* "concat" is the default behaviour and simply adds all dynamic columns to the end,
* "unique" will only add columns, that have _not_ been defined in the static configuration
*/
dynamicColumnsMode?: "concat" | "unique";
/**
* A Map containing the list of columns defined for each dataType with the dataType as the key,
* used along with "columns" property, needed when using multiple dataTypes with different columns
*/
dataTypeColumns?: { [key: string]: Column[] };
/**
* Enables/Disables grouping of data @default(true)
*/
groupingEnabled?: boolean;
/**
* Enables/Disables showing seconds for "date" or "datetime" values @default(false)
*/
ignoreSeconds?: boolean;
/**
* Field that is used to get the productNo out of the data.
* Needed for knowing which products are rendered in the table,
* which is needed to reduce the category attributes to the ones viable for the products in the list
*/
productNumberField?: string;
/**
* Enables/Disables highlighting "readonly" fields with gray background and and overlayed icon @default(true)
*/
highlightReadOnly?: boolean;
/**
* Enables/Disables prompting the user for confirmation in case of unsaved changes,
* if set to true it automatically ignores unsaved changes @default(false)
*/
reloadWithUnsavedChanges?: boolean;
/**
* Set display density for data-list, available options are: "comfortable", "cosy" and "compact" @default("comfortable")
*/
density?: string;
/**
* Enables/Disables rendering the rows count after the data-list title @default(true)
*/
renderCount?: boolean;
/**
* List of column sorting configurations to be used for sorting the data
*/
sortBy?: SortBy[];
/**
* Map used to set conditional css class selectors for column headers,
* using the css class selector as the key and a callback method identifier as the value.
* The callback method should return a boolean result and should be registered to "HeaderClassesCallbackRegistry" in widget.module.
* by default it already handles marking the headers of columns with mandatory attributes using this callback method "default-mandatory-attribute"
*/
headerClasses?: { [key: string]: string };
/**
* Shows/Hides data-list when "uri" to load the data is changed @default(true)
*/
showTableOnLinkInput?: boolean;
/**
* Enables/Disables clearing the currently applied filters and sorting state when reset is triggered @default(true)
*/
clearSortingAndFilteringOnReset?: boolean;
/**
* Label used for the mode toggle-slider
*/
toggleButtonLabel?: string;
/**
* Link used for redirection when the row is clicked in tile mode
*/
tileRedirectLink?: string;
/**
* Name of the field that shows in the tile view as the tile identifier
*/
tileIdentifierField?: string;
/**
* Enables/Disables overriding the row click event redirection in tile mode and emit the row data instead @default(false)
*/
overrideTileClickEvent?: boolean;
/**
* Sets table width @default("100%")
*/
tableWidth?: any;
/**
* Height specified for the frame when in tile view mode, used to adjust the tile height @default(270)
*/
frameHeight?: number;
/**
* Enables/Disables adjusting data-list height relative to the number of rows @default(false)
*/
tableHeightRelativeToRows?: boolean;
/**
* Sets the table height by configuring the number of visible rows
*/
tableHeightVisibleRows?: number;
/**
* Shows/Hides data-list filter field @default(true)
*/
globalFilterInput?: boolean;
/**
* Disables/Enables context menu button action @default(false)
*/
disableContextMenu?: boolean;
/**
* Enables/Disables rows selection when cell is clicked,
* can only be used when "rowSelectable" property is disabled @default(true)
*/
cellSelectable?: boolean;
/**
* Enables/Disables getting a number of rows (the number should be the same as the currently viewed rows, if "pageLimitPerScroll" property is not set),
* opposed to just getting the next row when using lazy loading mode @default(false)
*/
getNextPageOnLazyLoad?: boolean;
/**
* Limit for number rows loaded on scroll action when using lazy loading mode
*/
pageLimitPerScroll?: number;
/**
* Limit for number rows loaded when using eager loading mode, if not set it gets "ALL" by default.
*/
eagerLimit?: number;
/**
* Enables/Disables row pinning @default(false)
*/
rowPinningEnabled?: boolean;
/**
* Sets data-list filter mode,
* available options are: "quickFilter", "excelStyleFilter" or "inlineFilter" @default("excelStyleFilter")
*/
filterMode?: string;
/**
* Enables/Disables relaoding the data-list when dataType is changed @default(true)
*/
reloadOnDataTypeChange?: boolean;
/**
* Url used to export data-list data
*/
exportPath?: string;
/**
* Enables/Disables adding a prefix to the data-list title dynamically @default(false)
*/
dynamicTitle?: boolean;
/**
* List of sorting configurations used to sort the data-list, using a single column or a combination of columns
*/
sortingExpressions?: SortingExpression[];
/**
* Enables/Disables using the igx-grid export functionality
*/
useIgxExport?: any;
/**
* Enables/Disables changing table height dynamically
*/
dynamicTableHeight?: any;
/**
* Additional modifiers used to adjust the data-list height.
* The modifiers must be configured and added to body in _positions.scss
*/
dynamicTableHeightAdditionalModifiers?: string[];
/**
* Additional height to adjust the data-list, height should be in px (e.g "15px")
*/
dynamicTableHeightAdditionalHeight?: string;
/**
* Additional subheader for the data-list
*/
subheader?: string;
/**
* Shows the rows count with the subheader, only used when subheader property is set @default(false)
*/
totalWithSubheader?: boolean;
/**
* Description added after the rows count value, only used when rows count is shown with the title (ie: totalWithSubheader property is not set or set to false)
*/
countDescription?: string;
/**
* The templates for dynamically added columns
*/
columnTemplates?: { [key: string]: Column };
/**
* Data-list footer configuration
*/
footer?: any;
/**
* Hierachical data-list property, shows/hides "Attributes" dialog open button for children data-lists @default(false)
*/
shownAttributesSelection?: boolean;
/**
* Hierachical data-list property, needed to check the children's link source
*/
link?: ChildrenLink;
/**
* whether or not it is allowed to copy paste for every attribute type.
* If this is false it will only be allowed to copy paste in STRING,PLAIN_STRING,INTEGER_NUMBER,DECIMAL_NUMBER attributes
* @default(false)
*/
excelCopyPasteEverywhere?: boolean;
/**
* Adress for the copy paste parsing to use, @default(/api/core/attributes/parse?include=attribute.source&include=attribute.validation)
*/
excelCopyParseUrl?: string;
/**
* Add widgets to data-list header
*/
headerComponents?: any;
/**
* Key of the configurations entry
*/
[key: string]: any;
}
export interface ChildrenLink {
/**
* Children link source type, available options: "from-response"
*/
type?: string;
/**
* Link property key in response _links object
*/
key?: string;
}
export interface ViewModeOption {
/**
* Identifier to be set as option value
*/
identifier?: string;
/**
* Description to be displayed in the dropdown
*/
description?: string;
/**
* Icon representing the option
*/
icon?: string;
/**
* references a callback function to allow customizing a cell's column
*/
columnSelector?: string;
/**
* Enable/disable rows drag and drop
*/
enableRowDragging?: boolean;
}
export interface SortBy {
/**
* Column "field" value that should be used for sorting
*/
field?: string;
/**
* Sorting direction, use "asc" for ascending sorting or"desc" for descending sorting
*/
direction?: string;
}
/**
* Interface to transport the recommended attributes data
*
* A separate `count` property is required to handle cases, where
* one attribute entry results in the display of multiple different attributes
*/
export interface RecommendedAttributes {
/**
* list of attributes that will be added to the request URI
*/
attributes: Attribute[];
/**
* number of attributes that are recommended to the user
*/
count: number;
}
export interface DataListTreeConfiguration extends DataListConfiguration {
/**
* Property key in response identifying parent rows @default("parentIdentifier")
*/
foreignKey?: string;
/**
* Property key in response indicating whether a row has children or not
*/
hasChildrenKey?: string;
/**
* Link property key in response used for loading the row children @default("children")
*/
childrenLinkName?: string;
/**
* When emitting selection events the counts will be grouped by this property. In most cases this property should contain the level the selected entry is on
*/
selectionGroupingProperty?: string;
/**
* Auto expand all rows
*/
autoExpand?: boolean;
/**
* Count of levels to be expanded
*/
expansionDepth?: number;
/**
* Clears data in list while new data is loading
*/
clearDataOnNewLink?: boolean;
/**
* adress used to parse the attributes when copy pasting from excel
* If this is unset copy-paste will be disabled
*/
excelCopyParseUrl?: string;
/**
* Filtering strategy used in free text search. available strategies are "default", "parents-only"
*/
filteringStrategy?: "default" | "parents-only";
}
export interface DataListHierachicalConfiguration
extends DataListConfiguration {
/**
* List of child tables configurations
*/
islands?: DataListConfiguration[];
/**
* Icon shown when row is collaped
*/
rowCollapsedIcon?: string;
/**
* Icon shown when row is expanded
*/
rowExpandedIcon?: string;
/**
* Removes margin, padding and header of islands to mimic CSS of data-list-tree @default(false)
*/
removeIslandCss?: boolean;
/**
* Tooltip shown for expander icon
*/
expanderTooltip?: string;
/**
* Shows/Hides table @default(false)
*/
hideTable?: boolean;
}
export interface SortingExpression {
/**
* Sorting direction, use "asc" for ascending sorting or "desc" for descending sorting
*/
direction?: string;
/**
* Column "field" value that should be used for grouping
*/
field?: string;
}
export interface GroupingExpression extends SortingExpression {
/**
* Sorting strategy
*/
strategy?: string;
}
export interface UriParams {
timestamp?: number;
template?: any;
offset?: number;
limit?: number;
sort?: string;
filter?: string[];
[key: string]: any;
}
export interface IslandSelectionParams {
[island: string]: { [parent: string]: SelectionParams };
}
export interface SelectionParams {
count?: number;
rows?: any[];
rowData?: any[];
cacheId?: string;
children?: IslandSelectionParams;
treeSelections?: any;
}
export const EMPTY_SELECTION: SelectionParams = {
count: 0,
rows: [],
rowData: [],
children: {},
};
export interface SelectFilterParams {
/**
* List of properties keys used to filter the attributes in the "Attributes" dialog
*/
filterAttribute?: string | string[];
/**
* Filter selection dropdown placeholder
*/
placeholder?: string;
/**
* Url used to get the options to be shown in the filter selection dropdown
*/
href?: string;
/**
* Property key used to get data from response
*/
dataType?: string;
/**
* List of options to be shown in the filter selection dropdown
*/
options?: any[];
}
export interface DataListStatus {
//The field that changed last, will be null if this status is send after init (restored from local-storage)
lastChange: string;
//The currently selected attributes - if any
attributes: Attribute[];
//The current dataType
dataType: string;
}