@acorex/modules 20.3.0-next.19 → 20.3.0-next.20
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/common/index.d.ts +11 -2
- package/fesm2022/acorex-modules-common.mjs +913 -5
- package/fesm2022/acorex-modules-common.mjs.map +1 -1
- package/fesm2022/acorex-modules-content-management.mjs +4 -4
- package/fesm2022/acorex-modules-content-management.mjs.map +1 -1
- package/fesm2022/acorex-modules-data-management.mjs +0 -1
- package/fesm2022/acorex-modules-data-management.mjs.map +1 -1
- package/fesm2022/{acorex-modules-human-capital-management-acorex-modules-human-capital-management-D39vzY_d.mjs → acorex-modules-human-capital-management-acorex-modules-human-capital-management-BwmZR-qY.mjs} +9 -9
- package/fesm2022/{acorex-modules-human-capital-management-acorex-modules-human-capital-management-D39vzY_d.mjs.map → acorex-modules-human-capital-management-acorex-modules-human-capital-management-BwmZR-qY.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-human-capital-management-employee-skill.entity-Dd6cSked.mjs → acorex-modules-human-capital-management-employee-skill.entity-tBHFvJSk.mjs} +2 -2
- package/fesm2022/{acorex-modules-human-capital-management-employee-skill.entity-Dd6cSked.mjs.map → acorex-modules-human-capital-management-employee-skill.entity-tBHFvJSk.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-human-capital-management-employee.entity-BtenRYTI.mjs → acorex-modules-human-capital-management-employee.entity-ycy1OPim.mjs} +3 -3
- package/fesm2022/acorex-modules-human-capital-management-employee.entity-ycy1OPim.mjs.map +1 -0
- package/fesm2022/{acorex-modules-human-capital-management-employment-type.entity-D_jB5gh2.mjs → acorex-modules-human-capital-management-employment-type.entity-vBzJD4oD.mjs} +2 -2
- package/fesm2022/{acorex-modules-human-capital-management-employment-type.entity-D_jB5gh2.mjs.map → acorex-modules-human-capital-management-employment-type.entity-vBzJD4oD.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-human-capital-management-leave-request.entity-iX5YQBQy.mjs → acorex-modules-human-capital-management-leave-request.entity-iVWdJM_r.mjs} +2 -2
- package/fesm2022/{acorex-modules-human-capital-management-leave-request.entity-iX5YQBQy.mjs.map → acorex-modules-human-capital-management-leave-request.entity-iVWdJM_r.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-human-capital-management-leave-type.entity-BRPpSgMR.mjs → acorex-modules-human-capital-management-leave-type.entity-C_f9HA6B.mjs} +2 -2
- package/fesm2022/{acorex-modules-human-capital-management-leave-type.entity-BRPpSgMR.mjs.map → acorex-modules-human-capital-management-leave-type.entity-C_f9HA6B.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-human-capital-management-position-assignment.entity-Bl5GznJG.mjs → acorex-modules-human-capital-management-position-assignment.entity-CQLcD6LO.mjs} +2 -2
- package/fesm2022/{acorex-modules-human-capital-management-position-assignment.entity-Bl5GznJG.mjs.map → acorex-modules-human-capital-management-position-assignment.entity-CQLcD6LO.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-human-capital-management-skill-level.entity-C2JSzWDw.mjs → acorex-modules-human-capital-management-skill-level.entity-CoBQ9Jbt.mjs} +2 -2
- package/fesm2022/{acorex-modules-human-capital-management-skill-level.entity-C2JSzWDw.mjs.map → acorex-modules-human-capital-management-skill-level.entity-CoBQ9Jbt.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-human-capital-management-skill.entity-hW9jC2GU.mjs → acorex-modules-human-capital-management-skill.entity-BhKcpZiD.mjs} +2 -2
- package/fesm2022/{acorex-modules-human-capital-management-skill.entity-hW9jC2GU.mjs.map → acorex-modules-human-capital-management-skill.entity-BhKcpZiD.mjs.map} +1 -1
- package/fesm2022/acorex-modules-human-capital-management.mjs +1 -1
- package/fesm2022/acorex-modules-locale-management.mjs +12 -87
- package/fesm2022/acorex-modules-locale-management.mjs.map +1 -1
- package/fesm2022/acorex-modules-location-management.mjs +7 -109
- package/fesm2022/acorex-modules-location-management.mjs.map +1 -1
- package/fesm2022/acorex-modules-report-management.mjs +78 -50
- package/fesm2022/acorex-modules-report-management.mjs.map +1 -1
- package/fesm2022/acorex-modules-task-management.mjs +12 -187
- package/fesm2022/acorex-modules-task-management.mjs.map +1 -1
- package/fesm2022/acorex-modules-training-management.mjs +7 -0
- package/fesm2022/acorex-modules-training-management.mjs.map +1 -1
- package/fesm2022/acorex-modules-workflow-management-overview.command-BY_DtTDo.mjs +31 -0
- package/fesm2022/acorex-modules-workflow-management-overview.command-BY_DtTDo.mjs.map +1 -0
- package/fesm2022/acorex-modules-workflow-management.mjs +257 -81
- package/fesm2022/acorex-modules-workflow-management.mjs.map +1 -1
- package/package.json +6 -6
- package/report-management/index.d.ts +4 -4
- package/workflow-management/index.d.ts +1 -1
- package/fesm2022/acorex-modules-human-capital-management-employee.entity-BtenRYTI.mjs.map +0 -1
|
@@ -699,9 +699,10 @@ class AXPEntityBulkArchiveAction extends AXPWorkflowAction {
|
|
|
699
699
|
}
|
|
700
700
|
async execute(context) {
|
|
701
701
|
const refType = context.getVariable('options.refType');
|
|
702
|
-
const
|
|
702
|
+
const data = context.getVariable('data');
|
|
703
|
+
const selectedIds = Array.isArray(data) ? data.map((c) => c.id) : data ? [data.id] : [];
|
|
703
704
|
if (!refType || selectedIds.length === 0) {
|
|
704
|
-
throw new Error('Missing required parameters: refType and
|
|
705
|
+
throw new Error('Missing required parameters: refType and data');
|
|
705
706
|
}
|
|
706
707
|
const [moduleName, entityName] = refType.split('.');
|
|
707
708
|
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
@@ -859,9 +860,10 @@ class AXPEntityBulkUnarchiveAction extends AXPWorkflowAction {
|
|
|
859
860
|
}
|
|
860
861
|
async execute(context) {
|
|
861
862
|
const refType = context.getVariable('options.refType');
|
|
862
|
-
const
|
|
863
|
+
const data = context.getVariable('data');
|
|
864
|
+
const selectedIds = Array.isArray(data) ? data.map((c) => c.id) : data ? [data.id] : [];
|
|
863
865
|
if (!refType || selectedIds.length === 0) {
|
|
864
|
-
throw new Error('Missing required parameters: refType and
|
|
866
|
+
throw new Error('Missing required parameters: refType and data');
|
|
865
867
|
}
|
|
866
868
|
const [moduleName, entityName] = refType.split('.');
|
|
867
869
|
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
@@ -1680,6 +1682,909 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
1680
1682
|
}]
|
|
1681
1683
|
}] });
|
|
1682
1684
|
|
|
1685
|
+
const disablePlugin = {
|
|
1686
|
+
name: 'disable',
|
|
1687
|
+
order: 70,
|
|
1688
|
+
apply: (ctx) => {
|
|
1689
|
+
ensureListActions(ctx);
|
|
1690
|
+
//#region ---- Add isDisabled Property ----
|
|
1691
|
+
// Ensure settings group exists
|
|
1692
|
+
const groupId = 'settings';
|
|
1693
|
+
const groups = ctx.groups.list() ?? [];
|
|
1694
|
+
if (!groups.some((g) => g.id === groupId)) {
|
|
1695
|
+
ctx.groups.add({ id: groupId, title: '@general:terms.interface.settings' });
|
|
1696
|
+
}
|
|
1697
|
+
// Add isDisabled property if it doesn't exist
|
|
1698
|
+
const props = ctx.properties.list();
|
|
1699
|
+
if (!props.some((p) => p.name === 'isDisabled')) {
|
|
1700
|
+
ctx.properties.add({
|
|
1701
|
+
name: 'isDisabled',
|
|
1702
|
+
title: '@general:terms.status.states.is-disabled',
|
|
1703
|
+
groupId,
|
|
1704
|
+
schema: {
|
|
1705
|
+
dataType: 'boolean',
|
|
1706
|
+
interface: {
|
|
1707
|
+
type: AXPWidgetsList.Editors.ToggleSwitch,
|
|
1708
|
+
options: {
|
|
1709
|
+
// Default to false (not disabled)
|
|
1710
|
+
defaultValue: false,
|
|
1711
|
+
// trulyText: '@general:terms.disabled',
|
|
1712
|
+
// falsyText: '@general:terms.enabled',
|
|
1713
|
+
negative: true,
|
|
1714
|
+
nullValue: false,
|
|
1715
|
+
},
|
|
1716
|
+
},
|
|
1717
|
+
},
|
|
1718
|
+
validations: [],
|
|
1719
|
+
options: {
|
|
1720
|
+
sort: { enabled: true },
|
|
1721
|
+
filter: {
|
|
1722
|
+
advance: { enabled: true },
|
|
1723
|
+
inline: { enabled: true }
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
// Add isDisabled to columns for list view
|
|
1729
|
+
const columns = ctx.columns.list() ?? [];
|
|
1730
|
+
if (!columns.some((c) => c.name === 'isDisabled')) {
|
|
1731
|
+
ctx.columns.add({
|
|
1732
|
+
name: 'isDisabled',
|
|
1733
|
+
title: '@general:terms.status.states.is-enabled',
|
|
1734
|
+
width: 100,
|
|
1735
|
+
sortable: true,
|
|
1736
|
+
filterable: true,
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
//#endregion
|
|
1740
|
+
//#region ---- Add Disable Actions ----
|
|
1741
|
+
ctx.interfaces.update((i) => {
|
|
1742
|
+
const disableCmdName = 'disable-entity';
|
|
1743
|
+
const enableCmdName = 'enable-entity';
|
|
1744
|
+
const bulkDisableCmdName = 'bulk-disable-entity';
|
|
1745
|
+
const bulkEnableCmdName = 'bulk-enable-entity';
|
|
1746
|
+
// Add disable action to list view
|
|
1747
|
+
const listActions = i.master.list.actions;
|
|
1748
|
+
if (!actionExists(listActions, disableCmdName)) {
|
|
1749
|
+
listActions.push({
|
|
1750
|
+
title: '@general:actions.disable.title',
|
|
1751
|
+
command: {
|
|
1752
|
+
name: disableCmdName,
|
|
1753
|
+
options: {
|
|
1754
|
+
refId: '{{ context.eval("id") }}',
|
|
1755
|
+
refType: `${ctx.entity.module}.${ctx.entity.name}`,
|
|
1756
|
+
},
|
|
1757
|
+
},
|
|
1758
|
+
priority: 'secondary',
|
|
1759
|
+
type: 'disable',
|
|
1760
|
+
icon: 'fa-light fa-ban',
|
|
1761
|
+
scope: AXPEntityCommandScope.Individual,
|
|
1762
|
+
hidden: `{{ context.eval("isDisabled") }}`,
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
// Add enable action to list view
|
|
1766
|
+
if (!actionExists(listActions, enableCmdName)) {
|
|
1767
|
+
listActions.push({
|
|
1768
|
+
title: '@general:actions.enable.title',
|
|
1769
|
+
command: {
|
|
1770
|
+
name: enableCmdName,
|
|
1771
|
+
options: {
|
|
1772
|
+
refId: '{{ context.eval("id") }}',
|
|
1773
|
+
refType: `${ctx.entity.module}.${ctx.entity.name}`,
|
|
1774
|
+
},
|
|
1775
|
+
},
|
|
1776
|
+
priority: 'secondary',
|
|
1777
|
+
type: 'enable',
|
|
1778
|
+
icon: 'fa-light fa-check',
|
|
1779
|
+
scope: AXPEntityCommandScope.Individual,
|
|
1780
|
+
hidden: `{{ !context.eval("isDisabled") }}`,
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
// Add bulk disable action to list view
|
|
1784
|
+
if (!actionExists(listActions, bulkDisableCmdName)) {
|
|
1785
|
+
listActions.push({
|
|
1786
|
+
title: '@general:actions.bulk-disable.title',
|
|
1787
|
+
command: {
|
|
1788
|
+
name: bulkDisableCmdName,
|
|
1789
|
+
options: {
|
|
1790
|
+
refType: `${ctx.entity.module}.${ctx.entity.name}`,
|
|
1791
|
+
},
|
|
1792
|
+
},
|
|
1793
|
+
priority: 'secondary',
|
|
1794
|
+
type: 'disable',
|
|
1795
|
+
icon: 'fa-light fa-ban',
|
|
1796
|
+
scope: AXPEntityCommandScope.Selected,
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
// Add bulk enable action to list view
|
|
1800
|
+
if (!actionExists(listActions, bulkEnableCmdName)) {
|
|
1801
|
+
listActions.push({
|
|
1802
|
+
title: '@general:actions.bulk-enable.title',
|
|
1803
|
+
command: {
|
|
1804
|
+
name: bulkEnableCmdName,
|
|
1805
|
+
options: {
|
|
1806
|
+
refType: `${ctx.entity.module}.${ctx.entity.name}`,
|
|
1807
|
+
},
|
|
1808
|
+
},
|
|
1809
|
+
priority: 'secondary',
|
|
1810
|
+
type: 'enable',
|
|
1811
|
+
icon: 'fa-light fa-check',
|
|
1812
|
+
scope: AXPEntityCommandScope.Selected,
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
// Add disable action to single view
|
|
1816
|
+
const singleActions = i.master?.single?.actions || [];
|
|
1817
|
+
if (!actionExists(singleActions, disableCmdName)) {
|
|
1818
|
+
singleActions.push({
|
|
1819
|
+
title: '@general:actions.disable.title',
|
|
1820
|
+
command: {
|
|
1821
|
+
name: disableCmdName,
|
|
1822
|
+
options: {
|
|
1823
|
+
refId: '{{ context.eval("id") }}',
|
|
1824
|
+
refType: `${ctx.entity.module}.${ctx.entity.name}`,
|
|
1825
|
+
},
|
|
1826
|
+
},
|
|
1827
|
+
priority: 'secondary',
|
|
1828
|
+
type: 'disable',
|
|
1829
|
+
icon: 'fa-light fa-ban',
|
|
1830
|
+
scope: AXPEntityCommandScope.Individual,
|
|
1831
|
+
hidden: `{{ context.eval("isDisabled") }}`,
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
// Add enable action to single view
|
|
1835
|
+
if (!actionExists(singleActions, enableCmdName)) {
|
|
1836
|
+
singleActions.push({
|
|
1837
|
+
title: '@general:actions.enable.title',
|
|
1838
|
+
command: {
|
|
1839
|
+
name: enableCmdName,
|
|
1840
|
+
options: {
|
|
1841
|
+
refId: '{{ context.eval("id") }}',
|
|
1842
|
+
refType: `${ctx.entity.module}.${ctx.entity.name}`,
|
|
1843
|
+
},
|
|
1844
|
+
},
|
|
1845
|
+
priority: 'secondary',
|
|
1846
|
+
type: 'enable',
|
|
1847
|
+
icon: 'fa-light fa-check',
|
|
1848
|
+
scope: AXPEntityCommandScope.Individual,
|
|
1849
|
+
hidden: `{{ !context.eval("isDisabled") }}`,
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
return i;
|
|
1853
|
+
});
|
|
1854
|
+
//#endregion
|
|
1855
|
+
//#region ---- Update Interface Layouts ----
|
|
1856
|
+
// Ensure update view includes isDisabled
|
|
1857
|
+
ctx.interfaces.master.modify.update((update) => {
|
|
1858
|
+
const next = update ?? { sections: [], properties: [] };
|
|
1859
|
+
next.sections = next.sections ?? [];
|
|
1860
|
+
if (!next.sections.some((s) => s.id === groupId)) {
|
|
1861
|
+
next.sections.push({ id: groupId });
|
|
1862
|
+
}
|
|
1863
|
+
next.properties = next.properties ?? [];
|
|
1864
|
+
if (!next.properties.some((p) => p.name === 'isDisabled')) {
|
|
1865
|
+
next.properties.push({
|
|
1866
|
+
name: 'isDisabled',
|
|
1867
|
+
layout: {
|
|
1868
|
+
positions: { lg: { colSpan: 6, order: 95 } },
|
|
1869
|
+
},
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
return next;
|
|
1873
|
+
});
|
|
1874
|
+
// Ensure single view includes isDisabled
|
|
1875
|
+
ctx.interfaces.master.single.update((single) => {
|
|
1876
|
+
const next = single ?? { title: ctx.entity.title, sections: [], properties: [] };
|
|
1877
|
+
next.sections = next.sections ?? [];
|
|
1878
|
+
if (!next.sections.some((s) => s.id === groupId)) {
|
|
1879
|
+
next.sections.push({ id: groupId, order: 150 });
|
|
1880
|
+
}
|
|
1881
|
+
next.properties = next.properties ?? [];
|
|
1882
|
+
if (!next.properties.some((p) => p.name === 'isDisabled')) {
|
|
1883
|
+
next.properties.push({
|
|
1884
|
+
name: 'isDisabled',
|
|
1885
|
+
layout: {
|
|
1886
|
+
positions: { lg: { colSpan: 6, order: 95 } },
|
|
1887
|
+
},
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
return next;
|
|
1891
|
+
});
|
|
1892
|
+
// Add disabled view to show only disabled items
|
|
1893
|
+
ctx.interfaces.master.list.update((list) => {
|
|
1894
|
+
const next = list ?? { actions: [], views: [] };
|
|
1895
|
+
next.views = next.views ?? [];
|
|
1896
|
+
// Check if disabled view already exists
|
|
1897
|
+
if (!next.views.some((v) => v.name === 'disabled')) {
|
|
1898
|
+
next.views.push(createQueryView('disabled', '@general:terms.status.states.is-disabled', false, {
|
|
1899
|
+
conditions: [
|
|
1900
|
+
{
|
|
1901
|
+
name: 'isDisabled',
|
|
1902
|
+
operator: { type: 'equal' },
|
|
1903
|
+
value: true,
|
|
1904
|
+
hidden: true
|
|
1905
|
+
},
|
|
1906
|
+
],
|
|
1907
|
+
sorts: [
|
|
1908
|
+
{ name: 'disabledAt', dir: 'desc' },
|
|
1909
|
+
{ name: 'title', dir: 'asc' },
|
|
1910
|
+
],
|
|
1911
|
+
}));
|
|
1912
|
+
}
|
|
1913
|
+
return next;
|
|
1914
|
+
});
|
|
1915
|
+
//#endregion
|
|
1916
|
+
},
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1919
|
+
const AXPEntityDisabledEvent = createWorkFlowEvent('[Entity] Disabled');
|
|
1920
|
+
class AXPEntityDisableAction extends AXPWorkflowAction {
|
|
1921
|
+
constructor() {
|
|
1922
|
+
super(...arguments);
|
|
1923
|
+
this.entityRegistery = inject(AXPEntityDefinitionRegistryService);
|
|
1924
|
+
this.dialogService = inject(AXDialogService);
|
|
1925
|
+
this.loadingDialog = inject(AXLoadingDialogService);
|
|
1926
|
+
this.translationService = inject(AXTranslationService);
|
|
1927
|
+
}
|
|
1928
|
+
async execute(context) {
|
|
1929
|
+
const refId = context.getVariable('options.refId');
|
|
1930
|
+
const refType = context.getVariable('options.refType');
|
|
1931
|
+
if (!refId || !refType) {
|
|
1932
|
+
throw new Error('Missing required parameters: refId and refType');
|
|
1933
|
+
}
|
|
1934
|
+
const [moduleName, entityName] = refType.split('.');
|
|
1935
|
+
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
1936
|
+
// Show confirmation dialog
|
|
1937
|
+
const dialogResult = await this.dialogService.confirm(await this.translationService.translateAsync('@general:actions.disable.confirm.title'), await this.translationService.translateAsync('@general:actions.disable.confirm.message'), 'warning', 'horizontal', false, 'cancel');
|
|
1938
|
+
if (!dialogResult.result) {
|
|
1939
|
+
context.setOutput('isCanceled', true);
|
|
1940
|
+
context.setOutput('error', 'Operation cancelled by user');
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
// Show loading dialog
|
|
1944
|
+
const loadingDialog = this.loadingDialog.show({
|
|
1945
|
+
title: await this.translationService.translateAsync('@general:actions.disable.confirm.processing'),
|
|
1946
|
+
mode: 'indeterminate',
|
|
1947
|
+
status: 'Disabling...',
|
|
1948
|
+
});
|
|
1949
|
+
try {
|
|
1950
|
+
// Get the current entity data
|
|
1951
|
+
const currentData = await this.getEntityData(refType, refId);
|
|
1952
|
+
// Prepare disable data
|
|
1953
|
+
const disableData = this.prepareDisableData(currentData);
|
|
1954
|
+
// Update the entity to mark it as disabled
|
|
1955
|
+
if (entityDefinition.commands?.update) {
|
|
1956
|
+
const updateExec = entityDefinition.commands.update.execute;
|
|
1957
|
+
await updateExec(disableData);
|
|
1958
|
+
context.setOutput('id', refId);
|
|
1959
|
+
context.setOutput('isCanceled', false);
|
|
1960
|
+
// Set refresh metadata
|
|
1961
|
+
if (entityDefinition.parentKey && currentData[entityDefinition.parentKey]) {
|
|
1962
|
+
context.setVariable('meta', { refreshTargetId: currentData[entityDefinition.parentKey] });
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
else {
|
|
1966
|
+
throw new Error('Entity does not support update operation');
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
catch (error) {
|
|
1970
|
+
console.error('Disable operation failed:', error);
|
|
1971
|
+
context.setOutput('error', error instanceof Error ? error.message : 'Unknown error');
|
|
1972
|
+
context.setOutput('isCanceled', true);
|
|
1973
|
+
}
|
|
1974
|
+
finally {
|
|
1975
|
+
loadingDialog.close();
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
async getEntityData(refType, refId) {
|
|
1979
|
+
try {
|
|
1980
|
+
// Use the entity's byKey query to get actual data
|
|
1981
|
+
const [moduleName, entityName] = refType.split('.');
|
|
1982
|
+
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
1983
|
+
if (entityDefinition.queries?.byKey) {
|
|
1984
|
+
const queryExec = entityDefinition.queries.byKey.execute;
|
|
1985
|
+
return await queryExec(refId);
|
|
1986
|
+
}
|
|
1987
|
+
// Fallback to basic structure if no query available
|
|
1988
|
+
return { id: refId };
|
|
1989
|
+
}
|
|
1990
|
+
catch (error) {
|
|
1991
|
+
console.error('Failed to retrieve entity data:', error);
|
|
1992
|
+
throw new Error(`Failed to retrieve entity data: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
prepareDisableData(currentData) {
|
|
1996
|
+
const disableData = { ...currentData };
|
|
1997
|
+
// Set the disabled flag
|
|
1998
|
+
disableData.isDisabled = true;
|
|
1999
|
+
// Optionally add disable timestamp
|
|
2000
|
+
disableData.disabledAt = new Date();
|
|
2001
|
+
return disableData;
|
|
2002
|
+
}
|
|
2003
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityDisableAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2004
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityDisableAction }); }
|
|
2005
|
+
}
|
|
2006
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityDisableAction, decorators: [{
|
|
2007
|
+
type: Injectable
|
|
2008
|
+
}] });
|
|
2009
|
+
class AXPEntityDisableSuccessAction extends AXPWorkflowAction {
|
|
2010
|
+
async execute(context) {
|
|
2011
|
+
const refType = context.getVariable('options.refType');
|
|
2012
|
+
const id = context.getOutput('id');
|
|
2013
|
+
const meta = context.getVariable('meta');
|
|
2014
|
+
// Dispatch disable event
|
|
2015
|
+
this.dispatch(AXPEntityDisabledEvent({
|
|
2016
|
+
entity: refType,
|
|
2017
|
+
id,
|
|
2018
|
+
meta
|
|
2019
|
+
}));
|
|
2020
|
+
// Refresh the entity list
|
|
2021
|
+
this.dispatch(AXPRefreshEvent({
|
|
2022
|
+
entity: refType,
|
|
2023
|
+
meta
|
|
2024
|
+
}));
|
|
2025
|
+
}
|
|
2026
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityDisableSuccessAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2027
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityDisableSuccessAction }); }
|
|
2028
|
+
}
|
|
2029
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityDisableSuccessAction, decorators: [{
|
|
2030
|
+
type: Injectable
|
|
2031
|
+
}] });
|
|
2032
|
+
const AXPDisableEntityWorkflow = {
|
|
2033
|
+
startStepId: 'disable-entity',
|
|
2034
|
+
steps: {
|
|
2035
|
+
'disable-entity': {
|
|
2036
|
+
action: 'AXPEntityDisableAction',
|
|
2037
|
+
nextSteps: [
|
|
2038
|
+
{
|
|
2039
|
+
conditions: [{ type: 'SINGLE', expression: 'context.getOutput("isCanceled") == false' }],
|
|
2040
|
+
nextStepId: 'show-success-toast',
|
|
2041
|
+
},
|
|
2042
|
+
],
|
|
2043
|
+
},
|
|
2044
|
+
'show-success-toast': {
|
|
2045
|
+
action: 'AXPToastAction',
|
|
2046
|
+
input: {
|
|
2047
|
+
color: 'success',
|
|
2048
|
+
title: 'workflow.entity-disabled',
|
|
2049
|
+
content: 'workflow.entity-disabled-body',
|
|
2050
|
+
},
|
|
2051
|
+
nextSteps: [
|
|
2052
|
+
{
|
|
2053
|
+
conditions: [],
|
|
2054
|
+
nextStepId: 'disable-success',
|
|
2055
|
+
},
|
|
2056
|
+
],
|
|
2057
|
+
},
|
|
2058
|
+
'disable-success': {
|
|
2059
|
+
action: 'AXPEntityDisableSuccessAction',
|
|
2060
|
+
},
|
|
2061
|
+
},
|
|
2062
|
+
};
|
|
2063
|
+
|
|
2064
|
+
const AXPEntityEnabledEvent = createWorkFlowEvent('[Entity] Enabled');
|
|
2065
|
+
class AXPEntityEnableAction extends AXPWorkflowAction {
|
|
2066
|
+
constructor() {
|
|
2067
|
+
super(...arguments);
|
|
2068
|
+
this.entityRegistery = inject(AXPEntityDefinitionRegistryService);
|
|
2069
|
+
this.dialogService = inject(AXDialogService);
|
|
2070
|
+
this.loadingDialog = inject(AXLoadingDialogService);
|
|
2071
|
+
this.translationService = inject(AXTranslationService);
|
|
2072
|
+
}
|
|
2073
|
+
async execute(context) {
|
|
2074
|
+
const refId = context.getVariable('options.refId');
|
|
2075
|
+
const refType = context.getVariable('options.refType');
|
|
2076
|
+
if (!refId || !refType) {
|
|
2077
|
+
throw new Error('Missing required parameters: refId and refType');
|
|
2078
|
+
}
|
|
2079
|
+
const [moduleName, entityName] = refType.split('.');
|
|
2080
|
+
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
2081
|
+
// Show confirmation dialog
|
|
2082
|
+
const dialogResult = await this.dialogService.confirm(await this.translationService.translateAsync('@general:actions.enable.confirm.title'), await this.translationService.translateAsync('@general:actions.enable.confirm.message'), 'success', 'horizontal', false, 'cancel');
|
|
2083
|
+
if (!dialogResult.result) {
|
|
2084
|
+
context.setOutput('isCanceled', true);
|
|
2085
|
+
context.setOutput('error', 'Operation cancelled by user');
|
|
2086
|
+
return;
|
|
2087
|
+
}
|
|
2088
|
+
// Show loading dialog
|
|
2089
|
+
const loadingDialog = this.loadingDialog.show({
|
|
2090
|
+
title: await this.translationService.translateAsync('@general:actions.enable.confirm.processing'),
|
|
2091
|
+
mode: 'indeterminate',
|
|
2092
|
+
status: 'Enabling...',
|
|
2093
|
+
});
|
|
2094
|
+
try {
|
|
2095
|
+
// Get the current entity data
|
|
2096
|
+
const currentData = await this.getEntityData(refType, refId);
|
|
2097
|
+
// Prepare enable data
|
|
2098
|
+
const enableData = this.prepareEnableData(currentData);
|
|
2099
|
+
// Update the entity to mark it as enabled
|
|
2100
|
+
if (entityDefinition.commands?.update) {
|
|
2101
|
+
const updateExec = entityDefinition.commands.update.execute;
|
|
2102
|
+
await updateExec(enableData);
|
|
2103
|
+
context.setOutput('id', refId);
|
|
2104
|
+
context.setOutput('isCanceled', false);
|
|
2105
|
+
// Set refresh metadata
|
|
2106
|
+
if (entityDefinition.parentKey && currentData[entityDefinition.parentKey]) {
|
|
2107
|
+
context.setVariable('meta', { refreshTargetId: currentData[entityDefinition.parentKey] });
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
else {
|
|
2111
|
+
throw new Error('Entity does not support update operation');
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
catch (error) {
|
|
2115
|
+
console.error('Enable operation failed:', error);
|
|
2116
|
+
context.setOutput('error', error instanceof Error ? error.message : 'Unknown error');
|
|
2117
|
+
context.setOutput('isCanceled', true);
|
|
2118
|
+
}
|
|
2119
|
+
finally {
|
|
2120
|
+
loadingDialog.close();
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
async getEntityData(refType, refId) {
|
|
2124
|
+
try {
|
|
2125
|
+
// Use the entity's byKey query to get actual data
|
|
2126
|
+
const [moduleName, entityName] = refType.split('.');
|
|
2127
|
+
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
2128
|
+
if (entityDefinition.queries?.byKey) {
|
|
2129
|
+
const queryExec = entityDefinition.queries.byKey.execute;
|
|
2130
|
+
return await queryExec(refId);
|
|
2131
|
+
}
|
|
2132
|
+
// Fallback to basic structure if no query available
|
|
2133
|
+
return { id: refId };
|
|
2134
|
+
}
|
|
2135
|
+
catch (error) {
|
|
2136
|
+
console.error('Failed to retrieve entity data:', error);
|
|
2137
|
+
throw new Error(`Failed to retrieve entity data: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
prepareEnableData(currentData) {
|
|
2141
|
+
const enableData = { ...currentData };
|
|
2142
|
+
// Set the disabled flag to false
|
|
2143
|
+
enableData.isDisabled = false;
|
|
2144
|
+
// Optionally add enable timestamp
|
|
2145
|
+
enableData.enabledAt = new Date();
|
|
2146
|
+
return enableData;
|
|
2147
|
+
}
|
|
2148
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityEnableAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2149
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityEnableAction }); }
|
|
2150
|
+
}
|
|
2151
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityEnableAction, decorators: [{
|
|
2152
|
+
type: Injectable
|
|
2153
|
+
}] });
|
|
2154
|
+
class AXPEntityEnableSuccessAction extends AXPWorkflowAction {
|
|
2155
|
+
async execute(context) {
|
|
2156
|
+
const refType = context.getVariable('options.refType');
|
|
2157
|
+
const id = context.getOutput('id');
|
|
2158
|
+
const meta = context.getVariable('meta');
|
|
2159
|
+
// Dispatch enable event
|
|
2160
|
+
this.dispatch(AXPEntityEnabledEvent({
|
|
2161
|
+
entity: refType,
|
|
2162
|
+
id,
|
|
2163
|
+
meta
|
|
2164
|
+
}));
|
|
2165
|
+
// Refresh the entity list
|
|
2166
|
+
this.dispatch(AXPRefreshEvent({
|
|
2167
|
+
entity: refType,
|
|
2168
|
+
meta
|
|
2169
|
+
}));
|
|
2170
|
+
}
|
|
2171
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityEnableSuccessAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2172
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityEnableSuccessAction }); }
|
|
2173
|
+
}
|
|
2174
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityEnableSuccessAction, decorators: [{
|
|
2175
|
+
type: Injectable
|
|
2176
|
+
}] });
|
|
2177
|
+
const AXPEnableEntityWorkflow = {
|
|
2178
|
+
startStepId: 'enable-entity',
|
|
2179
|
+
steps: {
|
|
2180
|
+
'enable-entity': {
|
|
2181
|
+
action: 'AXPEntityEnableAction',
|
|
2182
|
+
nextSteps: [
|
|
2183
|
+
{
|
|
2184
|
+
conditions: [{ type: 'SINGLE', expression: 'context.getOutput("isCanceled") == false' }],
|
|
2185
|
+
nextStepId: 'show-success-toast',
|
|
2186
|
+
},
|
|
2187
|
+
],
|
|
2188
|
+
},
|
|
2189
|
+
'show-success-toast': {
|
|
2190
|
+
action: 'AXPToastAction',
|
|
2191
|
+
input: {
|
|
2192
|
+
color: 'success',
|
|
2193
|
+
title: 'workflow.entity-enabled',
|
|
2194
|
+
content: 'workflow.entity-enabled-body',
|
|
2195
|
+
},
|
|
2196
|
+
nextSteps: [
|
|
2197
|
+
{
|
|
2198
|
+
conditions: [],
|
|
2199
|
+
nextStepId: 'enable-success',
|
|
2200
|
+
},
|
|
2201
|
+
],
|
|
2202
|
+
},
|
|
2203
|
+
'enable-success': {
|
|
2204
|
+
action: 'AXPEntityEnableSuccessAction',
|
|
2205
|
+
},
|
|
2206
|
+
},
|
|
2207
|
+
};
|
|
2208
|
+
|
|
2209
|
+
const AXPEntityBulkDisabledEvent = createWorkFlowEvent('[Entity] Bulk Disabled');
|
|
2210
|
+
class AXPEntityBulkDisableAction extends AXPWorkflowAction {
|
|
2211
|
+
constructor() {
|
|
2212
|
+
super(...arguments);
|
|
2213
|
+
this.entityRegistery = inject(AXPEntityDefinitionRegistryService);
|
|
2214
|
+
this.dialogService = inject(AXDialogService);
|
|
2215
|
+
this.loadingDialog = inject(AXLoadingDialogService);
|
|
2216
|
+
this.translationService = inject(AXTranslationService);
|
|
2217
|
+
}
|
|
2218
|
+
async execute(context) {
|
|
2219
|
+
const refType = context.getVariable('options.refType');
|
|
2220
|
+
const data = context.getVariable('data');
|
|
2221
|
+
const selectedIds = Array.isArray(data) ? data.map((c) => c.id) : data ? [data.id] : [];
|
|
2222
|
+
if (!refType || selectedIds.length === 0) {
|
|
2223
|
+
throw new Error('Missing required parameters: refType and data');
|
|
2224
|
+
}
|
|
2225
|
+
const [moduleName, entityName] = refType.split('.');
|
|
2226
|
+
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
2227
|
+
// Show confirmation dialog
|
|
2228
|
+
const dialogResult = await this.dialogService.confirm(await this.translationService.translateAsync('@general:actions.bulk-disable.confirm.title'), await this.translationService.translateAsync('@general:actions.bulk-disable.confirm.message', {
|
|
2229
|
+
params: { count: selectedIds.length }
|
|
2230
|
+
}), 'warning', 'horizontal', false, 'cancel');
|
|
2231
|
+
if (!dialogResult.result) {
|
|
2232
|
+
context.setOutput('isCanceled', true);
|
|
2233
|
+
context.setOutput('error', 'Operation cancelled by user');
|
|
2234
|
+
return;
|
|
2235
|
+
}
|
|
2236
|
+
// Show loading dialog
|
|
2237
|
+
const loadingDialog = this.loadingDialog.show({
|
|
2238
|
+
title: await this.translationService.translateAsync('@general:actions.bulk-disable.confirm.processing'),
|
|
2239
|
+
mode: 'indeterminate',
|
|
2240
|
+
status: 'Disabling items...',
|
|
2241
|
+
});
|
|
2242
|
+
try {
|
|
2243
|
+
const results = [];
|
|
2244
|
+
const errors = [];
|
|
2245
|
+
// Process each selected item
|
|
2246
|
+
for (const refId of selectedIds) {
|
|
2247
|
+
try {
|
|
2248
|
+
// Get the current entity data
|
|
2249
|
+
const currentData = await this.getEntityData(refType, refId);
|
|
2250
|
+
// Prepare disable data
|
|
2251
|
+
const disableData = this.prepareDisableData(currentData);
|
|
2252
|
+
// Update the entity to mark it as disabled
|
|
2253
|
+
if (entityDefinition.commands?.update) {
|
|
2254
|
+
const updateExec = entityDefinition.commands.update.execute;
|
|
2255
|
+
await updateExec(disableData);
|
|
2256
|
+
results.push(refId);
|
|
2257
|
+
}
|
|
2258
|
+
else {
|
|
2259
|
+
throw new Error('Entity does not support update operation');
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
catch (error) {
|
|
2263
|
+
console.error(`Failed to disable entity ${refId}:`, error);
|
|
2264
|
+
errors.push({ id: refId, error: error instanceof Error ? error.message : 'Unknown error' });
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
context.setOutput('processedIds', results);
|
|
2268
|
+
context.setOutput('errors', errors);
|
|
2269
|
+
context.setOutput('isCanceled', false);
|
|
2270
|
+
}
|
|
2271
|
+
catch (error) {
|
|
2272
|
+
console.error('Bulk disable operation failed:', error);
|
|
2273
|
+
context.setOutput('error', error instanceof Error ? error.message : 'Unknown error');
|
|
2274
|
+
context.setOutput('isCanceled', true);
|
|
2275
|
+
}
|
|
2276
|
+
finally {
|
|
2277
|
+
loadingDialog.close();
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
async getEntityData(refType, refId) {
|
|
2281
|
+
try {
|
|
2282
|
+
// Use the entity's byKey query to get actual data
|
|
2283
|
+
const [moduleName, entityName] = refType.split('.');
|
|
2284
|
+
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
2285
|
+
if (entityDefinition.queries?.byKey) {
|
|
2286
|
+
const queryExec = entityDefinition.queries.byKey.execute;
|
|
2287
|
+
return await queryExec(refId);
|
|
2288
|
+
}
|
|
2289
|
+
// Fallback to basic structure if no query available
|
|
2290
|
+
return { id: refId };
|
|
2291
|
+
}
|
|
2292
|
+
catch (error) {
|
|
2293
|
+
console.error('Failed to retrieve entity data:', error);
|
|
2294
|
+
throw new Error(`Failed to retrieve entity data: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
prepareDisableData(currentData) {
|
|
2298
|
+
const disableData = { ...currentData };
|
|
2299
|
+
// Set the disabled flag
|
|
2300
|
+
disableData.isDisabled = true;
|
|
2301
|
+
// Optionally add disable timestamp
|
|
2302
|
+
disableData.disabledAt = new Date();
|
|
2303
|
+
return disableData;
|
|
2304
|
+
}
|
|
2305
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkDisableAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2306
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkDisableAction }); }
|
|
2307
|
+
}
|
|
2308
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkDisableAction, decorators: [{
|
|
2309
|
+
type: Injectable
|
|
2310
|
+
}] });
|
|
2311
|
+
class AXPEntityBulkDisableSuccessAction extends AXPWorkflowAction {
|
|
2312
|
+
async execute(context) {
|
|
2313
|
+
const refType = context.getVariable('options.refType');
|
|
2314
|
+
const processedIds = context.getOutput('processedIds') || [];
|
|
2315
|
+
const errors = context.getOutput('errors') || [];
|
|
2316
|
+
const meta = context.getVariable('meta');
|
|
2317
|
+
// Dispatch bulk disable event
|
|
2318
|
+
this.dispatch(AXPEntityBulkDisabledEvent({
|
|
2319
|
+
entity: refType,
|
|
2320
|
+
ids: processedIds,
|
|
2321
|
+
meta
|
|
2322
|
+
}));
|
|
2323
|
+
// Refresh the entity list
|
|
2324
|
+
this.dispatch(AXPRefreshEvent({
|
|
2325
|
+
entity: refType,
|
|
2326
|
+
meta
|
|
2327
|
+
}));
|
|
2328
|
+
// Show error summary if there were any errors
|
|
2329
|
+
if (errors.length > 0) {
|
|
2330
|
+
const errorMessage = errors.map(e => `${e.id}: ${e.error}`).join('\n');
|
|
2331
|
+
console.warn('Some items failed to disable:', errorMessage);
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkDisableSuccessAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2335
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkDisableSuccessAction }); }
|
|
2336
|
+
}
|
|
2337
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkDisableSuccessAction, decorators: [{
|
|
2338
|
+
type: Injectable
|
|
2339
|
+
}] });
|
|
2340
|
+
const AXPBulkDisableEntityWorkflow = {
|
|
2341
|
+
startStepId: 'bulk-disable-entity',
|
|
2342
|
+
steps: {
|
|
2343
|
+
'bulk-disable-entity': {
|
|
2344
|
+
action: 'AXPEntityBulkDisableAction',
|
|
2345
|
+
nextSteps: [
|
|
2346
|
+
{
|
|
2347
|
+
conditions: [{ type: 'SINGLE', expression: 'context.getOutput("isCanceled") == false' }],
|
|
2348
|
+
nextStepId: 'show-success-toast',
|
|
2349
|
+
},
|
|
2350
|
+
],
|
|
2351
|
+
},
|
|
2352
|
+
'show-success-toast': {
|
|
2353
|
+
action: 'AXPToastAction',
|
|
2354
|
+
input: {
|
|
2355
|
+
color: 'success',
|
|
2356
|
+
title: 'workflow.entity-bulk-disabled',
|
|
2357
|
+
content: 'workflow.entity-bulk-disabled-body',
|
|
2358
|
+
},
|
|
2359
|
+
nextSteps: [
|
|
2360
|
+
{
|
|
2361
|
+
conditions: [],
|
|
2362
|
+
nextStepId: 'bulk-disable-success',
|
|
2363
|
+
},
|
|
2364
|
+
],
|
|
2365
|
+
},
|
|
2366
|
+
'bulk-disable-success': {
|
|
2367
|
+
action: 'AXPEntityBulkDisableSuccessAction',
|
|
2368
|
+
},
|
|
2369
|
+
},
|
|
2370
|
+
};
|
|
2371
|
+
|
|
2372
|
+
const AXPEntityBulkEnabledEvent = createWorkFlowEvent('[Entity] Bulk Enabled');
|
|
2373
|
+
class AXPEntityBulkEnableAction extends AXPWorkflowAction {
|
|
2374
|
+
constructor() {
|
|
2375
|
+
super(...arguments);
|
|
2376
|
+
this.entityRegistery = inject(AXPEntityDefinitionRegistryService);
|
|
2377
|
+
this.dialogService = inject(AXDialogService);
|
|
2378
|
+
this.loadingDialog = inject(AXLoadingDialogService);
|
|
2379
|
+
this.translationService = inject(AXTranslationService);
|
|
2380
|
+
}
|
|
2381
|
+
async execute(context) {
|
|
2382
|
+
const refType = context.getVariable('options.refType');
|
|
2383
|
+
const data = context.getVariable('data');
|
|
2384
|
+
const selectedIds = Array.isArray(data) ? data.map((c) => c.id) : data ? [data.id] : [];
|
|
2385
|
+
if (!refType || selectedIds.length === 0) {
|
|
2386
|
+
throw new Error('Missing required parameters: refType and data');
|
|
2387
|
+
}
|
|
2388
|
+
const [moduleName, entityName] = refType.split('.');
|
|
2389
|
+
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
2390
|
+
// Show confirmation dialog
|
|
2391
|
+
const dialogResult = await this.dialogService.confirm(await this.translationService.translateAsync('@general:actions.bulk-enable.confirm.title'), await this.translationService.translateAsync('@general:actions.bulk-enable.confirm.message', {
|
|
2392
|
+
params: { count: selectedIds.length }
|
|
2393
|
+
}), 'success', 'horizontal', false, 'cancel');
|
|
2394
|
+
if (!dialogResult.result) {
|
|
2395
|
+
context.setOutput('isCanceled', true);
|
|
2396
|
+
context.setOutput('error', 'Operation cancelled by user');
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
// Show loading dialog
|
|
2400
|
+
const loadingDialog = this.loadingDialog.show({
|
|
2401
|
+
title: await this.translationService.translateAsync('@general:actions.bulk-enable.confirm.processing'),
|
|
2402
|
+
mode: 'indeterminate',
|
|
2403
|
+
status: 'Enabling items...',
|
|
2404
|
+
});
|
|
2405
|
+
try {
|
|
2406
|
+
const results = [];
|
|
2407
|
+
const errors = [];
|
|
2408
|
+
// Process each selected item
|
|
2409
|
+
for (const refId of selectedIds) {
|
|
2410
|
+
try {
|
|
2411
|
+
// Get the current entity data
|
|
2412
|
+
const currentData = await this.getEntityData(refType, refId);
|
|
2413
|
+
// Prepare enable data
|
|
2414
|
+
const enableData = this.prepareEnableData(currentData);
|
|
2415
|
+
// Update the entity to mark it as enabled
|
|
2416
|
+
if (entityDefinition.commands?.update) {
|
|
2417
|
+
const updateExec = entityDefinition.commands.update.execute;
|
|
2418
|
+
await updateExec(enableData);
|
|
2419
|
+
results.push(refId);
|
|
2420
|
+
}
|
|
2421
|
+
else {
|
|
2422
|
+
throw new Error('Entity does not support update operation');
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
catch (error) {
|
|
2426
|
+
console.error(`Failed to enable entity ${refId}:`, error);
|
|
2427
|
+
errors.push({ id: refId, error: error instanceof Error ? error.message : 'Unknown error' });
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
context.setOutput('processedIds', results);
|
|
2431
|
+
context.setOutput('errors', errors);
|
|
2432
|
+
context.setOutput('isCanceled', false);
|
|
2433
|
+
}
|
|
2434
|
+
catch (error) {
|
|
2435
|
+
console.error('Bulk enable operation failed:', error);
|
|
2436
|
+
context.setOutput('error', error instanceof Error ? error.message : 'Unknown error');
|
|
2437
|
+
context.setOutput('isCanceled', true);
|
|
2438
|
+
}
|
|
2439
|
+
finally {
|
|
2440
|
+
loadingDialog.close();
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
async getEntityData(refType, refId) {
|
|
2444
|
+
try {
|
|
2445
|
+
// Use the entity's byKey query to get actual data
|
|
2446
|
+
const [moduleName, entityName] = refType.split('.');
|
|
2447
|
+
const entityDefinition = await this.entityRegistery.resolve(moduleName, entityName);
|
|
2448
|
+
if (entityDefinition.queries?.byKey) {
|
|
2449
|
+
const queryExec = entityDefinition.queries.byKey.execute;
|
|
2450
|
+
return await queryExec(refId);
|
|
2451
|
+
}
|
|
2452
|
+
// Fallback to basic structure if no query available
|
|
2453
|
+
return { id: refId };
|
|
2454
|
+
}
|
|
2455
|
+
catch (error) {
|
|
2456
|
+
console.error('Failed to retrieve entity data:', error);
|
|
2457
|
+
throw new Error(`Failed to retrieve entity data: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
prepareEnableData(currentData) {
|
|
2461
|
+
const enableData = { ...currentData };
|
|
2462
|
+
// Set the disabled flag to false
|
|
2463
|
+
enableData.isDisabled = false;
|
|
2464
|
+
// Optionally add enable timestamp
|
|
2465
|
+
enableData.enabledAt = new Date();
|
|
2466
|
+
return enableData;
|
|
2467
|
+
}
|
|
2468
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkEnableAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2469
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkEnableAction }); }
|
|
2470
|
+
}
|
|
2471
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkEnableAction, decorators: [{
|
|
2472
|
+
type: Injectable
|
|
2473
|
+
}] });
|
|
2474
|
+
class AXPEntityBulkEnableSuccessAction extends AXPWorkflowAction {
|
|
2475
|
+
async execute(context) {
|
|
2476
|
+
const refType = context.getVariable('options.refType');
|
|
2477
|
+
const processedIds = context.getOutput('processedIds') || [];
|
|
2478
|
+
const errors = context.getOutput('errors') || [];
|
|
2479
|
+
const meta = context.getVariable('meta');
|
|
2480
|
+
// Dispatch bulk enable event
|
|
2481
|
+
this.dispatch(AXPEntityBulkEnabledEvent({
|
|
2482
|
+
entity: refType,
|
|
2483
|
+
ids: processedIds,
|
|
2484
|
+
meta
|
|
2485
|
+
}));
|
|
2486
|
+
// Refresh the entity list
|
|
2487
|
+
this.dispatch(AXPRefreshEvent({
|
|
2488
|
+
entity: refType,
|
|
2489
|
+
meta
|
|
2490
|
+
}));
|
|
2491
|
+
// Show error summary if there were any errors
|
|
2492
|
+
if (errors.length > 0) {
|
|
2493
|
+
const errorMessage = errors.map(e => `${e.id}: ${e.error}`).join('\n');
|
|
2494
|
+
console.warn('Some items failed to enable:', errorMessage);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkEnableSuccessAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2498
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkEnableSuccessAction }); }
|
|
2499
|
+
}
|
|
2500
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPEntityBulkEnableSuccessAction, decorators: [{
|
|
2501
|
+
type: Injectable
|
|
2502
|
+
}] });
|
|
2503
|
+
const AXPBulkEnableEntityWorkflow = {
|
|
2504
|
+
startStepId: 'bulk-enable-entity',
|
|
2505
|
+
steps: {
|
|
2506
|
+
'bulk-enable-entity': {
|
|
2507
|
+
action: 'AXPEntityBulkEnableAction',
|
|
2508
|
+
nextSteps: [
|
|
2509
|
+
{
|
|
2510
|
+
conditions: [{ type: 'SINGLE', expression: 'context.getOutput("isCanceled") == false' }],
|
|
2511
|
+
nextStepId: 'show-success-toast',
|
|
2512
|
+
},
|
|
2513
|
+
],
|
|
2514
|
+
},
|
|
2515
|
+
'show-success-toast': {
|
|
2516
|
+
action: 'AXPToastAction',
|
|
2517
|
+
input: {
|
|
2518
|
+
color: 'success',
|
|
2519
|
+
title: 'workflow.entity-bulk-enabled',
|
|
2520
|
+
content: 'workflow.entity-bulk-enabled-body',
|
|
2521
|
+
},
|
|
2522
|
+
nextSteps: [
|
|
2523
|
+
{
|
|
2524
|
+
conditions: [],
|
|
2525
|
+
nextStepId: 'bulk-enable-success',
|
|
2526
|
+
},
|
|
2527
|
+
],
|
|
2528
|
+
},
|
|
2529
|
+
'bulk-enable-success': {
|
|
2530
|
+
action: 'AXPEntityBulkEnableSuccessAction',
|
|
2531
|
+
},
|
|
2532
|
+
},
|
|
2533
|
+
};
|
|
2534
|
+
|
|
2535
|
+
class AXPDisablePluginModule {
|
|
2536
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPDisablePluginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2537
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.3", ngImport: i0, type: AXPDisablePluginModule, imports: [i1.AXPWorkflowModule] }); }
|
|
2538
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPDisablePluginModule, providers: [
|
|
2539
|
+
{ provide: AXP_ENTITY_ACTION_PLUGIN, multi: true, useValue: disablePlugin },
|
|
2540
|
+
], imports: [AXPWorkflowModule.forChild({
|
|
2541
|
+
actions: {
|
|
2542
|
+
AXPEntityDisableAction,
|
|
2543
|
+
AXPEntityDisableSuccessAction,
|
|
2544
|
+
AXPEntityEnableAction,
|
|
2545
|
+
AXPEntityEnableSuccessAction,
|
|
2546
|
+
AXPEntityBulkDisableAction,
|
|
2547
|
+
AXPEntityBulkDisableSuccessAction,
|
|
2548
|
+
AXPEntityBulkEnableAction,
|
|
2549
|
+
AXPEntityBulkEnableSuccessAction,
|
|
2550
|
+
},
|
|
2551
|
+
workflows: {
|
|
2552
|
+
'disable-entity': AXPDisableEntityWorkflow,
|
|
2553
|
+
'enable-entity': AXPEnableEntityWorkflow,
|
|
2554
|
+
'bulk-disable-entity': AXPBulkDisableEntityWorkflow,
|
|
2555
|
+
'bulk-enable-entity': AXPBulkEnableEntityWorkflow,
|
|
2556
|
+
},
|
|
2557
|
+
})] }); }
|
|
2558
|
+
}
|
|
2559
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPDisablePluginModule, decorators: [{
|
|
2560
|
+
type: NgModule,
|
|
2561
|
+
args: [{
|
|
2562
|
+
imports: [
|
|
2563
|
+
AXPWorkflowModule.forChild({
|
|
2564
|
+
actions: {
|
|
2565
|
+
AXPEntityDisableAction,
|
|
2566
|
+
AXPEntityDisableSuccessAction,
|
|
2567
|
+
AXPEntityEnableAction,
|
|
2568
|
+
AXPEntityEnableSuccessAction,
|
|
2569
|
+
AXPEntityBulkDisableAction,
|
|
2570
|
+
AXPEntityBulkDisableSuccessAction,
|
|
2571
|
+
AXPEntityBulkEnableAction,
|
|
2572
|
+
AXPEntityBulkEnableSuccessAction,
|
|
2573
|
+
},
|
|
2574
|
+
workflows: {
|
|
2575
|
+
'disable-entity': AXPDisableEntityWorkflow,
|
|
2576
|
+
'enable-entity': AXPEnableEntityWorkflow,
|
|
2577
|
+
'bulk-disable-entity': AXPBulkDisableEntityWorkflow,
|
|
2578
|
+
'bulk-enable-entity': AXPBulkEnableEntityWorkflow,
|
|
2579
|
+
},
|
|
2580
|
+
}),
|
|
2581
|
+
],
|
|
2582
|
+
providers: [
|
|
2583
|
+
{ provide: AXP_ENTITY_ACTION_PLUGIN, multi: true, useValue: disablePlugin },
|
|
2584
|
+
],
|
|
2585
|
+
}]
|
|
2586
|
+
}] });
|
|
2587
|
+
|
|
1683
2588
|
class AXPComparePopupComponent extends AXBasePageComponent {
|
|
1684
2589
|
constructor() {
|
|
1685
2590
|
super(...arguments);
|
|
@@ -3510,6 +4415,7 @@ class AXMCommonModule {
|
|
|
3510
4415
|
AXPComputedPropertiesModule,
|
|
3511
4416
|
AXPClonePluginModule,
|
|
3512
4417
|
AXPArchivePluginModule,
|
|
4418
|
+
AXPDisablePluginModule,
|
|
3513
4419
|
AXPPrimaryPluginModule,
|
|
3514
4420
|
AXPCompareModule] }); }
|
|
3515
4421
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMCommonModule, providers: [
|
|
@@ -3552,6 +4458,7 @@ class AXMCommonModule {
|
|
|
3552
4458
|
AXPComputedPropertiesModule,
|
|
3553
4459
|
AXPClonePluginModule,
|
|
3554
4460
|
AXPArchivePluginModule,
|
|
4461
|
+
AXPDisablePluginModule,
|
|
3555
4462
|
AXPPrimaryPluginModule,
|
|
3556
4463
|
AXPCompareModule] }); }
|
|
3557
4464
|
}
|
|
@@ -3568,6 +4475,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
3568
4475
|
AXPComputedPropertiesModule,
|
|
3569
4476
|
AXPClonePluginModule,
|
|
3570
4477
|
AXPArchivePluginModule,
|
|
4478
|
+
AXPDisablePluginModule,
|
|
3571
4479
|
AXPPrimaryPluginModule,
|
|
3572
4480
|
AXPCompareModule,
|
|
3573
4481
|
],
|
|
@@ -3612,5 +4520,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
3612
4520
|
* Generated bundle index. Do not edit.
|
|
3613
4521
|
*/
|
|
3614
4522
|
|
|
3615
|
-
export { AXMCommonModule, AXMLockPopupWorkflow, AXMLockPopupWorkflowAction, AXMMenuProvider, AXMSearchCommandProvider, AXMSettingProvider, AXMUnlockConfirmWorkflow, AXMUnlockConfirmWorkflowAction, AXPGlobalSearchModule, AXPGlobalSearchViewModel, AXPVersionHistoryModule, AXPWidgetsList, AXP_GLOBAL_SEARCH_CONFIG_TOKEN, RootConfig };
|
|
4523
|
+
export { AXMCommonModule, AXMLockPopupWorkflow, AXMLockPopupWorkflowAction, AXMMenuProvider, AXMSearchCommandProvider, AXMSettingProvider, AXMUnlockConfirmWorkflow, AXMUnlockConfirmWorkflowAction, AXPDisablePluginModule, AXPGlobalSearchModule, AXPGlobalSearchViewModel, AXPVersionHistoryModule, AXPWidgetsList, AXP_GLOBAL_SEARCH_CONFIG_TOKEN, RootConfig, disablePlugin };
|
|
3616
4524
|
//# sourceMappingURL=acorex-modules-common.mjs.map
|