d2aura 26.0.14 → 26.0.16
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/api/eda/edaManagerApi.d.ts +7 -3
- package/api/eda/edaManagerApi.js +28 -2
- package/api/eda/edaManagerApi.js.map +1 -1
- package/api/eda/generated/events.d.ts +93 -62
- package/api/eda/generated/events.js +146 -88
- package/api/eda/generated/events.js.map +1 -1
- package/api/eda/generated/structures.d.ts +99 -86
- package/api/eda/generated/structures.js.map +1 -1
- package/api/types/advancedFilter.d.ts +3 -0
- package/api/types/advancedFilter.js.map +1 -1
- package/api/webPush/webPushApi.js.map +1 -1
- package/api/webPush/webPushUtils.js.map +1 -1
- package/core/i18n/d2aura.en.json +14 -0
- package/core/i18n/d2aura.sk.json +62 -0
- package/coreui/abstractListPanel.d.ts +2 -1
- package/coreui/abstractListPanel.js +5 -1
- package/coreui/abstractListPanel.js.map +1 -1
- package/coreui/components/advancedFilter/advancedFilterButton.d.ts +2 -2
- package/coreui/components/advancedFilter/advancedFilterButton.js.map +1 -1
- package/coreui/components/advancedFilter/advancedFilteredGrid.d.ts +3 -2
- package/coreui/components/advancedFilter/advancedFilteredGrid.js +9 -1
- package/coreui/components/advancedFilter/advancedFilteredGrid.js.map +1 -1
- package/coreui/components/advancedFilter/conditionList/advancedFilterConditionDetailPanel.d.ts +2 -2
- package/coreui/components/advancedFilter/conditionList/advancedFilterConditionDetailPanel.js +1 -1
- package/coreui/components/advancedFilter/conditionList/advancedFilterConditionDetailPanel.js.map +1 -1
- package/coreui/components/advancedFilter/conditionList/advancedFilterConditionListModalDialog.d.ts +2 -2
- package/coreui/components/advancedFilter/conditionList/advancedFilterConditionListModalDialog.js.map +1 -1
- package/coreui/components/advancedFilter/conditionList/advancedFilterConditionListPanel.d.ts +2 -2
- package/coreui/components/advancedFilter/conditionList/advancedFilterConditionListPanel.js +10 -2
- package/coreui/components/advancedFilter/conditionList/advancedFilterConditionListPanel.js.map +1 -1
- package/coreui/components/d2Chart/d2ChartAdvancedZoom.d.ts +25 -0
- package/coreui/components/d2Chart/d2ChartAdvancedZoom.js +197 -0
- package/coreui/components/d2Chart/d2ChartAdvancedZoom.js.map +1 -0
- package/coreui/components/d2Chart/d2ChartPanel.d.ts +2 -0
- package/coreui/components/d2Chart/d2ChartPanel.js +9 -2
- package/coreui/components/d2Chart/d2ChartPanel.js.map +1 -1
- package/coreui/components/d2Chart/d2ChartToolboxPanel.d.ts +1 -0
- package/coreui/components/d2Chart/d2ChartToolboxPanel.js +2 -2
- package/coreui/components/d2Chart/d2ChartToolboxPanel.js.map +1 -1
- package/coreui/components/edaManager/abstract/edaManagerAbstractPanel.js +1 -1
- package/coreui/components/edaManager/abstract/edaManagerAbstractPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaChartViewer.js +23 -19
- package/coreui/components/edaManagerComponent/components/edaChartViewer.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaDataBasePanel.js +1 -1
- package/coreui/components/edaManagerComponent/components/edaDataBasePanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaGraphPanel.js +15 -18
- package/coreui/components/edaManagerComponent/components/edaGraphPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaSampleRangePickerPanel.d.ts +11 -3
- package/coreui/components/edaManagerComponent/components/edaSampleRangePickerPanel.js +31 -24
- package/coreui/components/edaManagerComponent/components/edaSampleRangePickerPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaTablePanel.js +116 -95
- package/coreui/components/edaManagerComponent/components/edaTablePanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaTreeView.d.ts +5 -0
- package/coreui/components/edaManagerComponent/components/edaTreeView.js +189 -60
- package/coreui/components/edaManagerComponent/components/edaTreeView.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaVectorDetailPanel.js +1 -1
- package/coreui/components/edaManagerComponent/components/edaVectorDetailPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/constants/actionTypes.d.ts +5 -0
- package/coreui/components/edaManagerComponent/constants/actionTypes.js +7 -0
- package/coreui/components/edaManagerComponent/constants/actionTypes.js.map +1 -0
- package/coreui/components/edaManagerComponent/constants/edaTypes.d.ts +13 -0
- package/coreui/components/edaManagerComponent/constants/edaTypes.js +15 -0
- package/coreui/components/edaManagerComponent/constants/edaTypes.js.map +1 -1
- package/coreui/components/edaManagerComponent/context/edaVectorDataContext.d.ts +1 -0
- package/coreui/components/edaManagerComponent/context/edaVectorDataContext.js +8 -1
- package/coreui/components/edaManagerComponent/context/edaVectorDataContext.js.map +1 -1
- package/coreui/components/edaManagerComponent/context/edaVectorDataProvider.js +31 -38
- package/coreui/components/edaManagerComponent/context/edaVectorDataProvider.js.map +1 -1
- package/coreui/components/edaManagerComponent/context/sharedSampleRangeContext.d.ts +6 -1
- package/coreui/components/edaManagerComponent/context/sharedSampleRangeContext.js +8 -1
- package/coreui/components/edaManagerComponent/context/sharedSampleRangeContext.js.map +1 -1
- package/coreui/components/edaManagerComponent/context/useEdaActions.d.ts +5 -3
- package/coreui/components/edaManagerComponent/context/useEdaActions.js +21 -7
- package/coreui/components/edaManagerComponent/context/useEdaActions.js.map +1 -1
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/controlButtons.d.ts +13 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/controlButtons.js +19 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/controlButtons.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/descriptiveVectorDetailPanel.d.ts +8 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/descriptiveVectorDetailPanel.js +171 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/descriptiveVectorDetailPanel.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/graphPanel.d.ts +22 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/graphPanel.js +75 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/graphPanel.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/intervalInput.d.ts +12 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/intervalInput.js +52 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/intervalInput.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/tablePanel.d.ts +22 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/tablePanel.js +130 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/tablePanel.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/types.d.ts +58 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/types.js +51 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/types.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/useSharedData.d.ts +18 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/useSharedData.js +74 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/useSharedData.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/utils.d.ts +38 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/utils.js +299 -0
- package/coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/utils.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/edaDescriptiveVectorEditorDialog.d.ts +10 -0
- package/coreui/components/edaManagerComponent/dialogs/edaDescriptiveVectorEditorDialog.js +343 -0
- package/coreui/components/edaManagerComponent/dialogs/edaDescriptiveVectorEditorDialog.js.map +1 -0
- package/coreui/components/edaManagerComponent/{components → dialogs}/edaTableEditorDialog.js +1 -1
- package/coreui/components/edaManagerComponent/dialogs/edaTableEditorDialog.js.map +1 -0
- package/coreui/components/edaManagerComponent/{components → dialogs}/exportDialog.d.ts +2 -2
- package/coreui/components/edaManagerComponent/{components → dialogs}/exportDialog.js +7 -8
- package/coreui/components/edaManagerComponent/dialogs/exportDialog.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/groupVectorSelection.d.ts +12 -0
- package/coreui/components/edaManagerComponent/dialogs/groupVectorSelection.js +74 -0
- package/coreui/components/edaManagerComponent/dialogs/groupVectorSelection.js.map +1 -0
- package/coreui/components/edaManagerComponent/dialogs/insertVectorDialog.d.ts +16 -0
- package/coreui/components/edaManagerComponent/dialogs/insertVectorDialog.js +32 -0
- package/coreui/components/edaManagerComponent/dialogs/insertVectorDialog.js.map +1 -0
- package/coreui/components/edaManagerComponent/edaDetail.js +21 -7
- package/coreui/components/edaManagerComponent/edaDetail.js.map +1 -1
- package/coreui/components/edaManagerComponent/edaNavigator.d.ts +2 -0
- package/coreui/components/edaManagerComponent/edaNavigator.js +4 -4
- package/coreui/components/edaManagerComponent/edaNavigator.js.map +1 -1
- package/coreui/components/edaManagerComponent/edaSelect.d.ts +2 -0
- package/coreui/components/edaManagerComponent/edaSelect.js +13 -13
- package/coreui/components/edaManagerComponent/edaSelect.js.map +1 -1
- package/coreui/components/edaManagerComponent/icons/folderRemoveOutlined.d.ts +6 -0
- package/coreui/components/edaManagerComponent/icons/folderRemoveOutlined.js +7 -0
- package/coreui/components/edaManagerComponent/icons/folderRemoveOutlined.js.map +1 -0
- package/coreui/components/edaManagerComponent/utils/export.d.ts +1 -1
- package/coreui/components/edaManagerComponent/utils/export.js +20 -23
- package/coreui/components/edaManagerComponent/utils/export.js.map +1 -1
- package/coreui/components/select/abstractMultiSelect.d.ts +32 -0
- package/coreui/components/select/abstractMultiSelect.js +126 -0
- package/coreui/components/select/abstractMultiSelect.js.map +1 -0
- package/coreui/components/select/abstractSelectModalDialog.d.ts +5 -0
- package/coreui/components/select/abstractSelectModalDialog.js +45 -5
- package/coreui/components/select/abstractSelectModalDialog.js.map +1 -1
- package/coreui/components/webPush/webPushSwitch.js.map +1 -1
- package/coreui/images/logo.svg +9 -9
- package/coreui/images/logo_full.svg +11 -11
- package/d2configuration/edaManager/{DB.EM_EDA_DescriptiveVector.xml → DB.EM_EDA_VectorScenario.xml} +10 -10
- package/d2configuration/edaManager/E.EM_DETAIL_IMPL.xml +4 -4
- package/d2configuration/edaManager/E.EM_DETAIL_UNIT.xml +35 -15
- package/d2configuration/edaManager/E.EM_NAVIGATOR_IMPL.xml +13 -5
- package/d2configuration/edaManager/E.EM_NAVIGATOR_SQL.xml +12 -1
- package/d2configuration/edaManager/E.EM_NAVIGATOR_UNIT.xml +113 -5
- package/d2configuration/edaManager/E.EM_VECTOR_IMPL.xml +11 -1
- package/d2configuration/edaManager/E.EM_VECTOR_UNIT.xml +25 -1
- package/d2configuration/edaManager/{SD.EM_EDA_StatVectorRec_V1.xml → SD.EM_EDA_VectorScenario.xml} +13 -36
- package/package.json +2 -2
- package/coreui/components/edaManagerComponent/components/edaTableEditorDialog.js.map +0 -1
- package/coreui/components/edaManagerComponent/components/exportDialog.js.map +0 -1
- package/d2configuration/edaManager/SD.EM_EDA_DescriptiveVector.xml +0 -179
- package/d2configuration/edaManager/SD.EM_EDA_InsertValuesToVector_V1.xml +0 -227
- package/d2configuration/edaManager/SD.EM_EDA_ReadValuesFromVector_V1.xml +0 -178
- package/d2configuration/edaManager/SD.EM_EDA_VectorValues.xml +0 -58
- /package/coreui/components/edaManagerComponent/{components → dialogs}/edaTableEditorDialog.d.ts +0 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import dayjs from "d2core/dayjs";
|
|
3
|
+
import { EdaPeriodType, EdaPeriodValueType, EdaRoundingType, EdaVectorType } from "../../constants/edaTypes";
|
|
4
|
+
import i18n from "d2core/i18n/i18n";
|
|
5
|
+
import { DaysInWeek, FullPeriodType, YearPeriodType } from "./types";
|
|
6
|
+
import { FolderFilled, FolderOutlined } from "@ant-design/icons";
|
|
7
|
+
export function getFormattedPeriodTime(periodType, time, fullMask, dateMask) {
|
|
8
|
+
switch (periodType) {
|
|
9
|
+
case EdaPeriodType.Base:
|
|
10
|
+
return "";
|
|
11
|
+
case EdaPeriodType.Week:
|
|
12
|
+
return i18n(DaysInWeek[time.second()]);
|
|
13
|
+
case EdaPeriodType.Day:
|
|
14
|
+
return time.format("HH:mm");
|
|
15
|
+
case EdaPeriodType.Interval:
|
|
16
|
+
return time.format(fullMask);
|
|
17
|
+
case EdaPeriodType.Year: {
|
|
18
|
+
const year = time.year();
|
|
19
|
+
switch (year) {
|
|
20
|
+
case YearPeriodType.Quarter:
|
|
21
|
+
return time.format("Q");
|
|
22
|
+
case YearPeriodType.Month:
|
|
23
|
+
return time.format("MMMM").replace(/^\w/, (c) => c.toUpperCase());
|
|
24
|
+
case YearPeriodType.Week:
|
|
25
|
+
return String(time.second());
|
|
26
|
+
case YearPeriodType.Day:
|
|
27
|
+
return time.format(dateMask);
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return "Invalid";
|
|
33
|
+
}
|
|
34
|
+
export function getFormattedPeriodValue(valueType, value, value2) {
|
|
35
|
+
switch (valueType) {
|
|
36
|
+
case EdaPeriodValueType.Value:
|
|
37
|
+
return String(value);
|
|
38
|
+
case EdaPeriodValueType.CoefficientPlus:
|
|
39
|
+
return `+(${value})`;
|
|
40
|
+
case EdaPeriodValueType.CoefficientMul:
|
|
41
|
+
return `*(${value})`;
|
|
42
|
+
case EdaPeriodValueType.Interpolation:
|
|
43
|
+
return `${value} ${i18n("To[Till]")} ${value2}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function toFullPeriodType(data) {
|
|
47
|
+
switch (data.periodType) {
|
|
48
|
+
case EdaPeriodType.Base:
|
|
49
|
+
return FullPeriodType.Base;
|
|
50
|
+
case EdaPeriodType.Interval:
|
|
51
|
+
return FullPeriodType.Interval;
|
|
52
|
+
case EdaPeriodType.Week:
|
|
53
|
+
return FullPeriodType.Week;
|
|
54
|
+
case EdaPeriodType.Day:
|
|
55
|
+
return FullPeriodType.Day;
|
|
56
|
+
case EdaPeriodType.Year:
|
|
57
|
+
switch (data.timeFrom.year()) {
|
|
58
|
+
case 1972:
|
|
59
|
+
return FullPeriodType.YearQuarter;
|
|
60
|
+
case 1973:
|
|
61
|
+
return FullPeriodType.YearMonth;
|
|
62
|
+
case 1974:
|
|
63
|
+
return FullPeriodType.YearWeek;
|
|
64
|
+
case 1975:
|
|
65
|
+
return FullPeriodType.YearDay;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
throw "Invalid period type";
|
|
69
|
+
}
|
|
70
|
+
export function buildTable(data) {
|
|
71
|
+
const result = [];
|
|
72
|
+
for (let i = 0; i < data.length; i++) {
|
|
73
|
+
let d = data[i];
|
|
74
|
+
result.push({ id: i, ...d });
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
export function buildTree(data, fullMask, dateMask) {
|
|
79
|
+
const parentMap = new Map();
|
|
80
|
+
for (const item of data) {
|
|
81
|
+
const pId = item.parent ?? 0;
|
|
82
|
+
if (!parentMap.has(pId)) {
|
|
83
|
+
parentMap.set(pId, []);
|
|
84
|
+
}
|
|
85
|
+
parentMap.get(pId).push(item);
|
|
86
|
+
}
|
|
87
|
+
function recurse(parentId) {
|
|
88
|
+
const childrenData = parentMap.get(parentId) || [];
|
|
89
|
+
return childrenData.map((d) => {
|
|
90
|
+
const children = recurse(d.idx);
|
|
91
|
+
return {
|
|
92
|
+
key: d.idx,
|
|
93
|
+
title: getTitle(d, fullMask, dateMask),
|
|
94
|
+
data: d,
|
|
95
|
+
children: children,
|
|
96
|
+
icon: !d.valid ? React.createElement(FolderFilled, null) : React.createElement(FolderOutlined, null),
|
|
97
|
+
isLeaf: children.length === 0,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return recurse(0);
|
|
102
|
+
}
|
|
103
|
+
export function getPeriodName(period) {
|
|
104
|
+
return i18n("EdaPeriodType_" + EdaPeriodType[period]);
|
|
105
|
+
}
|
|
106
|
+
export function canMove(data, selected, direction) {
|
|
107
|
+
const branch = data.filter((d) => d.parent === selected.parent);
|
|
108
|
+
const position = branch.findIndex((b) => b.idx === selected.idx);
|
|
109
|
+
return direction === "up" ? position > 0 : position < branch.length - 1;
|
|
110
|
+
}
|
|
111
|
+
export function reorder(data, selected, direction) {
|
|
112
|
+
const result = [...data];
|
|
113
|
+
const swapVector = getNextVector(data, selected, direction);
|
|
114
|
+
const upperVector = direction === "up" ? swapVector : selected;
|
|
115
|
+
const insertionIndex = result.findIndex((d) => d.idx === upperVector.idx);
|
|
116
|
+
let branch;
|
|
117
|
+
let swap;
|
|
118
|
+
if (direction === "up") {
|
|
119
|
+
branch = removeBranch(result, selected.idx);
|
|
120
|
+
swap = removeBranch(result, swapVector.idx);
|
|
121
|
+
result.splice(insertionIndex, 0, ...branch, ...swap);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
swap = removeBranch(result, swapVector.idx);
|
|
125
|
+
branch = removeBranch(result, selected.idx);
|
|
126
|
+
result.splice(insertionIndex, 0, ...swap, ...branch);
|
|
127
|
+
}
|
|
128
|
+
return reindexData(result, selected);
|
|
129
|
+
}
|
|
130
|
+
export function addEntry(data, selected) {
|
|
131
|
+
const result = [...data];
|
|
132
|
+
if (!selected) {
|
|
133
|
+
result.push(getNewEntry(data.length + 1, 0));
|
|
134
|
+
return { data: result, selected };
|
|
135
|
+
}
|
|
136
|
+
const selectedIndex = result.findIndex((d) => d.idx === selected.idx);
|
|
137
|
+
let insertionIndex = selectedIndex + 1;
|
|
138
|
+
while (insertionIndex < result.length && result[insertionIndex].parent >= selected.idx) {
|
|
139
|
+
insertionIndex++;
|
|
140
|
+
}
|
|
141
|
+
const newEntry = getNewEntry(data.length + 1, selected.parent);
|
|
142
|
+
result.splice(insertionIndex, 0, newEntry);
|
|
143
|
+
return reindexData(result, selected);
|
|
144
|
+
}
|
|
145
|
+
export function addSubEntry(data, selected) {
|
|
146
|
+
const result = [...data];
|
|
147
|
+
const selectedIndex = result.findIndex((d) => d.idx === selected.idx);
|
|
148
|
+
let insertionIndex = selectedIndex + 1;
|
|
149
|
+
while (insertionIndex < result.length && result[insertionIndex].parent >= selected.idx) {
|
|
150
|
+
insertionIndex++;
|
|
151
|
+
}
|
|
152
|
+
result.splice(insertionIndex, 0, getNewEntry(data.length + 1, selected.idx));
|
|
153
|
+
return reindexData(result, selected);
|
|
154
|
+
}
|
|
155
|
+
export function removeEntry(data, selected) {
|
|
156
|
+
const result = [...data];
|
|
157
|
+
let next = getNextVector(data, selected, "down");
|
|
158
|
+
if (!next) {
|
|
159
|
+
next = getNextVector(data, selected, "up");
|
|
160
|
+
}
|
|
161
|
+
if (!next && selected.parent !== 0) {
|
|
162
|
+
next = data.find((d) => d.idx === selected.parent);
|
|
163
|
+
}
|
|
164
|
+
removeBranch(result, selected.idx);
|
|
165
|
+
return reindexData(result, next);
|
|
166
|
+
}
|
|
167
|
+
export function removeSubEntries(data, selected) {
|
|
168
|
+
const result = [...data];
|
|
169
|
+
const start = result.findIndex((d) => d.idx === selected.idx);
|
|
170
|
+
let count = 0;
|
|
171
|
+
while (start + 1 + count < result.length && result[start + 1 + count].parent >= selected.idx) {
|
|
172
|
+
count++;
|
|
173
|
+
}
|
|
174
|
+
if (count > 0) {
|
|
175
|
+
result.splice(start + 1, count);
|
|
176
|
+
}
|
|
177
|
+
return reindexData(result, selected);
|
|
178
|
+
}
|
|
179
|
+
export function getOrigModifiedVectors() {
|
|
180
|
+
return [
|
|
181
|
+
{
|
|
182
|
+
ID: 0,
|
|
183
|
+
DisplayName: i18n("Original vector"),
|
|
184
|
+
Type: EdaVectorType.Change,
|
|
185
|
+
RoundingType: EdaRoundingType.NoRounding,
|
|
186
|
+
RoundingPlaces: 0,
|
|
187
|
+
Name: "OriginalVector",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
ID: 1,
|
|
191
|
+
DisplayName: i18n("Modified vector"),
|
|
192
|
+
Type: EdaVectorType.Change,
|
|
193
|
+
RoundingType: EdaRoundingType.NoRounding,
|
|
194
|
+
RoundingPlaces: 0,
|
|
195
|
+
Name: "ModifiedVector",
|
|
196
|
+
}
|
|
197
|
+
];
|
|
198
|
+
}
|
|
199
|
+
function getNewEntry(idx, parent) {
|
|
200
|
+
return {
|
|
201
|
+
idx,
|
|
202
|
+
parent,
|
|
203
|
+
value: 0,
|
|
204
|
+
value2: 0,
|
|
205
|
+
valid: true,
|
|
206
|
+
valueType: EdaPeriodValueType.Value,
|
|
207
|
+
supplement: 0,
|
|
208
|
+
status: 0,
|
|
209
|
+
periodType: EdaPeriodType.Base,
|
|
210
|
+
timeFrom: dayjs().startOf('year'),
|
|
211
|
+
timeTo: dayjs().endOf('year').millisecond(0),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function removeBranch(data, idx) {
|
|
215
|
+
const start = data.findIndex((d) => d.idx === idx);
|
|
216
|
+
let count = 1;
|
|
217
|
+
while (start + count < data.length && data[start + count].parent >= idx) {
|
|
218
|
+
count++;
|
|
219
|
+
}
|
|
220
|
+
return data.splice(start, count);
|
|
221
|
+
}
|
|
222
|
+
function getTitle(data, fullMask, dateMask) {
|
|
223
|
+
const from = getFormattedPeriodTime(data.periodType, data.timeFrom, fullMask, dateMask);
|
|
224
|
+
const to = getFormattedPeriodTime(data.periodType, data.timeTo, fullMask, dateMask);
|
|
225
|
+
let description = "Invalid period type! " + data.periodType;
|
|
226
|
+
switch (data.periodType) {
|
|
227
|
+
case EdaPeriodType.Base:
|
|
228
|
+
description = getPeriodName(data.periodType);
|
|
229
|
+
break;
|
|
230
|
+
case EdaPeriodType.Week: {
|
|
231
|
+
description = i18n(`%{from} To %{to}`, { from, to });
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case EdaPeriodType.Day:
|
|
235
|
+
description = i18n("Daily From %{from} To %{to}", { from, to });
|
|
236
|
+
break;
|
|
237
|
+
case EdaPeriodType.Interval:
|
|
238
|
+
description = i18n("From %{from} To %{to}", { from, to });
|
|
239
|
+
break;
|
|
240
|
+
case EdaPeriodType.Year: {
|
|
241
|
+
if (data.timeFrom.year() !== data.timeTo.year()) {
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
switch (data.timeFrom.year()) {
|
|
245
|
+
case YearPeriodType.Quarter: {
|
|
246
|
+
description = i18n(`%{from} To %{to}`, { from: `${from}. ${i18n("Quarter")}`, to: `${to}. ${i18n("Quarter")}` });
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case YearPeriodType.Month: {
|
|
250
|
+
description = i18n(`%{from} To %{to}`, { from: from, to: to });
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
case YearPeriodType.Week: {
|
|
254
|
+
description = i18n(`%{from} To %{to}`, { from: `${from}.`, to: `${to}. ${i18n("Week")}` });
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case YearPeriodType.Day: {
|
|
258
|
+
description = i18n("From %{from} To %{to}", { from, to });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return `${description} => ${getFormattedPeriodValue(data.valueType, data.value, data.value2)}`;
|
|
265
|
+
}
|
|
266
|
+
function getNextVector(data, selected, direction) {
|
|
267
|
+
if ((direction === "up" && !canMove(data, selected, "up")) || (direction === "down" && !canMove(data, selected, "down"))) {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
const sameBranch = data.filter((d) => d.parent === selected.parent);
|
|
271
|
+
const sameBranchIndex = sameBranch.findIndex((d) => d.idx === selected.idx);
|
|
272
|
+
const swapIndex = direction === "up" ? sameBranchIndex - 1 : sameBranchIndex + 1;
|
|
273
|
+
return sameBranch[swapIndex];
|
|
274
|
+
}
|
|
275
|
+
function reindexData(data, selected) {
|
|
276
|
+
const idMap = new Map();
|
|
277
|
+
let updatedSelected = selected;
|
|
278
|
+
const reindexedResult = data.map((item, index) => {
|
|
279
|
+
const newIdx = index + 1;
|
|
280
|
+
idMap.set(item.idx, newIdx);
|
|
281
|
+
const newItem = { ...item, idx: newIdx };
|
|
282
|
+
if (item.idx === selected?.idx) {
|
|
283
|
+
updatedSelected = newItem;
|
|
284
|
+
}
|
|
285
|
+
return newItem;
|
|
286
|
+
});
|
|
287
|
+
const finalData = reindexedResult.map((item) => {
|
|
288
|
+
if (item.parent && idMap.has(item.parent)) {
|
|
289
|
+
const updatedItem = { ...item, parent: idMap.get(item.parent) };
|
|
290
|
+
if (item.idx === updatedSelected?.idx) {
|
|
291
|
+
updatedSelected = updatedItem;
|
|
292
|
+
}
|
|
293
|
+
return updatedItem;
|
|
294
|
+
}
|
|
295
|
+
return item;
|
|
296
|
+
});
|
|
297
|
+
return { data: finalData, selected: updatedSelected };
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../coreui/components/edaManagerComponent/dialogs/descriptiveVectorDialog/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC3G,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,UAAU,EAAqB,cAAc,EAAuB,cAAc,EAAC,MAAM,SAAS,CAAC;AAC3G,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAE/D,MAAM,UAAU,sBAAsB,CAAC,UAAyB,EAAE,IAAiB,EAAE,QAAgB,EAAE,QAAgB;IACnH,QAAQ,UAAU,EAAE,CAAC;QACjB,KAAK,aAAa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I,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAC,CAAA;AACvD,CAAC","sourcesContent":["import React from \"react\";\r\nimport dayjs from \"d2core/dayjs\";\r\nimport {EdaPeriodType, EdaPeriodValueType, EdaRoundingType, EdaVectorType} from \"../../constants/edaTypes\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {DaysInWeek, DescriptiveVector, FullPeriodType, TableNode, TreeNode, YearPeriodType} from \"./types\";\r\nimport {FolderFilled, FolderOutlined} from \"@ant-design/icons\";\r\n\r\nexport function getFormattedPeriodTime(periodType: EdaPeriodType, time: dayjs.Dayjs, fullMask: string, dateMask: string): string {\r\n switch (periodType) {\r\n case EdaPeriodType.Base:\r\n return \"\";\r\n case EdaPeriodType.Week:\r\n return i18n(DaysInWeek[time.second()]);\r\n case EdaPeriodType.Day:\r\n return time.format(\"HH:mm\");\r\n case EdaPeriodType.Interval:\r\n return time.format(fullMask);\r\n case EdaPeriodType.Year: {\r\n const year = time.year();\r\n\r\n switch (year) {\r\n case YearPeriodType.Quarter:\r\n return time.format(\"Q\");\r\n case YearPeriodType.Month:\r\n return time.format(\"MMMM\").replace(/^\\w/, (c) => c.toUpperCase());\r\n case YearPeriodType.Week:\r\n return String(time.second());\r\n case YearPeriodType.Day:\r\n return time.format(dateMask);\r\n }\r\n break;\r\n }\r\n }\r\n\r\n return \"Invalid\";\r\n}\r\n\r\nexport function getFormattedPeriodValue(valueType: EdaPeriodValueType, value: number, value2: number): string {\r\n switch (valueType) {\r\n case EdaPeriodValueType.Value:\r\n return String(value);\r\n case EdaPeriodValueType.CoefficientPlus:\r\n return `+(${value})`;\r\n case EdaPeriodValueType.CoefficientMul:\r\n return `*(${value})`;\r\n case EdaPeriodValueType.Interpolation:\r\n return `${value} ${i18n(\"To[Till]\")} ${value2}`;\r\n }\r\n}\r\n\r\nexport function toFullPeriodType(data: DescriptiveVector): FullPeriodType {\r\n switch (data.periodType as EdaPeriodType) {\r\n case EdaPeriodType.Base:\r\n return FullPeriodType.Base;\r\n case EdaPeriodType.Interval:\r\n return FullPeriodType.Interval;\r\n case EdaPeriodType.Week:\r\n return FullPeriodType.Week;\r\n case EdaPeriodType.Day:\r\n return FullPeriodType.Day;\r\n case EdaPeriodType.Year:\r\n switch (data.timeFrom.year()) {\r\n case 1972:\r\n return FullPeriodType.YearQuarter;\r\n case 1973:\r\n return FullPeriodType.YearMonth;\r\n case 1974:\r\n return FullPeriodType.YearWeek;\r\n case 1975:\r\n return FullPeriodType.YearDay;\r\n }\r\n }\r\n\r\n throw \"Invalid period type\";\r\n}\r\n\r\nexport function buildTable(data: DescriptiveVector[]): TableNode[] {\r\n const result: TableNode[] = [];\r\n\r\n for (let i = 0; i < data.length; i++) {\r\n let d = data[i];\r\n\r\n result.push({id: i, ...d});\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport function buildTree(data: DescriptiveVector[], fullMask: string, dateMask: string): TreeNode[] {\r\n const parentMap = new Map<number, DescriptiveVector[]>();\r\n\r\n for (const item of data) {\r\n const pId = item.parent ?? 0;\r\n\r\n if (!parentMap.has(pId)) {\r\n parentMap.set(pId, []);\r\n }\r\n\r\n parentMap.get(pId)!.push(item);\r\n }\r\n\r\n function recurse(parentId: number): TreeNode[] {\r\n const childrenData = parentMap.get(parentId) || [];\r\n return childrenData.map((d): TreeNode => {\r\n const children = recurse(d.idx);\r\n return {\r\n key: d.idx,\r\n title: getTitle(d, fullMask, dateMask),\r\n data: d,\r\n children: children,\r\n icon: !d.valid ? <FolderFilled /> : <FolderOutlined />,\r\n isLeaf: children.length === 0,\r\n };\r\n });\r\n }\r\n\r\n return recurse(0);\r\n}\r\n\r\nexport function getPeriodName(period: EdaPeriodType) {\r\n return i18n(\"EdaPeriodType_\" + EdaPeriodType[period]);\r\n}\r\n\r\nexport function canMove(data: DescriptiveVector[], selected: DescriptiveVector, direction: \"up\" | \"down\"): boolean {\r\n const branch = data.filter((d) => d.parent === selected.parent);\r\n const position = branch.findIndex((b) => b.idx === selected.idx);\r\n\r\n return direction === \"up\" ? position > 0 : position < branch.length - 1;\r\n}\r\n\r\nexport function reorder(data: DescriptiveVector[], selected: DescriptiveVector, direction: \"up\" | \"down\") {\r\n const result = [...data];\r\n const swapVector = getNextVector(data, selected, direction)!; // always can go UP or DOWN (otherwise button is disabled)\r\n const upperVector = direction === \"up\" ? swapVector : selected;\r\n const insertionIndex = result.findIndex((d) => d.idx === upperVector.idx);\r\n let branch: DescriptiveVector[];\r\n let swap: DescriptiveVector[];\r\n\r\n if (direction === \"up\") {\r\n branch = removeBranch(result, selected.idx);\r\n swap = removeBranch(result, swapVector.idx);\r\n result.splice(insertionIndex, 0, ...branch, ...swap);\r\n } else {\r\n swap = removeBranch(result, swapVector.idx);\r\n branch = removeBranch(result, selected.idx);\r\n result.splice(insertionIndex, 0, ...swap, ...branch);\r\n }\r\n\r\n return reindexData(result, selected);\r\n}\r\n\r\nexport function addEntry(data: DescriptiveVector[], selected?: DescriptiveVector): { data: DescriptiveVector[], selected?: DescriptiveVector } {\r\n const result = [...data];\r\n\r\n if (!selected) {\r\n result.push(getNewEntry(data.length + 1, 0));\r\n return {data: result, selected};\r\n }\r\n\r\n const selectedIndex = result.findIndex((d) => d.idx === selected.idx);\r\n let insertionIndex = selectedIndex + 1;\r\n\r\n while (insertionIndex < result.length && result[insertionIndex].parent >= selected.idx) {\r\n insertionIndex++;\r\n }\r\n\r\n const newEntry = getNewEntry(data.length + 1, selected.parent);\r\n\r\n result.splice(insertionIndex, 0, newEntry);\r\n return reindexData(result, selected);\r\n}\r\n\r\nexport function addSubEntry(data: DescriptiveVector[], selected: DescriptiveVector): { data: DescriptiveVector[], selected?: DescriptiveVector } {\r\n const result = [...data];\r\n const selectedIndex = result.findIndex((d) => d.idx === selected.idx);\r\n let insertionIndex = selectedIndex + 1;\r\n\r\n while (insertionIndex < result.length && result[insertionIndex].parent >= selected.idx) {\r\n insertionIndex++;\r\n }\r\n\r\n result.splice(insertionIndex, 0, getNewEntry(data.length + 1, selected.idx));\r\n return reindexData(result, selected);\r\n}\r\n\r\nexport function removeEntry(data: DescriptiveVector[], selected: DescriptiveVector): { data: DescriptiveVector[], selected?: DescriptiveVector } {\r\n const result = [...data];\r\n let next = getNextVector(data, selected, \"down\");\r\n\r\n if (!next) {\r\n next = getNextVector(data, selected, \"up\");\r\n }\r\n\r\n if (!next && selected.parent !== 0) {\r\n next = data.find((d) => d.idx === selected.parent);\r\n }\r\n\r\n removeBranch(result, selected.idx);\r\n return reindexData(result, next);\r\n}\r\n\r\nexport function removeSubEntries(data: DescriptiveVector[], selected: DescriptiveVector): { data: DescriptiveVector[], selected?: DescriptiveVector } {\r\n const result = [...data];\r\n const start = result.findIndex((d) => d.idx === selected.idx);\r\n let count = 0;\r\n\r\n while (start + 1 + count < result.length && result[start + 1 + count].parent >= selected.idx) {\r\n count++;\r\n }\r\n\r\n if (count > 0) {\r\n result.splice(start + 1, count);\r\n }\r\n\r\n return reindexData(result, selected);\r\n}\r\n\r\nexport function getOrigModifiedVectors() {\r\n return [\r\n {\r\n ID: 0,\r\n DisplayName: i18n(\"Original vector\"),\r\n Type: EdaVectorType.Change,\r\n RoundingType: EdaRoundingType.NoRounding,\r\n RoundingPlaces: 0,\r\n Name: \"OriginalVector\",\r\n },\r\n {\r\n ID: 1,\r\n DisplayName: i18n(\"Modified vector\"),\r\n Type: EdaVectorType.Change,\r\n RoundingType: EdaRoundingType.NoRounding,\r\n RoundingPlaces: 0,\r\n Name: \"ModifiedVector\",\r\n }\r\n ];\r\n}\r\n\r\nfunction getNewEntry(idx: number, parent: number): DescriptiveVector {\r\n return {\r\n idx,\r\n parent,\r\n value: 0,\r\n value2: 0,\r\n valid: true,\r\n valueType: EdaPeriodValueType.Value,\r\n supplement: 0,\r\n status: 0,\r\n periodType: EdaPeriodType.Base,\r\n timeFrom: dayjs().startOf('year'),\r\n timeTo: dayjs().endOf('year').millisecond(0),\r\n }\r\n}\r\n\r\nfunction removeBranch(data: DescriptiveVector[], idx: number) {\r\n const start = data.findIndex((d) => d.idx === idx);\r\n let count = 1;\r\n\r\n while (start + count < data.length && data[start + count].parent >= idx) {\r\n count++;\r\n }\r\n\r\n return data.splice(start, count);\r\n}\r\n\r\nfunction getTitle(data: DescriptiveVector, fullMask: string, dateMask: string): string {\r\n const from = getFormattedPeriodTime(data.periodType, data.timeFrom, fullMask, dateMask);\r\n const to = getFormattedPeriodTime(data.periodType, data.timeTo, fullMask, dateMask);\r\n let description = \"Invalid period type! \" + data.periodType;\r\n\r\n switch (data.periodType) {\r\n case EdaPeriodType.Base:\r\n description = getPeriodName(data.periodType);\r\n break;\r\n case EdaPeriodType.Week: {\r\n description = i18n(`%{from} To %{to}`, {from, to});\r\n break;\r\n }\r\n case EdaPeriodType.Day:\r\n description = i18n(\"Daily From %{from} To %{to}\", {from, to});\r\n break;\r\n case EdaPeriodType.Interval:\r\n description = i18n(\"From %{from} To %{to}\", {from, to});\r\n break;\r\n case EdaPeriodType.Year: {\r\n if (data.timeFrom.year() !== data.timeTo.year()) {\r\n break;\r\n }\r\n\r\n switch (data.timeFrom.year()) {\r\n case YearPeriodType.Quarter: {\r\n description = i18n(`%{from} To %{to}`, {from: `${from}. ${i18n(\"Quarter\")}`, to: `${to}. ${i18n(\"Quarter\")}`});\r\n break;\r\n }\r\n case YearPeriodType.Month: {\r\n description = i18n(`%{from} To %{to}`, {from: from, to: to});\r\n break;\r\n }\r\n case YearPeriodType.Week: {\r\n description = i18n(`%{from} To %{to}`, {from: `${from}.`, to: `${to}. ${i18n(\"Week\")}`});\r\n break;\r\n }\r\n case YearPeriodType.Day: {\r\n description = i18n(\"From %{from} To %{to}\", {from, to});\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n\r\n return `${description} => ${getFormattedPeriodValue(data.valueType, data.value, data.value2)}`;\r\n}\r\n\r\nfunction getNextVector(data: DescriptiveVector[], selected: DescriptiveVector, direction: \"up\" | \"down\"): DescriptiveVector | undefined {\r\n if ((direction === \"up\" && !canMove(data, selected, \"up\")) || (direction === \"down\" && !canMove(data, selected, \"down\"))) {\r\n return undefined;\r\n }\r\n\r\n const sameBranch = data.filter((d) => d.parent === selected.parent);\r\n const sameBranchIndex = sameBranch.findIndex((d) => d.idx === selected.idx);\r\n const swapIndex = direction === \"up\" ? sameBranchIndex - 1 : sameBranchIndex + 1;\r\n return sameBranch[swapIndex];\r\n}\r\n\r\nfunction reindexData(data: DescriptiveVector[], selected?: DescriptiveVector): { data: DescriptiveVector[], selected?: DescriptiveVector } {\r\n const idMap = new Map<number, number>();\r\n let updatedSelected: DescriptiveVector | undefined = selected;\r\n const reindexedResult = data.map((item, index) => {\r\n const newIdx = index + 1;\r\n idMap.set(item.idx, newIdx);\r\n\r\n const newItem = {...item, idx: newIdx};\r\n\r\n if (item.idx === selected?.idx) {\r\n updatedSelected = newItem;\r\n }\r\n\r\n return newItem;\r\n });\r\n const finalData = reindexedResult.map((item) => {\r\n if (item.parent && idMap.has(item.parent)) {\r\n const updatedItem = {...item, parent: idMap.get(item.parent)!};\r\n\r\n if (item.idx === updatedSelected?.idx) {\r\n updatedSelected = updatedItem;\r\n }\r\n\r\n return updatedItem;\r\n }\r\n return item;\r\n });\r\n\r\n return {data: finalData, selected: updatedSelected}\r\n}"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ModalDialogProps } from "d2coreui/components/modal/modalDialog";
|
|
3
|
+
import EdaManagerApi, { TreeItem } from "../../../../api/eda/edaManagerApi";
|
|
4
|
+
interface Props extends Omit<ModalDialogProps, "mode" | "onOk"> {
|
|
5
|
+
api: EdaManagerApi;
|
|
6
|
+
vector: TreeItem;
|
|
7
|
+
onSaved: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const EdaDescriptiveVectorEditorDialog: FC<Props>;
|
|
10
|
+
export {};
|