@trackunit/iris-app-runtime-core 0.3.97 → 0.3.100
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 +18 -18
- package/index.esm.js +18 -19
- package/package.json +1 -1
- package/src/CustomFieldRuntime.d.ts +5 -2
package/index.cjs.js
CHANGED
|
@@ -129,19 +129,19 @@ const CurrentUserRuntime = {
|
|
|
129
129
|
* @returns { CustomFieldValue } an updated CustomFieldValue
|
|
130
130
|
*/
|
|
131
131
|
const getCustomFieldValueToSaveFromRawValue = (customFieldDefinition, newValue) => {
|
|
132
|
-
if (customFieldDefinition.type ===
|
|
132
|
+
if (customFieldDefinition.type === "BOOLEAN") {
|
|
133
133
|
return {
|
|
134
134
|
booleanValue: newValue ? true : false,
|
|
135
|
-
type:
|
|
135
|
+
type: "BOOLEAN",
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
else if (customFieldDefinition.type ===
|
|
138
|
+
else if (customFieldDefinition.type === "DATE") {
|
|
139
139
|
return {
|
|
140
140
|
dateValue: newValue ? getDateValue(newValue) : null,
|
|
141
|
-
type:
|
|
141
|
+
type: "DATE",
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
else if (customFieldDefinition.type ===
|
|
144
|
+
else if (customFieldDefinition.type === "DROPDOWN") {
|
|
145
145
|
const stringArrayValue = [];
|
|
146
146
|
if (Array.isArray(newValue)) {
|
|
147
147
|
newValue.forEach(item => {
|
|
@@ -163,16 +163,16 @@ const getCustomFieldValueToSaveFromRawValue = (customFieldDefinition, newValue)
|
|
|
163
163
|
}
|
|
164
164
|
return {
|
|
165
165
|
stringArrayValue: stringArrayValue,
|
|
166
|
-
type:
|
|
166
|
+
type: "DROPDOWN",
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
else if (customFieldDefinition.type ===
|
|
169
|
+
else if (customFieldDefinition.type === "EMAIL") {
|
|
170
170
|
return {
|
|
171
171
|
stringValue: getStringValue(newValue),
|
|
172
|
-
type:
|
|
172
|
+
type: "EMAIL",
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
-
else if (customFieldDefinition.type ===
|
|
175
|
+
else if (customFieldDefinition.type === "NUMBER") {
|
|
176
176
|
let value = customFieldDefinition.isInteger
|
|
177
177
|
? parseInt(newValue)
|
|
178
178
|
: parseFloat(newValue);
|
|
@@ -181,31 +181,31 @@ const getCustomFieldValueToSaveFromRawValue = (customFieldDefinition, newValue)
|
|
|
181
181
|
}
|
|
182
182
|
return {
|
|
183
183
|
numberValue: value,
|
|
184
|
-
type:
|
|
184
|
+
type: "NUMBER",
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
-
else if (customFieldDefinition.type ===
|
|
187
|
+
else if (customFieldDefinition.type === "MONETARY") {
|
|
188
188
|
return {
|
|
189
189
|
numberValue: newValue,
|
|
190
|
-
type:
|
|
190
|
+
type: "MONETARY",
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
-
else if (customFieldDefinition.type ===
|
|
193
|
+
else if (customFieldDefinition.type === "PHONE_NUMBER") {
|
|
194
194
|
return {
|
|
195
195
|
stringValue: getStringValue(newValue),
|
|
196
|
-
type:
|
|
196
|
+
type: "PHONE_NUMBER",
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
else if (customFieldDefinition.type ===
|
|
199
|
+
else if (customFieldDefinition.type === "STRING") {
|
|
200
200
|
return {
|
|
201
201
|
stringValue: getStringValue(newValue),
|
|
202
|
-
type:
|
|
202
|
+
type: "STRING",
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
-
else if (customFieldDefinition.type ===
|
|
205
|
+
else if (customFieldDefinition.type === "WEB_ADDRESS") {
|
|
206
206
|
return {
|
|
207
207
|
stringValue: getStringValue(newValue),
|
|
208
|
-
type:
|
|
208
|
+
type: "WEB_ADDRESS",
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
211
|
throw new Error("Unsupported custom field type");
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CustomFieldType } from '@trackunit/iris-app-runtime-core-api';
|
|
2
1
|
export * from '@trackunit/iris-app-runtime-core-api';
|
|
3
2
|
import { connectToParent } from 'penpal';
|
|
4
3
|
|
|
@@ -126,19 +125,19 @@ const CurrentUserRuntime = {
|
|
|
126
125
|
* @returns { CustomFieldValue } an updated CustomFieldValue
|
|
127
126
|
*/
|
|
128
127
|
const getCustomFieldValueToSaveFromRawValue = (customFieldDefinition, newValue) => {
|
|
129
|
-
if (customFieldDefinition.type ===
|
|
128
|
+
if (customFieldDefinition.type === "BOOLEAN") {
|
|
130
129
|
return {
|
|
131
130
|
booleanValue: newValue ? true : false,
|
|
132
|
-
type:
|
|
131
|
+
type: "BOOLEAN",
|
|
133
132
|
};
|
|
134
133
|
}
|
|
135
|
-
else if (customFieldDefinition.type ===
|
|
134
|
+
else if (customFieldDefinition.type === "DATE") {
|
|
136
135
|
return {
|
|
137
136
|
dateValue: newValue ? getDateValue(newValue) : null,
|
|
138
|
-
type:
|
|
137
|
+
type: "DATE",
|
|
139
138
|
};
|
|
140
139
|
}
|
|
141
|
-
else if (customFieldDefinition.type ===
|
|
140
|
+
else if (customFieldDefinition.type === "DROPDOWN") {
|
|
142
141
|
const stringArrayValue = [];
|
|
143
142
|
if (Array.isArray(newValue)) {
|
|
144
143
|
newValue.forEach(item => {
|
|
@@ -160,16 +159,16 @@ const getCustomFieldValueToSaveFromRawValue = (customFieldDefinition, newValue)
|
|
|
160
159
|
}
|
|
161
160
|
return {
|
|
162
161
|
stringArrayValue: stringArrayValue,
|
|
163
|
-
type:
|
|
162
|
+
type: "DROPDOWN",
|
|
164
163
|
};
|
|
165
164
|
}
|
|
166
|
-
else if (customFieldDefinition.type ===
|
|
165
|
+
else if (customFieldDefinition.type === "EMAIL") {
|
|
167
166
|
return {
|
|
168
167
|
stringValue: getStringValue(newValue),
|
|
169
|
-
type:
|
|
168
|
+
type: "EMAIL",
|
|
170
169
|
};
|
|
171
170
|
}
|
|
172
|
-
else if (customFieldDefinition.type ===
|
|
171
|
+
else if (customFieldDefinition.type === "NUMBER") {
|
|
173
172
|
let value = customFieldDefinition.isInteger
|
|
174
173
|
? parseInt(newValue)
|
|
175
174
|
: parseFloat(newValue);
|
|
@@ -178,31 +177,31 @@ const getCustomFieldValueToSaveFromRawValue = (customFieldDefinition, newValue)
|
|
|
178
177
|
}
|
|
179
178
|
return {
|
|
180
179
|
numberValue: value,
|
|
181
|
-
type:
|
|
180
|
+
type: "NUMBER",
|
|
182
181
|
};
|
|
183
182
|
}
|
|
184
|
-
else if (customFieldDefinition.type ===
|
|
183
|
+
else if (customFieldDefinition.type === "MONETARY") {
|
|
185
184
|
return {
|
|
186
185
|
numberValue: newValue,
|
|
187
|
-
type:
|
|
186
|
+
type: "MONETARY",
|
|
188
187
|
};
|
|
189
188
|
}
|
|
190
|
-
else if (customFieldDefinition.type ===
|
|
189
|
+
else if (customFieldDefinition.type === "PHONE_NUMBER") {
|
|
191
190
|
return {
|
|
192
191
|
stringValue: getStringValue(newValue),
|
|
193
|
-
type:
|
|
192
|
+
type: "PHONE_NUMBER",
|
|
194
193
|
};
|
|
195
194
|
}
|
|
196
|
-
else if (customFieldDefinition.type ===
|
|
195
|
+
else if (customFieldDefinition.type === "STRING") {
|
|
197
196
|
return {
|
|
198
197
|
stringValue: getStringValue(newValue),
|
|
199
|
-
type:
|
|
198
|
+
type: "STRING",
|
|
200
199
|
};
|
|
201
200
|
}
|
|
202
|
-
else if (customFieldDefinition.type ===
|
|
201
|
+
else if (customFieldDefinition.type === "WEB_ADDRESS") {
|
|
203
202
|
return {
|
|
204
203
|
stringValue: getStringValue(newValue),
|
|
205
|
-
type:
|
|
204
|
+
type: "WEB_ADDRESS",
|
|
206
205
|
};
|
|
207
206
|
}
|
|
208
207
|
throw new Error("Unsupported custom field type");
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CustomFieldError, CustomFieldType, CustomFieldValue, EntityIdentity, UnitSiType, UnitUsType, ValueAndDefinition, ValueAndDefinitionKey } from "@trackunit/iris-app-runtime-core-api";
|
|
2
2
|
import { SystemOfMeasurementType } from "@trackunit/react-core-contexts-api";
|
|
3
3
|
export interface DropdownSelection {
|
|
4
4
|
value: string;
|
|
@@ -10,7 +10,10 @@ export interface DropdownSelection {
|
|
|
10
10
|
* @param newValue the new value to set
|
|
11
11
|
* @returns { CustomFieldValue } an updated CustomFieldValue
|
|
12
12
|
*/
|
|
13
|
-
export declare const getCustomFieldValueToSaveFromRawValue: (customFieldDefinition:
|
|
13
|
+
export declare const getCustomFieldValueToSaveFromRawValue: (customFieldDefinition: {
|
|
14
|
+
type: CustomFieldType;
|
|
15
|
+
isInteger?: boolean | null;
|
|
16
|
+
}, newValue: boolean | string | string[] | DropdownSelection[] | DropdownSelection | number) => CustomFieldValue;
|
|
14
17
|
/**
|
|
15
18
|
* Convert the received value to a string
|
|
16
19
|
*/
|