@trackunit/iris-app-runtime-core 0.3.70 → 0.3.72
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/index.cjs.js +13 -3
- package/index.esm.js +13 -3
- package/package.json +3 -3
- package/src/CustomFieldRuntime.d.ts +5 -2
package/index.cjs.js
CHANGED
|
@@ -546,7 +546,7 @@ const CurrentUserRuntime = {
|
|
|
546
546
|
* @param newValue the new value to set
|
|
547
547
|
* @returns { CustomFieldValue } an updated CustomFieldValue
|
|
548
548
|
*/
|
|
549
|
-
const
|
|
549
|
+
const getCustomFieldValueToSaveFromRawValue = (customFieldDefinition, newValue) => {
|
|
550
550
|
if (customFieldDefinition.type === irisAppRuntimeCoreApi.CustomFieldType.BOOLEAN) {
|
|
551
551
|
return {
|
|
552
552
|
booleanValue: newValue ? true : false,
|
|
@@ -666,7 +666,7 @@ const CustomFieldRuntime = {
|
|
|
666
666
|
if (found) {
|
|
667
667
|
values.push({
|
|
668
668
|
definitionKey: key,
|
|
669
|
-
value:
|
|
669
|
+
value: getCustomFieldValueToSaveFromRawValue(found, formData[key]),
|
|
670
670
|
});
|
|
671
671
|
}
|
|
672
672
|
else {
|
|
@@ -675,6 +675,16 @@ const CustomFieldRuntime = {
|
|
|
675
675
|
});
|
|
676
676
|
return api.setCustomFieldsFor(entity, values);
|
|
677
677
|
}),
|
|
678
|
+
getCustomFieldValueForDisplayInUI: (value, _unit, _systemOfMeasurement, language) => {
|
|
679
|
+
if (value === undefined || value === null || value === "") {
|
|
680
|
+
return "";
|
|
681
|
+
}
|
|
682
|
+
const numberValue = Number(value);
|
|
683
|
+
const numberAsString = numberValue > 9999
|
|
684
|
+
? Math.round(numberValue)
|
|
685
|
+
: new Intl.NumberFormat(language, { maximumSignificantDigits: 4, minimumSignificantDigits: 4 }).format(numberValue);
|
|
686
|
+
return numberAsString;
|
|
687
|
+
},
|
|
678
688
|
};
|
|
679
689
|
|
|
680
690
|
const EnvironmentRuntime = {
|
|
@@ -804,7 +814,7 @@ exports.SiteRuntime = SiteRuntime;
|
|
|
804
814
|
exports.ToastRuntime = ToastRuntime;
|
|
805
815
|
exports.TokenRuntime = TokenRuntime;
|
|
806
816
|
exports.UserSubscriptionRuntime = UserSubscriptionRuntime;
|
|
807
|
-
exports.
|
|
817
|
+
exports.getCustomFieldValueToSaveFromRawValue = getCustomFieldValueToSaveFromRawValue;
|
|
808
818
|
exports.getDateValue = getDateValue;
|
|
809
819
|
exports.getHostConnector = getHostConnector;
|
|
810
820
|
exports.getStringValue = getStringValue;
|
package/index.esm.js
CHANGED
|
@@ -543,7 +543,7 @@ const CurrentUserRuntime = {
|
|
|
543
543
|
* @param newValue the new value to set
|
|
544
544
|
* @returns { CustomFieldValue } an updated CustomFieldValue
|
|
545
545
|
*/
|
|
546
|
-
const
|
|
546
|
+
const getCustomFieldValueToSaveFromRawValue = (customFieldDefinition, newValue) => {
|
|
547
547
|
if (customFieldDefinition.type === CustomFieldType.BOOLEAN) {
|
|
548
548
|
return {
|
|
549
549
|
booleanValue: newValue ? true : false,
|
|
@@ -663,7 +663,7 @@ const CustomFieldRuntime = {
|
|
|
663
663
|
if (found) {
|
|
664
664
|
values.push({
|
|
665
665
|
definitionKey: key,
|
|
666
|
-
value:
|
|
666
|
+
value: getCustomFieldValueToSaveFromRawValue(found, formData[key]),
|
|
667
667
|
});
|
|
668
668
|
}
|
|
669
669
|
else {
|
|
@@ -672,6 +672,16 @@ const CustomFieldRuntime = {
|
|
|
672
672
|
});
|
|
673
673
|
return api.setCustomFieldsFor(entity, values);
|
|
674
674
|
}),
|
|
675
|
+
getCustomFieldValueForDisplayInUI: (value, _unit, _systemOfMeasurement, language) => {
|
|
676
|
+
if (value === undefined || value === null || value === "") {
|
|
677
|
+
return "";
|
|
678
|
+
}
|
|
679
|
+
const numberValue = Number(value);
|
|
680
|
+
const numberAsString = numberValue > 9999
|
|
681
|
+
? Math.round(numberValue)
|
|
682
|
+
: new Intl.NumberFormat(language, { maximumSignificantDigits: 4, minimumSignificantDigits: 4 }).format(numberValue);
|
|
683
|
+
return numberAsString;
|
|
684
|
+
},
|
|
675
685
|
};
|
|
676
686
|
|
|
677
687
|
const EnvironmentRuntime = {
|
|
@@ -786,4 +796,4 @@ const UserSubscriptionRuntime = {
|
|
|
786
796
|
}),
|
|
787
797
|
};
|
|
788
798
|
|
|
789
|
-
export { AnalyticsContextRuntime, AssetRuntime, AssetSortingRuntime, CurrentUserRuntime, CustomFieldRuntime, EnvironmentRuntime, GlobalSelectionRuntime, NavigationRuntime, OemBrandingContextRuntime, ParamsRuntime, RestRuntime, SiteRuntime, ToastRuntime, TokenRuntime, UserSubscriptionRuntime,
|
|
799
|
+
export { AnalyticsContextRuntime, AssetRuntime, AssetSortingRuntime, CurrentUserRuntime, CustomFieldRuntime, EnvironmentRuntime, GlobalSelectionRuntime, NavigationRuntime, OemBrandingContextRuntime, ParamsRuntime, RestRuntime, SiteRuntime, ToastRuntime, TokenRuntime, UserSubscriptionRuntime, getCustomFieldValueToSaveFromRawValue, getDateValue, getHostConnector, getStringValue, setupHostConnector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-runtime-core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.72",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"module": "./index.esm.js",
|
|
10
10
|
"main": "./index.cjs.js",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@trackunit/iris-app-runtime-core-api": "0.3.
|
|
13
|
-
"@trackunit/react-core-contexts-api": "0.2.
|
|
12
|
+
"@trackunit/iris-app-runtime-core-api": "0.3.65",
|
|
13
|
+
"@trackunit/react-core-contexts-api": "0.2.55"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {}
|
|
16
16
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { CustomFieldDefinition, CustomFieldError, CustomFieldValue, EntityIdentity, ValueAndDefinition, ValueAndDefinitionKey } from "@trackunit/iris-app-runtime-core-api";
|
|
1
|
+
import { CustomFieldDefinition, CustomFieldError, CustomFieldValue, EntityIdentity, UnitSiType, UnitUsType, ValueAndDefinition, ValueAndDefinitionKey } from "@trackunit/iris-app-runtime-core-api";
|
|
2
2
|
export interface DropdownSelection {
|
|
3
3
|
value: string;
|
|
4
4
|
}
|
|
5
|
+
/** System of measurement. */
|
|
6
|
+
export type SystemOfMeasurement = "SI" | "US_CUSTOMARY";
|
|
5
7
|
/**
|
|
6
8
|
* Get the value of a custom field from a raw value.
|
|
7
9
|
*
|
|
@@ -9,7 +11,7 @@ export interface DropdownSelection {
|
|
|
9
11
|
* @param newValue the new value to set
|
|
10
12
|
* @returns { CustomFieldValue } an updated CustomFieldValue
|
|
11
13
|
*/
|
|
12
|
-
export declare const
|
|
14
|
+
export declare const getCustomFieldValueToSaveFromRawValue: (customFieldDefinition: CustomFieldDefinition, newValue: boolean | string | string[] | DropdownSelection[] | DropdownSelection | number) => CustomFieldValue;
|
|
13
15
|
/**
|
|
14
16
|
* Convert the received value to a string
|
|
15
17
|
*/
|
|
@@ -23,5 +25,6 @@ export interface ICustomFieldRuntime {
|
|
|
23
25
|
getCustomFieldsFor: (entity: EntityIdentity) => Promise<ValueAndDefinition[]>;
|
|
24
26
|
setCustomFieldsFor: (entity: EntityIdentity, values: ValueAndDefinitionKey[]) => Promise<void | CustomFieldError>;
|
|
25
27
|
setCustomFieldsFromFormData: (entity: EntityIdentity, formData: Record<string, boolean | string | string[] | number>, originalDefinitions: ValueAndDefinition[]) => Promise<void | CustomFieldError>;
|
|
28
|
+
getCustomFieldValueForDisplayInUI: (value: number | string | null | undefined, unit: UnitUsType | UnitSiType | null | undefined, systemOfMeasurement?: SystemOfMeasurement, language?: string) => number | string | null | undefined;
|
|
26
29
|
}
|
|
27
30
|
export declare const CustomFieldRuntime: ICustomFieldRuntime;
|