@eric-emg/symphiq-components 1.2.283 → 1.2.285
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/symphiq-components.mjs +20 -4
- package/fesm2022/symphiq-components.mjs.map +1 -1
- package/index.d.ts +11 -11
- package/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2681,8 +2681,13 @@ function generateTargetsFromCalculations(shopId, calculations, existingTargets)
|
|
|
2681
2681
|
const endDate = getCurrentYearEnd();
|
|
2682
2682
|
return calculations.map((calc) => {
|
|
2683
2683
|
const existingTarget = existingTargets?.find(t => t.metric === calc.metric);
|
|
2684
|
+
if (existingTarget) {
|
|
2685
|
+
return {
|
|
2686
|
+
...existingTarget,
|
|
2687
|
+
amount: calc.targetValue
|
|
2688
|
+
};
|
|
2689
|
+
}
|
|
2684
2690
|
return {
|
|
2685
|
-
...(existingTarget?.id !== undefined && { id: existingTarget.id }),
|
|
2686
2691
|
shopId,
|
|
2687
2692
|
metric: calc.metric,
|
|
2688
2693
|
amount: calc.targetValue,
|
|
@@ -61686,9 +61691,20 @@ class InitialTargetSettingComponent {
|
|
|
61686
61691
|
const pendingChanges = this.pendingTargetChanges();
|
|
61687
61692
|
if (pendingChanges.size > 0) {
|
|
61688
61693
|
const calculations = this.displayedMetricCalculations();
|
|
61689
|
-
const existingTargets = this.targets();
|
|
61690
|
-
const
|
|
61691
|
-
|
|
61694
|
+
const existingTargets = this.targets() ?? [];
|
|
61695
|
+
const changedMetrics = new Set(pendingChanges.keys());
|
|
61696
|
+
const changedTargets = [];
|
|
61697
|
+
for (const metric of changedMetrics) {
|
|
61698
|
+
const existingTarget = existingTargets.find(t => t.metric === metric);
|
|
61699
|
+
const calc = calculations.find(c => c.metric === metric);
|
|
61700
|
+
if (existingTarget && calc) {
|
|
61701
|
+
changedTargets.push({
|
|
61702
|
+
...existingTarget,
|
|
61703
|
+
amount: calc.targetValue
|
|
61704
|
+
});
|
|
61705
|
+
}
|
|
61706
|
+
}
|
|
61707
|
+
this.targetsUpdated.emit(changedTargets);
|
|
61692
61708
|
this.pendingTargetChanges.set(new Map());
|
|
61693
61709
|
}
|
|
61694
61710
|
this.saveTargetsClick.emit();
|