@acorex-platform/module-report-management-client 1.0.1 → 2.0.0-beta.0
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/fesm2022/{acorex-platform-module-report-management-client-acorex-platform-module-report-management-client-eSjEqt5D.mjs → acorex-platform-module-report-management-client-acorex-platform-module-report-management-client-DKnaOM7_.mjs} +36 -53
- package/fesm2022/acorex-platform-module-report-management-client-acorex-platform-module-report-management-client-DKnaOM7_.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-report-category.mjs +0 -14
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-report-category.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-report-generation-request.mjs +2 -16
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-report-generation-request.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-report.mjs +179 -25
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-report.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-report-management-client-contracts-entity-catalog-acorex-platform-module-report-management-client-contracts-entity-catalog-CboBAIna.mjs → acorex-platform-module-report-management-client-contracts-entity-catalog-acorex-platform-module-report-management-client-contracts-entity-catalog-CSABQXeE.mjs} +4 -20
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-acorex-platform-module-report-management-client-contracts-entity-catalog-CSABQXeE.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-report-management-client-contracts-entity-catalog-report-category.entity-BQFdNXAm.mjs → acorex-platform-module-report-management-client-contracts-entity-catalog-report-category.entity-GPDKYKW_.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-report-management-client-contracts-entity-catalog-report-category.entity-BQFdNXAm.mjs.map → acorex-platform-module-report-management-client-contracts-entity-catalog-report-category.entity-GPDKYKW_.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-module-report-management-client-contracts-entity-catalog-report-generation-request.entity-D381cWLE.mjs → acorex-platform-module-report-management-client-contracts-entity-catalog-report-generation-request.entity-B3cCnjKO.mjs} +4 -4
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-report-generation-request.entity-B3cCnjKO.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-report.entity-B_BWJu1a.mjs +292 -0
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-report.entity-B_BWJu1a.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog.mjs +1 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts.mjs +1866 -25
- package/fesm2022/acorex-platform-module-report-management-client-contracts.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-report-management-client-entity-reports-page-component.provider-CaxletoS.mjs → acorex-platform-module-report-management-client-entity-reports-page-component.provider-BqgxvuLq.mjs} +3 -3
- package/fesm2022/{acorex-platform-module-report-management-client-entity-reports-page-component.provider-CaxletoS.mjs.map → acorex-platform-module-report-management-client-entity-reports-page-component.provider-BqgxvuLq.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-module-report-management-client-entity-reports-page.component-CK5bCQhm.mjs → acorex-platform-module-report-management-client-entity-reports-page.component-D9AfxSeN.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-report-management-client-entity-reports-page.component-CK5bCQhm.mjs.map → acorex-platform-module-report-management-client-entity-reports-page.component-D9AfxSeN.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-report-management-client-local-entities.mjs +0 -2
- package/fesm2022/acorex-platform-module-report-management-client-local-entities.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-report-management-client-report-definition-access.service-DUpwky68.mjs +67 -0
- package/fesm2022/acorex-platform-module-report-management-client-report-definition-access.service-DUpwky68.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-report-management-client-report-filter-page.component-C8XSGSdz.mjs +255 -0
- package/fesm2022/acorex-platform-module-report-management-client-report-filter-page.component-C8XSGSdz.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-report-management-client-report-layout-page-component.provider-BfBckWsh.mjs +28 -0
- package/fesm2022/acorex-platform-module-report-management-client-report-layout-page-component.provider-BfBckWsh.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-report-management-client-report-layout-page.component-DFmdGIY9.mjs +876 -0
- package/fesm2022/acorex-platform-module-report-management-client-report-layout-page.component-DFmdGIY9.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-report-management-client-report-layout-switcher.util-C3OVIaEz.mjs → acorex-platform-module-report-management-client-report-layout-switcher.util-DRG-8RcA.mjs} +258 -41
- package/fesm2022/acorex-platform-module-report-management-client-report-layout-switcher.util-DRG-8RcA.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-report-management-client-report-popup-viewer.component-CKE8NG5T.mjs → acorex-platform-module-report-management-client-report-popup-viewer.component-BVI1z7F3.mjs} +6 -6
- package/fesm2022/{acorex-platform-module-report-management-client-report-popup-viewer.component-CKE8NG5T.mjs.map → acorex-platform-module-report-management-client-report-popup-viewer.component-BVI1z7F3.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-module-report-management-client-report-viewer-page.component-CPlbhBa_.mjs → acorex-platform-module-report-management-client-report-viewer-page.component-CPHO4vlQ.mjs} +84 -26
- package/fesm2022/acorex-platform-module-report-management-client-report-viewer-page.component-CPHO4vlQ.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-report-management-client.mjs +1 -1
- package/i18n/en-AU/report-management.json +260 -35
- package/i18n/en-US/report-management.json +260 -35
- package/i18n/fa-IR/report-management.json +260 -35
- package/package.json +2 -9
- package/types/acorex-platform-module-report-management-client-contracts.d.ts +395 -109
- package/types/acorex-platform-module-report-management-client.d.ts +5 -5
- package/fesm2022/acorex-platform-module-report-management-client-acorex-platform-module-report-management-client-eSjEqt5D.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-query-snapshot-policy.mjs +0 -157
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-query-snapshot-policy.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-query-snapshot.mjs +0 -197
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entities-query-snapshot.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-acorex-platform-module-report-management-client-contracts-entity-catalog-CboBAIna.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-query-snapshot-policy.entity-BUY06Dz0.mjs +0 -97
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-query-snapshot-policy.entity-BUY06Dz0.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-query-snapshot.entity-CnnX3xZt.mjs +0 -137
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-query-snapshot.entity-CnnX3xZt.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-report-generation-request.entity-D381cWLE.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-report.entity-Bwui0M8X.mjs +0 -124
- package/fesm2022/acorex-platform-module-report-management-client-contracts-entity-catalog-report.entity-Bwui0M8X.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-report-layout-switcher.util-C3OVIaEz.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-report-management-client-report-viewer-page.component-CPlbhBa_.mjs.map +0 -1
- package/types/acorex-platform-module-report-management-client-contracts-entities-query-snapshot-policy.d.ts +0 -5
- package/types/acorex-platform-module-report-management-client-contracts-entities-query-snapshot.d.ts +0 -5
|
@@ -0,0 +1,876 @@
|
|
|
1
|
+
import { extractRequestErrorInfo } from '@acorex-platform/framework-client/common';
|
|
2
|
+
import { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';
|
|
3
|
+
import * as i1 from '@acorex-platform/framework-client/layout/widget-core';
|
|
4
|
+
import { AXPWidgetCoreModule } from '@acorex-platform/framework-client/layout/widget-core';
|
|
5
|
+
import { AXPPageLayoutBaseComponent, AXPPageLayoutBase } from '@acorex-platform/framework-client/layout/views';
|
|
6
|
+
import { extractValue, resolveMultiLanguageString } from '@acorex-platform/framework-shared/core';
|
|
7
|
+
import { reportLayoutFieldKebabKey, REPORT_LAYOUT_FIELD_LABEL_KEYS, reportLayoutFieldFallbackLabel, RootConfig, reportLayoutPresetByKey, readReportLayoutForm, readReportLayoutSections, reportLayoutQueryName, autoMapReportLayoutInputs, reportLayoutFieldSchema, reportLayoutStoredColumns, reportLayoutStoredParameters, pickReportLayoutForm, sameReportLayoutForm, reportLayoutSectionsChanged, applyReportLayoutForm, applyReportLayoutSections } from '@acorex-platform/module-report-management-client/contracts';
|
|
8
|
+
import { AXPCommandExecutor } from '@acorex-platform/framework-client/runtime';
|
|
9
|
+
import * as i0 from '@angular/core';
|
|
10
|
+
import { inject, Injectable, input, signal, computed, effect, untracked, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
11
|
+
import { isEqual } from 'lodash-es';
|
|
12
|
+
import { A as AXMReportDefinitionAccessService } from './acorex-platform-module-report-management-client-report-definition-access.service-DUpwky68.mjs';
|
|
13
|
+
import { objectKeyValueTransforms } from '@acorex-platform/framework-client/core';
|
|
14
|
+
|
|
15
|
+
//#region ---- Constants ----
|
|
16
|
+
const editor = 'reports.entities.report.layout-editor';
|
|
17
|
+
/** The page edits a copy of the stored sections under this context key. */
|
|
18
|
+
const SECTIONS_ROOT = 'sections';
|
|
19
|
+
/** A select widget hands back its row. Only the id is stored. */
|
|
20
|
+
const ID_VALUE = objectKeyValueTransforms('id');
|
|
21
|
+
/** A multi select hands back its rows. Only the ids are stored. */
|
|
22
|
+
const ID_LIST_VALUE = {
|
|
23
|
+
getter: (value) => (Array.isArray(value) ? value.map((item) => extractValue(item, 'id')) : value),
|
|
24
|
+
setter: (value) => (Array.isArray(value) ? value.map((item) => extractValue(item, 'id')) : value),
|
|
25
|
+
};
|
|
26
|
+
/** Registered things the editors let the user pick instead of typing their names. */
|
|
27
|
+
const QUERY_ENTITY = 'PlatformManagement.QueryDefinition';
|
|
28
|
+
const COMMAND_ENTITY = 'PlatformManagement.CommandDefinition';
|
|
29
|
+
const REPORT_ENTITY = 'ReportManagement.Report';
|
|
30
|
+
const STIMULSOFT_TEMPLATE_ENTITY$1 = 'DocumentOutput.StimulsoftTemplate';
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region ---- Labels ----
|
|
33
|
+
function label(key) {
|
|
34
|
+
return `@report-management:${editor}.${key}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Section names (layout, data source, actions, export) and the known properties have a translation.
|
|
38
|
+
* An unknown property shows its own name, split into words.
|
|
39
|
+
*/
|
|
40
|
+
function fieldLabel(key, depth, kind) {
|
|
41
|
+
if (depth === 0) {
|
|
42
|
+
return label(reportLayoutFieldKebabKey(key));
|
|
43
|
+
}
|
|
44
|
+
if (kind === 'query') {
|
|
45
|
+
return label('query-name');
|
|
46
|
+
}
|
|
47
|
+
return REPORT_LAYOUT_FIELD_LABEL_KEYS.has(key)
|
|
48
|
+
? label(`fields.${reportLayoutFieldKebabKey(key)}`)
|
|
49
|
+
: reportLayoutFieldFallbackLabel(key);
|
|
50
|
+
}
|
|
51
|
+
function optionTitle(value) {
|
|
52
|
+
return value === '\t' ? '\\t' : value;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region ---- Include switch ----
|
|
56
|
+
function toggleField(path, labelKey, hintKey) {
|
|
57
|
+
return {
|
|
58
|
+
type: 'form-field',
|
|
59
|
+
name: path,
|
|
60
|
+
options: {
|
|
61
|
+
label: label(labelKey),
|
|
62
|
+
showLabel: true,
|
|
63
|
+
...(hintKey ? { hint: label(hintKey), hintDisplayMode: 'note' } : {}),
|
|
64
|
+
},
|
|
65
|
+
children: [{ type: 'toggle-editor', path, name: path }],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const INCLUDE_NODE = toggleField('enabled', 'include', 'include-hint');
|
|
69
|
+
const INCLUDE_ONLY = [INCLUDE_NODE];
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region ---- Field editors ----
|
|
72
|
+
/** Dropdown over the fields of the view's query. `multiple` stores a list of names. */
|
|
73
|
+
function columnPicker(base, columns, multiple, disabled) {
|
|
74
|
+
return {
|
|
75
|
+
...base,
|
|
76
|
+
type: 'select-editor',
|
|
77
|
+
valueTransforms: multiple ? ID_LIST_VALUE : ID_VALUE,
|
|
78
|
+
options: {
|
|
79
|
+
disabled,
|
|
80
|
+
multiple,
|
|
81
|
+
valueField: 'id',
|
|
82
|
+
textField: 'title',
|
|
83
|
+
allowSearch: true,
|
|
84
|
+
hasClearButton: true,
|
|
85
|
+
dataSource: columns.map((column) => ({ id: column.id, title: column.title })),
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Dropdown over the rows of a registered entity. The stored value is one property of the picked row. */
|
|
90
|
+
function entityPicker(base, entity, valueField, textField, disabled) {
|
|
91
|
+
return {
|
|
92
|
+
...base,
|
|
93
|
+
type: 'lookup-editor',
|
|
94
|
+
options: { disabled, entity, valueField, textField, look: 'select', allowClear: true, allowSearch: true },
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Editor widget for one property, chosen from the kind inferred from its stored value. */
|
|
98
|
+
function editorNode(field, path, choices) {
|
|
99
|
+
const disabled = field.locked === true;
|
|
100
|
+
const base = { path, name: path };
|
|
101
|
+
switch (field.kind) {
|
|
102
|
+
case 'query':
|
|
103
|
+
return entityPicker(base, QUERY_ENTITY, 'name', 'catalogTitle', disabled);
|
|
104
|
+
case 'command':
|
|
105
|
+
return entityPicker(base, COMMAND_ENTITY, 'name', 'catalogTitle', disabled);
|
|
106
|
+
case 'report':
|
|
107
|
+
return entityPicker(base, REPORT_ENTITY, 'id', 'title', disabled);
|
|
108
|
+
case 'template':
|
|
109
|
+
return entityPicker(base, STIMULSOFT_TEMPLATE_ENTITY$1, 'id', 'title', disabled);
|
|
110
|
+
case 'column':
|
|
111
|
+
case 'column-list': {
|
|
112
|
+
// Until a query with known result fields is chosen there is nothing to pick from, so the name is typed.
|
|
113
|
+
const multiple = field.kind === 'column-list';
|
|
114
|
+
if (choices.columns.length === 0) {
|
|
115
|
+
return multiple ? { ...base, type: 'tag-editor', options: { disabled } } : { ...base, type: 'text-editor', options: { disabled } };
|
|
116
|
+
}
|
|
117
|
+
return columnPicker(base, choices.columns, multiple, disabled);
|
|
118
|
+
}
|
|
119
|
+
case 'parameter':
|
|
120
|
+
// The filters of the report are fixed choices; none are defined until the filter tab has some.
|
|
121
|
+
return choices.parameters.length === 0
|
|
122
|
+
? { ...base, type: 'text-editor', options: { disabled } }
|
|
123
|
+
: columnPicker(base, choices.parameters, false, disabled);
|
|
124
|
+
case 'toggle':
|
|
125
|
+
return { ...base, type: 'toggle-editor', options: { disabled } };
|
|
126
|
+
case 'number':
|
|
127
|
+
return { ...base, type: 'number-editor', options: { disabled } };
|
|
128
|
+
case 'multiline':
|
|
129
|
+
return { ...base, type: 'large-text-editor', options: { disabled } };
|
|
130
|
+
case 'locale-text':
|
|
131
|
+
return { ...base, type: 'text-editor', options: { disabled, multiLanguage: true } };
|
|
132
|
+
case 'color':
|
|
133
|
+
return { ...base, type: 'color-editor', options: { disabled } };
|
|
134
|
+
case 'icon':
|
|
135
|
+
return { ...base, type: 'icon-chooser', options: { disabled } };
|
|
136
|
+
case 'tags':
|
|
137
|
+
return { ...base, type: 'tag-editor', options: { disabled } };
|
|
138
|
+
case 'select':
|
|
139
|
+
return {
|
|
140
|
+
...base,
|
|
141
|
+
type: 'select-editor',
|
|
142
|
+
valueTransforms: ID_VALUE,
|
|
143
|
+
options: {
|
|
144
|
+
disabled,
|
|
145
|
+
valueField: 'id',
|
|
146
|
+
textField: 'title',
|
|
147
|
+
dataSource: (field.options ?? []).map((value) => ({ id: value, title: optionTitle(value) })),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
case 'json':
|
|
151
|
+
return { ...base, type: 'json-viewer' };
|
|
152
|
+
default:
|
|
153
|
+
return { ...base, type: 'text-editor', options: { disabled } };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** Only switches, numbers, choices and colours are short enough to share a row. Text takes the whole row. */
|
|
157
|
+
function isWide(field) {
|
|
158
|
+
return !(field.kind === 'toggle' ||
|
|
159
|
+
field.kind === 'number' ||
|
|
160
|
+
field.kind === 'select' ||
|
|
161
|
+
field.kind === 'color');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A form field spans 12 grid tracks unless told otherwise. In a group with fewer tracks that creates
|
|
165
|
+
* extra implicit columns and squeezes every sibling, so each field states how many tracks it takes.
|
|
166
|
+
*/
|
|
167
|
+
function gridSpan(cols, wide) {
|
|
168
|
+
const span = wide ? cols : 1;
|
|
169
|
+
return { colSpan: span, positions: { sm: { colSpan: cols } } };
|
|
170
|
+
}
|
|
171
|
+
function labeledField(field, path, depth, cols, choices) {
|
|
172
|
+
return {
|
|
173
|
+
type: 'form-field',
|
|
174
|
+
name: path,
|
|
175
|
+
options: { label: fieldLabel(field.key, depth, field.kind), showLabel: true, ...gridSpan(cols, isWide(field)) },
|
|
176
|
+
children: [editorNode(field, path, choices)],
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region ---- Containers ----
|
|
181
|
+
/** Two columns only for a group of short fields, and never inside a repeater row, which is narrow. */
|
|
182
|
+
function groupCols(children, inRow) {
|
|
183
|
+
const nested = children.some((child) => child.kind === 'group' || child.kind === 'list');
|
|
184
|
+
return inRow || nested ? 1 : 2;
|
|
185
|
+
}
|
|
186
|
+
function groupNode(field, prefix, depth, inRow, choices) {
|
|
187
|
+
const children = field.fields ?? [];
|
|
188
|
+
const cols = groupCols(children, inRow);
|
|
189
|
+
return {
|
|
190
|
+
type: 'fieldset-layout',
|
|
191
|
+
name: `${prefix}${field.path}`,
|
|
192
|
+
options: {
|
|
193
|
+
title: fieldLabel(field.key, depth),
|
|
194
|
+
look: depth === 0 ? 'card' : 'group',
|
|
195
|
+
collapsible: depth === 0,
|
|
196
|
+
isOpen: true,
|
|
197
|
+
cols,
|
|
198
|
+
},
|
|
199
|
+
children: children.map((child) => fieldNode(child, prefix, depth + 1, inRow, cols, choices)),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A repeater clones one row template per stored row.
|
|
204
|
+
* The template covers every property found in any row, and its paths are relative to the row.
|
|
205
|
+
*/
|
|
206
|
+
function listNode(field, prefix, depth, choices) {
|
|
207
|
+
const path = `${prefix}${field.path}`;
|
|
208
|
+
const row = {
|
|
209
|
+
type: 'fieldset-layout',
|
|
210
|
+
options: { look: 'card', showHeader: false, cols: 1 },
|
|
211
|
+
children: (field.fields ?? []).map((child) => fieldNode(child, '', depth + 1, true, 1, choices)),
|
|
212
|
+
};
|
|
213
|
+
return {
|
|
214
|
+
type: 'fieldset-layout',
|
|
215
|
+
name: path,
|
|
216
|
+
options: {
|
|
217
|
+
title: fieldLabel(field.key, depth),
|
|
218
|
+
look: depth === 0 ? 'card' : 'group',
|
|
219
|
+
collapsible: depth === 0,
|
|
220
|
+
isOpen: true,
|
|
221
|
+
cols: 1,
|
|
222
|
+
},
|
|
223
|
+
children: [
|
|
224
|
+
{
|
|
225
|
+
type: 'repeater-layout',
|
|
226
|
+
name: path,
|
|
227
|
+
path,
|
|
228
|
+
options: { hasControls: true, allowReorder: true, defaultItem: {} },
|
|
229
|
+
children: [row],
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function fieldNode(field, prefix, depth, inRow, cols, choices) {
|
|
235
|
+
switch (field.kind) {
|
|
236
|
+
case 'group':
|
|
237
|
+
return groupNode(field, prefix, depth, inRow, choices);
|
|
238
|
+
case 'list':
|
|
239
|
+
return listNode(field, prefix, depth, choices);
|
|
240
|
+
default:
|
|
241
|
+
return labeledField(field, `${prefix}${field.path}`, depth, cols, choices);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region ---- Page nodes ----
|
|
246
|
+
/** Nodes per schema, then per set of column and filter choices. */
|
|
247
|
+
const nodeCache = new WeakMap();
|
|
248
|
+
function choicesSignature(options) {
|
|
249
|
+
return options.map((option) => `${option.id}\u0000${option.title}`).join('\u0001');
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Include switch, then one editor per property found in the stored JSON of this view.
|
|
253
|
+
* `columns` are the fields of the chosen query; the column editors list them.
|
|
254
|
+
* `parameters` are the filters of the report; the filter mapping lists them.
|
|
255
|
+
* Nodes are cached per schema and choices so a toggle or a keystroke does not rebuild the widget tree.
|
|
256
|
+
*/
|
|
257
|
+
function reportLayoutFieldNodes(enabled, fields, columns = [], parameters = []) {
|
|
258
|
+
if (!enabled || fields.length === 0) {
|
|
259
|
+
return INCLUDE_ONLY;
|
|
260
|
+
}
|
|
261
|
+
let bySignature = nodeCache.get(fields);
|
|
262
|
+
if (!bySignature) {
|
|
263
|
+
bySignature = new Map();
|
|
264
|
+
nodeCache.set(fields, bySignature);
|
|
265
|
+
}
|
|
266
|
+
const signature = `${choicesSignature(columns)}\u0002${choicesSignature(parameters)}`;
|
|
267
|
+
let nodes = bySignature.get(signature);
|
|
268
|
+
if (!nodes) {
|
|
269
|
+
const choices = { columns, parameters };
|
|
270
|
+
nodes = [INCLUDE_NODE, ...fields.map((field) => fieldNode(field, `${SECTIONS_ROOT}.`, 0, false, 1, choices))];
|
|
271
|
+
bySignature.set(signature, nodes);
|
|
272
|
+
}
|
|
273
|
+
return nodes;
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
|
|
277
|
+
//#region ----- Constants -----
|
|
278
|
+
const QUERY_DEFINITION_MODULE = 'PlatformManagement';
|
|
279
|
+
const QUERY_DEFINITION_ENTITY = 'QueryDefinition';
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region ----- Service -----
|
|
282
|
+
/**
|
|
283
|
+
* Result fields of the registered queries, read from the same `PlatformManagement.QueryDefinition`
|
|
284
|
+
* catalog the query pickers use. Lets the report editors offer real field names instead of free text.
|
|
285
|
+
*/
|
|
286
|
+
class AXMReportQueryCatalogService {
|
|
287
|
+
constructor() {
|
|
288
|
+
//#region ----- Services & Dependencies -----
|
|
289
|
+
this.queries = inject(AXPEntityService)
|
|
290
|
+
.withEntity(QUERY_DEFINITION_MODULE, QUERY_DEFINITION_ENTITY)
|
|
291
|
+
.data();
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region ----- State -----
|
|
294
|
+
this.columnsByQuery = new Map();
|
|
295
|
+
this.filtersByQuery = new Map();
|
|
296
|
+
}
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region ----- Public API -----
|
|
299
|
+
/** Filter input names declared on the query (not result columns). */
|
|
300
|
+
filters(queryName) {
|
|
301
|
+
const name = queryName.trim();
|
|
302
|
+
if (!name) {
|
|
303
|
+
return Promise.resolve([]);
|
|
304
|
+
}
|
|
305
|
+
let cached = this.filtersByQuery.get(name);
|
|
306
|
+
if (!cached) {
|
|
307
|
+
cached = this.loadFilters(name).catch(() => {
|
|
308
|
+
this.filtersByQuery.delete(name);
|
|
309
|
+
return [];
|
|
310
|
+
});
|
|
311
|
+
this.filtersByQuery.set(name, cached);
|
|
312
|
+
}
|
|
313
|
+
return cached;
|
|
314
|
+
}
|
|
315
|
+
/** Fields the query returns. Empty when the query is unknown or does not declare its result fields. */
|
|
316
|
+
columns(queryName) {
|
|
317
|
+
const name = queryName.trim();
|
|
318
|
+
if (!name) {
|
|
319
|
+
return Promise.resolve([]);
|
|
320
|
+
}
|
|
321
|
+
let cached = this.columnsByQuery.get(name);
|
|
322
|
+
if (!cached) {
|
|
323
|
+
cached = this.load(name).catch(() => {
|
|
324
|
+
this.columnsByQuery.delete(name);
|
|
325
|
+
return [];
|
|
326
|
+
});
|
|
327
|
+
this.columnsByQuery.set(name, cached);
|
|
328
|
+
}
|
|
329
|
+
return cached;
|
|
330
|
+
}
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region ----- Private -----
|
|
333
|
+
async findByName(name) {
|
|
334
|
+
const found = await this.queries.query({
|
|
335
|
+
skip: 0,
|
|
336
|
+
take: 1,
|
|
337
|
+
filter: { logic: 'and', filters: [{ field: 'name', operator: { type: 'equal' }, value: name }] },
|
|
338
|
+
});
|
|
339
|
+
return found.items.find((item) => item.name === name);
|
|
340
|
+
}
|
|
341
|
+
async loadFilters(name) {
|
|
342
|
+
const row = await this.findByName(name);
|
|
343
|
+
const filters = row?.filter;
|
|
344
|
+
return (Array.isArray(filters) ? filters : [])
|
|
345
|
+
.map((item) => (typeof item?.name === 'string' ? item.name.trim() : ''))
|
|
346
|
+
.filter((item) => item.length > 0);
|
|
347
|
+
}
|
|
348
|
+
async load(name) {
|
|
349
|
+
const columns = (await this.findByName(name))?.columns;
|
|
350
|
+
return (Array.isArray(columns) ? columns : [])
|
|
351
|
+
.filter((column) => typeof column?.name === 'string' && column.name.trim().length > 0)
|
|
352
|
+
.map((column) => ({ name: column.name, title: column.title, interface: column.interface }));
|
|
353
|
+
}
|
|
354
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMReportQueryCatalogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
355
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMReportQueryCatalogService, providedIn: 'root' }); }
|
|
356
|
+
}
|
|
357
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMReportQueryCatalogService, decorators: [{
|
|
358
|
+
type: Injectable,
|
|
359
|
+
args: [{ providedIn: 'root' }]
|
|
360
|
+
}] });
|
|
361
|
+
|
|
362
|
+
//#region ----- Imports -----
|
|
363
|
+
const SAVE_COMMAND = 'ReportDefinitionLayout:Save';
|
|
364
|
+
const DISCARD_COMMAND = 'ReportDefinitionLayout:Discard';
|
|
365
|
+
const DESIGN_LAYOUT_COMMAND = 'ReportDefinitionLayout:DesignStimulsoft';
|
|
366
|
+
const STIMULSOFT_DESIGN_COMMAND = 'DocumentOutput.StimulsoftTemplate:Design';
|
|
367
|
+
const STIMULSOFT_TEMPLATE_MODULE = 'DocumentOutput';
|
|
368
|
+
const STIMULSOFT_TEMPLATE_ENTITY = 'StimulsoftTemplate';
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region ----- Component -----
|
|
371
|
+
class AXMReportLayoutPageComponent extends AXPPageLayoutBaseComponent {
|
|
372
|
+
static { this.pageActionsFromInstance = true; }
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region ----- Lifecycle -----
|
|
375
|
+
constructor() {
|
|
376
|
+
super();
|
|
377
|
+
//#region ----- Inputs -----
|
|
378
|
+
this.rootContext = input({}, /* @ts-ignore */
|
|
379
|
+
...(ngDevMode ? [{ debugName: "rootContext" }] : /* istanbul ignore next */ []));
|
|
380
|
+
this.pageConfig = input(/* @ts-ignore */
|
|
381
|
+
...(ngDevMode ? [undefined, { debugName: "pageConfig" }] : /* istanbul ignore next */ []));
|
|
382
|
+
this.options = input({}, /* @ts-ignore */
|
|
383
|
+
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region ----- Services & Dependencies -----
|
|
386
|
+
this.entityService = inject(AXPEntityService);
|
|
387
|
+
this.commandExecutor = inject(AXPCommandExecutor);
|
|
388
|
+
this.hostPageLayout = inject(AXPPageLayoutBase, { optional: true, skipSelf: true });
|
|
389
|
+
this.reports = this.entityService
|
|
390
|
+
.withEntity(RootConfig.module.name, RootConfig.entities.report.name)
|
|
391
|
+
.data();
|
|
392
|
+
this.stimulsoftTemplates = this.entityService
|
|
393
|
+
.withEntity(STIMULSOFT_TEMPLATE_MODULE, STIMULSOFT_TEMPLATE_ENTITY)
|
|
394
|
+
.data();
|
|
395
|
+
this.access = inject(AXMReportDefinitionAccessService);
|
|
396
|
+
this.queryCatalog = inject(AXMReportQueryCatalogService);
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region ----- State Signals -----
|
|
399
|
+
/** Whether the current tenant may change this definition (platform-global rows are platform-only). */
|
|
400
|
+
this.canEdit = signal(false, /* @ts-ignore */
|
|
401
|
+
...(ngDevMode ? [{ debugName: "canEdit" }] : /* istanbul ignore next */ []));
|
|
402
|
+
this.accessResolved = signal(false, /* @ts-ignore */
|
|
403
|
+
...(ngDevMode ? [{ debugName: "accessResolved" }] : /* istanbul ignore next */ []));
|
|
404
|
+
this.readonlyNotice = signal('', /* @ts-ignore */
|
|
405
|
+
...(ngDevMode ? [{ debugName: "readonlyNotice" }] : /* istanbul ignore next */ []));
|
|
406
|
+
this.localForm = signal(null, /* @ts-ignore */
|
|
407
|
+
...(ngDevMode ? [{ debugName: "localForm" }] : /* istanbul ignore next */ []));
|
|
408
|
+
/** Edited copy of the stored JSON objects. Null until the first edit. */
|
|
409
|
+
this.localSections = signal(null, /* @ts-ignore */
|
|
410
|
+
...(ngDevMode ? [{ debugName: "localSections" }] : /* istanbul ignore next */ []));
|
|
411
|
+
this.savedRecord = signal(null, /* @ts-ignore */
|
|
412
|
+
...(ngDevMode ? [{ debugName: "savedRecord" }] : /* istanbul ignore next */ []));
|
|
413
|
+
this.isDirty = signal(false, /* @ts-ignore */
|
|
414
|
+
...(ngDevMode ? [{ debugName: "isDirty" }] : /* istanbul ignore next */ []));
|
|
415
|
+
this.isSaving = signal(false, /* @ts-ignore */
|
|
416
|
+
...(ngDevMode ? [{ debugName: "isSaving" }] : /* istanbul ignore next */ []));
|
|
417
|
+
this.widgetRenderKey = signal(0, /* @ts-ignore */
|
|
418
|
+
...(ngDevMode ? [{ debugName: "widgetRenderKey" }] : /* istanbul ignore next */ []));
|
|
419
|
+
/** Result fields of the query this view reads. Empty until a query with declared fields is chosen. */
|
|
420
|
+
this.queryColumns = signal([], /* @ts-ignore */
|
|
421
|
+
...(ngDevMode ? [{ debugName: "queryColumns" }] : /* istanbul ignore next */ []));
|
|
422
|
+
this.queryColumnsToken = 0;
|
|
423
|
+
/** Result fields of the query stored on this view (column pickers only). */
|
|
424
|
+
this.storedQueryColumns = signal([], /* @ts-ignore */
|
|
425
|
+
...(ngDevMode ? [{ debugName: "storedQueryColumns" }] : /* istanbul ignore next */ []));
|
|
426
|
+
this.storedQueryColumnsToken = 0;
|
|
427
|
+
/** Filter input names on the stored query (`bindTo` targets like `filters.<name>`). */
|
|
428
|
+
this.storedQueryFilterNames = signal([], /* @ts-ignore */
|
|
429
|
+
...(ngDevMode ? [{ debugName: "storedQueryFilterNames" }] : /* istanbul ignore next */ []));
|
|
430
|
+
this.storedQueryFiltersToken = 0;
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region ----- Computed Properties -----
|
|
433
|
+
this.preset = computed(() => {
|
|
434
|
+
const fromOptions = this.options()?.['layoutKey'];
|
|
435
|
+
const fromConfig = this.pageConfig()?.['field'];
|
|
436
|
+
const key = typeof fromOptions === 'string' ? fromOptions : typeof fromConfig === 'string' ? fromConfig : undefined;
|
|
437
|
+
return reportLayoutPresetByKey(key);
|
|
438
|
+
}, /* @ts-ignore */
|
|
439
|
+
...(ngDevMode ? [{ debugName: "preset" }] : /* istanbul ignore next */ []));
|
|
440
|
+
this.baseline = computed(() => {
|
|
441
|
+
const preset = this.preset();
|
|
442
|
+
if (!preset) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
return readReportLayoutForm(this.reportSnapshot(), preset);
|
|
446
|
+
}, /* @ts-ignore */
|
|
447
|
+
...(ngDevMode ? [{ debugName: "baseline" }] : /* istanbul ignore next */ []));
|
|
448
|
+
/** The stored objects as they are, before any filter is mapped for display. */
|
|
449
|
+
this.storedSections = computed(() => {
|
|
450
|
+
const preset = this.preset();
|
|
451
|
+
return preset ? readReportLayoutSections(this.reportSnapshot(), preset) : {};
|
|
452
|
+
}, { ...(ngDevMode ? { debugName: "storedSections" } : /* istanbul ignore next */ {}), equal: isEqual });
|
|
453
|
+
this.storedQueryName = computed(() => reportLayoutQueryName(this.storedSections()), /* @ts-ignore */
|
|
454
|
+
...(ngDevMode ? [{ debugName: "storedQueryName" }] : /* istanbul ignore next */ []));
|
|
455
|
+
/** Filters of the report: the path each is stored under and a title to show. */
|
|
456
|
+
this.reportParameters = computed(() => {
|
|
457
|
+
const groups = this.rootContext()?.['parameterGroups'];
|
|
458
|
+
const lang = this.translateService.getActiveLang() || 'en-US';
|
|
459
|
+
const options = [];
|
|
460
|
+
for (const group of Array.isArray(groups) ? groups : []) {
|
|
461
|
+
for (const parameter of group?.parameters ?? []) {
|
|
462
|
+
const path = typeof parameter?.path === 'string' ? parameter.path.trim() : '';
|
|
463
|
+
if (!path || options.some((option) => option.id === path)) {
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
const title = resolveMultiLanguageString(parameter.title, lang)?.trim();
|
|
467
|
+
options.push({ id: path, title: title && title !== path ? `${title} (${path})` : path });
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return options;
|
|
471
|
+
}, { ...(ngDevMode ? { debugName: "reportParameters" } : /* istanbul ignore next */ {}), equal: isEqual });
|
|
472
|
+
/**
|
|
473
|
+
* Server to UI: a copy of the stored objects, so the widgets never write into the loaded definition.
|
|
474
|
+
* Every report filter that matches a query filter input is shown as mapped (`filters.<name>`), without counting as an edit.
|
|
475
|
+
*/
|
|
476
|
+
this.baselineSections = computed(() => autoMapReportLayoutInputs(this.storedSections(), this.reportParameters().map((option) => option.id), this.storedQueryFilterNames()), { ...(ngDevMode ? { debugName: "baselineSections" } : /* istanbul ignore next */ {}), equal: isEqual });
|
|
477
|
+
/** Editors are chosen from the stored values. They only change when the stored shape does. */
|
|
478
|
+
this.fieldSchema = computed(() => reportLayoutFieldSchema(this.baselineSections(), this.preset()), { ...(ngDevMode ? { debugName: "fieldSchema" } : /* istanbul ignore next */ {}), equal: isEqual });
|
|
479
|
+
this.context = computed(() => {
|
|
480
|
+
const form = this.localForm() ?? this.baseline();
|
|
481
|
+
if (!form) {
|
|
482
|
+
return {};
|
|
483
|
+
}
|
|
484
|
+
return { ...form, sections: this.baselineSections() };
|
|
485
|
+
}, /* @ts-ignore */
|
|
486
|
+
...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
487
|
+
/** The query follows the user's edit, so the column pickers switch as soon as another query is chosen. */
|
|
488
|
+
this.queryName = computed(() => reportLayoutQueryName(this.localSections() ?? this.baselineSections()), /* @ts-ignore */
|
|
489
|
+
...(ngDevMode ? [{ debugName: "queryName" }] : /* istanbul ignore next */ []));
|
|
490
|
+
/**
|
|
491
|
+
* Fields the column pickers offer: those of the chosen query, plus any name already stored on the view,
|
|
492
|
+
* so a stored value is never hidden because the catalog does not list it.
|
|
493
|
+
*/
|
|
494
|
+
this.columnOptions = computed(() => {
|
|
495
|
+
const columns = this.queryColumns();
|
|
496
|
+
if (columns.length === 0) {
|
|
497
|
+
return [];
|
|
498
|
+
}
|
|
499
|
+
const options = columns.map((column) => ({
|
|
500
|
+
id: column.name,
|
|
501
|
+
title: column.title && column.title !== column.name ? `${column.title} (${column.name})` : column.name,
|
|
502
|
+
}));
|
|
503
|
+
const known = new Set(options.map((option) => option.id));
|
|
504
|
+
for (const stored of reportLayoutStoredColumns(this.baselineSections(), this.fieldSchema())) {
|
|
505
|
+
if (!known.has(stored)) {
|
|
506
|
+
options.push({ id: stored, title: stored });
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return options;
|
|
510
|
+
}, { ...(ngDevMode ? { debugName: "columnOptions" } : /* istanbul ignore next */ {}), equal: isEqual });
|
|
511
|
+
/** Filters the mapping offers, plus any filter already stored on the view so it is never hidden. */
|
|
512
|
+
this.parameterOptions = computed(() => {
|
|
513
|
+
const options = [...this.reportParameters()];
|
|
514
|
+
const known = new Set(options.map((option) => option.id));
|
|
515
|
+
for (const stored of reportLayoutStoredParameters(this.baselineSections(), this.fieldSchema())) {
|
|
516
|
+
if (!known.has(stored)) {
|
|
517
|
+
options.push({ id: stored, title: stored });
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return options;
|
|
521
|
+
}, { ...(ngDevMode ? { debugName: "parameterOptions" } : /* istanbul ignore next */ {}), equal: isEqual });
|
|
522
|
+
this.fieldNodes = computed(() => {
|
|
523
|
+
const form = this.localForm() ?? this.baseline();
|
|
524
|
+
if (!this.preset() || !form) {
|
|
525
|
+
return [];
|
|
526
|
+
}
|
|
527
|
+
return reportLayoutFieldNodes(form.enabled, this.fieldSchema(), this.columnOptions(), this.parameterOptions());
|
|
528
|
+
}, /* @ts-ignore */
|
|
529
|
+
...(ngDevMode ? [{ debugName: "fieldNodes" }] : /* istanbul ignore next */ []));
|
|
530
|
+
effect(() => {
|
|
531
|
+
const root = this.rootContext() ?? {};
|
|
532
|
+
untracked(() => {
|
|
533
|
+
void this.resolveAccess(root);
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
effect(() => {
|
|
537
|
+
const name = this.queryName();
|
|
538
|
+
untracked(() => {
|
|
539
|
+
void this.loadQueryColumns(name);
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
effect(() => {
|
|
543
|
+
const name = this.storedQueryName();
|
|
544
|
+
untracked(() => {
|
|
545
|
+
void this.loadStoredQueryColumns(name);
|
|
546
|
+
void this.loadStoredQueryFilterNames(name);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region ----- Unsaved Changes -----
|
|
552
|
+
hasUnsavedChanges() {
|
|
553
|
+
return this.isDirty();
|
|
554
|
+
}
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region ----- Event Handlers -----
|
|
557
|
+
async getPrimaryMenuItems() {
|
|
558
|
+
const dirty = this.isDirty();
|
|
559
|
+
const saving = this.isSaving();
|
|
560
|
+
const saveTitle = await this.translateService.translateAsync('@general:actions.save.title');
|
|
561
|
+
const discardTitle = await this.translateService.translateAsync('@general:actions.discard.title');
|
|
562
|
+
if (!this.canEdit()) {
|
|
563
|
+
return [];
|
|
564
|
+
}
|
|
565
|
+
const items = [
|
|
566
|
+
{
|
|
567
|
+
title: discardTitle,
|
|
568
|
+
icon: 'fa-light fa-rotate-left',
|
|
569
|
+
zone: 'footer',
|
|
570
|
+
priority: 'secondary',
|
|
571
|
+
color: 'default',
|
|
572
|
+
visible: dirty,
|
|
573
|
+
disabled: saving,
|
|
574
|
+
command: { name: DISCARD_COMMAND, options: {} },
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
title: saveTitle,
|
|
578
|
+
icon: 'fa-light fa-floppy-disk',
|
|
579
|
+
zone: 'footer',
|
|
580
|
+
priority: 'primary',
|
|
581
|
+
color: 'primary',
|
|
582
|
+
visible: dirty,
|
|
583
|
+
disabled: saving,
|
|
584
|
+
command: { name: SAVE_COMMAND, options: {} },
|
|
585
|
+
},
|
|
586
|
+
];
|
|
587
|
+
if (this.preset()?.layoutType === 'pdf') {
|
|
588
|
+
items.unshift({
|
|
589
|
+
title: await this.translateService.translateAsync('@report-management:reports.entities.report.layout-editor.design-stimulsoft'),
|
|
590
|
+
icon: 'fa-light fa-pen-ruler',
|
|
591
|
+
zone: 'header',
|
|
592
|
+
priority: 'secondary',
|
|
593
|
+
color: 'default',
|
|
594
|
+
command: { name: DESIGN_LAYOUT_COMMAND, options: {} },
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
return items;
|
|
598
|
+
}
|
|
599
|
+
onContextChanged(event) {
|
|
600
|
+
const baseline = this.baseline();
|
|
601
|
+
const data = event.data;
|
|
602
|
+
if (!baseline || event.state !== 'changed' || this.isSaving() || data == null || typeof data !== 'object') {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
const record = data;
|
|
606
|
+
const baselineSections = this.baselineSections();
|
|
607
|
+
const currentForm = this.localForm() ?? baseline;
|
|
608
|
+
const currentSections = this.localSections() ?? baselineSections;
|
|
609
|
+
const next = pickReportLayoutForm(record, currentForm);
|
|
610
|
+
const nextSections = pickSections(record['sections'], currentSections);
|
|
611
|
+
if (sameReportLayoutForm(next, currentForm) && isEqual(nextSections, currentSections)) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
const dirty = !sameReportLayoutForm(next, baseline) || reportLayoutSectionsChanged(baselineSections, nextSections, this.preset());
|
|
615
|
+
this.localForm.set(next);
|
|
616
|
+
this.localSections.set(nextSections);
|
|
617
|
+
if (dirty !== this.isDirty()) {
|
|
618
|
+
this.isDirty.set(dirty);
|
|
619
|
+
this.recompute();
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
execute(command) {
|
|
623
|
+
if (command.name === DISCARD_COMMAND) {
|
|
624
|
+
this.localForm.set(null);
|
|
625
|
+
this.localSections.set(null);
|
|
626
|
+
this.isDirty.set(false);
|
|
627
|
+
this.widgetRenderKey.update((key) => key + 1);
|
|
628
|
+
this.recompute();
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (command.name === SAVE_COMMAND) {
|
|
632
|
+
return this.handleSave();
|
|
633
|
+
}
|
|
634
|
+
if (command.name === DESIGN_LAYOUT_COMMAND) {
|
|
635
|
+
return this.openStimulsoftDesigner();
|
|
636
|
+
}
|
|
637
|
+
return undefined;
|
|
638
|
+
}
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region ----- Persistence -----
|
|
641
|
+
reportSnapshot() {
|
|
642
|
+
const root = this.rootContext() ?? {};
|
|
643
|
+
const id = typeof root['id'] === 'string' ? root['id'] : '';
|
|
644
|
+
const saved = this.savedRecord();
|
|
645
|
+
if (saved && saved.id === id) {
|
|
646
|
+
return saved;
|
|
647
|
+
}
|
|
648
|
+
return {
|
|
649
|
+
layouts: Array.isArray(root['layouts']) ? root['layouts'] : [],
|
|
650
|
+
defaultLayoutId: typeof root['defaultLayoutId'] === 'string' ? root['defaultLayoutId'] : '',
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* UI to server: the switches go through the form mapper, then the edited JSON objects are mapped back
|
|
655
|
+
* onto the layout. The stored shape stays the one the server already uses.
|
|
656
|
+
*/
|
|
657
|
+
buildStoredLayouts(preset, form) {
|
|
658
|
+
const applied = applyReportLayoutForm(this.reportSnapshot(), preset, form);
|
|
659
|
+
const baselineSections = this.baselineSections();
|
|
660
|
+
return {
|
|
661
|
+
layouts: applyReportLayoutSections(applied.layouts, preset, baselineSections, this.localSections() ?? baselineSections),
|
|
662
|
+
defaultLayoutId: applied.defaultLayoutId,
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
async handleSave() {
|
|
666
|
+
const preset = this.preset();
|
|
667
|
+
const baseline = this.baseline();
|
|
668
|
+
const form = this.localForm() ?? baseline;
|
|
669
|
+
const id = this.rootContext()?.['id'];
|
|
670
|
+
if (!preset || !form || typeof id !== 'string' || !id) {
|
|
671
|
+
this.toastService.show({
|
|
672
|
+
color: 'danger',
|
|
673
|
+
title: await this.translateService.translateAsync('@general:messages.error.title'),
|
|
674
|
+
content: await this.translateService.translateAsync('@general:messages.entity.invalid-data'),
|
|
675
|
+
});
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
const applied = this.buildStoredLayouts(preset, form);
|
|
679
|
+
this.isSaving.set(true);
|
|
680
|
+
this.recompute();
|
|
681
|
+
try {
|
|
682
|
+
await this.reports.update(id, {
|
|
683
|
+
layouts: applied.layouts,
|
|
684
|
+
defaultLayoutId: applied.defaultLayoutId,
|
|
685
|
+
});
|
|
686
|
+
const root = this.rootContext();
|
|
687
|
+
if (root) {
|
|
688
|
+
root['layouts'] = applied.layouts;
|
|
689
|
+
root['defaultLayoutId'] = applied.defaultLayoutId;
|
|
690
|
+
}
|
|
691
|
+
this.savedRecord.set({ id, layouts: applied.layouts, defaultLayoutId: applied.defaultLayoutId });
|
|
692
|
+
this.localForm.set(null);
|
|
693
|
+
this.localSections.set(null);
|
|
694
|
+
this.isDirty.set(false);
|
|
695
|
+
this.widgetRenderKey.update((key) => key + 1);
|
|
696
|
+
this.toastService.show({
|
|
697
|
+
color: 'success',
|
|
698
|
+
title: await this.translateService.translateAsync('@general:messages.generic.success.title'),
|
|
699
|
+
content: await this.translateService.translateAsync('@general:messages.generic.success.description'),
|
|
700
|
+
location: 'bottom-center',
|
|
701
|
+
closeButton: true,
|
|
702
|
+
timeOut: 3000,
|
|
703
|
+
timeOutProgress: true,
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
catch {
|
|
707
|
+
this.toastService.show({
|
|
708
|
+
color: 'danger',
|
|
709
|
+
title: await this.translateService.translateAsync('@general:messages.error.title'),
|
|
710
|
+
content: await this.translateService.translateAsync('@general:messages.entity.update-failed'),
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
finally {
|
|
714
|
+
this.isSaving.set(false);
|
|
715
|
+
this.recompute();
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
async loadQueryColumns(name) {
|
|
719
|
+
const token = ++this.queryColumnsToken;
|
|
720
|
+
const columns = await this.queryCatalog.columns(name);
|
|
721
|
+
if (token === this.queryColumnsToken) {
|
|
722
|
+
this.queryColumns.set(columns);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
async loadStoredQueryColumns(name) {
|
|
726
|
+
const token = ++this.storedQueryColumnsToken;
|
|
727
|
+
const columns = (await this.queryCatalog.columns(name)).map((column) => column.name);
|
|
728
|
+
if (token !== this.storedQueryColumnsToken || isEqual(columns, this.storedQueryColumns())) {
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
this.storedQueryColumns.set(columns);
|
|
732
|
+
}
|
|
733
|
+
async loadStoredQueryFilterNames(name) {
|
|
734
|
+
const token = ++this.storedQueryFiltersToken;
|
|
735
|
+
const filters = await this.queryCatalog.filters(name);
|
|
736
|
+
if (token !== this.storedQueryFiltersToken || isEqual(filters, this.storedQueryFilterNames())) {
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
this.storedQueryFilterNames.set(filters);
|
|
740
|
+
if (!this.isDirty()) {
|
|
741
|
+
this.widgetRenderKey.update((key) => key + 1);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async resolveAccess(root) {
|
|
745
|
+
const hasId = typeof root['id'] === 'string' && !!root['id'];
|
|
746
|
+
const allowed = hasId ? await this.access.canEdit(root) : false;
|
|
747
|
+
this.canEdit.set(allowed);
|
|
748
|
+
this.accessResolved.set(hasId);
|
|
749
|
+
this.readonlyNotice.set(allowed
|
|
750
|
+
? ''
|
|
751
|
+
: await this.translateService.translateAsync('@report-management:reports.entities.report.layout-editor.readonly-notice'));
|
|
752
|
+
this.recompute();
|
|
753
|
+
}
|
|
754
|
+
async openStimulsoftDesigner() {
|
|
755
|
+
if (!this.canEdit()) {
|
|
756
|
+
await this.showDesignerUnavailable();
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
const preset = this.preset();
|
|
760
|
+
const id = this.rootContext()?.['id'];
|
|
761
|
+
const baseline = this.baseline();
|
|
762
|
+
const current = this.localForm() ?? baseline;
|
|
763
|
+
if (!preset || preset.layoutType !== 'pdf' || !current || typeof id !== 'string' || !id) {
|
|
764
|
+
await this.showDesignerUnavailable();
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
const snapshot = this.reportSnapshot();
|
|
768
|
+
const queryName = current.queryName.trim() || queryNameFromLayouts(snapshot.layouts);
|
|
769
|
+
const form = { ...current, enabled: true, queryName };
|
|
770
|
+
const applied = this.buildStoredLayouts(preset, form);
|
|
771
|
+
const pdf = applied.layouts.find((layout) => layout.layout.type === 'pdf');
|
|
772
|
+
if (!pdf || pdf.layout.type !== 'pdf') {
|
|
773
|
+
await this.showDesignerUnavailable();
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
try {
|
|
777
|
+
let templateId = pdf.layout.stimulsoftTemplateId?.trim() ?? '';
|
|
778
|
+
const templateName = `report-${id}-pdf`;
|
|
779
|
+
if (!templateId) {
|
|
780
|
+
const found = await this.stimulsoftTemplates.query({
|
|
781
|
+
skip: 0,
|
|
782
|
+
take: 5,
|
|
783
|
+
filter: {
|
|
784
|
+
logic: 'and',
|
|
785
|
+
filters: [{ field: 'name', operator: { type: 'equal' }, value: templateName }],
|
|
786
|
+
},
|
|
787
|
+
});
|
|
788
|
+
templateId = found.items.find((item) => item.name === templateName)?.id ?? '';
|
|
789
|
+
}
|
|
790
|
+
if (!templateId) {
|
|
791
|
+
const reportTitle = resolveMultiLanguageString(this.rootContext()?.['title'], this.translateService.getActiveLang() || 'en-US');
|
|
792
|
+
templateId = await this.stimulsoftTemplates.create({
|
|
793
|
+
name: templateName,
|
|
794
|
+
title: reportTitle ? `${reportTitle} PDF` : 'PDF View',
|
|
795
|
+
format: 'pdf',
|
|
796
|
+
status: 'draft',
|
|
797
|
+
queryNames: queryName ? [queryName] : [],
|
|
798
|
+
content: '',
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
pdf.layout = {
|
|
802
|
+
...pdf.layout,
|
|
803
|
+
stimulsoftTemplateId: templateId,
|
|
804
|
+
stimulsoftDataSourceName: queryName || pdf.layout.stimulsoftDataSourceName,
|
|
805
|
+
};
|
|
806
|
+
await this.reports.update(id, {
|
|
807
|
+
layouts: applied.layouts,
|
|
808
|
+
defaultLayoutId: applied.defaultLayoutId,
|
|
809
|
+
});
|
|
810
|
+
const root = this.rootContext();
|
|
811
|
+
if (root) {
|
|
812
|
+
root['layouts'] = applied.layouts;
|
|
813
|
+
root['defaultLayoutId'] = applied.defaultLayoutId;
|
|
814
|
+
}
|
|
815
|
+
this.savedRecord.set({ id, layouts: applied.layouts, defaultLayoutId: applied.defaultLayoutId });
|
|
816
|
+
this.localForm.set(null);
|
|
817
|
+
this.localSections.set(null);
|
|
818
|
+
this.isDirty.set(false);
|
|
819
|
+
this.widgetRenderKey.update((key) => key + 1);
|
|
820
|
+
this.recompute();
|
|
821
|
+
await this.commandExecutor.execute(STIMULSOFT_DESIGN_COMMAND, { templateId });
|
|
822
|
+
}
|
|
823
|
+
catch (error) {
|
|
824
|
+
const message = extractRequestErrorInfo(error)?.message || (error instanceof Error ? error.message : '');
|
|
825
|
+
this.toastService.show({
|
|
826
|
+
color: 'danger',
|
|
827
|
+
title: await this.translateService.translateAsync('@general:messages.error.title'),
|
|
828
|
+
content: message || (await this.translateService.translateAsync('@report-management:reports.entities.report.layout-editor.design-stimulsoft-unavailable')),
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
async showDesignerUnavailable() {
|
|
833
|
+
this.toastService.show({
|
|
834
|
+
color: 'warning',
|
|
835
|
+
title: await this.translateService.translateAsync('@report-management:reports.entities.report.layout-editor.design-stimulsoft'),
|
|
836
|
+
content: await this.translateService.translateAsync('@report-management:reports.entities.report.layout-editor.design-stimulsoft-unavailable'),
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
recompute() {
|
|
840
|
+
super.recompute();
|
|
841
|
+
const maybeLayout = this.hostPageLayout;
|
|
842
|
+
maybeLayout?.recompute?.();
|
|
843
|
+
}
|
|
844
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMReportLayoutPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
845
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: AXMReportLayoutPageComponent, isStandalone: true, selector: "axm-report-layout-page", inputs: { rootContext: { classPropertyName: "rootContext", publicName: "rootContext", isSignal: true, isRequired: false, transformFunction: null }, pageConfig: { classPropertyName: "pageConfig", publicName: "pageConfig", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "axp-page-layout-base block h-full min-h-0 overflow-auto" }, providers: [
|
|
846
|
+
{
|
|
847
|
+
provide: AXPPageLayoutBase,
|
|
848
|
+
useExisting: AXMReportLayoutPageComponent,
|
|
849
|
+
},
|
|
850
|
+
], usesInheritance: true, ngImport: i0, template: "@if (preset()) {\n <!-- ----- Editors for the selected static layout ----- -->\n @for (renderKey of [widgetRenderKey()]; track renderKey) {\n <!-- ----- The container has no box of its own, so this wrapper stacks the sections and keeps them content-high ----- -->\n <div class=\"flex flex-col gap-4 p-4 [&_axp-fieldset-widget-view]:h-auto [&_axp-form-field-widget-view]:h-auto\">\n @if (!canEdit() && accessResolved()) {\n <!-- ----- Notice for definitions the current tenant cannot change ----- -->\n <div class=\"text-sm opacity-70\">{{ readonlyNotice() }}</div>\n }\n <axp-widgets-container [context]=\"context()\" (onContextChanged)=\"onContextChanged($event)\">\n @for (node of fieldNodes(); track node.name) {\n <ng-container axp-widget-renderer [node]=\"node\" [mode]=\"canEdit() ? 'edit' : 'view'\"></ng-container>\n }\n </axp-widgets-container>\n </div>\n }\n}\n", dependencies: [{ kind: "ngmodule", type: AXPWidgetCoreModule }, { kind: "component", type: i1.AXPWidgetContainerComponent, selector: "axp-widgets-container", inputs: ["context", "functions"], outputs: ["onContextChanged"] }, { kind: "directive", type: i1.AXPWidgetRendererDirective, selector: "[axp-widget-renderer]", inputs: ["parentNode", "index", "mode", "node", "placeholder"], outputs: ["onOptionsChanged", "onValueChanged", "onLoad"], exportAs: ["widgetRenderer"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
851
|
+
}
|
|
852
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMReportLayoutPageComponent, decorators: [{
|
|
853
|
+
type: Component,
|
|
854
|
+
args: [{ selector: 'axm-report-layout-page', standalone: true, imports: [AXPWidgetCoreModule], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
855
|
+
{
|
|
856
|
+
provide: AXPPageLayoutBase,
|
|
857
|
+
useExisting: AXMReportLayoutPageComponent,
|
|
858
|
+
},
|
|
859
|
+
], host: {
|
|
860
|
+
class: 'axp-page-layout-base block h-full min-h-0 overflow-auto',
|
|
861
|
+
}, template: "@if (preset()) {\n <!-- ----- Editors for the selected static layout ----- -->\n @for (renderKey of [widgetRenderKey()]; track renderKey) {\n <!-- ----- The container has no box of its own, so this wrapper stacks the sections and keeps them content-high ----- -->\n <div class=\"flex flex-col gap-4 p-4 [&_axp-fieldset-widget-view]:h-auto [&_axp-form-field-widget-view]:h-auto\">\n @if (!canEdit() && accessResolved()) {\n <!-- ----- Notice for definitions the current tenant cannot change ----- -->\n <div class=\"text-sm opacity-70\">{{ readonlyNotice() }}</div>\n }\n <axp-widgets-container [context]=\"context()\" (onContextChanged)=\"onContextChanged($event)\">\n @for (node of fieldNodes(); track node.name) {\n <ng-container axp-widget-renderer [node]=\"node\" [mode]=\"canEdit() ? 'edit' : 'view'\"></ng-container>\n }\n </axp-widgets-container>\n </div>\n }\n}\n" }]
|
|
862
|
+
}], ctorParameters: () => [], propDecorators: { rootContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "rootContext", required: false }] }], pageConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageConfig", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
863
|
+
function pickSections(value, fallback) {
|
|
864
|
+
return value != null && typeof value === 'object' && !Array.isArray(value) ? value : fallback;
|
|
865
|
+
}
|
|
866
|
+
function queryNameFromLayouts(layouts) {
|
|
867
|
+
for (const layout of layouts) {
|
|
868
|
+
if (layout.dataSource?.type === 'query' && layout.dataSource.name.trim()) {
|
|
869
|
+
return layout.dataSource.name.trim();
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return '';
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export { AXMReportLayoutPageComponent };
|
|
876
|
+
//# sourceMappingURL=acorex-platform-module-report-management-client-report-layout-page.component-DFmdGIY9.mjs.map
|