mountain-ui 1.0.22 → 1.0.23
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mountain-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.23",
|
|
5
5
|
"description": "A comprehensive UI component library for ERP systems with field types, entities, and registry management built with Svelte",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "index.js",
|
package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/Input.svelte
CHANGED
|
@@ -29,53 +29,86 @@
|
|
|
29
29
|
const field1 = entityRegistry.selectField(column1);
|
|
30
30
|
const field2 = entityRegistry.selectField(column2);
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
let previousValue1 = Symbol();
|
|
33
|
+
let previousValue2 = Symbol();
|
|
34
|
+
|
|
35
|
+
function getFieldValue(field) {
|
|
36
|
+
if (!field) return null;
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
// Champ local
|
|
39
|
+
if (field.entity_id === entity_id) {
|
|
40
|
+
let v = ctx[field.id];
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
let value2 = raw2 ? parseFloat(raw2) : null;
|
|
42
|
+
if (v == null) return null;
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
v = parseFloat(v);
|
|
45
|
+
|
|
46
|
+
if (field.type === 'number-float-percent') {
|
|
47
|
+
v /= 100;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return isNaN(v) ? 0 : v;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
// Champ lié
|
|
54
|
+
const linkField = entityRegistry.getLinkedField(entity_id, field.entity_id);
|
|
55
|
+
|
|
56
|
+
if (!linkField) return null;
|
|
57
|
+
|
|
58
|
+
let v = detailsCtx[linkField.id]?.[field.normalized_name]?.flat;
|
|
59
|
+
|
|
60
|
+
if (v == null) return null;
|
|
61
|
+
|
|
62
|
+
v = parseFloat(v);
|
|
63
|
+
|
|
64
|
+
if (field.type === 'number-float-percent') {
|
|
65
|
+
v /= 100;
|
|
53
66
|
}
|
|
54
67
|
|
|
55
|
-
|
|
68
|
+
return isNaN(v) ? 0 : v;
|
|
69
|
+
}
|
|
56
70
|
|
|
57
|
-
|
|
58
|
-
if (
|
|
71
|
+
$effect(() => {
|
|
72
|
+
if (!$field1 || !$field2) return;
|
|
73
|
+
|
|
74
|
+
const value1 = getFieldValue($field1);
|
|
75
|
+
const value2 = getFieldValue($field2);
|
|
76
|
+
|
|
77
|
+
if (value1 === null || value2 === null) return;
|
|
78
|
+
|
|
79
|
+
if (
|
|
80
|
+
value1 === previousValue1 &&
|
|
81
|
+
value2 === previousValue2
|
|
82
|
+
) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
previousValue1 = value1;
|
|
87
|
+
previousValue2 = value2;
|
|
59
88
|
|
|
60
|
-
|
|
89
|
+
let result = null;
|
|
61
90
|
|
|
62
91
|
switch (operator) {
|
|
63
92
|
case '+':
|
|
64
|
-
|
|
93
|
+
result = value1 + value2;
|
|
65
94
|
break;
|
|
95
|
+
|
|
66
96
|
case '-':
|
|
67
|
-
|
|
97
|
+
result = value1 - value2;
|
|
68
98
|
break;
|
|
99
|
+
|
|
69
100
|
case '*':
|
|
70
|
-
|
|
101
|
+
result = value1 * value2;
|
|
71
102
|
break;
|
|
103
|
+
|
|
72
104
|
case '/':
|
|
73
|
-
|
|
105
|
+
result = value2 === 0 ? null : value1 / value2;
|
|
74
106
|
break;
|
|
75
107
|
}
|
|
76
108
|
|
|
77
|
-
if (
|
|
78
|
-
|
|
109
|
+
if (result !== value) {
|
|
110
|
+
value = result;
|
|
111
|
+
onChange(result);
|
|
79
112
|
}
|
|
80
113
|
});
|
|
81
114
|
|