@talxis/base-controls 1.2410.3 → 1.2410.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -11
- package/dist/components/DatasetControl/DatasetControl.d.ts +3 -0
- package/dist/components/DatasetControl/DatasetControl.js +63 -0
- package/dist/components/DatasetControl/DatasetControl.js.map +1 -0
- package/dist/components/DatasetControl/hooks/useRerender.d.ts +1 -0
- package/dist/components/DatasetControl/hooks/useRerender.js +9 -0
- package/dist/components/DatasetControl/hooks/useRerender.js.map +1 -0
- package/dist/components/DatasetControl/index.d.ts +2 -0
- package/dist/components/DatasetControl/index.js +2 -0
- package/dist/components/DatasetControl/index.js.map +1 -0
- package/dist/components/DatasetControl/interfaces.d.ts +10 -0
- package/dist/components/DatasetControl/styles.d.ts +8 -0
- package/dist/components/DatasetControl/styles.js +17 -0
- package/dist/components/DatasetControl/styles.js.map +1 -0
- package/dist/components/DatasetControl/translations.d.ts +10 -0
- package/dist/components/DatasetControl/translations.js +7 -0
- package/dist/components/DatasetControl/translations.js.map +1 -0
- package/dist/components/Decimal/Decimal.js +1 -1
- package/dist/components/Decimal/Decimal.js.map +1 -1
- package/dist/components/Duration/Duration.js +1 -1
- package/dist/components/Duration/Duration.js.map +1 -1
- package/dist/components/Grid/Grid.js +9 -2
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/AgGrid.js +21 -46
- package/dist/components/Grid/core/components/AgGrid/AgGrid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/controllers/useAgGridController.d.ts +0 -1
- package/dist/components/Grid/core/components/AgGrid/controllers/useAgGridController.js +7 -7
- package/dist/components/Grid/core/components/AgGrid/controllers/useAgGridController.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.d.ts +0 -2
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js +0 -7
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/styles.d.ts +1 -4
- package/dist/components/Grid/core/components/AgGrid/styles.js +6 -9
- package/dist/components/Grid/core/components/AgGrid/styles.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.js +0 -2
- package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.js +16 -4
- package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.js.map +1 -1
- package/dist/components/Grid/core/components/Component/model/Component.js +7 -2
- package/dist/components/Grid/core/components/Component/model/Component.js.map +1 -1
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.js +3 -0
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.js.map +1 -1
- package/dist/components/Grid/core/constants.d.ts +1 -0
- package/dist/components/Grid/core/constants.js +4 -0
- package/dist/components/Grid/core/constants.js.map +1 -0
- package/dist/components/Grid/core/controllers/useGridController.d.ts +0 -2
- package/dist/components/Grid/core/controllers/useGridController.js +1 -17
- package/dist/components/Grid/core/controllers/useGridController.js.map +1 -1
- package/dist/components/Grid/core/model/Grid.d.ts +10 -3
- package/dist/components/Grid/core/model/Grid.js +45 -16
- package/dist/components/Grid/core/model/Grid.js.map +1 -1
- package/dist/components/Grid/core/services/KeyListener.d.ts +8 -0
- package/dist/components/Grid/core/services/KeyListener.js +22 -0
- package/dist/components/Grid/core/services/KeyListener.js.map +1 -0
- package/dist/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.js +2 -2
- package/dist/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.js.map +1 -1
- package/dist/components/Grid/filtering/controller/useColumnFilterConditionController.js.map +1 -1
- package/dist/components/Grid/interfaces.d.ts +2 -2
- package/dist/components/Grid/paging/components/Paging/Paging.js +7 -1
- package/dist/components/Grid/paging/components/Paging/Paging.js.map +1 -1
- package/dist/components/Grid/paging/controllers/usePagingController.d.ts +2 -1
- package/dist/components/Grid/paging/controllers/usePagingController.js +1 -0
- package/dist/components/Grid/paging/controllers/usePagingController.js.map +1 -1
- package/dist/components/Grid/paging/model/Paging.d.ts +2 -1
- package/dist/components/Grid/paging/model/Paging.js +22 -4
- package/dist/components/Grid/paging/model/Paging.js.map +1 -1
- package/dist/components/Grid/selection/controllers/useSelectionController.js +7 -3
- package/dist/components/Grid/selection/controllers/useSelectionController.js.map +1 -1
- package/dist/components/Grid/selection/model/Selection.d.ts +1 -1
- package/dist/components/Grid/selection/model/Selection.js +7 -4
- package/dist/components/Grid/selection/model/Selection.js.map +1 -1
- package/dist/components/Grid/sorting/Sorting.js +2 -3
- package/dist/components/Grid/sorting/Sorting.js.map +1 -1
- package/dist/components/Grid/translations.d.ts +4 -0
- package/dist/components/Grid/translations.js +2 -1
- package/dist/components/Grid/translations.js.map +1 -1
- package/dist/index.d.ts +24 -7
- package/dist/index.js +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/components/Grid/core/hooks/useRerender.js +0 -13
- package/dist/components/Grid/core/hooks/useRerender.js.map +0 -1
- package/dist/utils/Numeral.d.ts +0 -6
- package/dist/utils/Numeral.js +0 -64
- package/dist/utils/Numeral.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../../../../../../../src/components/Grid/core/components/Component/model/Component.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport { IControl } from \"../../../../../../interfaces/context\";\nimport { IParameters } from \"../../../../../../interfaces/parameters\";\nimport { IDateTime } from \"../../../../../DateTime/interfaces\";\nimport { IDecimal } from \"../../../../../Decimal/interfaces\";\nimport { ILookup } from \"../../../../../Lookup/interfaces\";\nimport { IMultiSelectOptionSet } from \"../../../../../MultiSelectOptionSet/interfaces\";\nimport { IOptionSet } from \"../../../../../OptionSet/interfaces\";\nimport { ITextField } from \"../../../../../TextField/interfaces\";\nimport { ITwoOptions } from \"../../../../../TwoOptions/interfaces\";\nimport { ColumnValidation } from \"../../../../validation/model/ColumnValidation\";\nimport { DataType } from \"../../../enums/DataType\";\nimport { GridDependency } from \"../../../model/GridDependency\";\nimport { IControlProps } from \"../Component\";\n\nconst debounce = (func: (...args: any[]) => Promise<any>, wait: number) => {\n let timeout: NodeJS.Timeout | null = null;\n let promiseCache: Promise<any> | null = null;\n\n return async (...args: any[]) => {\n if (!promiseCache) {\n promiseCache = func(...args);\n }\n\n if (timeout) clearTimeout(timeout);\n\n timeout = setTimeout(() => {\n promiseCache = null;\n }, wait);\n\n return promiseCache;\n };\n};\n\nexport class Component extends GridDependency {\n private _debouncedGetLookupValue = debounce(this._getLookupValue.bind(this), 50);\n private static _lookupSavedQueriesCache = new Map<string, Promise<ComponentFramework.WebApi.Entity>>;\n\n public async getControlProps(props: IControlProps): Promise<IControl<any, any, any, any>> {\n const { column, value, onNotifyOutputChanged, formattedValue } = { ...props };\n const [isValid, validationErrorMessage] = new ColumnValidation(this._grid, props.column).validate(value);\n const onOverrideControlProps = props?.onOverrideControlProps ?? ((props: IControl<any, any, any, any>) => props);\n switch (column.dataType) {\n case DataType.LOOKUP_SIMPLE:\n case DataType.LOOKUP_OWNER:\n case DataType.LOOKUP_CUSTOMER: {\n const columnMetadata = await this._grid.metadata.get(column);\n const targets = columnMetadata.Attributes.get(column.attributeName).attributeDescriptor.Targets ?? [];\n if (column.dataType === DataType.LOOKUP_OWNER) {\n targets.push('systemuser', 'team')\n }\n const result = {\n context: this._pcfContext,\n parameters: {\n value: {\n getAllViews: async (entityName: string, __queryType: number = 64) => {\n const cacheKey = `${entityName}_${__queryType}`\n if (!Component._lookupSavedQueriesCache.get(cacheKey)) {\n Component._lookupSavedQueriesCache.set(cacheKey, new Promise(async (resolve) => {\n const response = await this._pcfContext.webAPI.retrieveMultipleRecords('savedquery', `?$filter=returnedtypecode eq '${entityName}' and querytype eq ${__queryType} and isdefault eq true&$select=name,savedqueryid,fetchxml`);\n resolve(response.entities[0])\n }))\n }\n const result = await Component._lookupSavedQueriesCache.get(cacheKey)!;\n return [\n {\n isDefault: true,\n viewName: result.name,\n viewId: result.savedqueryid,\n fetchXml: result.fetchxml\n }\n ]\n },\n raw: await this._debouncedGetLookupValue(targets, value),\n attributes: {\n Targets: targets,\n DisplayName: columnMetadata.DisplayName\n },\n error: !isValid,\n errorMessage: validationErrorMessage,\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n\n } as ILookup;\n return onOverrideControlProps(result);\n }\n case DataType.TWO_OPTIONS: {\n const twoOptionsValue = value as boolean | undefined | null;\n const [defaultValue, options] = await this._grid.metadata.getOptions(column)\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: twoOptionsValue === true ? true : false,\n error: !isValid,\n errorMessage: validationErrorMessage,\n attributes: {\n Options: options\n }\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as ITwoOptions)\n }\n case DataType.OPTIONSET: {\n const optionSetValue = value as number | null | undefined;\n const [defaultValue, options] = await this._grid.metadata.getOptions(column)\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: optionSetValue ?? null,\n error: !isValid,\n errorMessage: validationErrorMessage,\n attributes: {\n Options: options\n }\n },\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as IOptionSet);\n }\n case DataType.MULTI_SELECT_OPTIONSET: {\n const [defaultValue, options] = await this._grid.metadata.getOptions(column)\n const optionSetValue = value as number[] | null | undefined;\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: optionSetValue ?? null,\n error: !isValid,\n errorMessage: validationErrorMessage,\n attributes: {\n Options: options\n }\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as IMultiSelectOptionSet);\n }\n case DataType.DATE_AND_TIME_DATE_AND_TIME:\n case DataType.DATE_AND_TIME_DATE_ONLY: {\n const dateTimeValue = value as Date | null | undefined;\n const metadata = await this._grid.metadata.get(column);\n const date = dayjs(dateTimeValue);\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: date.isValid() ? date.toDate() : dateTimeValue,\n error: !isValid,\n errorMessage: validationErrorMessage,\n attributes: {\n Behavior: metadata.Attributes.get(column.attributeName).Behavior,\n Format: column.dataType\n }\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as IDateTime);\n }\n case DataType.WHOLE_NONE:\n case DataType.DECIMAL:\n case DataType.CURRENCY:\n case DataType.WHOLE_DURATION: {\n const decimalValue = value as number | null | undefined\n const metadata = await this._grid.metadata.get(column);\n const precision = metadata.Attributes.get(column.attributeName).Precision;\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: decimalValue ?? null,\n error: !isValid,\n //formatted value is only used for currency => there is no way to get the currency symbol so the formatCurrency method is useless\n formatted: formattedValue,\n errorMessage: validationErrorMessage,\n type: column.dataType,\n attributes: {\n Precision: precision\n }\n },\n NotifyOutputChangedOnUnmount: {\n raw: true,\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n\n } as IDecimal);\n }\n default: {\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n isResizable: {\n raw: false\n },\n NotifyOutputChangedOnUnmount: {\n raw: true,\n },\n value: {\n raw: value,\n error: !isValid,\n errorMessage: validationErrorMessage\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as ITextField);\n }\n }\n }\n private async _getLookupValue(targets: string[], value: ComponentFramework.LookupValue[] | null | undefined): Promise<ComponentFramework.LookupValue[]> {\n if (!value || value.length === 0) {\n return [];\n }\n //this is case from filters where we only have the id to work it => we need to go through targets and search for the records\n if (!value[0].entityType) {\n for (const lookup of value) {\n for (const target of targets) {\n try {\n const lookupEntityMetadata = await this._pcfContext.utils.getEntityMetadata(target, []);\n const response = await this._pcfContext.webAPI.retrieveRecord(target, lookup.id, `?$select=${lookupEntityMetadata.PrimaryNameAttribute}`);\n lookup.entityType = target;\n lookup.name = response[lookupEntityMetadata.PrimaryNameAttribute];\n break;\n }\n catch (err) {\n continue;\n }\n }\n }\n }\n return value;\n }\n}"],"names":[],"mappings":";;;;;AAeA,MAAM,QAAQ,GAAG,CAAC,IAAsC,EAAE,IAAY,KAAI;IACtE,IAAI,OAAO,GAA0B,IAAI,CAAC;IAC1C,IAAI,YAAY,GAAwB,IAAI,CAAC;AAE7C,IAAA,OAAO,OAAO,GAAG,IAAW,KAAI;QAC5B,IAAI,CAAC,YAAY,EAAE;AACf,YAAA,YAAY,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAChC,SAAA;AAED,QAAA,IAAI,OAAO;YAAE,YAAY,CAAC,OAAO,CAAC,CAAC;AAEnC,QAAA,OAAO,GAAG,UAAU,CAAC,MAAK;YACtB,YAAY,GAAG,IAAI,CAAC;SACvB,EAAE,IAAI,CAAC,CAAC;AAET,QAAA,OAAO,YAAY,CAAC;AACxB,KAAC,CAAC;AACN,CAAC,CAAC;AAEI,MAAO,SAAU,SAAQ,cAAc,CAAA;AAA7C,IAAA,WAAA,GAAA;;AACY,QAAA,IAAA,CAAA,wBAAwB,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;KAwMpF;IArMU,MAAM,eAAe,CAAC,KAAoB,EAAA;AAC7C,QAAA,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;QAC9E,MAAM,CAAC,OAAO,EAAE,sBAAsB,CAAC,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,C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;AAtMc,SAAwB,CAAA,wBAAA,GAAG,IAAI,GAAsD;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../../../../../../../src/components/Grid/core/components/Component/model/Component.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport { IControl } from \"../../../../../../interfaces/context\";\nimport { IDateTime } from \"../../../../../DateTime/interfaces\";\nimport { IDecimal } from \"../../../../../Decimal/interfaces\";\nimport { ILookup } from \"../../../../../Lookup/interfaces\";\nimport { IMultiSelectOptionSet } from \"../../../../../MultiSelectOptionSet/interfaces\";\nimport { IOptionSet } from \"../../../../../OptionSet/interfaces\";\nimport { ITextField } from \"../../../../../TextField/interfaces\";\nimport { ITwoOptions } from \"../../../../../TwoOptions/interfaces\";\nimport { ColumnValidation } from \"../../../../validation/model/ColumnValidation\";\nimport { DataType } from \"../../../enums/DataType\";\nimport { GridDependency } from \"../../../model/GridDependency\";\nimport { IControlProps } from \"../Component\";\n\nconst debounce = (func: (...args: any[]) => Promise<any>, wait: number) => {\n let timeout: NodeJS.Timeout | null = null;\n let promiseCache: Promise<any> | null = null;\n\n return async (...args: any[]) => {\n if (!promiseCache) {\n promiseCache = func(...args);\n }\n\n if (timeout) clearTimeout(timeout);\n\n timeout = setTimeout(() => {\n promiseCache = null;\n }, wait);\n\n return promiseCache;\n };\n};\n\nexport class Component extends GridDependency {\n private _debouncedGetLookupValue = debounce(this._getLookupValue.bind(this), 50);\n private static _lookupSavedQueriesCache = new Map<string, Promise<ComponentFramework.WebApi.Entity>>;\n\n public async getControlProps(props: IControlProps): Promise<IControl<any, any, any, any>> {\n const { column, value, onNotifyOutputChanged, formattedValue } = { ...props };\n const [isValid, validationErrorMessage] = new ColumnValidation(this._grid, props.column).validate(value);\n const onOverrideControlProps = props?.onOverrideControlProps ?? ((props: IControl<any, any, any, any>) => props);\n switch (column.dataType) {\n case DataType.LOOKUP_SIMPLE:\n case DataType.LOOKUP_OWNER:\n case DataType.LOOKUP_CUSTOMER: {\n const columnMetadata = await this._grid.metadata.get(column);\n const targets = columnMetadata.Attributes.get(column.attributeName).attributeDescriptor.Targets ?? [];\n //@ts-ignore - typings\n if (column.dataType === DataType.LOOKUP_OWNER && window.TALXIS.Portal) {\n targets.push('systemuser', 'team')\n }\n let displayName = \"\";\n if(targets.length === 1) {\n displayName = (await this._pcfContext.utils.getEntityMetadata(targets[0])).DisplayName;\n }\n const result = {\n context: this._pcfContext,\n parameters: {\n value: {\n getAllViews: async (entityName: string, __queryType: number = 64) => {\n const cacheKey = `${entityName}_${__queryType}`\n if (!Component._lookupSavedQueriesCache.get(cacheKey)) {\n Component._lookupSavedQueriesCache.set(cacheKey, new Promise(async (resolve) => {\n const response = await this._pcfContext.webAPI.retrieveMultipleRecords('savedquery', `?$filter=returnedtypecode eq '${entityName}' and querytype eq ${__queryType} and isdefault eq true&$select=name,savedqueryid,fetchxml`);\n resolve(response.entities[0])\n }))\n }\n const result = await Component._lookupSavedQueriesCache.get(cacheKey)!;\n return [\n {\n isDefault: true,\n viewName: result.name,\n viewId: result.savedqueryid,\n fetchXml: result.fetchxml\n }\n ]\n },\n raw: await this._debouncedGetLookupValue(targets, value),\n attributes: {\n Targets: targets,\n DisplayName: displayName\n },\n error: !isValid,\n errorMessage: validationErrorMessage,\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n\n } as ILookup;\n return onOverrideControlProps(result);\n }\n case DataType.TWO_OPTIONS: {\n const twoOptionsValue = value as boolean | undefined | null;\n const [defaultValue, options] = await this._grid.metadata.getOptions(column)\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: twoOptionsValue === true ? true : false,\n error: !isValid,\n errorMessage: validationErrorMessage,\n attributes: {\n Options: options\n }\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as ITwoOptions)\n }\n case DataType.OPTIONSET: {\n const optionSetValue = value as number | null | undefined;\n const [defaultValue, options] = await this._grid.metadata.getOptions(column)\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: optionSetValue ?? null,\n error: !isValid,\n errorMessage: validationErrorMessage,\n attributes: {\n Options: options\n }\n },\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as IOptionSet);\n }\n case DataType.MULTI_SELECT_OPTIONSET: {\n const [defaultValue, options] = await this._grid.metadata.getOptions(column)\n const optionSetValue = value as number[] | null | undefined;\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: optionSetValue ?? null,\n error: !isValid,\n errorMessage: validationErrorMessage,\n attributes: {\n Options: options\n }\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as IMultiSelectOptionSet);\n }\n case DataType.DATE_AND_TIME_DATE_AND_TIME:\n case DataType.DATE_AND_TIME_DATE_ONLY: {\n const dateTimeValue = value as Date | null | undefined;\n const metadata = await this._grid.metadata.get(column);\n const date = dayjs(dateTimeValue);\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: date.isValid() ? date.toDate() : dateTimeValue,\n error: !isValid,\n errorMessage: validationErrorMessage,\n attributes: {\n Behavior: metadata.Attributes.get(column.attributeName).Behavior,\n Format: column.dataType\n }\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as IDateTime);\n }\n case DataType.WHOLE_NONE:\n case DataType.DECIMAL:\n case DataType.CURRENCY:\n case DataType.WHOLE_DURATION: {\n const decimalValue = value as number | null | undefined\n const metadata = await this._grid.metadata.get(column);\n const precision = metadata.Attributes.get(column.attributeName).Precision;\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n value: {\n raw: decimalValue ?? null,\n error: !isValid,\n //formatted value is only used for currency => there is no way to get the currency symbol so the formatCurrency method is useless\n formatted: formattedValue,\n errorMessage: validationErrorMessage,\n type: column.dataType,\n attributes: {\n Precision: precision\n }\n },\n NotifyOutputChangedOnUnmount: {\n raw: true,\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n\n } as IDecimal);\n }\n default: {\n return onOverrideControlProps({\n context: this._pcfContext,\n parameters: {\n isResizable: {\n raw: false\n },\n NotifyOutputChangedOnUnmount: {\n raw: true,\n },\n value: {\n raw: value,\n error: !isValid,\n errorMessage: validationErrorMessage\n }\n },\n onNotifyOutputChanged: (outputs) => onNotifyOutputChanged(outputs.value)\n } as ITextField);\n }\n }\n }\n private async _getLookupValue(targets: string[], value: ComponentFramework.LookupValue[] | null | undefined): Promise<ComponentFramework.LookupValue[]> {\n if (!value || value.length === 0) {\n return [];\n }\n //this is case from filters where we only have the id to work it => we need to go through targets and search for the records\n if (!value[0].entityType) {\n for (const lookup of value) {\n for (const target of targets) {\n try {\n const lookupEntityMetadata = await this._pcfContext.utils.getEntityMetadata(target, []);\n const response = await this._pcfContext.webAPI.retrieveRecord(target, lookup.id, `?$select=${lookupEntityMetadata.PrimaryNameAttribute}`);\n lookup.entityType = target;\n lookup.name = response[lookupEntityMetadata.PrimaryNameAttribute];\n break;\n }\n catch (err) {\n continue;\n }\n }\n }\n }\n return value;\n }\n}"],"names":[],"mappings":";;;;;AAcA,MAAM,QAAQ,GAAG,CAAC,IAAsC,EAAE,IAAY,KAAI;IACtE,IAAI,OAAO,GAA0B,IAAI,CAAC;IAC1C,IAAI,YAAY,GAAwB,IAAI,CAAC;AAE7C,IAAA,OAAO,OAAO,GAAG,IAAW,KAAI;QAC5B,IAAI,CAAC,YAAY,EAAE;AACf,YAAA,YAAY,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAChC,SAAA;AAED,QAAA,IAAI,OAAO;YAAE,YAAY,CAAC,OAAO,CAAC,CAAC;AAEnC,QAAA,OAAO,GAAG,UAAU,CAAC,MAAK;YACtB,YAAY,GAAG,IAAI,CAAC;SACvB,EAAE,IAAI,CAAC,CAAC;AAET,QAAA,OAAO,YAAY,CAAC;AACxB,KAAC,CAAC;AACN,CAAC,CAAC;AAEI,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ED,QAAA,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE;AACtB,YAAA,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE;AACxB,gBAAA,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;oBAC1B,IAAI;AACA,wBAAA,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;wBACxF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAA,SAAA,EAAY,oBAAoB,CAAC,oBAAoB,CAAE,CAAA,CAAC,CAAC;AAC1I,wBAAA,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC;wBAC3B,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAC;wBAClE,MAAM;AACT,qBAAA;AACD,oBAAA,OAAO,GAAG,EAAE;wBACR,SAAS;AACZ,qBAAA;AACJ,iBAAA;AACJ,aAAA;AACJ,SAAA;AACD,QAAA,OAAO,KAAK,CAAC;KAChB;;AA3Mc,SAAwB,CAAA,wBAAA,GAAG,IAAI,GAAsD;;;;"}
|
|
@@ -38,7 +38,10 @@ const RecordGrids = (props) => {
|
|
|
38
38
|
Grid: {
|
|
39
39
|
...grid.dataset,
|
|
40
40
|
sorting: [],
|
|
41
|
+
linking: grid.dataset.linking,
|
|
41
42
|
columns: [...record.columns.values()],
|
|
43
|
+
sortedRecordIds: [record.getRecordId()],
|
|
44
|
+
getTargetEntityType: () => grid.dataset.getTargetEntityType(),
|
|
42
45
|
filtering: {
|
|
43
46
|
...grid.dataset.filtering,
|
|
44
47
|
getFilter: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordGrids.js","sources":["../../../../../../../../../../src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.tsx"],"sourcesContent":["import React from 'react';\nimport { Grid } from '../../../../../../../Grid';\nimport { useGridInstance } from '../../../../../../hooks/useGridInstance';\nimport { IUpdatedRecord } from '../../../../../../services/RecordUpdateService/model/RecordUpdateService';\nimport { Text } from '@fluentui/react';\nimport { IEntityColumn, IEntityRecord, IGrid, IGridParameters } from '../../../../../../../interfaces';\nimport { Icon } from '@fluentui/react';\nimport { getRecordGridStyles } from './styles';\nimport { useTheme } from '@fluentui/react';\n\ninterface IRecordGrids {\n record: IUpdatedRecord;\n}\nexport const RecordGrids = (props: IRecordGrids) => {\n const grid = useGridInstance();\n const record = { ...props.record };\n const styles = getRecordGridStyles(useTheme());\n const sharedProps: IGrid = {\n context: {\n ...grid.pcfContext,\n mode: {\n ...grid.pcfContext.mode,\n //needed so the nested grids to do not interfere with the state of parent grid\n setControlState: (state: ComponentFramework.Dictionary) => false\n }\n },\n state: {},\n parameters: {\n EnableFiltering: {\n raw: false\n },\n EnablePagination: {\n raw: false\n },\n EnableSorting: {\n raw: false\n },\n EnableNavigation: {\n raw: false\n },\n SelectableRows: {\n type: 'static',\n raw: 'none'\n },\n Grid: {\n ...grid.dataset,\n sorting: [],\n columns: [...record.columns.values()],\n filtering: {\n ...grid.dataset.filtering,\n getFilter: () => {\n return {\n conditions: [],\n filterOperator: 0,\n }\n }\n },\n getSelectedRecordIds: () => [],\n paging: {\n ...grid.dataset.paging,\n pageSize: 1\n }\n }\n } as IGridParameters\n }\n\n const invalidColumns = (() => {\n const columns: IEntityColumn[] = [];\n for(const column of record.columns.values()) {\n if(!record.isValid(column.name)) {\n columns.push(column);\n }\n }\n return columns;\n })();\n\n const hasInvalidColumn = invalidColumns.length > 0;\n\n const getOriginalRecord = (record: IUpdatedRecord): IEntityRecord => {\n return {\n getFormattedValue: (columnKey: string) => record.getOriginalFormattedValue(columnKey),\n getRecordId: () => record.getRecordId(),\n getNamedReference: () => record.getNamedReference(),\n getValue: (columnKey: string) => record.getOriginalValue(columnKey),\n save: async () => {\n const result = await record.save();\n grid.pcfContext.factory.requestRender();\n },\n //only comes when clear is called to return to the original value\n setValue: (columnKey: string, value: any) => {\n record.clear();\n //TODO: the internal record id map wont get updated\n //with the references to updated records until they appear \n //in the grid => you cant see the changes \n grid.pcfContext.factory.requestRender();\n }\n }\n }\n const getUpdatedRecord = (record: IUpdatedRecord): IEntityRecord => {\n return {\n getFormattedValue: (columnKey: string) => record.getFormattedValue(columnKey),\n getRecordId: () => record.getRecordId(),\n getNamedReference: () => record.getNamedReference(),\n getValue: (columnKey: string) => record.getValue(columnKey),\n save: () => { throw new Error('Should not be called!') },\n setValue: (columnKey: string, value: any) => {\n record.setValue(columnKey, value)\n grid.pcfContext.factory.requestRender();\n }\n }\n }\n\n return (\n <div className={styles.root}>\n <div className={styles.readOnlyGrid}>\n <div className={styles.gridTitleWrapper}>\n <Text title={record.getOriginalFormattedPrimaryNameValue()} variant='large'>{record.getOriginalFormattedPrimaryNameValue()}</Text>\n </div>\n <Grid\n {...sharedProps}\n parameters={{\n ...sharedProps.parameters,\n ChangeEditorMode: {\n raw: \"read\",\n error: hasInvalidColumn,\n },\n Grid: {\n ...sharedProps.parameters.Grid,\n error: hasInvalidColumn,\n errorMessage: hasInvalidColumn ? grid.labels['saving-validation-error']({\n columnDisplayNames: invalidColumns.map( x => x.displayName).join(', ')\n }): undefined,\n records: {\n [record.getRecordId()]: getOriginalRecord(record)\n }\n },\n\n } as IGridParameters} />\n </div>\n <Icon iconName=\"DoubleChevronDown8\" />\n <div className={styles.editableGrid}>\n <Grid\n {...sharedProps}\n parameters={{\n ...sharedProps.parameters,\n ChangeEditorMode: {\n raw: \"edit\"\n },\n EnableEditing: {\n raw: true\n },\n Grid: {\n ...sharedProps.parameters.Grid,\n records: {\n [record.getRecordId()]: getUpdatedRecord(record)\n }\n }\n } as IGridParameters} />\n </div>\n </div>\n )\n}"],"names":["_jsxs","_jsx"],"mappings":";;;;;;AAaa,MAAA,WAAW,GAAG,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E,gBAAgB;AAC1B,6BAAA;AACD,4BAAA,IAAI,EAAE;AACF,gCAAA,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI;AAC9B,gCAAA,KAAK,EAAE,gBAAgB;gCACvB,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;AACpE,oCAAA,kBAAkB,EAAE,cAAc,CAAC,GAAG,CAAE,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iCACzE,CAAC,GAAE,SAAS;AACb,gCAAA,OAAO,EAAE;oCACL,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,iBAAiB,CAAC,MAAM,CAAC;AACpD,iCAAA;AACJ,6BAAA;yBAEe,EAAI,CAAA,CAAA,EAAA,CAC1B,EACNA,GAAC,CAAA,IAAI,IAAC,QAAQ,EAAC,oBAAoB,EAAA,CAAG,EACtCA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,YAAY,EAC/B,QAAA,EAAAA,GAAA,CAAC,IAAI,EACG,EAAA,GAAA,WAAW,EACf,UAAU,EAAE;wBACR,GAAG,WAAW,CAAC,UAAU;AACzB,wBAAA,gBAAgB,EAAE;AACd,4BAAA,GAAG,EAAE,MAAM;AACd,yBAAA;AACD,wBAAA,aAAa,EAAE;AACX,4BAAA,GAAG,EAAE,IAAI;AACZ,yBAAA;AACD,wBAAA,IAAI,EAAE;AACF,4BAAA,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI;AAC9B,4BAAA,OAAO,EAAE;gCACL,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC;AACnD,6BAAA;AACJ,yBAAA;qBACe,EAAI,CAAA,EAAA,CAC1B,CACJ,EAAA,CAAA,EACT;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"RecordGrids.js","sources":["../../../../../../../../../../src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.tsx"],"sourcesContent":["import React from 'react';\nimport { Grid } from '../../../../../../../Grid';\nimport { useGridInstance } from '../../../../../../hooks/useGridInstance';\nimport { IUpdatedRecord } from '../../../../../../services/RecordUpdateService/model/RecordUpdateService';\nimport { Text } from '@fluentui/react';\nimport { IEntityColumn, IEntityRecord, IGrid, IGridParameters } from '../../../../../../../interfaces';\nimport { Icon } from '@fluentui/react';\nimport { getRecordGridStyles } from './styles';\nimport { useTheme } from '@fluentui/react';\n\ninterface IRecordGrids {\n record: IUpdatedRecord;\n}\nexport const RecordGrids = (props: IRecordGrids) => {\n const grid = useGridInstance();\n const record = { ...props.record };\n const styles = getRecordGridStyles(useTheme());\n const sharedProps: IGrid = {\n context: {\n ...grid.pcfContext,\n mode: {\n ...grid.pcfContext.mode,\n //needed so the nested grids to do not interfere with the state of parent grid\n setControlState: (state: ComponentFramework.Dictionary) => false\n }\n },\n state: {},\n parameters: {\n EnableFiltering: {\n raw: false\n },\n EnablePagination: {\n raw: false\n },\n EnableSorting: {\n raw: false\n },\n EnableNavigation: {\n raw: false\n },\n SelectableRows: {\n type: 'static',\n raw: 'none'\n },\n Grid: {\n ...grid.dataset,\n sorting: [],\n linking: grid.dataset.linking,\n columns: [...record.columns.values()],\n sortedRecordIds: [record.getRecordId()],\n getTargetEntityType: () => grid.dataset.getTargetEntityType(),\n filtering: {\n ...grid.dataset.filtering,\n getFilter: () => {\n return {\n conditions: [],\n filterOperator: 0,\n }\n }\n },\n getSelectedRecordIds: () => [],\n paging: {\n ...grid.dataset.paging,\n pageSize: 1\n }\n }\n } as IGridParameters\n }\n\n const invalidColumns = (() => {\n const columns: IEntityColumn[] = [];\n for(const column of record.columns.values()) {\n if(!record.isValid(column.name)) {\n columns.push(column);\n }\n }\n return columns;\n })();\n\n const hasInvalidColumn = invalidColumns.length > 0;\n\n const getOriginalRecord = (record: IUpdatedRecord): IEntityRecord => {\n return {\n getFormattedValue: (columnKey: string) => record.getOriginalFormattedValue(columnKey),\n getRecordId: () => record.getRecordId(),\n getNamedReference: () => record.getNamedReference(),\n getValue: (columnKey: string) => record.getOriginalValue(columnKey),\n save: async () => {\n const result = await record.save();\n grid.pcfContext.factory.requestRender();\n },\n //only comes when clear is called to return to the original value\n setValue: (columnKey: string, value: any) => {\n record.clear();\n //TODO: the internal record id map wont get updated\n //with the references to updated records until they appear \n //in the grid => you cant see the changes \n grid.pcfContext.factory.requestRender();\n }\n }\n }\n const getUpdatedRecord = (record: IUpdatedRecord): IEntityRecord => {\n return {\n getFormattedValue: (columnKey: string) => record.getFormattedValue(columnKey),\n getRecordId: () => record.getRecordId(),\n getNamedReference: () => record.getNamedReference(),\n getValue: (columnKey: string) => record.getValue(columnKey),\n save: () => { throw new Error('Should not be called!') },\n setValue: (columnKey: string, value: any) => {\n record.setValue(columnKey, value)\n grid.pcfContext.factory.requestRender();\n }\n }\n }\n\n return (\n <div className={styles.root}>\n <div className={styles.readOnlyGrid}>\n <div className={styles.gridTitleWrapper}>\n <Text title={record.getOriginalFormattedPrimaryNameValue()} variant='large'>{record.getOriginalFormattedPrimaryNameValue()}</Text>\n </div>\n <Grid\n {...sharedProps}\n parameters={{\n ...sharedProps.parameters,\n ChangeEditorMode: {\n raw: \"read\",\n error: hasInvalidColumn,\n },\n Grid: {\n ...sharedProps.parameters.Grid,\n error: hasInvalidColumn,\n errorMessage: hasInvalidColumn ? grid.labels['saving-validation-error']({\n columnDisplayNames: invalidColumns.map( x => x.displayName).join(', ')\n }): undefined,\n records: {\n [record.getRecordId()]: getOriginalRecord(record)\n }\n },\n\n } as IGridParameters} />\n </div>\n <Icon iconName=\"DoubleChevronDown8\" />\n <div className={styles.editableGrid}>\n <Grid\n {...sharedProps}\n parameters={{\n ...sharedProps.parameters,\n ChangeEditorMode: {\n raw: \"edit\"\n },\n EnableEditing: {\n raw: true\n },\n Grid: {\n ...sharedProps.parameters.Grid,\n records: {\n [record.getRecordId()]: getUpdatedRecord(record)\n }\n }\n } as IGridParameters} />\n </div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,OAAO,EAAE;gCACL,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC;AACnD,6BAAA;AACJ,yBAAA;qBACe,EAAI,CAAA,EAAA,CAC1B,CACJ,EAAA,CAAA,EACT;AACL;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ROW_HEIGHT = 42;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/Grid/core/constants.ts"],"sourcesContent":["export const ROW_HEIGHT = 42;"],"names":[],"mappings":"AAAO,MAAM,UAAU,GAAG;;;;"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { IEntityRecord } from "../../interfaces";
|
|
2
1
|
import { Grid } from "../model/Grid";
|
|
3
2
|
import { IGridColumn } from "../interfaces/IGridColumn";
|
|
4
3
|
interface IGridController {
|
|
5
4
|
columns: IGridColumn[];
|
|
6
|
-
records: IEntityRecord[];
|
|
7
5
|
}
|
|
8
6
|
export declare const useGridController: (gridInstance?: Grid) => IGridController;
|
|
9
7
|
export {};
|
|
@@ -5,33 +5,17 @@ import { GridContext } from '../../GridContext.js';
|
|
|
5
5
|
const useGridController = (gridInstance) => {
|
|
6
6
|
const grid = gridInstance ?? useContext(GridContext).gridInstance;
|
|
7
7
|
const [columns, setColumns] = useState(grid.columns);
|
|
8
|
-
const [records, setRecords] = useState(() => grid.refreshRecords());
|
|
9
|
-
const getRecordValues = (columns, records) => {
|
|
10
|
-
const newRecordValues = records.map(x => {
|
|
11
|
-
const values = [];
|
|
12
|
-
for (const column of columns) {
|
|
13
|
-
values.push(x.getValue(column.key));
|
|
14
|
-
}
|
|
15
|
-
return values;
|
|
16
|
-
});
|
|
17
|
-
return newRecordValues;
|
|
18
|
-
};
|
|
19
8
|
//only change columns and records reference if there is a change
|
|
20
9
|
useEffect(() => {
|
|
21
10
|
(async () => {
|
|
22
11
|
const newColumns = await grid.refreshColumns();
|
|
23
|
-
const newRecordValues = getRecordValues(newColumns, grid.refreshRecords());
|
|
24
12
|
if (!equal(newColumns, columns)) {
|
|
25
13
|
setColumns(newColumns);
|
|
26
14
|
}
|
|
27
|
-
if (!equal(newRecordValues, getRecordValues(newColumns, records))) {
|
|
28
|
-
setRecords(grid.records);
|
|
29
|
-
}
|
|
30
15
|
})();
|
|
31
16
|
}, [grid.shouldRerender]);
|
|
32
17
|
return {
|
|
33
|
-
columns
|
|
34
|
-
records
|
|
18
|
+
columns
|
|
35
19
|
};
|
|
36
20
|
};
|
|
37
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGridController.js","sources":["../../../../../src/components/Grid/core/controllers/useGridController.ts"],"sourcesContent":["import { useContext, useEffect, useState } from \"react\"\nimport equal from 'fast-deep-equal/es6';\nimport { IEntityRecord } from \"../../interfaces\";\nimport { Grid } from \"../model/Grid\";\nimport { IGridColumn } from \"../interfaces/IGridColumn\";\nimport { GridContext } from \"../../GridContext\";\n\ninterface IGridController {\n columns: IGridColumn[]
|
|
1
|
+
{"version":3,"file":"useGridController.js","sources":["../../../../../src/components/Grid/core/controllers/useGridController.ts"],"sourcesContent":["import { useContext, useEffect, useState } from \"react\"\nimport equal from 'fast-deep-equal/es6';\nimport { IEntityRecord } from \"../../interfaces\";\nimport { Grid } from \"../model/Grid\";\nimport { IGridColumn } from \"../interfaces/IGridColumn\";\nimport { GridContext } from \"../../GridContext\";\n\ninterface IGridController {\n columns: IGridColumn[]\n}\n\nexport const useGridController = (gridInstance?: Grid): IGridController => {\n const grid = gridInstance ?? useContext(GridContext).gridInstance;\n const [columns, setColumns] = useState<IGridColumn[]>(grid.columns);\n\n\n //only change columns and records reference if there is a change\n useEffect(() => {\n (async () => {\n const newColumns = await grid.refreshColumns();\n if(!equal(newColumns, columns)) {\n setColumns(newColumns);\n }\n })();\n }, [grid.shouldRerender]);\n return {\n columns\n }\n}"],"names":[],"mappings":";;;;AAWa,MAAA,iBAAiB,GAAG,CAAC,YAAmB,KAAqB;IACtE,MAAM,IAAI,GAAG,YAAY,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC;AAClE,IAAA,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,OAAO,CAAC,CAAC;;IAIpE,SAAS,CAAC,MAAK;QACX,CAAC,YAAW;AACR,YAAA,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;AAC/C,YAAA,IAAG,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE;gBAC5B,UAAU,CAAC,UAAU,CAAC,CAAC;AAC1B,aAAA;SACJ,GAAG,CAAC;AACT,KAAC,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAC1B,OAAO;QACH,OAAO;KACV,CAAA;AACL;;;;"}
|
|
@@ -6,6 +6,7 @@ import { Paging } from "../../paging/model/Paging";
|
|
|
6
6
|
import { Selection } from "../../selection/model/Selection";
|
|
7
7
|
import { Sorting } from "../../sorting/Sorting";
|
|
8
8
|
import { IGridColumn } from "../interfaces/IGridColumn";
|
|
9
|
+
import { KeyHoldListener } from "../services/KeyListener";
|
|
9
10
|
import { RecordUpdateService } from "../services/RecordUpdateService/model/RecordUpdateService";
|
|
10
11
|
import { Metadata } from "./Metadata";
|
|
11
12
|
export declare class Grid {
|
|
@@ -13,11 +14,16 @@ export declare class Grid {
|
|
|
13
14
|
private _dataset;
|
|
14
15
|
private _pcfContext;
|
|
15
16
|
private _columns;
|
|
16
|
-
private
|
|
17
|
+
private _previousRecordsReference;
|
|
17
18
|
private _labels;
|
|
18
19
|
private _shouldRerender;
|
|
20
|
+
private _records;
|
|
19
21
|
private _dependencies;
|
|
20
|
-
|
|
22
|
+
private _maxHeight;
|
|
23
|
+
private _minHeight;
|
|
24
|
+
private _initialPageSize;
|
|
25
|
+
readonly keyHoldListener: KeyHoldListener;
|
|
26
|
+
constructor(props: IGrid, labels: any, keyHoldListener: KeyHoldListener);
|
|
21
27
|
get isNavigationEnabled(): boolean;
|
|
22
28
|
get isEditable(): boolean;
|
|
23
29
|
get parameters(): import("../../interfaces").IGridParameters;
|
|
@@ -42,12 +48,13 @@ export declare class Grid {
|
|
|
42
48
|
get enableOptionSetColors(): boolean;
|
|
43
49
|
get linking(): ComponentFramework.PropertyHelper.DataSetApi.Linking;
|
|
44
50
|
get inlineRibbonButtonIds(): string[] | undefined;
|
|
51
|
+
get height(): string;
|
|
45
52
|
openDatasetItem(entityReference: ComponentFramework.EntityReference): void;
|
|
46
53
|
updateDependencies(props: IGrid): void;
|
|
47
54
|
refreshColumns(): Promise<IGridColumn[]>;
|
|
48
|
-
refreshRecords(): IEntityRecord[];
|
|
49
55
|
private _isColumnEditable;
|
|
50
56
|
private _isColumnRequired;
|
|
51
57
|
private _isColumnSortable;
|
|
52
58
|
private _isColumnFilterable;
|
|
59
|
+
private _getMaxHeight;
|
|
53
60
|
}
|
|
@@ -3,19 +3,24 @@ import { Filtering } from '../../filtering/model/Filtering.js';
|
|
|
3
3
|
import { Paging } from '../../paging/model/Paging.js';
|
|
4
4
|
import { Selection } from '../../selection/model/Selection.js';
|
|
5
5
|
import { Sorting } from '../../sorting/Sorting.js';
|
|
6
|
+
import { ROW_HEIGHT } from '../constants.js';
|
|
6
7
|
import { DataType } from '../enums/DataType.js';
|
|
7
8
|
import { RecordUpdateService } from '../services/RecordUpdateService/model/RecordUpdateService.js';
|
|
8
9
|
import { Metadata } from './Metadata.js';
|
|
9
10
|
|
|
10
11
|
class Grid {
|
|
11
|
-
constructor(props, labels) {
|
|
12
|
+
constructor(props, labels, keyHoldListener) {
|
|
12
13
|
this._columns = [];
|
|
13
|
-
|
|
14
|
+
//used for optimization
|
|
15
|
+
this._previousRecordsReference = {};
|
|
14
16
|
this._shouldRerender = false;
|
|
17
|
+
this._records = [];
|
|
18
|
+
this._minHeight = 150;
|
|
15
19
|
this._props = props;
|
|
16
20
|
this._dataset = props.parameters.Grid;
|
|
17
21
|
this._pcfContext = props.context;
|
|
18
22
|
this._labels = labels;
|
|
23
|
+
this.keyHoldListener = keyHoldListener;
|
|
19
24
|
this._dependencies = {
|
|
20
25
|
recordUpdateService: new RecordUpdateService(this),
|
|
21
26
|
filtering: new Filtering(this),
|
|
@@ -24,6 +29,8 @@ class Grid {
|
|
|
24
29
|
sorting: new Sorting(this),
|
|
25
30
|
paging: new Paging(this)
|
|
26
31
|
};
|
|
32
|
+
this._initialPageSize = this.paging.pageSize;
|
|
33
|
+
this._maxHeight = this._getMaxHeight();
|
|
27
34
|
}
|
|
28
35
|
;
|
|
29
36
|
get isNavigationEnabled() {
|
|
@@ -103,9 +110,25 @@ class Grid {
|
|
|
103
110
|
}
|
|
104
111
|
return idString.split(',');
|
|
105
112
|
}
|
|
113
|
+
get height() {
|
|
114
|
+
let height = this._maxHeight;
|
|
115
|
+
if (this.parameters.Height?.raw) {
|
|
116
|
+
return this.parameters.Height?.raw;
|
|
117
|
+
}
|
|
118
|
+
if (this._records.length === 0) {
|
|
119
|
+
height = this._minHeight;
|
|
120
|
+
}
|
|
121
|
+
else if (this._records.length <= this._initialPageSize) {
|
|
122
|
+
height = this._records.length * ROW_HEIGHT;
|
|
123
|
+
}
|
|
124
|
+
if (height > this._maxHeight) {
|
|
125
|
+
height = this._maxHeight;
|
|
126
|
+
}
|
|
127
|
+
return `${height}px`;
|
|
128
|
+
}
|
|
106
129
|
openDatasetItem(entityReference) {
|
|
107
130
|
this._dataset.openDatasetItem(entityReference);
|
|
108
|
-
const clickedRecord = this.
|
|
131
|
+
const clickedRecord = this.records.find(x => x.getRecordId() === entityReference.id.guid);
|
|
109
132
|
//we need to make sure the item we are opening gets selected in order for the
|
|
110
133
|
//OnOpenRecord ribbon scripts to work correctly
|
|
111
134
|
//if no record found we have clicked a lookup, no selection should be happening in that case
|
|
@@ -117,6 +140,11 @@ class Grid {
|
|
|
117
140
|
this._props = props;
|
|
118
141
|
this._dataset = props.parameters.Grid;
|
|
119
142
|
this._pcfContext = props.context;
|
|
143
|
+
//THIS COULD MAKE GRID STOP WORKING IN POWER APPS!
|
|
144
|
+
if (this._previousRecordsReference !== this._dataset.records) {
|
|
145
|
+
this._records = Object.values(this._dataset.records);
|
|
146
|
+
this._previousRecordsReference = this._dataset.records;
|
|
147
|
+
}
|
|
120
148
|
for (const [key, dependency] of Object.entries(this._dependencies)) {
|
|
121
149
|
dependency.onDependenciesUpdated();
|
|
122
150
|
}
|
|
@@ -184,14 +212,6 @@ class Grid {
|
|
|
184
212
|
this._columns = gridColumns;
|
|
185
213
|
return gridColumns;
|
|
186
214
|
}
|
|
187
|
-
refreshRecords() {
|
|
188
|
-
const records = [];
|
|
189
|
-
for (const [_, record] of Object.entries(this._dataset.records)) {
|
|
190
|
-
records.push(record);
|
|
191
|
-
}
|
|
192
|
-
this._records = records;
|
|
193
|
-
return records;
|
|
194
|
-
}
|
|
195
215
|
async _isColumnEditable(column) {
|
|
196
216
|
//top priority, overriden through props
|
|
197
217
|
if (typeof column.isEditable === 'boolean') {
|
|
@@ -201,10 +221,6 @@ class Grid {
|
|
|
201
221
|
if (!this._props.parameters.EnableEditing?.raw) {
|
|
202
222
|
return false;
|
|
203
223
|
}
|
|
204
|
-
//we are not supporting editing for linked entities
|
|
205
|
-
if (column.entityAliasName) {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
224
|
//these field types do not support editing
|
|
209
225
|
switch (column.dataType) {
|
|
210
226
|
case DataType.FILE:
|
|
@@ -212,7 +228,7 @@ class Grid {
|
|
|
212
228
|
return false;
|
|
213
229
|
}
|
|
214
230
|
}
|
|
215
|
-
const metadata = await this.
|
|
231
|
+
const metadata = await this.metadata.get(column);
|
|
216
232
|
//IsEditable is not available in Power Apps
|
|
217
233
|
return metadata.Attributes.get(column.attributeName)?.attributeDescriptor.IsValidForUpdate ?? false;
|
|
218
234
|
}
|
|
@@ -231,6 +247,9 @@ class Grid {
|
|
|
231
247
|
return false;
|
|
232
248
|
}
|
|
233
249
|
_isColumnSortable(column) {
|
|
250
|
+
if (column.name.endsWith('__virtual')) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
234
253
|
if (this._props.parameters.EnableSorting?.raw === false) {
|
|
235
254
|
return false;
|
|
236
255
|
}
|
|
@@ -242,11 +261,21 @@ class Grid {
|
|
|
242
261
|
return !column.disableSorting;
|
|
243
262
|
}
|
|
244
263
|
_isColumnFilterable(column) {
|
|
264
|
+
if (column.name.endsWith('__virtual')) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
245
267
|
if (this.props.parameters.EnableFiltering?.raw === false) {
|
|
246
268
|
return false;
|
|
247
269
|
}
|
|
248
270
|
return column.isFilterable ?? true;
|
|
249
271
|
}
|
|
272
|
+
_getMaxHeight() {
|
|
273
|
+
let maxHeight = this._initialPageSize * ROW_HEIGHT;
|
|
274
|
+
if (maxHeight > 600) {
|
|
275
|
+
maxHeight = 600;
|
|
276
|
+
}
|
|
277
|
+
return maxHeight;
|
|
278
|
+
}
|
|
250
279
|
}
|
|
251
280
|
|
|
252
281
|
export { Grid };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.js","sources":["../../../../../src/components/Grid/core/model/Grid.ts"],"sourcesContent":["import { IDatasetProperty } from \"../../../../interfaces\";\nimport { RIBBON_COLUMN_KEY } from \"../../constants\";\nimport { Filtering } from \"../../filtering/model/Filtering\";\nimport { IEntityColumn, IEntityRecord, IGrid } from \"../../interfaces\";\nimport { Paging } from \"../../paging/model/Paging\";\nimport { Selection } from \"../../selection/model/Selection\";\nimport { Sorting } from \"../../sorting/Sorting\";\nimport { DataType } from \"../enums/DataType\";\nimport { IGridColumn } from \"../interfaces/IGridColumn\";\nimport { RecordUpdateService } from \"../services/RecordUpdateService/model/RecordUpdateService\";\nimport { Metadata } from \"./Metadata\";\n\nexport class Grid {\n private _props: IGrid;\n private _dataset: IDatasetProperty\n private _pcfContext: ComponentFramework.Context<any>;\n private _columns: IGridColumn[] = [];\n private _records: IEntityRecord[] = [];\n //TODO: fix\n private _labels: any;\n private _shouldRerender: boolean = false;\n //TODO: the dependencies might not have fully loaded grid\n //need to make sure that the grid is initialized before creating them\n private _dependencies: {\n recordUpdateService: RecordUpdateService,\n filtering: Filtering,\n sorting: Sorting,\n metadata: Metadata,\n selection: Selection,\n paging: Paging\n };\n constructor(props: IGrid, labels: any) {\n this._props = props;\n this._dataset = props.parameters.Grid;\n this._pcfContext = props.context;\n this._labels = labels;\n\n this._dependencies = {\n recordUpdateService: new RecordUpdateService(this),\n filtering: new Filtering(this),\n selection: new Selection(this),\n metadata: new Metadata(this),\n sorting: new Sorting(this),\n paging: new Paging(this)\n }\n\n };\n public get isNavigationEnabled() {\n //enabled by default\n return this.parameters.EnableNavigation?.raw !== false;\n }\n public get isEditable() {\n return this._columns.find(x => x.isEditable) ? true : false;\n }\n public get parameters() {\n return this._props.parameters\n }\n public get error() {\n return this._dataset.error;\n }\n public get errorMessage() {\n return this._dataset.errorMessage\n }\n public get labels() {\n return this._labels;\n }\n public get dataset() {\n return this._dataset;\n }\n public get pcfContext() {\n return this._pcfContext;\n }\n public get props() {\n return this._props;\n }\n public get columns() {\n return this._columns;\n }\n public get records() {\n return this._records;\n }\n public get recordUpdateService() {\n return this._dependencies.recordUpdateService;\n }\n public get sorting() {\n return this._dependencies.sorting;\n }\n public get metadata() {\n return this._dependencies.metadata;\n }\n public get filtering() {\n return this._dependencies.filtering;\n }\n public get selection() {\n return this._dependencies.selection;\n }\n public get paging() {\n return this._dependencies.paging;\n }\n public get shouldRerender() {\n return this._shouldRerender;\n }\n public get loading() {\n return this._dataset.loading;\n }\n public get state() {\n return this._props.state;\n }\n public get useContainerAsHeight() {\n return this.parameters.UseContainerAsHeight?.raw === true;\n }\n public get enableOptionSetColors() {\n return this.parameters.EnableOptionSetColors?.raw === true;\n }\n public get linking() {\n return this.dataset.linking;\n }\n public get inlineRibbonButtonIds() {\n const idString = this.parameters.InlineRibbonButtonIds?.raw;\n if (!idString) {\n return undefined;\n }\n return idString.split(',');\n }\n\n public openDatasetItem(entityReference: ComponentFramework.EntityReference) {\n this._dataset.openDatasetItem(entityReference);\n const clickedRecord = this._records.find(x => x.getRecordId() === entityReference.id.guid);\n //we need to make sure the item we are opening gets selected in order for the\n //OnOpenRecord ribbon scripts to work correctly\n //if no record found we have clicked a lookup, no selection should be happening in that case\n if (clickedRecord) {\n this.selection.toggle(clickedRecord, true, true, true);\n }\n }\n\n public updateDependencies(props: IGrid): void {\n this._props = props;\n this._dataset = props.parameters.Grid;\n this._pcfContext = props.context;\n for (const [key, dependency] of Object.entries(this._dependencies)) {\n dependency.onDependenciesUpdated()\n }\n this._shouldRerender = !this.shouldRerender;\n }\n public async refreshColumns(): Promise<IGridColumn[]> {\n const gridColumns: IGridColumn[] = [];\n for (const column of this._dataset.columns) {\n if(column.isHidden) {\n continue;\n }\n const sorted = this._dataset.sorting?.find(sort => sort.name === column.name);\n const entityAliasName = column.name?.includes('.') ? column.name.split('.')[0] : null;\n const attributeName = entityAliasName ? column.name.split('.')[1] : column.name;\n const key = entityAliasName ? `${entityAliasName}.${attributeName}` : attributeName;\n switch (column.dataType) {\n case DataType.FILE:\n case DataType.IMAGE: {\n if (entityAliasName) {\n //we do not support file fields with linked entities\n //the getValue API throws an error in Power Apps\n continue;\n }\n }\n }\n const gridColumn = {\n entityAliasName: entityAliasName,\n attributeName: attributeName,\n key: entityAliasName ? `${entityAliasName}.${attributeName}` : attributeName,\n isPrimary: column.isPrimary,\n dataType: column.dataType as DataType,\n displayName: column.displayName,\n isEditable: column.isEditable,\n isFilterable: this._isColumnFilterable(column),\n isRequired: column.isRequired,\n isSortable: this._isColumnSortable(column),\n isSorted: sorted ? true : false,\n isSortedDescending: sorted?.sortDirection === 1 ? true : false,\n width: this.state?.columnSizing?.columnSizingModel?.find((x: any) => x.colId === key)?.width || column.visualSizeFactor,\n isResizable: column.isResizable ?? true,\n isHidden: column.isHidden\n } as IGridColumn;\n\n const condition = await this.filtering.condition(gridColumn);\n gridColumn.isFiltered = condition.isAppliedToDataset;\n gridColumn.isEditable = await this._isColumnEditable(gridColumn);\n gridColumn.isRequired = await this._isColumnRequired(gridColumn);\n\n if (gridColumn.key === RIBBON_COLUMN_KEY) {\n gridColumn.isFilterable = false;\n gridColumn.isSortable = false;\n }\n gridColumns.push(gridColumn);\n }\n/* gridColumns.unshift({\n key: RIBBON_COLUMN_KEY,\n attributeName: RIBBON_COLUMN_KEY,\n }) */\n if (this.selection.type !== undefined) {\n gridColumns.unshift({\n key: '__checkbox',\n attributeName: '__checkbox',\n width: 45,\n isResizable: false\n })\n }\n this._columns = gridColumns;\n return gridColumns;\n }\n\n public refreshRecords(): IEntityRecord[] {\n const records = [];\n for (const [_, record] of Object.entries(this._dataset.records)) {\n records.push(record);\n }\n this._records = records;\n return records\n }\n\n private async _isColumnEditable(column: IGridColumn): Promise<boolean> {\n //top priority, overriden through props\n if (typeof column.isEditable === 'boolean') {\n return column.isEditable\n }\n //only allow editing if specifically allowed\n if (!this._props.parameters.EnableEditing?.raw) {\n return false;\n }\n //we are not supporting editing for linked entities\n if (column.entityAliasName) {\n return false;\n }\n //these field types do not support editing\n switch (column.dataType) {\n case DataType.FILE:\n case DataType.IMAGE: {\n return false;\n }\n }\n const metadata = await this._pcfContext.utils.getEntityMetadata(this._dataset.getTargetEntityType(), [column.attributeName]);\n //IsEditable is not available in Power Apps\n return metadata.Attributes.get(column.attributeName)?.attributeDescriptor.IsValidForUpdate ?? false;\n }\n\n private async _isColumnRequired(column: IGridColumn) {\n if (typeof column.isRequired === 'boolean') {\n return column.isRequired;\n }\n if (!this.parameters.EnableEditing?.raw) {\n return false;\n }\n const metadata = await this.metadata.get(column);\n const requiredLevel = metadata.Attributes.get(column.attributeName)?.attributeDescriptor.RequiredLevel;\n if (requiredLevel === 1 || requiredLevel === 2) {\n return true;\n }\n return false;\n }\n private _isColumnSortable(column: IEntityColumn) {\n if (this._props.parameters.EnableSorting?.raw === false) {\n return false;\n }\n switch (column.dataType) {\n case DataType.IMAGE: {\n return false;\n }\n }\n return !column.disableSorting;\n }\n private _isColumnFilterable(column: IEntityColumn) {\n if (this.props.parameters.EnableFiltering?.raw === false) {\n return false;\n }\n return column.isFilterable ?? true;\n }\n}"],"names":[],"mappings":";;;;;;;;;MAYa,IAAI,CAAA;IAmBb,WAAY,CAAA,KAAY,EAAE,MAAW,EAAA;QAf7B,IAAQ,CAAA,QAAA,GAAkB,EAAE,CAAC;QAC7B,IAAQ,CAAA,QAAA,GAAoB,EAAE,CAAC;QAG/B,IAAe,CAAA,eAAA,GAAY,KAAK,CAAC;AAYrC,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;AACtC,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC;AACjC,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,IAAI,CAAC,aAAa,GAAG;AACjB,YAAA,mBAAmB,EAAE,IAAI,mBAAmB,CAAC,IAAI,CAAC;AAClD,YAAA,SAAS,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC;AAC9B,YAAA,SAAS,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC;AAC9B,YAAA,QAAQ,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC;AAC5B,YAAA,OAAO,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;AAC1B,YAAA,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC;SAC3B,CAAA;KAEJ;;AACD,IAAA,IAAW,mBAAmB,GAAA;;QAE1B,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,GAAG,KAAK,KAAK,CAAC;KAC1D;AACD,IAAA,IAAW,UAAU,GAAA;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,KAAK,CA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EAAE;AAC5C,YAAA,OAAO,IAAI,CAAC;AACf,SAAA;AACD,QAAA,OAAO,KAAK,CAAC;KAChB;AACO,IAAA,iBAAiB,CAAC,MAAqB,EAAA;QAC3C,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,EAAE,GAAG,KAAK,KAAK,EAAE;AACrD,YAAA,OAAO,KAAK,CAAC;AAChB,SAAA;QACD,QAAQ,MAAM,CAAC,QAAQ;AACnB,YAAA,KAAK,QAAQ,CAAC,KAAK,EAAE;AACjB,gBAAA,OAAO,KAAK,CAAC;AAChB,aAAA;AACJ,SAAA;AACD,QAAA,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;KACjC;AACO,IAAA,mBAAmB,CAAC,MAAqB,EAAA;QAC7C,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,KAAK,KAAK,EAAE;AACtD,YAAA,OAAO,KAAK,CAAC;AAChB,SAAA;AACD,QAAA,OAAO,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC;KACtC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"Grid.js","sources":["../../../../../src/components/Grid/core/model/Grid.ts"],"sourcesContent":["import { IDatasetProperty } from \"../../../../interfaces\";\nimport { RIBBON_COLUMN_KEY } from \"../../constants\";\nimport { Filtering } from \"../../filtering/model/Filtering\";\nimport { IEntityColumn, IEntityRecord, IGrid } from \"../../interfaces\";\nimport { Paging } from \"../../paging/model/Paging\";\nimport { Selection } from \"../../selection/model/Selection\";\nimport { Sorting } from \"../../sorting/Sorting\";\nimport { ROW_HEIGHT } from \"../constants\";\nimport { DataType } from \"../enums/DataType\";\nimport { IGridColumn } from \"../interfaces/IGridColumn\";\nimport { KeyHoldListener } from \"../services/KeyListener\";\nimport { RecordUpdateService } from \"../services/RecordUpdateService/model/RecordUpdateService\";\nimport { Metadata } from \"./Metadata\";\n\nexport class Grid {\n private _props: IGrid;\n private _dataset: IDatasetProperty\n private _pcfContext: ComponentFramework.Context<any>;\n private _columns: IGridColumn[] = [];\n //used for optimization\n private _previousRecordsReference: {\n [id: string]: IEntityRecord;\n } = {};\n //TODO: fix types\n private _labels: any;\n private _shouldRerender: boolean = false;\n private _records: IEntityRecord[] = [];\n //TODO: the dependencies might not have fully loaded grid\n //need to make sure that the grid is initialized before creating them\n private _dependencies: {\n recordUpdateService: RecordUpdateService,\n filtering: Filtering,\n sorting: Sorting,\n metadata: Metadata,\n selection: Selection,\n paging: Paging\n };\n private _maxHeight: number;\n private _minHeight: number = 150;\n private _initialPageSize: number;\n public readonly keyHoldListener: KeyHoldListener;\n\n constructor(props: IGrid, labels: any, keyHoldListener: KeyHoldListener) {\n this._props = props;\n this._dataset = props.parameters.Grid;\n this._pcfContext = props.context;\n this._labels = labels;\n this.keyHoldListener = keyHoldListener;\n\n this._dependencies = {\n recordUpdateService: new RecordUpdateService(this),\n filtering: new Filtering(this),\n selection: new Selection(this),\n metadata: new Metadata(this),\n sorting: new Sorting(this),\n paging: new Paging(this)\n }\n this._initialPageSize = this.paging.pageSize;\n this._maxHeight = this._getMaxHeight();\n\n };\n public get isNavigationEnabled() {\n //enabled by default\n return this.parameters.EnableNavigation?.raw !== false;\n }\n public get isEditable() {\n return this._columns.find(x => x.isEditable) ? true : false;\n }\n public get parameters() {\n return this._props.parameters\n }\n public get error() {\n return this._dataset.error;\n }\n public get errorMessage() {\n return this._dataset.errorMessage\n }\n public get labels() {\n return this._labels;\n }\n public get dataset() {\n return this._dataset;\n }\n public get pcfContext() {\n return this._pcfContext;\n }\n public get props() {\n return this._props;\n }\n public get columns() {\n return this._columns;\n }\n public get records() {\n return this._records\n }\n public get recordUpdateService() {\n return this._dependencies.recordUpdateService;\n }\n public get sorting() {\n return this._dependencies.sorting;\n }\n public get metadata() {\n return this._dependencies.metadata;\n }\n public get filtering() {\n return this._dependencies.filtering;\n }\n public get selection() {\n return this._dependencies.selection;\n }\n public get paging() {\n return this._dependencies.paging;\n }\n public get shouldRerender() {\n return this._shouldRerender;\n }\n public get loading() {\n return this._dataset.loading;\n }\n public get state() {\n return this._props.state;\n }\n public get useContainerAsHeight() {\n return this.parameters.UseContainerAsHeight?.raw === true;\n }\n public get enableOptionSetColors() {\n return this.parameters.EnableOptionSetColors?.raw === true;\n }\n public get linking() {\n return this.dataset.linking;\n }\n public get inlineRibbonButtonIds() {\n const idString = this.parameters.InlineRibbonButtonIds?.raw;\n if (!idString) {\n return undefined;\n }\n return idString.split(',');\n }\n\n public get height() {\n let height = this._maxHeight;\n if(this.parameters.Height?.raw) {\n return this.parameters.Height?.raw;\n }\n if(this._records.length === 0) {\n height = this._minHeight;\n }\n else if(this._records.length <= this._initialPageSize) {\n height = this._records.length * ROW_HEIGHT;\n }\n if(height > this._maxHeight) {\n height = this._maxHeight;\n }\n return `${height}px`;\n\n }\n\n public openDatasetItem(entityReference: ComponentFramework.EntityReference) {\n this._dataset.openDatasetItem(entityReference);\n const clickedRecord = this.records.find(x => x.getRecordId() === entityReference.id.guid);\n //we need to make sure the item we are opening gets selected in order for the\n //OnOpenRecord ribbon scripts to work correctly\n //if no record found we have clicked a lookup, no selection should be happening in that case\n if (clickedRecord) {\n this.selection.toggle(clickedRecord, true, true, true);\n }\n }\n\n public updateDependencies(props: IGrid): void {\n this._props = props;\n this._dataset = props.parameters.Grid;\n this._pcfContext = props.context;\n //THIS COULD MAKE GRID STOP WORKING IN POWER APPS!\n if(this._previousRecordsReference !== this._dataset.records) {\n this._records = Object.values(this._dataset.records);\n this._previousRecordsReference = this._dataset.records;\n }\n for (const [key, dependency] of Object.entries(this._dependencies)) {\n dependency.onDependenciesUpdated()\n }\n this._shouldRerender = !this.shouldRerender;\n }\n public async refreshColumns(): Promise<IGridColumn[]> {\n const gridColumns: IGridColumn[] = [];\n for (const column of this._dataset.columns) {\n if(column.isHidden) {\n continue;\n }\n const sorted = this._dataset.sorting?.find(sort => sort.name === column.name);\n const entityAliasName = column.name?.includes('.') ? column.name.split('.')[0] : null;\n const attributeName = entityAliasName ? column.name.split('.')[1] : column.name;\n const key = entityAliasName ? `${entityAliasName}.${attributeName}` : attributeName;\n switch (column.dataType) {\n case DataType.FILE:\n case DataType.IMAGE: {\n if (entityAliasName) {\n //we do not support file fields with linked entities\n //the getValue API throws an error in Power Apps\n continue;\n }\n }\n }\n const gridColumn = {\n entityAliasName: entityAliasName,\n attributeName: attributeName,\n key: entityAliasName ? `${entityAliasName}.${attributeName}` : attributeName,\n isPrimary: column.isPrimary,\n dataType: column.dataType as DataType,\n displayName: column.displayName,\n isEditable: column.isEditable,\n isFilterable: this._isColumnFilterable(column),\n isRequired: column.isRequired,\n isSortable: this._isColumnSortable(column),\n isSorted: sorted ? true : false,\n isSortedDescending: sorted?.sortDirection === 1 ? true : false,\n width: this.state?.columnSizing?.columnSizingModel?.find((x: any) => x.colId === key)?.width || column.visualSizeFactor,\n isResizable: column.isResizable ?? true,\n isHidden: column.isHidden\n } as IGridColumn;\n\n const condition = await this.filtering.condition(gridColumn);\n gridColumn.isFiltered = condition.isAppliedToDataset;\n gridColumn.isEditable = await this._isColumnEditable(gridColumn);\n gridColumn.isRequired = await this._isColumnRequired(gridColumn);\n\n if (gridColumn.key === RIBBON_COLUMN_KEY) {\n gridColumn.isFilterable = false;\n gridColumn.isSortable = false;\n }\n gridColumns.push(gridColumn);\n }\n/* gridColumns.unshift({\n key: RIBBON_COLUMN_KEY,\n attributeName: RIBBON_COLUMN_KEY,\n }) */\n if (this.selection.type !== undefined) {\n gridColumns.unshift({\n key: '__checkbox',\n attributeName: '__checkbox',\n width: 45,\n isResizable: false\n })\n }\n this._columns = gridColumns;\n return gridColumns;\n }\n\n private async _isColumnEditable(column: IGridColumn): Promise<boolean> {\n //top priority, overriden through props\n if (typeof column.isEditable === 'boolean') {\n return column.isEditable\n }\n //only allow editing if specifically allowed\n if (!this._props.parameters.EnableEditing?.raw) {\n return false;\n }\n //these field types do not support editing\n switch (column.dataType) {\n case DataType.FILE:\n case DataType.IMAGE: {\n return false;\n }\n }\n const metadata = await this.metadata.get(column);\n //IsEditable is not available in Power Apps\n return metadata.Attributes.get(column.attributeName)?.attributeDescriptor.IsValidForUpdate ?? false;\n }\n\n private async _isColumnRequired(column: IGridColumn) {\n if (typeof column.isRequired === 'boolean') {\n return column.isRequired;\n }\n if (!this.parameters.EnableEditing?.raw) {\n return false;\n }\n const metadata = await this.metadata.get(column);\n const requiredLevel = metadata.Attributes.get(column.attributeName)?.attributeDescriptor.RequiredLevel;\n if (requiredLevel === 1 || requiredLevel === 2) {\n return true;\n }\n return false;\n }\n private _isColumnSortable(column: IEntityColumn) {\n if(column.name.endsWith('__virtual')) {\n return false;\n }\n if (this._props.parameters.EnableSorting?.raw === false) {\n return false;\n }\n switch (column.dataType) {\n case DataType.IMAGE: {\n return false;\n }\n }\n return !column.disableSorting;\n }\n private _isColumnFilterable(column: IEntityColumn) {\n if(column.name.endsWith('__virtual')) {\n return false;\n }\n if (this.props.parameters.EnableFiltering?.raw === false) {\n return false;\n }\n return column.isFilterable ?? true;\n }\n private _getMaxHeight(): number {\n let maxHeight = this._initialPageSize * ROW_HEIGHT;\n if(maxHeight > 600) {\n maxHeight = 600;\n }\n return maxHeight;\n }\n}"],"names":[],"mappings":";;;;;;;;;;MAca,IAAI,CAAA;AA4Bb,IAAA,WAAA,CAAY,KAAY,EAAE,MAAW,EAAE,eAAgC,EAAA;QAxB/D,IAAQ,CAAA,QAAA,GAAkB,EAAE,CAAC;;QAE7B,IAAyB,CAAA,yBAAA,GAE7B,EAAE,CAAC;QAGC,IAAe,CAAA,eAAA,GAAY,KAAK,CAAC;QACjC,IAAQ,CAAA,QAAA,GAAoB,EAAE,CAAC;QAY/B,IAAU,CAAA,UAAA,GAAW,GAAG,CAAC;AAK7B,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;AACtC,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,C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eyHoldListener {
|
|
2
|
+
constructor() {
|
|
3
|
+
this._currentlyHeldKey = null;
|
|
4
|
+
window.addEventListener('keydown', this._onKeyDown.bind(this));
|
|
5
|
+
window.addEventListener('keyup', this._onKeyUp.bind(this));
|
|
6
|
+
}
|
|
7
|
+
getHeldKey() {
|
|
8
|
+
return this._currentlyHeldKey;
|
|
9
|
+
}
|
|
10
|
+
_onKeyDown(e) {
|
|
11
|
+
this._currentlyHeldKey = e.key;
|
|
12
|
+
}
|
|
13
|
+
_onKeyUp(e) {
|
|
14
|
+
this._currentlyHeldKey = null;
|
|
15
|
+
}
|
|
16
|
+
destroy() {
|
|
17
|
+
window.removeEventListener('keydown', this._onKeyDown);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { KeyHoldListener };
|
|
22
|
+
//# sourceMappingURL=KeyListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyListener.js","sources":["../../../../../src/components/Grid/core/services/KeyListener.ts"],"sourcesContent":["export class KeyHoldListener {\n private _currentlyHeldKey: string | null = null;\n constructor() {\n window.addEventListener('keydown', this._onKeyDown.bind(this));\n window.addEventListener('keyup', this._onKeyUp.bind(this));\n }\n public getHeldKey(): string | null {\n return this._currentlyHeldKey;\n }\n private _onKeyDown(e: KeyboardEvent) {\n this._currentlyHeldKey = e.key;\n }\n private _onKeyUp(e: KeyboardEvent) {\n this._currentlyHeldKey = null;\n }\n destroy() {\n window.removeEventListener('keydown', this._onKeyDown);\n }\n}"],"names":[],"mappings":"MAAa,eAAe,CAAA;AAExB,IAAA,WAAA,GAAA;QADQ,IAAiB,CAAA,iBAAA,GAAkB,IAAI,CAAC;AAE5C,QAAA,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,QAAA,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;KAC9D;IACM,UAAU,GAAA;QACb,OAAO,IAAI,CAAC,iBAAiB,CAAC;KACjC;AACO,IAAA,UAAU,CAAC,CAAgB,EAAA;AAC/B,QAAA,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,GAAG,CAAC;KAClC;AACO,IAAA,QAAQ,CAAC,CAAgB,EAAA;AAC7B,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;KACjC;IACD,OAAO,GAAA;QACH,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;KAC1D;AACJ;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import equal from 'fast-deep-equal/es6';
|
|
2
2
|
import { cloneDeep } from 'lodash';
|
|
3
3
|
import numeral from 'numeral';
|
|
4
|
-
import { Numeral } from '../../../../../../utils/Numeral.js';
|
|
5
4
|
import { ColumnValidation } from '../../../../validation/model/ColumnValidation.js';
|
|
6
5
|
import { DataType } from '../../../enums/DataType.js';
|
|
7
6
|
import { GridDependency } from '../../../model/GridDependency.js';
|
|
7
|
+
import { Numeral } from '@talxis/client-libraries';
|
|
8
8
|
|
|
9
9
|
class RecordUpdateService extends GridDependency {
|
|
10
10
|
constructor(grid) {
|
|
@@ -162,7 +162,7 @@ class RecordUpdateService extends GridDependency {
|
|
|
162
162
|
if (!gridColumn.entityAliasName) {
|
|
163
163
|
return x.name === gridColumn.attributeName;
|
|
164
164
|
}
|
|
165
|
-
return x.name === gridColumn.
|
|
165
|
+
return x.name === gridColumn.key;
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
_isReadOnlyChangeEditor() {
|