@talxis/base-controls 1.2605.2-alpha → 1.2606.2
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/dist/components/Grid/cells/cell/Cell.js +2 -6
- package/dist/components/Grid/cells/cell/Cell.js.map +1 -1
- package/dist/components/Grid/column-headers/column-header/ColumnHeader.js +1 -1
- package/dist/components/Grid/column-headers/column-header/ColumnHeader.js.map +1 -1
- package/dist/components/Grid/grid/ag-grid/AgGridModel.js +1 -1
- package/dist/components/Grid/grid/ag-grid/AgGridModel.js.map +1 -1
- package/dist/components/Lookup/components/TargetSelector.js +1 -1
- package/dist/components/Lookup/components/TargetSelector.js.map +1 -1
- package/dist/components/Lookup/hooks/useLookup.d.ts +4 -0
- package/dist/components/Lookup/translations.d.ts +4 -0
- package/dist/components/Lookup/translations.js +4 -0
- package/dist/components/Lookup/translations.js.map +1 -1
- package/dist/components/TaskGrid/TaskGrid.js +2 -2
- package/dist/components/TaskGrid/TaskGrid.js.map +1 -1
- package/dist/components/TaskGrid/TaskGridDatasetControl.d.ts +2 -0
- package/dist/components/TaskGrid/TaskGridDatasetControl.js +42 -28
- package/dist/components/TaskGrid/TaskGridDatasetControl.js.map +1 -1
- package/dist/components/TaskGrid/TaskGridDatasetControlFactory.js +3 -0
- package/dist/components/TaskGrid/TaskGridDatasetControlFactory.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/cell-renderers/lookup-many/LookupManyCellRenderer.js +6 -3
- package/dist/components/TaskGrid/components/grid/cell-renderers/lookup-many/LookupManyCellRenderer.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/cell-renderers/percent-complete/PercentComplete.js +2 -4
- package/dist/components/TaskGrid/components/grid/cell-renderers/percent-complete/PercentComplete.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/cell-renderers/percent-complete/styles.d.ts +0 -6
- package/dist/components/TaskGrid/components/grid/cell-renderers/percent-complete/styles.js +0 -6
- package/dist/components/TaskGrid/components/grid/cell-renderers/percent-complete/styles.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/grid-customizer/GridCustomizer.js +10 -5
- package/dist/components/TaskGrid/components/grid/grid-customizer/GridCustomizer.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/group-cell/styles.d.ts +3 -0
- package/dist/components/TaskGrid/components/grid/group-cell/styles.js +3 -0
- package/dist/components/TaskGrid/components/grid/group-cell/styles.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/LookupMany.d.ts +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/LookupMany.js +3 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/LookupMany.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/colorful-lookup-many/components/index.d.ts +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/colorful-lookup-many/components/index.js +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/colorful-lookup-many/components/index.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/components/components.d.ts +11 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/components.js +17 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/components.js.map +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/index.d.ts +1 -10
- package/dist/components/TaskGrid/components/grid/lookup-many/components/index.js +1 -14
- package/dist/components/TaskGrid/components/grid/lookup-many/components/index.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/components/menu/Menu.d.ts +3 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/menu/Menu.js +10 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/menu/Menu.js.map +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/menu/index.d.ts +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/menu/index.js +2 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/menu/index.js.map +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/components/multi-value-container/MultiValueContainer.d.ts +5 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/components/multi-value-container/MultiValueContainer.js +3 -2
- package/dist/components/TaskGrid/components/grid/lookup-many/components/multi-value-container/MultiValueContainer.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/PeopleLookupMany.js +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/PeopleLookupMany.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/components.d.ts +2 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/components.js +15 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/components.js.map +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/index.d.ts +1 -2
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/index.js +1 -12
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/index.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/MultiValueContainer.d.ts +3 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/MultiValueContainer.js +12 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/MultiValueContainer.js.map +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/index.d.ts +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/index.js +2 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/index.js.map +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/styles.d.ts +9 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/styles.js +18 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-container/styles.js.map +1 -0
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-label/MultiValueLabel.js +1 -1
- package/dist/components/TaskGrid/components/grid/lookup-many/people-lookup-many/components/multi-value-label/MultiValueLabel.js.map +1 -1
- package/dist/components/TaskGrid/components/grid/multi-record-selector/components/multi-value-label/MultiValueLabel.d.ts +1 -1
- package/dist/components/TaskGrid/components/grid/multi-record-selector/components/multi-value-label/MultiValueLabel.js +3 -2
- package/dist/components/TaskGrid/components/grid/multi-record-selector/components/multi-value-label/MultiValueLabel.js.map +1 -1
- package/dist/components/TaskGrid/components/header/Header.d.ts +1 -1
- package/dist/components/TaskGrid/components/header/Header.js +58 -44
- package/dist/components/TaskGrid/components/header/Header.js.map +1 -1
- package/dist/components/TaskGrid/extensions/dataverse/DataverseCustomColumnsStrategy.d.ts +12 -6
- package/dist/components/TaskGrid/extensions/dataverse/DataverseCustomColumnsStrategy.js +23 -20
- package/dist/components/TaskGrid/extensions/dataverse/DataverseCustomColumnsStrategy.js.map +1 -1
- package/dist/components/TaskGrid/extensions/dataverse/DataverseGridCustomizerStrategy.d.ts +3 -3
- package/dist/components/TaskGrid/extensions/dataverse/DataverseGridCustomizerStrategy.js +4 -5
- package/dist/components/TaskGrid/extensions/dataverse/DataverseGridCustomizerStrategy.js.map +1 -1
- package/dist/components/TaskGrid/extensions/dataverse/DataverseSavedQueryStrategy.js +15 -15
- package/dist/components/TaskGrid/extensions/dataverse/DataverseSavedQueryStrategy.js.map +1 -1
- package/dist/components/TaskGrid/extensions/dataverse/DataverseTaskGridDescriptor.d.ts +27 -25
- package/dist/components/TaskGrid/extensions/dataverse/DataverseTaskGridDescriptor.js +68 -29
- package/dist/components/TaskGrid/extensions/dataverse/DataverseTaskGridDescriptor.js.map +1 -1
- package/dist/components/TaskGrid/extensions/dataverse/DataverseTaskStrategy.d.ts +19 -17
- package/dist/components/TaskGrid/extensions/dataverse/DataverseTaskStrategy.js +119 -74
- package/dist/components/TaskGrid/extensions/dataverse/DataverseTaskStrategy.js.map +1 -1
- package/dist/components/TaskGrid/extensions/dataverse/index.js +1 -1
- package/dist/components/TaskGrid/extensions/dataverse/lookup-many/LookupManyHandler.d.ts +18 -2
- package/dist/components/TaskGrid/extensions/dataverse/lookup-many/LookupManyHandler.js +80 -17
- package/dist/components/TaskGrid/extensions/dataverse/lookup-many/LookupManyHandler.js.map +1 -1
- package/dist/components/TaskGrid/extensions/dataverse/lookup-many/cell-renderer/FetchXmlLookupManyCellRenderer.js +10 -4
- package/dist/components/TaskGrid/extensions/dataverse/lookup-many/cell-renderer/FetchXmlLookupManyCellRenderer.js.map +1 -1
- package/dist/components/TaskGrid/interfaces.d.ts +36 -22
- package/dist/components/TaskGrid/providers/custom-columns/CustomColumnsDataProvider.d.ts +7 -1
- package/dist/components/TaskGrid/providers/custom-columns/CustomColumnsDataProvider.js +3 -0
- package/dist/components/TaskGrid/providers/custom-columns/CustomColumnsDataProvider.js.map +1 -1
- package/dist/components/TaskGrid/providers/saved-query/SavedQueryDataProvider.d.ts +1 -1
- package/dist/components/TaskGrid/providers/saved-query/SavedQueryDataProvider.js +9 -26
- package/dist/components/TaskGrid/providers/saved-query/SavedQueryDataProvider.js.map +1 -1
- package/dist/components/TaskGrid/providers/task/TaskDataProvider.d.ts +13 -20
- package/dist/components/TaskGrid/providers/task/TaskDataProvider.js +30 -22
- package/dist/components/TaskGrid/providers/task/TaskDataProvider.js.map +1 -1
- package/dist/components/TaskGrid/providers/task/record-tree/RecordTree.d.ts +8 -0
- package/dist/components/TaskGrid/providers/task/record-tree/RecordTree.js.map +1 -1
- package/dist/index.d.ts +68 -42
- package/dist/utils/dataset/adapters/VirtualDatasetAdapter.js.map +1 -1
- package/package.json +4 -4
- package/dist/components/TaskGrid/extensions/LexoRank.d.ts +0 -7
package/dist/components/TaskGrid/extensions/dataverse/DataverseGridCustomizerStrategy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataverseGridCustomizerStrategy.js","sources":["../../../../../src/components/TaskGrid/extensions/dataverse/DataverseGridCustomizerStrategy.ts"],"sourcesContent":["import { ColDef, GridApi, IGridCustomizer, IGridCustomizerStrategy } from \"../../components/grid\";\nimport { ITaskDataProvider } from \"../../providers\";\nimport { FetchXmlLookupManyCellRenderer } from \"./lookup-many/cell-renderer/FetchXmlLookupManyCellRenderer\";\
|
|
1
|
+
{"version":3,"file":"DataverseGridCustomizerStrategy.js","sources":["../../../../../src/components/TaskGrid/extensions/dataverse/DataverseGridCustomizerStrategy.ts"],"sourcesContent":["import { ColDef, GridApi, IGridCustomizer, IGridCustomizerStrategy } from \"../../components/grid\";\nimport { ITaskDataProvider } from \"../../providers\";\nimport { FetchXmlLookupManyCellRenderer } from \"./lookup-many/cell-renderer/FetchXmlLookupManyCellRenderer\";\n\n/**\n * Ready-to-use {@link IGridCustomizerStrategy} for the Dataverse / Talxis platform.\n *\n * Automatically applies custom cell renderers to lookup-many columns (columns whose\n * `metadata.LookupMany` is set). Returned by {@link DataverseTaskGridDescriptor} by default.\n *\n * Extend or replace this class via `onCreateGridCustomizerStrategy` on your descriptor when\n * you need additional AG Grid column, editor, or row-class customizations.\n */\nexport class DataverseGridCustomizerStrategy implements IGridCustomizerStrategy {\n private _customizer!: IGridCustomizer;\n private _provider?: ITaskDataProvider;\n private _gridApi!: GridApi;\n\n /** Stores references to the customizer, task data provider, and grid API. Called once by the internal `GridCustomizer` after the AG Grid instance is ready. */\n public onInitialize(customizer: IGridCustomizer): void {\n this._customizer = customizer;\n this._provider = customizer.getTaskDataProvider();\n this._gridApi = customizer.getGridApi();\n }\n\n /** Injects the lookup-many {@link CellRenderer} and sets `autoHeight`/non-editable flags for any column whose `metadata.LookupMany` is set. */\n public onGetColumnDefinitions(colDefs: ColDef[]): ColDef[] {\n for (const colDef of colDefs) {\n const column = this._getProvider().getColumnsMap()[colDef.field!];\n if (column?.metadata?.LookupMany) {\n colDef.cellRenderer = FetchXmlLookupManyCellRenderer;\n colDef.autoHeight = true;\n colDef.editable = false;\n colDef.suppressKeyboardEvent = () => true;\n }\n }\n return colDefs;\n }\n\n private _getProvider(): ITaskDataProvider {\n if (!this._provider) {\n throw new Error('TaskDataProvider is not available in GridCustomizerStrategy. Have you called onInitialize?');\n }\n return this._provider;\n }\n\n}"],"names":[],"mappings":";;AAIA;;;;;;;;AAQG;MACU,+BAA+B,CAAA;;AAMjC,IAAA,YAAY,CAAC,UAA2B,EAAA;AAC3C,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;AAC9B,QAAA,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,mBAAmB,EAAE,CAAC;AAClD,QAAA,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC;KAC3C;;AAGM,IAAA,sBAAsB,CAAC,OAAiB,EAAA;AAC3C,QAAA,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;AAC1B,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,KAAM,CAAC,CAAC;AAClE,YAAA,IAAI,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE;AAC9B,gBAAA,MAAM,CAAC,YAAY,GAAG,8BAA8B,CAAC;AACrD,gBAAA,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;AACzB,gBAAA,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;AACxB,gBAAA,MAAM,CAAC,qBAAqB,GAAG,MAAM,IAAI,CAAC;AAC7C,aAAA;AACJ,SAAA;AACD,QAAA,OAAO,OAAO,CAAC;KAClB;IAEO,YAAY,GAAA;AAChB,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;AACjB,YAAA,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;AACjH,SAAA;QACD,OAAO,IAAI,CAAC,SAAS,CAAC;KACzB;AAEJ;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FetchXmlDataProvider
|
|
1
|
+
import { FetchXmlDataProvider } from '@talxis/client-libraries';
|
|
2
|
+
import { Liquid } from 'liquidjs';
|
|
2
3
|
import { ErrorHelper } from '../../../../utils/error-handling/ErrorHelper.js';
|
|
3
4
|
|
|
4
5
|
const FETCH_XML = `
|
|
@@ -8,25 +9,24 @@ const FETCH_XML = `
|
|
|
8
9
|
<attribute name="talxis_name" />
|
|
9
10
|
<attribute name="talxis_description" />
|
|
10
11
|
<attribute name="talxis_layoutjson" />
|
|
12
|
+
<filter type="and">
|
|
13
|
+
<condition attribute="talxis_returnedtypecode" operator="eq" value="{{ entityName }}" />
|
|
14
|
+
{% if ownerId %}
|
|
15
|
+
<condition attribute="ownerid" operator="eq" value="{{ ownerId }}" />
|
|
16
|
+
{% endif %}
|
|
17
|
+
{% if recordId %}
|
|
18
|
+
<condition attribute="talxis_recordid" operator="eq" value="{{ recordId }}" />
|
|
19
|
+
{% else %}
|
|
20
|
+
<condition attribute="talxis_recordid" operator="null" />
|
|
21
|
+
{% endif %}
|
|
22
|
+
</filter>
|
|
11
23
|
<order attribute="talxis_name" />
|
|
12
24
|
</entity>
|
|
13
25
|
</fetch>
|
|
14
26
|
`;
|
|
27
|
+
const LIQUID = new Liquid();
|
|
15
28
|
const _getFetchXml = (entityName, recordId, ownerId) => {
|
|
16
|
-
|
|
17
|
-
const filter = new FetchXmlBuilder.filter("and");
|
|
18
|
-
filter.addCondition(new FetchXmlBuilder.condition("talxis_returnedtypecode", FetchXmlBuilder.Operator.Equal, [new FetchXmlBuilder.value(entityName)]));
|
|
19
|
-
if (ownerId) {
|
|
20
|
-
filter.addCondition(new FetchXmlBuilder.condition("ownerid", FetchXmlBuilder.Operator.Equal, [new FetchXmlBuilder.value(ownerId)]));
|
|
21
|
-
}
|
|
22
|
-
if (recordId) {
|
|
23
|
-
filter.addCondition(new FetchXmlBuilder.condition("talxis_recordid", FetchXmlBuilder.Operator.Equal, [new FetchXmlBuilder.value(recordId)]));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
filter.addCondition(new FetchXmlBuilder.condition("talxis_recordid", FetchXmlBuilder.Operator.Null));
|
|
27
|
-
}
|
|
28
|
-
fetch.entity.addFilter(filter);
|
|
29
|
-
return fetch.toXml();
|
|
29
|
+
return LIQUID.parseAndRenderSync(FETCH_XML, { entityName, recordId, ownerId });
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Ready-to-use {@link ISavedQueryStrategy} implementation for the Dataverse / Talxis platform.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataverseSavedQueryStrategy.js","sources":["../../../../../src/components/TaskGrid/extensions/dataverse/DataverseSavedQueryStrategy.ts"],"sourcesContent":["import { FetchXmlBuilder, FetchXmlDataProvider } from \"@talxis/client-libraries\";\nimport { IDeletedUserQueriesResult, ISavedQuery, ISavedQueryStrategy } from \"../../providers/saved-query/SavedQueryDataProvider\";\nimport { ErrorHelper } from \"../../../../utils/error-handling\";\n\nconst FETCH_XML = `\n<fetch count=\"5000\" page=\"1\">\n <entity name=\"talxis_userquery\">\n <attribute name=\"talxis_userqueryid\" />\n <attribute name=\"talxis_name\" />\n <attribute name=\"talxis_description\" />\n <attribute name=\"talxis_layoutjson\" />\n <order attribute=\"talxis_name\" />\n </entity>\n</fetch>\n`\n\nconst _getFetchXml = (entityName: string, recordId?: string, ownerId?: string) => {\n const fetch = FetchXmlBuilder.fetch.fromXml(FETCH_XML);\n const filter = new FetchXmlBuilder.filter(\"and\")\n filter.addCondition(new FetchXmlBuilder.condition(\"talxis_returnedtypecode\", FetchXmlBuilder.Operator.Equal, [new FetchXmlBuilder.value(entityName)]));\n if (ownerId) {\n filter.addCondition(new FetchXmlBuilder.condition(\"ownerid\", FetchXmlBuilder.Operator.Equal, [new FetchXmlBuilder.value(ownerId)]))\n }\n if (recordId) {\n filter.addCondition(new FetchXmlBuilder.condition(\"talxis_recordid\", FetchXmlBuilder.Operator.Equal, [new FetchXmlBuilder.value(recordId)]))\n }\n else {\n filter.addCondition(new FetchXmlBuilder.condition(\"talxis_recordid\", FetchXmlBuilder.Operator.Null));\n }\n fetch.entity.addFilter(filter);\n return fetch.toXml();\n}\n\n/**\n * Parameters for constructing a {@link DataverseSavedQueryStrategy}.\n */\ninterface IDataverseSavedQueryStrategyParameters {\n /** Callback that retrieves the system (shared) saved queries. */\n onGetSystemQueries: () => Promise<ISavedQuery[]>;\n /** Logical name of the entity whose queries are managed (used as `talxis_returnedtypecode`). */\n entityName: string;\n /** Optional record ID used to scope queries to a specific record (`talxis_recordid`). When omitted, only queries with a null `talxis_recordid` are returned. */\n recordId?: string;\n /** Optional owner ID used to filter queries by owner (`ownerid`). */\n ownerId?: string;\n}\n\n/**\n * Ready-to-use {@link ISavedQueryStrategy} implementation for the Dataverse / Talxis platform.\n *\n * Persists user-defined saved views as `talxis_userquery` records, optionally scoped to a\n * specific parent record (`talxis_recordid`) and/or owner (`ownerid`).\n * System queries are supplied via the `onGetSystemQueries` callback and are never persisted.\n *\n * Also acts as an `IDataProvider` (extends `FetchXmlDataProvider`) so it can be passed directly\n * to the user-query creation dialog.\n */\nexport class DataverseSavedQueryStrategy extends FetchXmlDataProvider implements ISavedQueryStrategy {\n private _recordId?: string;\n private _parentEntityName: string;\n private _onGetSystemQueries: () => Promise<ISavedQuery[]>;\n\n constructor(parameters: IDataverseSavedQueryStrategyParameters) {\n const fetchXml = _getFetchXml(parameters.entityName, parameters.recordId, parameters.ownerId);\n super({ fetchXml });\n this._parentEntityName = parameters.entityName;\n this._recordId = parameters.recordId;\n this._onGetSystemQueries = parameters.onGetSystemQueries;\n }\n\n /** Fetches all `talxis_userquery` records matching the configured entity/record/owner scope and maps them to {@link ISavedQuery}. */\n public async onGetUserQueries(): Promise<ISavedQuery[]> {\n const result = await this.refresh();\n return result.map(r => {\n return {\n id: r.getValue('talxis_userqueryid'),\n name: r.getValue('talxis_name'),\n description: r.getValue('talxis_description'),\n ...JSON.parse(r.getValue('talxis_layoutjson'))\n }\n });\n }\n\n /** Delegates to the `onGetSystemQueries` callback supplied at construction time. */\n public async onGetSystemQueries(): Promise<ISavedQuery[]> {\n return this._onGetSystemQueries();\n }\n\n /** Deletes the specified `talxis_userquery` records and returns a per-query success/failure result. */\n public async onDeleteUserQueries(queryIds: string[]): Promise<IDeletedUserQueriesResult> {\n const result = await this.deleteRecords(queryIds);\n if (result.success) {\n return {\n success: true,\n deletedQueryIds: queryIds\n }\n }\n else {\n return {\n success: false,\n deletedQueryIds: result.results.filter(r => r.success).map(r => r.recordId),\n errors: result.results.filter(r => !r.success).map(r => ({ queryId: r.recordId, error: r.errorMessage }))\n }\n }\n }\n\n /** Serialises the current query metadata (columns, filters, sorting, …) to `talxis_layoutjson` and saves the record. Returns the query ID on success. */\n public async onUpdateUserQuery(currentQuery: ISavedQuery): Promise<string | null> {\n const record = this.getRecordsMap()[currentQuery.id];\n if (!record) {\n throw new Error(`Query record with id ${currentQuery.id} not found`);\n }\n const { name, id, ...queryMetadata } = currentQuery;\n record.setValue('talxis_layoutjson', JSON.stringify(queryMetadata));\n const result = await record.save();\n if (!result.success) {\n throw new Error(`Failed to update query with id ${currentQuery.id}: ${ErrorHelper.getMessageFromError(result.errors?.map((e: any) => e.message).join('\\n'))}`);\n }\n return currentQuery.id;\n }\n\n /**\n * Creates a new `talxis_userquery` record that captures the current grid state (columns, filters, sorting, …).\n * A deterministic ID is generated with a `00001111` prefix so it sorts predictably alongside Dataverse-native GUIDs.\n * @returns The new record ID on success.\n */\n public async onCreateUserQuery(newQuery: { name: string; description?: string; }, currentQuery: ISavedQuery): Promise<string | null> {\n const userqueryid = `00001111${crypto.randomUUID().substring(8)}`;\n const { name, description } = newQuery;\n const { id, name: queryName, ...queryMetadata } = currentQuery;\n\n const rawData = {\n 'talxis_userqueryid': userqueryid,\n 'talxis_layoutjson': JSON.stringify(queryMetadata),\n 'talxis_name': name,\n 'talxis_description': description,\n 'talxis_returnedtypecode': this._parentEntityName,\n 'talxis_recordid': this._recordId ?? null,\n }\n const result = await window.Xrm.WebApi.createRecord('talxis_userquery', raw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AAC,CAAC,CAAM,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA,CAAE,CAAC,CAAC;AAClK,SAAA;QACD,OAAO,YAAY,CAAC,EAAE,CAAC;KAC1B;AAED;;;;AAIG;AACI,IAAA,MAAM,iBAAiB,CAAC,QAAiD,EAAE,YAAyB,EAAA;AACvG,QAAA,MAAM,WAAW,GAAG,CAAW,QAAA,EAAA,MAAM,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;AAClE,QAAA,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;AACvC,QAAA,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,aAAa,EAAE,GAAG,YAAY,CAAC;AAE/D,QAAA,MAAM,OAAO,GAAG;AACZ,YAAA,oBAAoB,EAAE,WAAW;AACjC,YAAA,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;AAClD,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,oBAAoB,EAAE,WAAW;YACjC,yBAAyB,EAAE,IAAI,CAAC,iBAAiB;AACjD,YAAA,iBAAiB,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI;SAC5C,CAAA;AACD,QAAA,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;QAEjF,OAAO,MAAM,CAAC,EAAE,CAAC;KACpB;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"DataverseSavedQueryStrategy.js","sources":["../../../../../src/components/TaskGrid/extensions/dataverse/DataverseSavedQueryStrategy.ts"],"sourcesContent":["import { FetchXmlDataProvider } from \"@talxis/client-libraries\";\nimport { Liquid } from \"liquidjs\";\nimport { IDeletedUserQueriesResult, ISavedQuery, ISavedQueryStrategy } from \"../../providers/saved-query/SavedQueryDataProvider\";\nimport { ErrorHelper } from \"../../../../utils/error-handling\";\n\nconst FETCH_XML = `\n<fetch count=\"5000\" page=\"1\">\n <entity name=\"talxis_userquery\">\n <attribute name=\"talxis_userqueryid\" />\n <attribute name=\"talxis_name\" />\n <attribute name=\"talxis_description\" />\n <attribute name=\"talxis_layoutjson\" />\n <filter type=\"and\">\n <condition attribute=\"talxis_returnedtypecode\" operator=\"eq\" value=\"{{ entityName }}\" />\n {% if ownerId %}\n <condition attribute=\"ownerid\" operator=\"eq\" value=\"{{ ownerId }}\" />\n {% endif %}\n {% if recordId %}\n <condition attribute=\"talxis_recordid\" operator=\"eq\" value=\"{{ recordId }}\" />\n {% else %}\n <condition attribute=\"talxis_recordid\" operator=\"null\" />\n {% endif %}\n </filter>\n <order attribute=\"talxis_name\" />\n </entity>\n</fetch>\n`\n\nconst LIQUID = new Liquid();\n\nconst _getFetchXml = (entityName: string, recordId?: string, ownerId?: string) => {\n return LIQUID.parseAndRenderSync(FETCH_XML, { entityName, recordId, ownerId });\n}\n\n/**\n * Parameters for constructing a {@link DataverseSavedQueryStrategy}.\n */\ninterface IDataverseSavedQueryStrategyParameters {\n /** Callback that retrieves the system (shared) saved queries. */\n onGetSystemQueries: () => Promise<ISavedQuery[]>;\n /** Logical name of the entity whose queries are managed (used as `talxis_returnedtypecode`). */\n entityName: string;\n /** Optional record ID used to scope queries to a specific record (`talxis_recordid`). When omitted, only queries with a null `talxis_recordid` are returned. */\n recordId?: string;\n /** Optional owner ID used to filter queries by owner (`ownerid`). */\n ownerId?: string;\n}\n\n/**\n * Ready-to-use {@link ISavedQueryStrategy} implementation for the Dataverse / Talxis platform.\n *\n * Persists user-defined saved views as `talxis_userquery` records, optionally scoped to a\n * specific parent record (`talxis_recordid`) and/or owner (`ownerid`).\n * System queries are supplied via the `onGetSystemQueries` callback and are never persisted.\n *\n * Also acts as an `IDataProvider` (extends `FetchXmlDataProvider`) so it can be passed directly\n * to the user-query creation dialog.\n */\nexport class DataverseSavedQueryStrategy extends FetchXmlDataProvider implements ISavedQueryStrategy {\n private _recordId?: string;\n private _parentEntityName: string;\n private _onGetSystemQueries: () => Promise<ISavedQuery[]>;\n\n constructor(parameters: IDataverseSavedQueryStrategyParameters) {\n const fetchXml = _getFetchXml(parameters.entityName, parameters.recordId, parameters.ownerId);\n super({ fetchXml });\n this._parentEntityName = parameters.entityName;\n this._recordId = parameters.recordId;\n this._onGetSystemQueries = parameters.onGetSystemQueries;\n }\n\n /** Fetches all `talxis_userquery` records matching the configured entity/record/owner scope and maps them to {@link ISavedQuery}. */\n public async onGetUserQueries(): Promise<ISavedQuery[]> {\n const result = await this.refresh();\n return result.map(r => {\n return {\n id: r.getValue('talxis_userqueryid'),\n name: r.getValue('talxis_name'),\n description: r.getValue('talxis_description'),\n ...JSON.parse(r.getValue('talxis_layoutjson'))\n }\n });\n }\n\n /** Delegates to the `onGetSystemQueries` callback supplied at construction time. */\n public async onGetSystemQueries(): Promise<ISavedQuery[]> {\n return this._onGetSystemQueries();\n }\n\n /** Deletes the specified `talxis_userquery` records and returns a per-query success/failure result. */\n public async onDeleteUserQueries(queryIds: string[]): Promise<IDeletedUserQueriesResult> {\n const result = await this.deleteRecords(queryIds);\n if (result.success) {\n return {\n success: true,\n deletedQueryIds: queryIds\n }\n }\n else {\n return {\n success: false,\n deletedQueryIds: result.results.filter(r => r.success).map(r => r.recordId),\n errors: result.results.filter(r => !r.success).map(r => ({ queryId: r.recordId, error: r.errorMessage }))\n }\n }\n }\n\n /** Serialises the current query metadata (columns, filters, sorting, …) to `talxis_layoutjson` and saves the record. Returns the query ID on success. */\n public async onUpdateUserQuery(currentQuery: ISavedQuery): Promise<string | null> {\n const record = this.getRecordsMap()[currentQuery.id];\n if (!record) {\n throw new Error(`Query record with id ${currentQuery.id} not found`);\n }\n const { name, id, ...queryMetadata } = currentQuery;\n record.setValue('talxis_layoutjson', JSON.stringify(queryMetadata));\n const result = await record.save();\n if (!result.success) {\n throw new Error(`Failed to update query with id ${currentQuery.id}: ${ErrorHelper.getMessageFromError(result.errors?.map((e: any) => e.message).join('\\n'))}`);\n }\n return currentQuery.id;\n }\n\n /**\n * Creates a new `talxis_userquery` record that captures the current grid state (columns, filters, sorting, …).\n * A deterministic ID is generated with a `00001111` prefix so it sorts predictably alongside Dataverse-native GUIDs.\n * @returns The new record ID on success.\n */\n public async onCreateUserQuery(newQuery: { name: string; description?: string; }, currentQuery: ISavedQuery): Promise<string | null> {\n const userqueryid = `00001111${crypto.randomUUID().substring(8)}`;\n const { name, description } = newQuery;\n const { id, name: queryName, ...queryMetadata } = currentQuery;\n\n const rawData = {\n 'talxis_userqueryid': userqueryid,\n 'talxis_layoutjson': JSON.stringify(queryMetadata),\n 'talxis_name': name,\n 'talxis_description': description,\n 'talxis_returnedtypecode': this._parentEntityName,\n 'talxis_recordid': this._recordId ?? null,\n }\n const result = await window.Xrm.WebApi.createRecord('talxis_userquery', rawData);\n\n return result.id;\n }\n}"],"names":[],"mappings":";;;;AAKA,MAAM,SAAS,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;CAqBjB,CAAA;AAED,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AAE5B,MAAM,YAAY,GAAG,CAAC,UAAkB,EAAE,QAAiB,EAAE,OAAgB,KAAI;AAC7E,IAAA,OAAO,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AACnF,CAAC,CAAA;AAgBD;;;;;;;;;AASG;AACG,MAAO,2BAA4B,SAAQ,oBAAoB,CAAA;AAKjE,IAAA,WAAA,CAAY,UAAkD,EAAA;AAC1D,QAAA,MAAM,QAAQ,GAAG,YAAY,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;AAC9F,QAAA,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;AACpB,QAAA,IAAI,CAAC,iBAAiB,GAA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CAAC,CAAC,CAAC,EAAE,CAAC;AAClE,QAAA,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;AACvC,QAAA,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,aAAa,EAAE,GAAG,YAAY,CAAC;AAE/D,QAAA,MAAM,OAAO,GAAG;AACZ,YAAA,oBAAoB,EAAE,WAAW;AACjC,YAAA,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;AAClD,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,oBAAoB,EAAE,WAAW;YACjC,yBAAyB,EAAE,IAAI,CAAC,iBAAiB;AACjD,YAAA,iBAAiB,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI;SAC5C,CAAA;AACD,QAAA,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;QAEjF,OAAO,MAAM,CAAC,EAAE,CAAC;KACpB;AACJ;;;;"}
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { ISavedQuery, ISavedQueryStrategy, ITaskDataProviderStrategy } from "../../providers";
|
|
1
|
+
import { IDataProvider, ISingleRecord } from "@talxis/client-libraries";
|
|
2
|
+
import { ICustomColumnsStrategy, ISavedQuery, ISavedQueryStrategy, ITaskDataProviderStrategy } from "../../providers";
|
|
4
3
|
import { IFieldMapping as IFieldMappingBase, ITaskGridDescriptor, ITaskGridParameters, ITaskStrategyDeps } from "../../interfaces";
|
|
5
4
|
import { IGridCustomizerStrategy } from "../../components/grid";
|
|
6
|
-
/** Minimal reference to a project record. Use `name` when already known to skip a metadata fetch. */
|
|
7
|
-
export interface IProjectReference extends Omit<ComponentFramework.EntityReference, 'name'> {
|
|
8
|
-
/** Logical entity name of the project entity (e.g. `"talxis_project"`). */
|
|
9
|
-
etn: string;
|
|
10
|
-
/** Display name of the project record. When provided, the descriptor skips a `getEntityMetadata` call during `onLoadDependencies`. */
|
|
11
|
-
name?: string;
|
|
12
|
-
}
|
|
13
5
|
/** Dataverse-specific field mapping. Extends the base with an optional project lookup column. */
|
|
14
6
|
export interface IFieldMapping extends Omit<IFieldMappingBase, 'stateCode'> {
|
|
15
|
-
/** Logical name of the lookup attribute that points to the parent project record. Required when `
|
|
7
|
+
/** Logical name of the lookup attribute that points to the parent project record. Required when `projectRecord` is set on the descriptor. */
|
|
16
8
|
projectId?: string;
|
|
17
9
|
}
|
|
10
|
+
/** Lightweight entity reference shape used when only logical name + id are available. */
|
|
11
|
+
export interface IEntityRecordReference {
|
|
12
|
+
entityName: string;
|
|
13
|
+
id: string;
|
|
14
|
+
}
|
|
15
|
+
/** Input accepted for source/project: either a fully hydrated record or an entity reference. */
|
|
16
|
+
export type RecordInput = IEntityRecordReference | ISingleRecord;
|
|
18
17
|
/** Constructor parameters for {@link DataverseTaskGridDescriptor}. */
|
|
19
|
-
interface IDataverseTaskGridDescriptorParams {
|
|
18
|
+
export interface IDataverseTaskGridDescriptorParams {
|
|
20
19
|
/** FetchXML that drives the initial data load. May use Liquid template variables (e.g. `{{ projectId }}`). */
|
|
21
20
|
baseFetchXml: string;
|
|
22
21
|
/** Maps logical entity attribute names to the roles expected by TaskGrid (e.g. `statecode` → `stateCode`). */
|
|
23
22
|
fieldMapping: IFieldMapping;
|
|
24
23
|
/** System (non-deletable) views exposed in the view switcher. At least one is required. */
|
|
25
24
|
systemQueries: ISavedQuery[];
|
|
26
|
-
/** Optional
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/** Set to `true` to enable personal saved views (user queries) via {@link DataverseSavedQueryStrategy}. Defaults to `false`. */
|
|
31
|
-
enableUserQueries?: boolean;
|
|
25
|
+
/** Optional source record. If provided, it's data will be propagated into liquid fetch XML templates. */
|
|
26
|
+
sourceRecord?: RecordInput;
|
|
27
|
+
projectRecord?: RecordInput;
|
|
28
|
+
height?: string;
|
|
32
29
|
/** Fine-grained feature flags forwarded to the grid. See {@link ITaskGridParameters}. */
|
|
33
30
|
gridParameters?: ITaskGridParameters;
|
|
34
31
|
/** When set, the hierarchy is rooted at this task ID instead of showing all top-level tasks. */
|
|
@@ -72,29 +69,34 @@ export declare class DataverseTaskGridDescriptor implements ITaskGridDescriptor
|
|
|
72
69
|
private _bulkEditFormId?;
|
|
73
70
|
private _userId?;
|
|
74
71
|
private _rootTaskId?;
|
|
75
|
-
private
|
|
72
|
+
private _projectRecord?;
|
|
73
|
+
private _sourceRecord?;
|
|
76
74
|
private _params;
|
|
77
75
|
private _gridParameters?;
|
|
78
|
-
private
|
|
76
|
+
private _height?;
|
|
77
|
+
private _onInitialize;
|
|
79
78
|
/** @param params — see {@link IDataverseTaskGridDescriptorParams} for full documentation of each option. */
|
|
80
|
-
constructor(params:
|
|
79
|
+
constructor(params: {
|
|
80
|
+
onInitialize: () => Promise<IDataverseTaskGridDescriptorParams>;
|
|
81
|
+
height?: string;
|
|
82
|
+
});
|
|
81
83
|
/** Resolves the project entity reference (fetches display name when not supplied). Called once by the factory before any strategy is created. */
|
|
82
84
|
onLoadDependencies(): Promise<void>;
|
|
83
85
|
/** Returns the field mapping with `stateCode` hard-coded to `"statecode"` (standard Dataverse attribute name). */
|
|
84
86
|
onGetFieldMapping(): IFieldMappingBase;
|
|
87
|
+
onGetHeight(): string | undefined;
|
|
85
88
|
/** Returns a {@link DataverseSavedQueryStrategy} when `enableUserQueries` is `true`, otherwise a read-only stub that exposes only the system queries. */
|
|
86
89
|
onCreateSavedQueryStrategy(): ISavedQueryStrategy;
|
|
90
|
+
onCreateCustomColumnsStrategy(): ICustomColumnsStrategy | undefined;
|
|
87
91
|
/** Returns a {@link DataverseTaskStrategy} configured with the descriptor's FetchXML, form IDs, and project reference. */
|
|
88
92
|
onCreateTaskStrategy(deps: ITaskStrategyDeps): ITaskDataProviderStrategy;
|
|
89
93
|
/** Returns a {@link DataverseSavedQueryStrategy} pre-configured as a data provider for the user-query creation/update dialog, with `talxis_name` and `talxis_description` columns. */
|
|
90
94
|
onCreateUserQueryDataProvider(): IDataProvider;
|
|
91
|
-
/** Returns the AG Grid Enterprise license key supplied at construction time, or `undefined` for community mode. */
|
|
92
|
-
onGetAgGridLicenseKey(): string | undefined;
|
|
93
95
|
/** Returns the feature flags supplied at construction time, or an empty object (all features enabled) when omitted. */
|
|
94
96
|
onGetGridParameters(): ITaskGridParameters;
|
|
95
97
|
/** Returns a {@link DataverseGridCustomizerStrategy} that adds lookup-many cell renderers for columns whose name ends with the lookup-many suffix. */
|
|
96
98
|
onCreateGridCustomizerStrategy(): IGridCustomizerStrategy;
|
|
97
|
-
private
|
|
99
|
+
private _getProjectRecord;
|
|
100
|
+
private _getSourceRecord;
|
|
98
101
|
private _getTaskEntityNameFromFetchXml;
|
|
99
102
|
}
|
|
100
|
-
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { FetchXmlBuilder } from '@talxis/client-libraries';
|
|
1
|
+
import { RecordBuilder, FetchXmlBuilder } from '@talxis/client-libraries';
|
|
2
2
|
import { DataverseSavedQueryStrategy } from './DataverseSavedQueryStrategy.js';
|
|
3
3
|
import { DataverseTaskStrategy } from './DataverseTaskStrategy.js';
|
|
4
4
|
import { DataverseGridCustomizerStrategy } from './DataverseGridCustomizerStrategy.js';
|
|
5
|
+
import { EntityDefinition } from '@talxis/client-metadata';
|
|
6
|
+
import { DataverseCustomColumnsStrategy } from './DataverseCustomColumnsStrategy.js';
|
|
5
7
|
|
|
8
|
+
const isSingleRecord = (record) => {
|
|
9
|
+
return !!record && typeof record.getRecordId === "function";
|
|
10
|
+
};
|
|
6
11
|
/**
|
|
7
12
|
* Ready-to-use {@link ITaskGridDescriptor} implementation for the Dataverse / Talxis platform.
|
|
8
13
|
*
|
|
@@ -23,6 +28,12 @@ class DataverseTaskGridDescriptor {
|
|
|
23
28
|
/** @param params — see {@link IDataverseTaskGridDescriptorParams} for full documentation of each option. */
|
|
24
29
|
constructor(params) {
|
|
25
30
|
this._systemQueries = [];
|
|
31
|
+
this._onInitialize = params.onInitialize;
|
|
32
|
+
this._height = params.height;
|
|
33
|
+
}
|
|
34
|
+
/** Resolves the project entity reference (fetches display name when not supplied). Called once by the factory before any strategy is created. */
|
|
35
|
+
async onLoadDependencies() {
|
|
36
|
+
const params = await this._onInitialize();
|
|
26
37
|
this._params = params;
|
|
27
38
|
this._systemQueries = params.systemQueries;
|
|
28
39
|
this._fieldMapping = params.fieldMapping;
|
|
@@ -32,13 +43,10 @@ class DataverseTaskGridDescriptor {
|
|
|
32
43
|
this._editFormId = params.editFormId;
|
|
33
44
|
this._createFormId = params.createFormId;
|
|
34
45
|
this._bulkEditFormId = params.bulkEditFormId;
|
|
35
|
-
this._agGridLicenseKey = params.agGridLicenseKey;
|
|
36
46
|
this._gridParameters = params.gridParameters;
|
|
37
47
|
this._taskEntityName = this._getTaskEntityNameFromFetchXml(params.baseFetchXml);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
async onLoadDependencies() {
|
|
41
|
-
this._projectReference = await this._getProjectReference();
|
|
48
|
+
this._projectRecord = await this._getProjectRecord();
|
|
49
|
+
this._sourceRecord = await this._getSourceRecord();
|
|
42
50
|
}
|
|
43
51
|
/** Returns the field mapping with `stateCode` hard-coded to `"statecode"` (standard Dataverse attribute name). */
|
|
44
52
|
onGetFieldMapping() {
|
|
@@ -48,6 +56,10 @@ class DataverseTaskGridDescriptor {
|
|
|
48
56
|
stateCode: 'statecode',
|
|
49
57
|
};
|
|
50
58
|
}
|
|
59
|
+
//needs to be seperate from onGetGridParameters since it is also required for skeleton rendering before the instance is created
|
|
60
|
+
onGetHeight() {
|
|
61
|
+
return this._height;
|
|
62
|
+
}
|
|
51
63
|
/** Returns a {@link DataverseSavedQueryStrategy} when `enableUserQueries` is `true`, otherwise a read-only stub that exposes only the system queries. */
|
|
52
64
|
onCreateSavedQueryStrategy() {
|
|
53
65
|
if (this._gridParameters?.enableUserQueries) {
|
|
@@ -55,7 +67,7 @@ class DataverseTaskGridDescriptor {
|
|
|
55
67
|
onGetSystemQueries: async () => this._systemQueries,
|
|
56
68
|
ownerId: this._userId,
|
|
57
69
|
entityName: this._taskEntityName,
|
|
58
|
-
recordId: this.
|
|
70
|
+
recordId: this._projectRecord?.getRecordId()
|
|
59
71
|
});
|
|
60
72
|
}
|
|
61
73
|
return {
|
|
@@ -72,24 +84,30 @@ class DataverseTaskGridDescriptor {
|
|
|
72
84
|
}
|
|
73
85
|
};
|
|
74
86
|
}
|
|
87
|
+
onCreateCustomColumnsStrategy() {
|
|
88
|
+
return new DataverseCustomColumnsStrategy({
|
|
89
|
+
entityName: this._taskEntityName,
|
|
90
|
+
recordId: this._projectRecord?.getRecordId(),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
75
93
|
/** Returns a {@link DataverseTaskStrategy} configured with the descriptor's FetchXML, form IDs, and project reference. */
|
|
76
94
|
onCreateTaskStrategy(deps) {
|
|
77
95
|
return new DataverseTaskStrategy({
|
|
78
96
|
fetchXml: this._fetchXml,
|
|
79
|
-
|
|
97
|
+
projectRecord: this._projectRecord,
|
|
98
|
+
sourceRecord: this._sourceRecord,
|
|
80
99
|
rootTaskId: this._rootTaskId,
|
|
81
100
|
bulkEditFormId: this._bulkEditFormId,
|
|
82
101
|
createFormId: this._createFormId,
|
|
83
102
|
editFormId: this._editFormId,
|
|
84
|
-
isInlineCreateEnabled: this._gridParameters?.enableInlineCreation ?? true,
|
|
85
103
|
isCascadeDeleteEnabled: this._params.enableCascadeDelete ?? false,
|
|
86
104
|
isDeletingTasksWithChildrenEnabled: this._params.enableDeletingTasksWithChildren ?? false,
|
|
87
|
-
});
|
|
105
|
+
}, deps);
|
|
88
106
|
}
|
|
89
107
|
/** Returns a {@link DataverseSavedQueryStrategy} pre-configured as a data provider for the user-query creation/update dialog, with `talxis_name` and `talxis_description` columns. */
|
|
90
108
|
onCreateUserQueryDataProvider() {
|
|
91
109
|
const provider = new DataverseSavedQueryStrategy({
|
|
92
|
-
recordId: this.
|
|
110
|
+
recordId: this._projectRecord?.getRecordId(),
|
|
93
111
|
entityName: this._taskEntityName,
|
|
94
112
|
ownerId: this._userId,
|
|
95
113
|
onGetSystemQueries: async () => {
|
|
@@ -105,10 +123,6 @@ class DataverseTaskGridDescriptor {
|
|
|
105
123
|
}]);
|
|
106
124
|
return provider;
|
|
107
125
|
}
|
|
108
|
-
/** Returns the AG Grid Enterprise license key supplied at construction time, or `undefined` for community mode. */
|
|
109
|
-
onGetAgGridLicenseKey() {
|
|
110
|
-
return this._agGridLicenseKey;
|
|
111
|
-
}
|
|
112
126
|
/** Returns the feature flags supplied at construction time, or an empty object (all features enabled) when omitted. */
|
|
113
127
|
onGetGridParameters() {
|
|
114
128
|
return this._gridParameters ?? {};
|
|
@@ -117,23 +131,48 @@ class DataverseTaskGridDescriptor {
|
|
|
117
131
|
onCreateGridCustomizerStrategy() {
|
|
118
132
|
return new DataverseGridCustomizerStrategy();
|
|
119
133
|
}
|
|
120
|
-
async
|
|
121
|
-
|
|
134
|
+
async _getProjectRecord() {
|
|
135
|
+
const projectRecord = this._params.projectRecord;
|
|
136
|
+
if (!projectRecord)
|
|
122
137
|
return undefined;
|
|
123
|
-
if (
|
|
124
|
-
return
|
|
138
|
+
if (isSingleRecord(projectRecord)) {
|
|
139
|
+
return projectRecord;
|
|
125
140
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
const projectId = projectRecord.id;
|
|
142
|
+
const projectEntityName = projectRecord.entityName;
|
|
143
|
+
const metadata = await EntityDefinition.fromEntityName(projectEntityName);
|
|
144
|
+
//@ts-ignore - typings
|
|
145
|
+
const attributes = (await window.Xrm.Utility.getEntityMetadata(projectEntityName, metadata.Attributes.map(attr => attr.LogicalName))).Attributes.get().filter(attr => attr.IsValidForGrid);
|
|
146
|
+
const projectData = await window.Xrm.WebApi.retrieveRecord(projectEntityName, projectId, `?$select=${metadata.PrimaryNameAttribute}`);
|
|
147
|
+
const builder = new RecordBuilder({
|
|
148
|
+
data: projectData,
|
|
149
|
+
entityMetadata: metadata,
|
|
150
|
+
attributes: attributes
|
|
151
|
+
});
|
|
152
|
+
return builder.getRecord();
|
|
153
|
+
}
|
|
154
|
+
async _getSourceRecord() {
|
|
155
|
+
const sourceRecord = this._params.sourceRecord;
|
|
156
|
+
if (!sourceRecord) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
const sourceRecordId = isSingleRecord(sourceRecord) ? sourceRecord.getRecordId() : sourceRecord.id;
|
|
160
|
+
if (this._projectRecord && this._projectRecord.getRecordId() === sourceRecordId) {
|
|
161
|
+
return this._projectRecord;
|
|
136
162
|
}
|
|
163
|
+
if (isSingleRecord(sourceRecord)) {
|
|
164
|
+
return sourceRecord;
|
|
165
|
+
}
|
|
166
|
+
const result = await window.Xrm.WebApi.retrieveRecord(sourceRecord.entityName, sourceRecord.id);
|
|
167
|
+
const entityMetadata = await EntityDefinition.fromEntityName(sourceRecord.entityName);
|
|
168
|
+
//@ts-ignore - typings
|
|
169
|
+
const attributes = (await window.Xrm.Utility.getEntityMetadata(sourceRecord.entityName, entityMetadata.Attributes.map(attr => attr.LogicalName))).Attributes.get().filter(attr => attr.IsValidForGrid);
|
|
170
|
+
const builder = new RecordBuilder({
|
|
171
|
+
data: result,
|
|
172
|
+
entityMetadata: entityMetadata,
|
|
173
|
+
attributes: attributes
|
|
174
|
+
});
|
|
175
|
+
return builder.getRecord();
|
|
137
176
|
}
|
|
138
177
|
_getTaskEntityNameFromFetchXml(fetchXml) {
|
|
139
178
|
const fetchXmlBuilder = FetchXmlBuilder.fetch.fromXml(fetchXml);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataverseTaskGridDescriptor.js","sources":["../../../../../src/components/TaskGrid/extensions/dataverse/DataverseTaskGridDescriptor.ts"],"sourcesContent":["import { FetchXmlBuilder, IDataProvider } from \"@talxis/client-libraries\";\nimport { IDeletedUserQueriesResult, ISavedQuery, ISavedQueryStrategy, ITaskDataProviderStrategy } from \"../../providers\";\nimport { IFieldMapping as IFieldMappingBase, ITaskGridDescriptor, ITaskGridParameters, ITaskStrategyDeps } from \"../../interfaces\";\nimport { IGridCustomizerStrategy } from \"../../components/grid\";\nimport { DataverseSavedQueryStrategy } from \"./DataverseSavedQueryStrategy\";\nimport { DataverseTaskStrategy } from \"./DataverseTaskStrategy\";\nimport { DataverseGridCustomizerStrategy } from \"./DataverseGridCustomizerStrategy\";\n\n/** Minimal reference to a project record. Use `name` when already known to skip a metadata fetch. */\nexport interface IProjectReference extends Omit<ComponentFramework.EntityReference, 'name'> {\n /** Logical entity name of the project entity (e.g. `\"talxis_project\"`). */\n etn: string;\n /** Display name of the project record. When provided, the descriptor skips a `getEntityMetadata` call during `onLoadDependencies`. */\n name?: string;\n}\n\n/** Dataverse-specific field mapping. Extends the base with an optional project lookup column. */\nexport interface IFieldMapping extends Omit<IFieldMappingBase, 'stateCode'> {\n /** Logical name of the lookup attribute that points to the parent project record. Required when `project` is set on the descriptor. */\n projectId?: string;\n}\n\n/** Constructor parameters for {@link DataverseTaskGridDescriptor}. */\ninterface IDataverseTaskGridDescriptorParams {\n /** FetchXML that drives the initial data load. May use Liquid template variables (e.g. `{{ projectId }}`). */\n baseFetchXml: string;\n /** Maps logical entity attribute names to the roles expected by TaskGrid (e.g. `statecode` → `stateCode`). */\n fieldMapping: IFieldMapping;\n /** System (non-deletable) views exposed in the view switcher. At least one is required. */\n systemQueries: ISavedQuery[];\n /** Optional project record reference. When provided, new tasks are pre-linked to this project and `baseFetchXml` receives `{{ projectId }}`. */\n project?: IProjectReference;\n /** AG Grid Enterprise license key. Omit to run in community mode. */\n agGridLicenseKey?: string;\n /** Set to `true` to enable personal saved views (user queries) via {@link DataverseSavedQueryStrategy}. Defaults to `false`. */\n enableUserQueries?: boolean;\n /** Fine-grained feature flags forwarded to the grid. See {@link ITaskGridParameters}. */\n gridParameters?: ITaskGridParameters;\n /** When set, the hierarchy is rooted at this task ID instead of showing all top-level tasks. */\n rootTaskId?: string;\n /** ID of the currently logged-in user. Used to scope user queries to the current owner. */\n userId?: string;\n /** Form ID to open when editing a single existing task. */\n editFormId?: string;\n /** Form ID to open when creating a new task via the dialog flow (non-inline). */\n createFormId?: string;\n /** Form ID to open for bulk-editing multiple selected tasks. */\n bulkEditFormId?: string;\n /** Set to `true` to enable cascade delete when deleting tasks with children. Defaults to `false`. */\n enableCascadeDelete?: boolean;\n /** Set to `true` to allow deletion of tasks that have child tasks. When `false`, such tasks are excluded from deletion and an error is returned. Defaults to `false`. */\n enableDeletingTasksWithChildren?: boolean;\n}\n\n/**\n * Ready-to-use {@link ITaskGridDescriptor} implementation for the Dataverse / Talxis platform.\n *\n * Wires together all required strategies — task CRUD, saved queries, grid customization — from\n * a single constructor parameter object. Pass an instance to `TaskGridDatasetControlFactory.createInstance`.\n *\n * @example\n * ```ts\n * const descriptor = new DataverseTaskGridDescriptor({\n * baseFetchXml: myFetchXml,\n * fieldMapping: { parentId: 'talxis_parenttaskid', subject: 'subject', stackRank: 'talxis_stackrank' },\n * systemQueries: [myDefaultView],\n * });\n * const control = await TaskGridDatasetControlFactory.createInstance({ taskGridDescriptor: descriptor, ... });\n * ```\n */\nexport class DataverseTaskGridDescriptor implements ITaskGridDescriptor {\n private _fetchXml: string;\n private _fieldMapping: IFieldMapping;\n private _systemQueries: ISavedQuery[] = [];\n private _taskEntityName: string;\n private _editFormId?: string;\n private _createFormId?: string;\n private _bulkEditFormId?: string;\n private _userId?: string;\n private _rootTaskId?: string;\n private _projectReference?: ComponentFramework.EntityReference;\n private _params: IDataverseTaskGridDescriptorParams;\n private _gridParameters?: ITaskGridParameters;\n private _agGridLicenseKey?: string;\n\n /** @param params — see {@link IDataverseTaskGridDescriptorParams} for full documentation of each option. */\n constructor(params: IDataverseTaskGridDescriptorParams) {\n this._params = params;\n this._systemQueries = params.systemQueries;\n this._fieldMapping = params.fieldMapping;\n this._userId = params.userId;\n this._fetchXml = params.baseFetchXml;\n this._rootTaskId = params.rootTaskId;\n this._editFormId = params.editFormId;\n this._createFormId = params.createFormId;\n this._bulkEditFormId = params.bulkEditFormId;\n this._agGridLicenseKey = params.agGridLicenseKey;\n this._gridParameters = params.gridParameters;\n this._taskEntityName = this._getTaskEntityNameFromFetchXml(params.baseFetchXml);\n }\n\n /** Resolves the project entity reference (fetches display name when not supplied). Called once by the factory before any strategy is created. */\n public async onLoadDependencies(): Promise<void> {\n this._projectReference = await this._getProjectReference();\n }\n\n /** Returns the field mapping with `stateCode` hard-coded to `\"statecode\"` (standard Dataverse attribute name). */\n public onGetFieldMapping(): IFieldMappingBase {\n this\n return {\n ...this._fieldMapping,\n //dataverse uses this for all entities\n stateCode: 'statecode',\n }\n }\n\n /** Returns a {@link DataverseSavedQueryStrategy} when `enableUserQueries` is `true`, otherwise a read-only stub that exposes only the system queries. */\n public onCreateSavedQueryStrategy(): ISavedQueryStrategy {\n if (this._gridParameters?.enableUserQueries) {\n return new DataverseSavedQueryStrategy({\n onGetSystemQueries: async () => this._systemQueries,\n ownerId: this._userId,\n entityName: this._taskEntityName,\n recordId: this._projectReference?.id.guid\n });\n }\n return {\n onGetSystemQueries: async () => this._systemQueries,\n onGetUserQueries: async () => [],\n onDeleteUserQueries: function (queryIds: string[]): Promise<IDeletedUserQueriesResult> {\n throw new Error(\"Function not implemented.\");\n },\n onUpdateUserQuery: function (currentQuery: ISavedQuery): Promise<string | null> {\n throw new Error(\"Function not implemented.\");\n },\n onCreateUserQuery: function (newQuery: { name: string; description?: string; }, currentQuery: ISavedQuery): Promise<string | null> {\n throw new Error(\"Function not implemented.\");\n }\n }\n }\n\n /** Returns a {@link DataverseTaskStrategy} configured with the descriptor's FetchXML, form IDs, and project reference. */\n public onCreateTaskStrategy(deps: ITaskStrategyDeps): ITaskDataProviderStrategy {\n return new DataverseTaskStrategy({\n fetchXml: this._fetchXml,\n projectReference: this._projectReference,\n rootTaskId: this._rootTaskId,\n bulkEditFormId: this._bulkEditFormId,\n createFormId: this._createFormId,\n editFormId: this._editFormId,\n isInlineCreateEnabled: this._gridParameters?.enableInlineCreation ?? true,\n isCascadeDeleteEnabled: this._params.enableCascadeDelete ?? false,\n isDeletingTasksWithChildrenEnabled: this._params.enableDeletingTasksWithChildren ?? false,\n });\n }\n /** Returns a {@link DataverseSavedQueryStrategy} pre-configured as a data provider for the user-query creation/update dialog, with `talxis_name` and `talxis_description` columns. */\n public onCreateUserQueryDataProvider(): IDataProvider {\n const provider = new DataverseSavedQueryStrategy({\n recordId: this._projectReference?.id.guid,\n entityName: this._taskEntityName,\n ownerId: this._userId,\n onGetSystemQueries: async () => {\n return []\n }\n })\n provider.setColumns([{\n name: 'talxis_name',\n visualSizeFactor: 200\n }, {\n name: 'talxis_description',\n visualSizeFactor: 300\n }]);\n return provider;\n }\n\n /** Returns the AG Grid Enterprise license key supplied at construction time, or `undefined` for community mode. */\n public onGetAgGridLicenseKey() {\n return this._agGridLicenseKey;\n }\n\n /** Returns the feature flags supplied at construction time, or an empty object (all features enabled) when omitted. */\n public onGetGridParameters(): ITaskGridParameters {\n return this._gridParameters ?? {};\n }\n\n /** Returns a {@link DataverseGridCustomizerStrategy} that adds lookup-many cell renderers for columns whose name ends with the lookup-many suffix. */\n public onCreateGridCustomizerStrategy(): IGridCustomizerStrategy {\n return new DataverseGridCustomizerStrategy();\n }\n\n private async _getProjectReference(): Promise<ComponentFramework.EntityReference | undefined> {\n if (!this._params.project) return undefined;\n if (this._params.project.name) {\n return this._params.project as ComponentFramework.EntityReference;\n }\n else {\n const projectId = this._params.project.id.guid;\n const projectEntityName = this._params.project.etn;\n const metadata = await window.Xrm.Utility.getEntityMetadata(projectEntityName);\n const projectData = await window.Xrm.WebApi.retrieveRecord(projectEntityName, projectId, `?$select=${metadata.PrimaryNameAttribute}`);\n\n return {\n id: { guid: projectId },\n name: projectData[metadata.PrimaryNameAttribute],\n etn: projectEntityName\n }\n }\n }\n\n private _getTaskEntityNameFromFetchXml(fetchXml: string): string {\n const fetchXmlBuilder = FetchXmlBuilder.fetch.fromXml(fetchXml);\n return fetchXmlBuilder.entity.name;\n }\n\n}"],"names":[],"mappings":";;;;;AAsDA;;;;;;;;;;;;;;;AAeG;MACU,2BAA2B,CAAA;;AAgBpC,IAAA,WAAA,CAAY,MAA0C,EAAA;QAb9C,IAAc,CAAA,cAAA,GAAkB,EAAE,CAAC;AAcvC,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;AACtB,QAAA,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;AAC3C,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;AACzC,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7B,QAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC;AACrC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;AACrC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;AACrC,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;AACzC,QAAA,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;AAC7C,QAAA,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACjD,QAAA,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,8BAA8B,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;KACnF;;AAGM,IAAA,MAAM,kBAAkB,GAAA;QAC3B,IAAI,CAAC,iBAAiB,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;KAC9D;;IAGM,iBAAiB,GAAA;QAEpB,OAAO;YACH,GAAG,IAA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,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC;YAC/C,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;AACnD,YAAA,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;YAC/E,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,iBAAiB,EAAE,SAAS,EAAE,CAAA,SAAA,EAAY,QAAQ,CAAC,oBAAoB,CAAE,CAAA,CAAC,CAAC;YAEtI,OAAO;AACH,gBAAA,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;AACvB,gBAAA,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,oBAAoB,CAAC;AAChD,gBAAA,GAAG,EAAE,iBAAiB;aACzB,CAAA;AACJ,SAAA;KACJ;AAEO,IAAA,8BAA8B,CAAC,QAAgB,EAAA;QACnD,MAAM,eAAe,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAChE,QAAA,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC;KACtC;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"DataverseTaskGridDescriptor.js","sources":["../../../../../src/components/TaskGrid/extensions/dataverse/DataverseTaskGridDescriptor.ts"],"sourcesContent":["import { FetchXmlBuilder, IDataProvider, IRawRecord, IRecord, ISingleRecord, RecordBuilder } from \"@talxis/client-libraries\";\nimport { ICustomColumnsStrategy, IDeletedUserQueriesResult, ISavedQuery, ISavedQueryStrategy, ITaskDataProviderStrategy } from \"../../providers\";\nimport { IFieldMapping as IFieldMappingBase, ITaskGridDescriptor, ITaskGridParameters, ITaskStrategyDeps } from \"../../interfaces\";\nimport { IGridCustomizerStrategy } from \"../../components/grid\";\nimport { DataverseSavedQueryStrategy } from \"./DataverseSavedQueryStrategy\";\nimport { DataverseTaskStrategy } from \"./DataverseTaskStrategy\";\nimport { DataverseGridCustomizerStrategy } from \"./DataverseGridCustomizerStrategy\";\nimport { EntityDefinition } from \"@talxis/client-metadata\";\nimport { DataverseCustomColumnsStrategy } from \"./DataverseCustomColumnsStrategy\";\n\n\n/** Dataverse-specific field mapping. Extends the base with an optional project lookup column. */\nexport interface IFieldMapping extends Omit<IFieldMappingBase, 'stateCode'> {\n /** Logical name of the lookup attribute that points to the parent project record. Required when `projectRecord` is set on the descriptor. */\n projectId?: string;\n}\n\n/** Lightweight entity reference shape used when only logical name + id are available. */\nexport interface IEntityRecordReference {\n entityName: string;\n id: string;\n}\n\n/** Input accepted for source/project: either a fully hydrated record or an entity reference. */\nexport type RecordInput = IEntityRecordReference | ISingleRecord;\n\nconst isSingleRecord = (record: RecordInput | undefined): record is ISingleRecord => {\n return !!record && typeof (record as ISingleRecord).getRecordId === \"function\";\n};\n\n/** Constructor parameters for {@link DataverseTaskGridDescriptor}. */\nexport interface IDataverseTaskGridDescriptorParams {\n /** FetchXML that drives the initial data load. May use Liquid template variables (e.g. `{{ projectId }}`). */\n baseFetchXml: string;\n /** Maps logical entity attribute names to the roles expected by TaskGrid (e.g. `statecode` → `stateCode`). */\n fieldMapping: IFieldMapping;\n /** System (non-deletable) views exposed in the view switcher. At least one is required. */\n systemQueries: ISavedQuery[];\n /** Optional source record. If provided, it's data will be propagated into liquid fetch XML templates. */\n sourceRecord?: RecordInput;\n\n projectRecord?: RecordInput;\n\n height?: string;\n /** Fine-grained feature flags forwarded to the grid. See {@link ITaskGridParameters}. */\n gridParameters?: ITaskGridParameters;\n /** When set, the hierarchy is rooted at this task ID instead of showing all top-level tasks. */\n rootTaskId?: string;\n /** ID of the currently logged-in user. Used to scope user queries to the current owner. */\n userId?: string;\n /** Form ID to open when editing a single existing task. */\n editFormId?: string;\n /** Form ID to open when creating a new task via the dialog flow (non-inline). */\n createFormId?: string;\n /** Form ID to open for bulk-editing multiple selected tasks. */\n bulkEditFormId?: string;\n /** Set to `true` to enable cascade delete when deleting tasks with children. Defaults to `false`. */\n enableCascadeDelete?: boolean;\n /** Set to `true` to allow deletion of tasks that have child tasks. When `false`, such tasks are excluded from deletion and an error is returned. Defaults to `false`. */\n enableDeletingTasksWithChildren?: boolean;\n}\n\n/**\n * Ready-to-use {@link ITaskGridDescriptor} implementation for the Dataverse / Talxis platform.\n *\n * Wires together all required strategies — task CRUD, saved queries, grid customization — from\n * a single constructor parameter object. Pass an instance to `TaskGridDatasetControlFactory.createInstance`.\n *\n * @example\n * ```ts\n * const descriptor = new DataverseTaskGridDescriptor({\n * baseFetchXml: myFetchXml,\n * fieldMapping: { parentId: 'talxis_parenttaskid', subject: 'subject', stackRank: 'talxis_stackrank' },\n * systemQueries: [myDefaultView],\n * });\n * const control = await TaskGridDatasetControlFactory.createInstance({ taskGridDescriptor: descriptor, ... });\n * ```\n */\nexport class DataverseTaskGridDescriptor implements ITaskGridDescriptor {\n private _fetchXml!: string;\n private _fieldMapping!: IFieldMapping;\n private _systemQueries: ISavedQuery[] = [];\n private _taskEntityName!: string;\n private _editFormId?: string;\n private _createFormId?: string;\n private _bulkEditFormId?: string;\n private _userId?: string;\n private _rootTaskId?: string;\n private _projectRecord?: ISingleRecord;\n private _sourceRecord?: ISingleRecord;\n private _params!: IDataverseTaskGridDescriptorParams;\n private _gridParameters?: ITaskGridParameters;\n private _height?: string;\n private _onInitialize: () => Promise<IDataverseTaskGridDescriptorParams>;\n\n /** @param params — see {@link IDataverseTaskGridDescriptorParams} for full documentation of each option. */\n constructor(params: { onInitialize: () => Promise<IDataverseTaskGridDescriptorParams>; height?: string }) {\n this._onInitialize = params.onInitialize;\n this._height = params.height;\n }\n\n /** Resolves the project entity reference (fetches display name when not supplied). Called once by the factory before any strategy is created. */\n public async onLoadDependencies(): Promise<void> {\n const params = await this._onInitialize();\n this._params = params;\n this._systemQueries = params.systemQueries;\n this._fieldMapping = params.fieldMapping;\n this._userId = params.userId;\n this._fetchXml = params.baseFetchXml;\n this._rootTaskId = params.rootTaskId;\n this._editFormId = params.editFormId;\n this._createFormId = params.createFormId;\n this._bulkEditFormId = params.bulkEditFormId;\n this._gridParameters = params.gridParameters;\n this._taskEntityName = this._getTaskEntityNameFromFetchXml(params.baseFetchXml);\n this._projectRecord = await this._getProjectRecord();\n this._sourceRecord = await this._getSourceRecord();\n }\n\n /** Returns the field mapping with `stateCode` hard-coded to `\"statecode\"` (standard Dataverse attribute name). */\n public onGetFieldMapping(): IFieldMappingBase {\n return {\n ...this._fieldMapping,\n //dataverse uses this for all entities\n stateCode: 'statecode',\n }\n }\n\n //needs to be seperate from onGetGridParameters since it is also required for skeleton rendering before the instance is created\n public onGetHeight(): string | undefined {\n return this._height;\n }\n\n /** Returns a {@link DataverseSavedQueryStrategy} when `enableUserQueries` is `true`, otherwise a read-only stub that exposes only the system queries. */\n public onCreateSavedQueryStrategy(): ISavedQueryStrategy {\n if (this._gridParameters?.enableUserQueries) {\n return new DataverseSavedQueryStrategy({\n onGetSystemQueries: async () => this._systemQueries,\n ownerId: this._userId,\n entityName: this._taskEntityName,\n recordId: this._projectRecord?.getRecordId()\n });\n }\n return {\n onGetSystemQueries: async () => this._systemQueries,\n onGetUserQueries: async () => [],\n onDeleteUserQueries: function (queryIds: string[]): Promise<IDeletedUserQueriesResult> {\n throw new Error(\"Function not implemented.\");\n },\n onUpdateUserQuery: function (currentQuery: ISavedQuery): Promise<string | null> {\n throw new Error(\"Function not implemented.\");\n },\n onCreateUserQuery: function (newQuery: { name: string; description?: string; }, currentQuery: ISavedQuery): Promise<string | null> {\n throw new Error(\"Function not implemented.\");\n }\n }\n }\n\n public onCreateCustomColumnsStrategy(): ICustomColumnsStrategy | undefined {\n return new DataverseCustomColumnsStrategy({\n entityName: this._taskEntityName,\n recordId: this._projectRecord?.getRecordId(),\n })\n }\n\n /** Returns a {@link DataverseTaskStrategy} configured with the descriptor's FetchXML, form IDs, and project reference. */\n public onCreateTaskStrategy(deps: ITaskStrategyDeps): ITaskDataProviderStrategy {\n return new DataverseTaskStrategy({\n fetchXml: this._fetchXml,\n projectRecord: this._projectRecord,\n sourceRecord: this._sourceRecord,\n rootTaskId: this._rootTaskId,\n bulkEditFormId: this._bulkEditFormId,\n createFormId: this._createFormId,\n editFormId: this._editFormId,\n isCascadeDeleteEnabled: this._params.enableCascadeDelete ?? false,\n isDeletingTasksWithChildrenEnabled: this._params.enableDeletingTasksWithChildren ?? false,\n }, deps);\n }\n /** Returns a {@link DataverseSavedQueryStrategy} pre-configured as a data provider for the user-query creation/update dialog, with `talxis_name` and `talxis_description` columns. */\n public onCreateUserQueryDataProvider(): IDataProvider {\n const provider = new DataverseSavedQueryStrategy({\n recordId: this._projectRecord?.getRecordId(),\n entityName: this._taskEntityName,\n ownerId: this._userId,\n onGetSystemQueries: async () => {\n return []\n }\n })\n provider.setColumns([{\n name: 'talxis_name',\n visualSizeFactor: 200\n }, {\n name: 'talxis_description',\n visualSizeFactor: 300\n }]);\n return provider;\n }\n\n /** Returns the feature flags supplied at construction time, or an empty object (all features enabled) when omitted. */\n public onGetGridParameters(): ITaskGridParameters {\n return this._gridParameters ?? {};\n }\n\n /** Returns a {@link DataverseGridCustomizerStrategy} that adds lookup-many cell renderers for columns whose name ends with the lookup-many suffix. */\n public onCreateGridCustomizerStrategy(): IGridCustomizerStrategy {\n return new DataverseGridCustomizerStrategy();\n }\n\n private async _getProjectRecord(): Promise<ISingleRecord | undefined> {\n const projectRecord = this._params.projectRecord;\n if (!projectRecord) return undefined;\n if (isSingleRecord(projectRecord)) {\n return projectRecord;\n }\n\n const projectId = projectRecord.id;\n const projectEntityName = projectRecord.entityName;\n const metadata = await EntityDefinition.fromEntityName(projectEntityName);\n //@ts-ignore - typings\n const attributes = (await window.Xrm.Utility.getEntityMetadata(projectEntityName, metadata.Attributes.map(attr => attr.LogicalName))).Attributes.get().filter(attr => attr.IsValidForGrid);\n const projectData = await window.Xrm.WebApi.retrieveRecord(projectEntityName, projectId, `?$select=${metadata.PrimaryNameAttribute}`);\n const builder = new RecordBuilder({\n data: projectData,\n entityMetadata: metadata,\n attributes: attributes\n });\n return builder.getRecord();\n }\n\n private async _getSourceRecord(): Promise<ISingleRecord | undefined> {\n const sourceRecord = this._params.sourceRecord;\n if (!sourceRecord) {\n return undefined;\n }\n const sourceRecordId = isSingleRecord(sourceRecord) ? sourceRecord.getRecordId() : sourceRecord.id;\n if (this._projectRecord && this._projectRecord.getRecordId() === sourceRecordId) {\n return this._projectRecord;\n }\n\n if (isSingleRecord(sourceRecord)) {\n return sourceRecord;\n }\n const result = await window.Xrm.WebApi.retrieveRecord(sourceRecord.entityName, sourceRecord.id);\n const entityMetadata = await EntityDefinition.fromEntityName(sourceRecord.entityName);\n //@ts-ignore - typings\n const attributes = (await window.Xrm.Utility.getEntityMetadata(sourceRecord.entityName, entityMetadata.Attributes.map(attr => attr.LogicalName))).Attributes.get().filter(attr => attr.IsValidForGrid);\n\n const builder = new RecordBuilder({\n data: result,\n entityMetadata: entityMetadata,\n attributes: attributes\n });\n\n return builder.getRecord();\n }\n\n private _getTaskEntityNameFromFetchXml(fetchXml: string): string {\n const fetchXmlBuilder = FetchXmlBuilder.fetch.fromXml(fetchXml);\n return fetchXmlBuilder.entity.name;\n }\n\n}"],"names":[],"mappings":";;;;;;;AA0BA,MAAM,cAAc,GAAG,CAAC,MAA+B,KAA6B;IAChF,OAAO,CAAC,CAAC,MAAM,IAAI,OAAQ,MAAwB,CAAC,WAAW,KAAK,UAAU,CAAC;AACnF,CAAC,CAAC;AAkCF;;;;;;;;;;;;;;;AAeG;MACU,2BAA2B,CAAA;;AAkBpC,IAAA,WAAA,CAAY,MAA4F,EAAA;QAfhG,IAAc,CAAA,cAAA,GAAkB,EAAE,CAAC;AAgBvC,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;AACzC,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;KAChC;;AAGM,IAAA,MAAM,kBA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AM,CAAC,cAAc,CAAC,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;QAChG,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC,cAAc,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;;QAEtF,MAAM,UAAU,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC;AAEvM,QAAA,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC;AAC9B,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,cAAc,EAAE,cAAc;AAC9B,YAAA,UAAU,EAAE,UAAU;AACzB,SAAA,CAAC,CAAC;AAEH,QAAA,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC;KAC9B;AAEO,IAAA,8BAA8B,CAAC,QAAgB,EAAA;QACnD,MAAM,eAAe,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAChE,QAAA,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC;KACtC;AAEJ;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="@types/powerapps-component-framework" />
|
|
2
2
|
/// <reference types="@types/xrm" />
|
|
3
|
-
import { IRecord, IRawRecord, IAvailableColumnOptions, IAvailableRelatedColumn, IRecordSaveOperationResult, IColumn } from "@talxis/client-libraries";
|
|
4
|
-
import { ITaskDataProviderStrategy, ITaskDataProvider, IDeleteTasksResult,
|
|
3
|
+
import { IRecord, IRawRecord, IAvailableColumnOptions, IAvailableRelatedColumn, IRecordSaveOperationResult, IColumn, ISingleRecord } from "@talxis/client-libraries";
|
|
4
|
+
import { ITaskDataProviderStrategy, ITaskDataProvider, IDeleteTasksResult, IOpenDatasetItemsResult } from "../../providers";
|
|
5
|
+
import { ITaskStrategyDeps } from "../..";
|
|
5
6
|
interface IFormParameters {
|
|
6
7
|
pageInput: Xrm.Navigation.PageInputEntityRecord;
|
|
7
8
|
navigationOptions: Xrm.Navigation.NavigationOptions;
|
|
@@ -10,8 +11,6 @@ interface IFormParameters {
|
|
|
10
11
|
export interface IDataverseTaskStrategyParams {
|
|
11
12
|
/** FetchXML used to load tasks. May contain Liquid template variables (e.g. `{{ projectId }}`). */
|
|
12
13
|
fetchXml: string;
|
|
13
|
-
/** When `true`, new tasks are created inline in the grid row without opening a form dialog. Defaults to `true`. */
|
|
14
|
-
isInlineCreateEnabled?: boolean;
|
|
15
14
|
/** When `false`, the edit form is opened in read-only mode. Defaults to `true`. */
|
|
16
15
|
isEditingEnabled?: boolean;
|
|
17
16
|
/** When `true`, deleting a task will also delete its child tasks. Defaults to `false`. */
|
|
@@ -25,7 +24,8 @@ export interface IDataverseTaskStrategyParams {
|
|
|
25
24
|
/** Form ID to open when bulk-editing multiple selected tasks. */
|
|
26
25
|
bulkEditFormId?: string;
|
|
27
26
|
/** Project record reference. When provided, new tasks are pre-linked to this project. */
|
|
28
|
-
|
|
27
|
+
projectRecord?: ISingleRecord;
|
|
28
|
+
sourceRecord?: ISingleRecord;
|
|
29
29
|
/** When set, the task hierarchy is rooted at this task ID. */
|
|
30
30
|
rootTaskId?: string;
|
|
31
31
|
/**
|
|
@@ -33,14 +33,15 @@ export interface IDataverseTaskStrategyParams {
|
|
|
33
33
|
* any form operation (`create`, `edit`, `bulkEdit`, `open`).
|
|
34
34
|
* Return the modified `pageInput` and `navigationOptions` to customize the dialog.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
form?: {
|
|
37
37
|
onGetFormParameters?: (operation: 'create' | 'edit' | 'bulkEdit' | 'open', defaultParameters: IFormParameters) => IFormParameters;
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
/** Extends {@link ITaskDataProviderStrategy} with a Dataverse-specific accessor for the project reference. */
|
|
41
41
|
export interface IDataverseTaskStrategy extends ITaskDataProviderStrategy {
|
|
42
42
|
/** Returns the resolved project entity reference, or `null` if no project was provided at construction time. */
|
|
43
|
-
|
|
43
|
+
getProjectRecord(): ISingleRecord | null;
|
|
44
|
+
getSourceRecord(): ISingleRecord | null;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* Ready-to-use {@link ITaskDataProviderStrategy} implementation for the Dataverse / Talxis platform.
|
|
@@ -56,6 +57,7 @@ export declare class DataverseTaskStrategy implements IDataverseTaskStrategy {
|
|
|
56
57
|
private _entitySetName;
|
|
57
58
|
private _entityName;
|
|
58
59
|
private _projectReference?;
|
|
60
|
+
private _projectRecord?;
|
|
59
61
|
private _projectMetadata?;
|
|
60
62
|
private _rootTaskId?;
|
|
61
63
|
private _taskTree;
|
|
@@ -69,13 +71,17 @@ export declare class DataverseTaskStrategy implements IDataverseTaskStrategy {
|
|
|
69
71
|
private _isDeletingTasksWithChildrenEnabled;
|
|
70
72
|
private _isCascadeDeleteEnabled;
|
|
71
73
|
private _lookupManyColumns;
|
|
74
|
+
private _customColumns;
|
|
75
|
+
private _sourceRecord?;
|
|
76
|
+
private _customColumnsDataProvider?;
|
|
72
77
|
private _lookupManyHandlers;
|
|
73
78
|
private _getFormParameters;
|
|
74
79
|
/** @param params — see {@link IDataverseTaskStrategyParams} for full documentation of each option. */
|
|
75
|
-
constructor(params: IDataverseTaskStrategyParams);
|
|
80
|
+
constructor(params: IDataverseTaskStrategyParams, deps: ITaskStrategyDeps);
|
|
76
81
|
onGetRawRecords(ids: string[], select?: string): Promise<IRawRecord[]>;
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
getProjectRecord(): ISingleRecord | null;
|
|
83
|
+
getSourceRecord(): ISingleRecord | null;
|
|
84
|
+
private _harmonizenizeCustomColumnsData;
|
|
79
85
|
private _harmonizeLookupManyData;
|
|
80
86
|
private _convertLookupManyToEntityReference;
|
|
81
87
|
private _getRawRecordsByIds;
|
|
@@ -85,18 +91,18 @@ export declare class DataverseTaskStrategy implements IDataverseTaskStrategy {
|
|
|
85
91
|
metadata: any;
|
|
86
92
|
}>;
|
|
87
93
|
private _getLookupManyColumns;
|
|
94
|
+
private _getCustomColumns;
|
|
88
95
|
private _restoreVirtualColumnMetadata;
|
|
89
96
|
private _injectLookupManyFilterOperators;
|
|
90
97
|
private _getFieldMapping;
|
|
91
98
|
private _getFetchXml;
|
|
92
99
|
onGetAvailableColumns(options?: IAvailableColumnOptions): Promise<IColumn[]>;
|
|
93
100
|
onGetAvailableRelatedColumns(): Promise<IAvailableRelatedColumn[]>;
|
|
94
|
-
onGetQuickFindColumns(): string[];
|
|
95
101
|
onCreateTask(parentTaskId?: string): Promise<IRawRecord | null>;
|
|
96
102
|
onDeleteTasks(taskIds: string[]): Promise<IDeleteTasksResult | null>;
|
|
97
103
|
onCreateTemplateFromTask(taskId: string): Promise<IRawRecord | null>;
|
|
98
104
|
onCreateTasksFromTemplate(templateId: string, parentTaskId?: string): Promise<IRawRecord[] | null>;
|
|
99
|
-
|
|
105
|
+
onOpenDatasetItems(entityReferences: ComponentFramework.EntityReference[], isTaskEntity: boolean): Promise<IOpenDatasetItemsResult | null>;
|
|
100
106
|
onMoveTask(movingTaskId: string, movingToTaskId: string, position: "above" | "below" | "child"): Promise<IRawRecord[] | null>;
|
|
101
107
|
/**
|
|
102
108
|
* Saves a single dirty field on a task record.
|
|
@@ -106,11 +112,7 @@ export declare class DataverseTaskStrategy implements IDataverseTaskStrategy {
|
|
|
106
112
|
onRecordSave(record: IRecord): Promise<IRecordSaveOperationResult>;
|
|
107
113
|
/** Returns `true` when the task's `stateCode` attribute equals `0` (active). */
|
|
108
114
|
onIsRecordActive(recordId: string): boolean;
|
|
109
|
-
/**
|
|
110
|
-
onOpenDatasetItem(entityReference: ComponentFramework.EntityReference, context?: {
|
|
111
|
-
columnName?: string;
|
|
112
|
-
}): Promise<void>;
|
|
113
|
-
/** Returns the root task ID supplied at construction time, used to scope the displayed hierarchy. */
|
|
115
|
+
/** Returns the root task ID used to scope the displayed hierarchy. */
|
|
114
116
|
onGetRootTaskId?(): string | undefined;
|
|
115
117
|
private _getNavigationalPropertyName;
|
|
116
118
|
private _getFormNavigationOptions;
|