blixify-ui-web 1.2.260 → 1.2.261
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/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +62 -27
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/updateModule.d.ts +20 -2
- package/lib/components/data/updateModule.d.ts.map +1 -1
- package/lib/components/data/updateModule.js +155 -58
- package/lib/components/data/updateModule.js.map +1 -1
- package/lib/components/display/newTable/index.d.ts.map +1 -1
- package/lib/components/display/newTable/index.js +218 -119
- package/lib/components/display/newTable/index.js.map +1 -1
- package/lib/components/display/recordActions/index.d.ts.map +1 -1
- package/lib/components/display/recordActions/index.js +25 -21
- package/lib/components/display/recordActions/index.js.map +1 -1
- package/lib/tail.css +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
2
|
import { DataStructure, DevSettings, ServerType } from "./dataTemplate/model";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* INFO: isUpdate marks a record that already exists — one being edited or
|
|
5
|
+
* saved, not one being created. A default (defaultValue) and the fills a
|
|
6
|
+
* required field gets (a date's "now", a list's first option) prefill a new
|
|
7
|
+
* record only. On an existing record a field the user emptied stays empty: an
|
|
8
|
+
* emptied date is saved as null rather than left undefined, which a request
|
|
9
|
+
* drops, so the old date was never removed. A date the record never had is
|
|
10
|
+
* still left out. Space's server-side copy of these rules
|
|
11
|
+
* (handleCastSubmitField in blixify-space-next) already keeps a cleared value
|
|
12
|
+
* on update.
|
|
13
|
+
*/
|
|
14
|
+
export declare const handleCastDataAttribute: (model: DataStructure, value: any, clonedSelectedData: any, server: ServerType, force?: boolean, isUpdate?: boolean) => void;
|
|
15
|
+
export declare const handleClonedDataAttribute: (selectedData: any, model: DataStructure[], server: ServerType, force?: boolean, isRemainId?: boolean, isUpdate?: boolean) => any;
|
|
5
16
|
export declare const handleRetrieveReferenceOptions: (selectedData: any, model: DataStructure[], dbModule: any, devSettings: DevSettings, setReferencesOptions: (options: any) => void, setReferencesDetails: (options: any) => void, skipOptionsFetch?: boolean) => Promise<void>;
|
|
6
17
|
export declare const handleCheckReferenceOptions: (selectedData: any, eachModel: DataStructure, prefix?: string, listObject?: boolean, listObjectParentData?: any) => any;
|
|
7
18
|
export declare const handleRetrieveObjectReferenceOptions: (eachModel: DataStructure, referencesOptions: any, referenceDetails: any, selectedData: any, dbModule: any, devSettings?: DevSettings, prefix?: string, listObject?: boolean, listObjectParentData?: any, searchText?: string, skipOptionsFetch?: boolean) => Promise<any>;
|
|
@@ -30,10 +41,17 @@ export declare const renderDataTemplateForm: (data: any, model: DataStructure[],
|
|
|
30
41
|
fill?: boolean;
|
|
31
42
|
/** INFO: a date picker opens as it mounts; see CellInput.openOnMount */
|
|
32
43
|
openOnMount?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* INFO: the cell edits a saved row, not the add row — its emptied values
|
|
46
|
+
* are not prefilled with defaults (see handleCastDataAttribute)
|
|
47
|
+
*/
|
|
48
|
+
isUpdate?: boolean;
|
|
33
49
|
}, props?: {
|
|
34
50
|
id?: string;
|
|
35
51
|
isObject?: boolean;
|
|
36
52
|
isObjectList?: boolean;
|
|
53
|
+
/** INFO: the form edits a saved record — see handleCastDataAttribute */
|
|
54
|
+
isUpdate?: boolean;
|
|
37
55
|
lib?: any;
|
|
38
56
|
type?: string;
|
|
39
57
|
showId?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateModule.d.ts","sourceRoot":"","sources":["../../../src/components/data/updateModule.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAiC5C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"updateModule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,KACjB,IAAI,CAAC;IACV,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC,mBACgB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,GAAG,CAAA;CAAE,WAC7C,OAAO,YACN,OAAO,eACJ,KAAK,GAAG,KAAK,GAAG,MAAM,kCACH,CAC9B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,GAAG,EACR,YAAY,EAAE,GAAG,EACjB,eAAe,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,KACjC,YAAY,GAAG,IAAI,eACX,OAAO,uBAKC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,sBAuhE3D,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAAc,GAAG,eAAe,GAAG;;;;;CAoBnE,CAAC"}
|
|
@@ -146,18 +146,93 @@ var deepCloneWithFiles = function (obj) {
|
|
|
146
146
|
}
|
|
147
147
|
return obj;
|
|
148
148
|
};
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
// INFO: a Monday date column read as its raw value (a column the server's
|
|
150
|
+
// modelType().read lists) — '{"date":"2026-11-17","time":"02:25:49",...}',
|
|
151
|
+
// as a JSON string or already parsed. Monday keeps the time in UTC; a date
|
|
152
|
+
// without a time is read as that day, like the column's text.
|
|
153
|
+
var handleParseMondayDate = function (raw) {
|
|
154
|
+
var mondayValue = raw;
|
|
155
|
+
if (typeof raw === "string") {
|
|
156
|
+
if (!raw.trim().startsWith("{"))
|
|
157
|
+
return undefined;
|
|
158
|
+
try {
|
|
159
|
+
mondayValue = JSON.parse(raw);
|
|
160
|
+
}
|
|
161
|
+
catch (_a) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (typeof (mondayValue === null || mondayValue === void 0 ? void 0 : mondayValue.date) !== "string")
|
|
166
|
+
return undefined;
|
|
167
|
+
return mondayValue.time
|
|
168
|
+
? (0, dayjs_1.default)("".concat(mondayValue.date, "T").concat(mondayValue.time, "Z"))
|
|
169
|
+
: (0, dayjs_1.default)(mondayValue.date);
|
|
170
|
+
};
|
|
171
|
+
// INFO: a stored date as a Date, or undefined when it holds no valid date. A
|
|
172
|
+
// Firestore timestamp is an object dayjs cannot read: through fbServer it
|
|
173
|
+
// arrives as { _seconds, _nanoseconds }, and through the firebase client as a
|
|
174
|
+
// Timestamp ({ seconds, nanoseconds, toDate() }). A Monday date can arrive as
|
|
175
|
+
// its raw JSON value (handleParseMondayDate).
|
|
176
|
+
var handleCastStoredDate = function (raw) {
|
|
177
|
+
var _a;
|
|
178
|
+
if (!raw)
|
|
179
|
+
return undefined;
|
|
180
|
+
var parsed;
|
|
181
|
+
if (typeof (raw === null || raw === void 0 ? void 0 : raw.toDate) === "function")
|
|
182
|
+
parsed = (0, dayjs_1.default)(raw.toDate());
|
|
183
|
+
else if (typeof (raw === null || raw === void 0 ? void 0 : raw._seconds) === "number")
|
|
184
|
+
parsed = (0, dayjs_1.default)(raw._seconds * 1000);
|
|
185
|
+
else if (typeof (raw === null || raw === void 0 ? void 0 : raw.seconds) === "number")
|
|
186
|
+
parsed = (0, dayjs_1.default)(raw.seconds * 1000);
|
|
187
|
+
else
|
|
188
|
+
parsed = (_a = handleParseMondayDate(raw)) !== null && _a !== void 0 ? _a : (0, dayjs_1.default)(raw);
|
|
189
|
+
return parsed.isValid() ? parsed.toDate() : undefined;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* INFO: isUpdate marks a record that already exists — one being edited or
|
|
193
|
+
* saved, not one being created. A default (defaultValue) and the fills a
|
|
194
|
+
* required field gets (a date's "now", a list's first option) prefill a new
|
|
195
|
+
* record only. On an existing record a field the user emptied stays empty: an
|
|
196
|
+
* emptied date is saved as null rather than left undefined, which a request
|
|
197
|
+
* drops, so the old date was never removed. A date the record never had is
|
|
198
|
+
* still left out. Space's server-side copy of these rules
|
|
199
|
+
* (handleCastSubmitField in blixify-space-next) already keeps a cleared value
|
|
200
|
+
* on update.
|
|
201
|
+
*/
|
|
202
|
+
var handleCastDataAttribute = function (model, value, clonedSelectedData, server, force, isUpdate) {
|
|
203
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
204
|
+
// INFO: what a new record is prefilled with — never an existing one
|
|
205
|
+
var prefillDefault = isUpdate ? undefined : model.defaultValue;
|
|
151
206
|
switch (model.type) {
|
|
152
207
|
case "string":
|
|
153
208
|
case "email":
|
|
154
209
|
case "contact":
|
|
155
210
|
case "markdown":
|
|
156
211
|
case "textArea":
|
|
157
|
-
if (
|
|
158
|
-
clonedSelectedData[model.id] = (_a = value[model.id]) !== null && _a !== void 0 ? _a :
|
|
212
|
+
if (prefillDefault)
|
|
213
|
+
clonedSelectedData[model.id] = (_a = value[model.id]) !== null && _a !== void 0 ? _a : prefillDefault;
|
|
159
214
|
break;
|
|
160
215
|
case "date":
|
|
216
|
+
if (isUpdate) {
|
|
217
|
+
var rawDate = value[model.id];
|
|
218
|
+
var storedDate = handleCastStoredDate(rawDate);
|
|
219
|
+
var hasField = Object.prototype.hasOwnProperty.call(value, model.id);
|
|
220
|
+
if (storedDate)
|
|
221
|
+
clonedSelectedData[model.id] = storedDate;
|
|
222
|
+
// INFO: an emptied date — the picker's Clear (undefined) or a cell's
|
|
223
|
+
// "x" (null) — is null on a save, so the request carries it, and
|
|
224
|
+
// undefined while editing, so the picker shows it empty
|
|
225
|
+
else if (hasField && (rawDate === null || rawDate === undefined))
|
|
226
|
+
clonedSelectedData[model.id] = force ? null : undefined;
|
|
227
|
+
// INFO: anything else is left out of the request, so the stored value
|
|
228
|
+
// stays as it is: a date the record never had (adding the key would
|
|
229
|
+
// read as emptied on the next save), a stored "" (a Monday column's
|
|
230
|
+
// empty text) and a value this cannot read as a date — a format not
|
|
231
|
+
// handled here is never mistaken for a cleared date and wiped
|
|
232
|
+
else
|
|
233
|
+
delete clonedSelectedData[model.id];
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
161
236
|
var prefillDate = false;
|
|
162
237
|
if (!model.optional || model.defaultValue)
|
|
163
238
|
prefillDate = true;
|
|
@@ -199,7 +274,7 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
199
274
|
clonedSelectedData[model.id] = false;
|
|
200
275
|
}
|
|
201
276
|
}
|
|
202
|
-
else if (
|
|
277
|
+
else if (prefillDefault) {
|
|
203
278
|
if (model.enableCheckbox) {
|
|
204
279
|
if (String(value[model.id]) === "true")
|
|
205
280
|
clonedSelectedData[model.id] = true;
|
|
@@ -207,7 +282,7 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
207
282
|
clonedSelectedData[model.id] = false;
|
|
208
283
|
else
|
|
209
284
|
clonedSelectedData[model.id] =
|
|
210
|
-
|
|
285
|
+
prefillDefault === "true" ? true : false;
|
|
211
286
|
}
|
|
212
287
|
else {
|
|
213
288
|
if (String(value[model.id]) === "true")
|
|
@@ -215,20 +290,22 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
215
290
|
else if (String(value[model.id]) === "false")
|
|
216
291
|
clonedSelectedData[model.id] = "false";
|
|
217
292
|
else
|
|
218
|
-
clonedSelectedData[model.id] = String(
|
|
293
|
+
clonedSelectedData[model.id] = String(prefillDefault);
|
|
219
294
|
}
|
|
220
295
|
}
|
|
221
296
|
break;
|
|
222
297
|
case "number":
|
|
298
|
+
// INFO: an existing record's number is never prefilled — an emptied one
|
|
299
|
+
// is null, where the prefill branch read "" as 0
|
|
223
300
|
var prefillNumber = false;
|
|
224
|
-
if (!model.optional ||
|
|
301
|
+
if (!isUpdate && (!model.optional || prefillDefault))
|
|
225
302
|
prefillNumber = true;
|
|
226
303
|
if (prefillNumber) {
|
|
227
304
|
if (value[model.id] ||
|
|
228
305
|
(value[model.id] !== null && value[model.id] !== undefined))
|
|
229
306
|
clonedSelectedData[model.id] = Number(value[model.id]);
|
|
230
|
-
else if (
|
|
231
|
-
clonedSelectedData[model.id] = Number(
|
|
307
|
+
else if (prefillDefault)
|
|
308
|
+
clonedSelectedData[model.id] = Number(prefillDefault);
|
|
232
309
|
else
|
|
233
310
|
clonedSelectedData[model.id] = null;
|
|
234
311
|
}
|
|
@@ -244,28 +321,29 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
244
321
|
break;
|
|
245
322
|
case "address":
|
|
246
323
|
clonedSelectedData[model.id] = (_d = value[model.id]) !== null && _d !== void 0 ? _d : {
|
|
247
|
-
lat: (
|
|
248
|
-
lng: (
|
|
249
|
-
name: (
|
|
250
|
-
country: (
|
|
251
|
-
state: (
|
|
252
|
-
district: (
|
|
324
|
+
lat: (_e = prefillDefault === null || prefillDefault === void 0 ? void 0 : prefillDefault.lat) !== null && _e !== void 0 ? _e : 0,
|
|
325
|
+
lng: (_f = prefillDefault === null || prefillDefault === void 0 ? void 0 : prefillDefault.lng) !== null && _f !== void 0 ? _f : 0,
|
|
326
|
+
name: (_g = prefillDefault === null || prefillDefault === void 0 ? void 0 : prefillDefault.name) !== null && _g !== void 0 ? _g : "",
|
|
327
|
+
country: (_h = prefillDefault === null || prefillDefault === void 0 ? void 0 : prefillDefault.country) !== null && _h !== void 0 ? _h : "",
|
|
328
|
+
state: (_j = prefillDefault === null || prefillDefault === void 0 ? void 0 : prefillDefault.state) !== null && _j !== void 0 ? _j : "",
|
|
329
|
+
district: (_k = prefillDefault === null || prefillDefault === void 0 ? void 0 : prefillDefault.district) !== null && _k !== void 0 ? _k : "",
|
|
253
330
|
};
|
|
254
331
|
break;
|
|
255
332
|
case "list":
|
|
256
333
|
case "multipleList":
|
|
257
|
-
var listSelection = (
|
|
334
|
+
var listSelection = (_l = model.listSelection) !== null && _l !== void 0 ? _l : [];
|
|
258
335
|
if (listSelection.length > 0) {
|
|
259
336
|
var selectedDefaultValue = model.type === "list" ? listSelection[0] : [listSelection[0]];
|
|
260
337
|
var defaultValue = model.type === "list" ? "" : [];
|
|
261
338
|
var prefillValue_1;
|
|
262
|
-
if (
|
|
263
|
-
prefillValue_1 =
|
|
264
|
-
|
|
339
|
+
if (prefillDefault)
|
|
340
|
+
prefillValue_1 = prefillDefault;
|
|
341
|
+
// INFO: an existing record's empty list is not given its first option
|
|
342
|
+
else if (model.optional || model.disabledAutoSelect || isUpdate)
|
|
265
343
|
prefillValue_1 = defaultValue;
|
|
266
344
|
else
|
|
267
345
|
prefillValue_1 = selectedDefaultValue;
|
|
268
|
-
var resolvedValue = (
|
|
346
|
+
var resolvedValue = (_m = value[model.id]) !== null && _m !== void 0 ? _m : prefillValue_1;
|
|
269
347
|
// INFO: For multipleList, ensure value is always an array
|
|
270
348
|
if (model.type === "multipleList" && resolvedValue !== undefined) {
|
|
271
349
|
if (!Array.isArray(resolvedValue)) {
|
|
@@ -278,36 +356,36 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
278
356
|
case "person":
|
|
279
357
|
case "listPerson":
|
|
280
358
|
var prefillValue = void 0;
|
|
281
|
-
if (
|
|
282
|
-
prefillValue =
|
|
359
|
+
if (prefillDefault)
|
|
360
|
+
prefillValue = prefillDefault;
|
|
283
361
|
else if (!model.optional)
|
|
284
362
|
prefillValue = model.type === "listPerson" ? [] : "";
|
|
285
|
-
clonedSelectedData[model.id] = (
|
|
363
|
+
clonedSelectedData[model.id] = (_o = value[model.id]) !== null && _o !== void 0 ? _o : prefillValue;
|
|
286
364
|
break;
|
|
287
365
|
case "roles":
|
|
288
366
|
var rolesValue = void 0;
|
|
289
|
-
if (
|
|
290
|
-
rolesValue =
|
|
367
|
+
if (prefillDefault)
|
|
368
|
+
rolesValue = prefillDefault;
|
|
291
369
|
else if (!model.optional)
|
|
292
370
|
rolesValue = [];
|
|
293
|
-
clonedSelectedData[model.id] = (
|
|
371
|
+
clonedSelectedData[model.id] = (_p = value[model.id]) !== null && _p !== void 0 ? _p : rolesValue;
|
|
294
372
|
break;
|
|
295
373
|
case "listObject":
|
|
296
|
-
clonedSelectedData[model.id] = (
|
|
374
|
+
clonedSelectedData[model.id] = (_q = value[model.id]) !== null && _q !== void 0 ? _q : [];
|
|
297
375
|
break;
|
|
298
376
|
case "listAddress":
|
|
299
|
-
clonedSelectedData[model.id] = (
|
|
377
|
+
clonedSelectedData[model.id] = (_r = value[model.id]) !== null && _r !== void 0 ? _r : [];
|
|
300
378
|
break;
|
|
301
379
|
case "object":
|
|
302
380
|
if (force)
|
|
303
|
-
clonedSelectedData[model.id] = (
|
|
381
|
+
clonedSelectedData[model.id] = (_s = value[model.id]) !== null && _s !== void 0 ? _s : {};
|
|
304
382
|
else
|
|
305
383
|
clonedSelectedData[model.id] = value[model.id];
|
|
306
384
|
break;
|
|
307
385
|
case "image":
|
|
308
386
|
case "file":
|
|
309
|
-
if (
|
|
310
|
-
clonedSelectedData[model.id] = (
|
|
387
|
+
if (prefillDefault)
|
|
388
|
+
clonedSelectedData[model.id] = (_t = value[model.id]) !== null && _t !== void 0 ? _t : prefillDefault;
|
|
311
389
|
else
|
|
312
390
|
clonedSelectedData[model.id] = value[model.id];
|
|
313
391
|
break;
|
|
@@ -346,8 +424,8 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
346
424
|
else if (value[model.id] instanceof Object) {
|
|
347
425
|
clonedSelectedData[model.id] = value[model.id];
|
|
348
426
|
}
|
|
349
|
-
else if (
|
|
350
|
-
clonedSelectedData[model.id] =
|
|
427
|
+
else if (prefillDefault) {
|
|
428
|
+
clonedSelectedData[model.id] = prefillDefault;
|
|
351
429
|
}
|
|
352
430
|
else
|
|
353
431
|
clonedSelectedData[model.id] = {
|
|
@@ -357,14 +435,14 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
357
435
|
};
|
|
358
436
|
break;
|
|
359
437
|
case "reference":
|
|
360
|
-
if (
|
|
361
|
-
clonedSelectedData[model.id] = (
|
|
438
|
+
if (prefillDefault)
|
|
439
|
+
clonedSelectedData[model.id] = (_u = value[model.id]) !== null && _u !== void 0 ? _u : prefillDefault;
|
|
362
440
|
if (force && value[model.id] === "others")
|
|
363
441
|
clonedSelectedData[model.id] = undefined;
|
|
364
442
|
break;
|
|
365
443
|
case "listReference":
|
|
366
|
-
if (
|
|
367
|
-
clonedSelectedData[model.id] = (
|
|
444
|
+
if (prefillDefault)
|
|
445
|
+
clonedSelectedData[model.id] = (_v = value[model.id]) !== null && _v !== void 0 ? _v : prefillDefault;
|
|
368
446
|
if (force && value[model.id] && Array.isArray(value[model.id]))
|
|
369
447
|
clonedSelectedData[model.id] = value[model.id].filter(function (eachVal) { return eachVal !== "others"; });
|
|
370
448
|
break;
|
|
@@ -373,8 +451,8 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
373
451
|
var useNewFormat = model.enableDraw || model.enableImageUpload;
|
|
374
452
|
if (useNewFormat) {
|
|
375
453
|
// New format: normalize to { texts: [], drawings: [], backgroundImage?: { fileName, token } }
|
|
376
|
-
if (
|
|
377
|
-
var defaultValue =
|
|
454
|
+
if (prefillDefault) {
|
|
455
|
+
var defaultValue = prefillDefault;
|
|
378
456
|
clonedSelectedData[model.id] =
|
|
379
457
|
Array.isArray(defaultValue) || !defaultValue
|
|
380
458
|
? { texts: defaultValue !== null && defaultValue !== void 0 ? defaultValue : [], drawings: [] }
|
|
@@ -391,15 +469,15 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
391
469
|
}
|
|
392
470
|
else {
|
|
393
471
|
// Old format: keep as texts[] array
|
|
394
|
-
if (
|
|
395
|
-
clonedSelectedData[model.id] = (
|
|
472
|
+
if (prefillDefault)
|
|
473
|
+
clonedSelectedData[model.id] = (_w = value[model.id]) !== null && _w !== void 0 ? _w : prefillDefault;
|
|
396
474
|
else
|
|
397
475
|
clonedSelectedData[model.id] = value[model.id];
|
|
398
476
|
}
|
|
399
477
|
break;
|
|
400
478
|
case "ganttchart":
|
|
401
|
-
if (
|
|
402
|
-
clonedSelectedData[model.id] = (
|
|
479
|
+
if (prefillDefault)
|
|
480
|
+
clonedSelectedData[model.id] = (_x = value[model.id]) !== null && _x !== void 0 ? _x : prefillDefault;
|
|
403
481
|
else
|
|
404
482
|
clonedSelectedData[model.id] = value[model.id];
|
|
405
483
|
// Convert date strings to Date objects for gantt tasks
|
|
@@ -419,14 +497,16 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
|
|
|
419
497
|
}
|
|
420
498
|
};
|
|
421
499
|
exports.handleCastDataAttribute = handleCastDataAttribute;
|
|
422
|
-
var handleClonedDataAttribute = function (selectedData, model, server, force, isRemainId
|
|
500
|
+
var handleClonedDataAttribute = function (selectedData, model, server, force, isRemainId,
|
|
501
|
+
// INFO: the record already exists — see handleCastDataAttribute
|
|
502
|
+
isUpdate) {
|
|
423
503
|
var defaultValue = selectedData;
|
|
424
504
|
var clonedSelectedData = deepCloneWithFiles(selectedData);
|
|
425
505
|
model.map(function (eachAttribute) {
|
|
426
506
|
if (eachAttribute.id === "_id" || eachAttribute.id === "id") {
|
|
427
507
|
return null;
|
|
428
508
|
}
|
|
429
|
-
(0, exports.handleCastDataAttribute)(eachAttribute, defaultValue, clonedSelectedData, server, force);
|
|
509
|
+
(0, exports.handleCastDataAttribute)(eachAttribute, defaultValue, clonedSelectedData, server, force, isUpdate);
|
|
430
510
|
return null;
|
|
431
511
|
});
|
|
432
512
|
if (!isRemainId) {
|
|
@@ -516,7 +596,7 @@ var handleRetrieveReferenceOptions = function (selectedData, model, dbModule, de
|
|
|
516
596
|
}); };
|
|
517
597
|
exports.handleRetrieveReferenceOptions = handleRetrieveReferenceOptions;
|
|
518
598
|
var handleCheckReferenceOptions = function (selectedData, eachModel, prefix, listObject, listObjectParentData) {
|
|
519
|
-
var _a;
|
|
599
|
+
var _a, _b;
|
|
520
600
|
var selectedDataValue = [];
|
|
521
601
|
if (Array.isArray(selectedData)) {
|
|
522
602
|
selectedData.forEach(function (eachData) {
|
|
@@ -540,10 +620,12 @@ var handleCheckReferenceOptions = function (selectedData, eachModel, prefix, lis
|
|
|
540
620
|
selectedDataValue = selectedData[prefix !== null && prefix !== void 0 ? prefix : ""];
|
|
541
621
|
else if (prefix)
|
|
542
622
|
selectedDataValue = selectedData[prefix][eachModel.id];
|
|
543
|
-
|
|
544
|
-
|
|
623
|
+
// INFO: the record's own pick first — the default is only what a new
|
|
624
|
+
// record starts with, so an edited one loaded the default's label
|
|
625
|
+
// instead of its own
|
|
545
626
|
else
|
|
546
|
-
selectedDataValue =
|
|
627
|
+
selectedDataValue =
|
|
628
|
+
(_a = selectedData[eachModel.id]) !== null && _a !== void 0 ? _a : eachModel.defaultValue;
|
|
547
629
|
// INFO : Prevent Reference Object Being Push into Options
|
|
548
630
|
if (typeof selectedDataValue === "object" &&
|
|
549
631
|
!Array.isArray(selectedDataValue))
|
|
@@ -552,7 +634,7 @@ var handleCheckReferenceOptions = function (selectedData, eachModel, prefix, lis
|
|
|
552
634
|
catch (err) { }
|
|
553
635
|
}
|
|
554
636
|
if (prefix && listObjectParentData) {
|
|
555
|
-
var listParentData = (
|
|
637
|
+
var listParentData = (_b = listObjectParentData === null || listObjectParentData === void 0 ? void 0 : listObjectParentData[prefix]) !== null && _b !== void 0 ? _b : [];
|
|
556
638
|
listParentData.map(function (eachListData) {
|
|
557
639
|
var currentValue = eachListData[eachModel.id];
|
|
558
640
|
if (currentValue) {
|
|
@@ -830,7 +912,9 @@ var handleQueryDependsCondition = function (data, query) {
|
|
|
830
912
|
var handleIsFieldRequired = function (model, data) {
|
|
831
913
|
var isRequiredWhen = !!model.requiredWhen &&
|
|
832
914
|
model.requiredWhen.length > 0 &&
|
|
833
|
-
model.requiredWhen.some(function (query) {
|
|
915
|
+
model.requiredWhen.some(function (query) {
|
|
916
|
+
return handleQueryDependsCondition(data, query);
|
|
917
|
+
});
|
|
834
918
|
return isRequiredWhen || !model.optional;
|
|
835
919
|
};
|
|
836
920
|
exports.handleIsFieldRequired = handleIsFieldRequired;
|
|
@@ -1327,7 +1411,7 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
|
|
|
1327
1411
|
// unavailable (iOS WKWebView). Keyed by columnId so the app can decide which
|
|
1328
1412
|
// field scans what, or ignore the id. The library holds no native dependency.
|
|
1329
1413
|
barcodeScanRequest) {
|
|
1330
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1414
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1331
1415
|
var inputList = {};
|
|
1332
1416
|
var formInputRefList = {};
|
|
1333
1417
|
var staticList = {};
|
|
@@ -1342,7 +1426,17 @@ barcodeScanRequest) {
|
|
|
1342
1426
|
//INFO - Default Model Contain Id While Object Type Don't have
|
|
1343
1427
|
return eachAttribute.id !== "_id" && eachAttribute.id !== "id";
|
|
1344
1428
|
});
|
|
1345
|
-
|
|
1429
|
+
// INFO: a saved record — a table cell of a saved row, or a form its host
|
|
1430
|
+
// marks as editing a saved record (props.isUpdate; a host that does not say
|
|
1431
|
+
// falls back to an id other than "new") — shows its empty fields empty
|
|
1432
|
+
// rather than prefilled with defaults. An object form adds a new item, so it
|
|
1433
|
+
// keeps its prefill.
|
|
1434
|
+
var isUpdateData = (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active)
|
|
1435
|
+
? !!cellInput.isUpdate
|
|
1436
|
+
: ((_c = props === null || props === void 0 ? void 0 : props.isUpdate) !== null && _c !== void 0 ? _c : (!!(props === null || props === void 0 ? void 0 : props.id) && props.id !== "new")) &&
|
|
1437
|
+
!(props === null || props === void 0 ? void 0 : props.isObject) &&
|
|
1438
|
+
!(props === null || props === void 0 ? void 0 : props.isObjectList);
|
|
1439
|
+
var clonedSelectedData = (0, exports.handleClonedDataAttribute)(data, model, (_e = (_d = referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.devSettings) === null || _d === void 0 ? void 0 : _d.server) !== null && _e !== void 0 ? _e : "mongoServer", false, isRemainId, isUpdateData);
|
|
1346
1440
|
/**
|
|
1347
1441
|
* INFO: a pick in a table cell is a finished action, so it saves on the pick.
|
|
1348
1442
|
* Waiting for the blur lost it on a refresh — a reload never blurs the cell
|
|
@@ -2008,7 +2102,10 @@ barcodeScanRequest) {
|
|
|
2008
2102
|
break;
|
|
2009
2103
|
case "date":
|
|
2010
2104
|
var dateValue = (0, dayjs_1.default)().toDate();
|
|
2011
|
-
|
|
2105
|
+
// INFO: a cleared date is stored as null; show it empty, not as today
|
|
2106
|
+
if (clonedSelectedData[eachAttribute.id] === null)
|
|
2107
|
+
dateValue = undefined;
|
|
2108
|
+
else if (typeof clonedSelectedData[eachAttribute.id] === "string")
|
|
2012
2109
|
dateValue = (0, dayjs_1.default)(clonedSelectedData[eachAttribute.id]).toDate();
|
|
2013
2110
|
else if (typeof clonedSelectedData[eachAttribute.id] === "object" &&
|
|
2014
2111
|
clonedSelectedData[eachAttribute.id] instanceof Date)
|
|
@@ -2394,7 +2491,7 @@ barcodeScanRequest) {
|
|
|
2394
2491
|
// a card and at the top level. Colour is reserved for the active step, the
|
|
2395
2492
|
// primary action and status; sections themselves stay neutral.
|
|
2396
2493
|
var sectionCardClassName = "col-span-12 rounded-lg border shadow-sm ".concat((props === null || props === void 0 ? void 0 : props.darkMode)
|
|
2397
|
-
? "border-gray-700 ".concat((
|
|
2494
|
+
? "border-gray-700 ".concat((_f = props === null || props === void 0 ? void 0 : props.darkModeBg) !== null && _f !== void 0 ? _f : "bg-gray-900")
|
|
2398
2495
|
: "border-gray-200 bg-white", " ").concat(mobileView ? "p-4" : "p-5");
|
|
2399
2496
|
var sectionGridClassName = "grid grid-cols-12 ".concat(mobileView ? "gap-x-6 gap-y-2 md:gap-6" : "gap-6");
|
|
2400
2497
|
var hasSections = sortedInputListEntries.some(function (_a) {
|
|
@@ -2409,7 +2506,7 @@ barcodeScanRequest) {
|
|
|
2409
2506
|
var key = _a[0];
|
|
2410
2507
|
return key !== "default";
|
|
2411
2508
|
}).length === 1 &&
|
|
2412
|
-
!((
|
|
2509
|
+
!((_g = inputList["default"]) === null || _g === void 0 ? void 0 : _g.length);
|
|
2413
2510
|
var resolvedSectionCardClassName = isLoneSection
|
|
2414
2511
|
? "col-span-12"
|
|
2415
2512
|
: sectionCardClassName;
|
|
@@ -2435,7 +2532,7 @@ barcodeScanRequest) {
|
|
|
2435
2532
|
renderInputs(key, inputs),
|
|
2436
2533
|
renderStaticDetailList(key))));
|
|
2437
2534
|
}),
|
|
2438
|
-
hasSections && ((
|
|
2535
|
+
hasSections && ((_h = inputList["default"]) === null || _h === void 0 ? void 0 : _h.length) > 0 ? (
|
|
2439
2536
|
// INFO: fields without a section sit in their own untitled card so they
|
|
2440
2537
|
// line up with the sections instead of floating on the page background
|
|
2441
2538
|
react_1.default.createElement("div", { className: sectionCardClassName },
|