bruce-models 1.9.1 → 1.9.3
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/dist/bruce-models.es5.js +73 -61
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +73 -61
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/calculator/calculator.js +71 -59
- package/dist/lib/calculator/calculator.js.map +1 -1
- package/dist/lib/project/project-view.js.map +1 -1
- package/dist/types/project/project-view.d.ts +4 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -2022,18 +2022,24 @@
|
|
|
2022
2022
|
* Needs to become ["Test", "Test1"].
|
|
2023
2023
|
* We need to cull this in admin-ui.
|
|
2024
2024
|
* @param path
|
|
2025
|
-
* @returns
|
|
2025
|
+
* @returns Possible paths this legacy one could mean.
|
|
2026
2026
|
*/
|
|
2027
2027
|
function parseLegacyPath(path) {
|
|
2028
2028
|
if (!path) {
|
|
2029
2029
|
return [];
|
|
2030
2030
|
}
|
|
2031
|
+
const paths = [];
|
|
2031
2032
|
if (path.startsWith("${") && path.endsWith("}")) {
|
|
2032
2033
|
path = path.replace("${", "");
|
|
2033
2034
|
path = path.replace("}", "");
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2035
|
+
// Split by dots.
|
|
2036
|
+
paths.push(exports.PathUtils.ParseLegacy(path));
|
|
2037
|
+
// Take string as is.
|
|
2038
|
+
paths.push([path]);
|
|
2039
|
+
}
|
|
2040
|
+
// Split by backslashes.
|
|
2041
|
+
paths.push(exports.PathUtils.Parse(path));
|
|
2042
|
+
return paths;
|
|
2037
2043
|
}
|
|
2038
2044
|
(function (Calculator) {
|
|
2039
2045
|
let EValueType;
|
|
@@ -2225,43 +2231,46 @@
|
|
|
2225
2231
|
}
|
|
2226
2232
|
Calculator.GetString = GetString;
|
|
2227
2233
|
function GetMappingValue(value, entity) {
|
|
2228
|
-
const
|
|
2229
|
-
let
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
const
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
if (mapSplit.length == 2) {
|
|
2244
|
-
const min = mapSplit[0];
|
|
2245
|
-
const max = mapSplit[1];
|
|
2246
|
-
if (min != "") {
|
|
2247
|
-
if (+eValue < +min) {
|
|
2248
|
-
continue;
|
|
2249
|
-
}
|
|
2234
|
+
const attrPaths = parseLegacyPath(value.field);
|
|
2235
|
+
for (let i = 0; i < attrPaths.length; i++) {
|
|
2236
|
+
const attrPath = attrPaths[i];
|
|
2237
|
+
let eValue = exports.Entity.GetValue({
|
|
2238
|
+
entity: entity,
|
|
2239
|
+
path: attrPath
|
|
2240
|
+
});
|
|
2241
|
+
const isValueNum = !isNaN(+eValue);
|
|
2242
|
+
for (let i = 0; i < value.values.length; i++) {
|
|
2243
|
+
const option = value.values[i];
|
|
2244
|
+
const mapValue = option.fieldValue;
|
|
2245
|
+
const isMapValueNum = !isNaN(+mapValue);
|
|
2246
|
+
if (isValueNum && isMapValueNum) {
|
|
2247
|
+
if (+mapValue == +eValue) {
|
|
2248
|
+
return option.appliedValue;
|
|
2250
2249
|
}
|
|
2251
|
-
|
|
2252
|
-
|
|
2250
|
+
const mapSplit = mapValue.split("-");
|
|
2251
|
+
if (mapSplit.length == 2) {
|
|
2252
|
+
const min = mapSplit[0];
|
|
2253
|
+
const max = mapSplit[1];
|
|
2254
|
+
if (min != "") {
|
|
2255
|
+
if (+eValue < +min) {
|
|
2256
|
+
continue;
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
if (max != "") {
|
|
2260
|
+
if (+eValue > +max) {
|
|
2261
|
+
continue;
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
if (min == "" && max == "") {
|
|
2253
2265
|
continue;
|
|
2254
2266
|
}
|
|
2267
|
+
return option.appliedValue;
|
|
2255
2268
|
}
|
|
2256
|
-
if (min == "" && max == "") {
|
|
2257
|
-
continue;
|
|
2258
|
-
}
|
|
2259
|
-
return option.appliedValue;
|
|
2260
2269
|
}
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2270
|
+
else {
|
|
2271
|
+
if (mapValue == eValue) {
|
|
2272
|
+
return option.appliedValue;
|
|
2273
|
+
}
|
|
2265
2274
|
}
|
|
2266
2275
|
}
|
|
2267
2276
|
}
|
|
@@ -2269,31 +2278,34 @@
|
|
|
2269
2278
|
}
|
|
2270
2279
|
Calculator.GetMappingValue = GetMappingValue;
|
|
2271
2280
|
function GetGradientValue(value, entity) {
|
|
2272
|
-
const
|
|
2273
|
-
let
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2281
|
+
const attrPaths = parseLegacyPath(value.field);
|
|
2282
|
+
for (let i = 0; i < attrPaths.length; i++) {
|
|
2283
|
+
const attrPath = attrPaths[i];
|
|
2284
|
+
let eValue = exports.Entity.GetValue({
|
|
2285
|
+
entity: entity,
|
|
2286
|
+
path: attrPath
|
|
2287
|
+
});
|
|
2288
|
+
eValue = Math.min(Math.max(eValue, value.min), value.max);
|
|
2289
|
+
if (eValue < value.points[0].position) {
|
|
2290
|
+
return exports.Color.ColorFromStr(value.points[0].color);
|
|
2291
|
+
}
|
|
2292
|
+
for (let i = 0; i < value.points.length - 1; i++) {
|
|
2293
|
+
const pointA = value.points[i];
|
|
2294
|
+
const pointB = value.points[i + 1];
|
|
2295
|
+
if (eValue >= pointA.position && eValue <= pointB.position) {
|
|
2296
|
+
if (pointA.position == pointB.position) {
|
|
2297
|
+
return exports.Color.ColorFromStr(pointA.color);
|
|
2298
|
+
}
|
|
2299
|
+
const distance = (eValue - pointA.position) / (pointB.position - pointA.position);
|
|
2300
|
+
const colorA = exports.Color.ColorFromStr(pointA.color);
|
|
2301
|
+
const colorB = exports.Color.ColorFromStr(pointB.color);
|
|
2302
|
+
return {
|
|
2303
|
+
red: colorA.red + (colorB.red - colorA.red) * distance,
|
|
2304
|
+
green: colorA.green + (colorB.green - colorA.green) * distance,
|
|
2305
|
+
blue: colorA.blue + (colorB.blue - colorA.blue) * distance,
|
|
2306
|
+
alpha: colorA.alpha + (colorB.alpha - colorA.alpha) * distance
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2297
2309
|
}
|
|
2298
2310
|
}
|
|
2299
2311
|
return exports.Color.ColorFromStr(value.points[value.points.length - 1].color);
|