blixify-ui-web 1.3.10 → 1.3.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAoHf,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAwI1B,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA6C1C,eAAO,MAAM,yBAAyB,UAAW,GAAG,YAYnD,CAAC;AAEF,eAAO,MAAM,YAAY,mFAoqhBvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAwHf,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAwI1B,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA6C1C,eAAO,MAAM,yBAAyB,UAAW,GAAG,YAYnD,CAAC;AAEF,eAAO,MAAM,YAAY,mFAoxhBvB,CAAC"}
@@ -2299,7 +2299,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
2299
2299
  var rowIndex = recordId
2300
2300
  ? tableData.findIndex(function (row) { return (row === null || row === void 0 ? void 0 : row.id) === recordId || (row === null || row === void 0 ? void 0 : row.recordId) === recordId; })
2301
2301
  : -1;
2302
- return rowIndex >= 0 && limit > 0 ? Math.floor(rowIndex / limit) : pageIndex;
2302
+ return rowIndex >= 0 && limit > 0
2303
+ ? Math.floor(rowIndex / limit)
2304
+ : pageIndex;
2303
2305
  };
2304
2306
  // INFO: called in the row click, while the list is still mounted and scrolled
2305
2307
  var handleCaptureListScroll = function (recordId) {
@@ -10498,6 +10500,76 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
10498
10500
  var nextTabs = ((_b = (_a = props.organise) === null || _a === void 0 ? void 0 : _a.extendedTabs) !== null && _b !== void 0 ? _b : []).map(function (eachTab) { return (__assign(__assign({}, eachTab), { defaultTab: eachTab.name === name ? !eachTab.defaultTab : false })); });
10499
10501
  (_d = (_c = props.organise) === null || _c === void 0 ? void 0 : _c.onChangeTabs) === null || _d === void 0 ? void 0 : _d.call(_c, nextTabs);
10500
10502
  };
10503
+ // INFO: a Kanban drop or a route planned on the map can change a few
10504
+ // records at once — a stop's lane or trip, and the sequence of the stops
10505
+ // around it. Each is saved with only its changed fields, then patched into
10506
+ // the list in place
10507
+ var handleSaveRecordChanges = function (changes) { return __awaiter(void 0, void 0, void 0, function () {
10508
+ var _loop_3, _i, changes_1, eachChange, err_29;
10509
+ var _a;
10510
+ return __generator(this, function (_b) {
10511
+ switch (_b.label) {
10512
+ case 0:
10513
+ setKanbanDroppable(false);
10514
+ _b.label = 1;
10515
+ case 1:
10516
+ _b.trys.push([1, 6, 7, 8]);
10517
+ _loop_3 = function (eachChange) {
10518
+ var currentRow;
10519
+ return __generator(this, function (_c) {
10520
+ switch (_c.label) {
10521
+ case 0: return [4 /*yield*/, writeServerQuery.call("update", {
10522
+ id: eachChange.id,
10523
+ data: eachChange.values,
10524
+ })];
10525
+ case 1:
10526
+ _c.sent();
10527
+ currentRow = tableDataRef.current.find(function (eachData) {
10528
+ return eachData.id === eachChange.id || eachData._id === eachChange.id;
10529
+ });
10530
+ if (!currentRow) return [3 /*break*/, 3];
10531
+ return [4 /*yield*/, handleGetListData({
10532
+ data: [
10533
+ __assign(__assign(__assign({}, currentRow), { _id: (_a = currentRow._id) !== null && _a !== void 0 ? _a : currentRow.id }), eachChange.values),
10534
+ ],
10535
+ }, "update", eachChange.id)];
10536
+ case 2:
10537
+ _c.sent();
10538
+ _c.label = 3;
10539
+ case 3: return [2 /*return*/];
10540
+ }
10541
+ });
10542
+ };
10543
+ _i = 0, changes_1 = changes;
10544
+ _b.label = 2;
10545
+ case 2:
10546
+ if (!(_i < changes_1.length)) return [3 /*break*/, 5];
10547
+ eachChange = changes_1[_i];
10548
+ return [5 /*yield**/, _loop_3(eachChange)];
10549
+ case 3:
10550
+ _b.sent();
10551
+ _b.label = 4;
10552
+ case 4:
10553
+ _i++;
10554
+ return [3 /*break*/, 2];
10555
+ case 5: return [3 /*break*/, 8];
10556
+ case 6:
10557
+ err_29 = _b.sent();
10558
+ setNotification({
10559
+ type: false,
10560
+ title: "Error",
10561
+ msg: (err_29 === null || err_29 === void 0 ? void 0 : err_29.response)
10562
+ ? handleGetWriteErrorMessage(err_29.response)
10563
+ : "The changes could not be saved",
10564
+ });
10565
+ return [3 /*break*/, 8];
10566
+ case 7:
10567
+ setKanbanDroppable(true);
10568
+ return [7 /*endfinally*/];
10569
+ case 8: return [2 /*return*/];
10570
+ }
10571
+ });
10572
+ }); };
10501
10573
  // INFO: opens the add tab modal on an existing tab, which it saves in place
10502
10574
  var handleEditTab = function (name) {
10503
10575
  var _a, _b;
@@ -10891,7 +10963,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
10891
10963
  // tableData / spaceTableData, so handleBuildNewTableGroups() keeps building
10892
10964
  // bands from one source; each group advances its own cursor
10893
10965
  var handleFetchGroupNextPage = function (groupKey) { return __awaiter(void 0, void 0, void 0, function () {
10894
- var current, groupSize, cursor, generation, page_1, existingIds_1, appendRaw_1, appendPretty_1, nextCursor, err_29, nextKey;
10966
+ var current, groupSize, cursor, generation, page_1, existingIds_1, appendRaw_1, appendPretty_1, nextCursor, err_30, nextKey;
10895
10967
  var _a, _b, _c, _d, _e, _f, _g;
10896
10968
  return __generator(this, function (_h) {
10897
10969
  switch (_h.label) {
@@ -10955,7 +11027,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
10955
11027
  });
10956
11028
  return [3 /*break*/, 5];
10957
11029
  case 3:
10958
- err_29 = _h.sent();
11030
+ err_30 = _h.sent();
10959
11031
  if (generation !== groupPagingGenRef.current)
10960
11032
  return [2 /*return*/];
10961
11033
  // INFO: clear the in-flight flag so a failed page can be retried on the
@@ -10980,7 +11052,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
10980
11052
  // INFO: page mode — swaps ONE group's rows for its page `page`; every other
10981
11053
  // group keeps the page it is on
10982
11054
  var handleFetchGroupPage = function (groupKey, page) { return __awaiter(void 0, void 0, void 0, function () {
10983
- var generation, result, keptRaw_1, keptPretty_1, loaded, err_30;
11055
+ var generation, result, keptRaw_1, keptPretty_1, loaded, err_31;
10984
11056
  return __generator(this, function (_a) {
10985
11057
  switch (_a.label) {
10986
11058
  case 0:
@@ -11016,7 +11088,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
11016
11088
  });
11017
11089
  return [3 /*break*/, 4];
11018
11090
  case 3:
11019
- err_30 = _a.sent();
11091
+ err_31 = _a.sent();
11020
11092
  if (generation !== groupPagingGenRef.current)
11021
11093
  return [2 /*return*/];
11022
11094
  handleSetGroupPageState(groupKey, { loadingMore: false });
@@ -12325,6 +12397,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
12325
12397
  else if (selectedTabData.viewType === "map") {
12326
12398
  var mapSettings_1 = selectedTabData.mapSettings;
12327
12399
  if (mapSettings_1) {
12400
+ // INFO: pins take the route column's colour unless another column is
12401
+ // picked, so a trip's pins match its line with one setting
12402
+ var pinGroup_1 = mapSettings_1.group || mapSettings_1.routeBy || "";
12328
12403
  var mapMarkerList_1 = [];
12329
12404
  var uniqueGroupList_1 = [];
12330
12405
  var markerColorMap_1 = {};
@@ -12335,11 +12410,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
12335
12410
  "orange",
12336
12411
  "purple",
12337
12412
  ];
12338
- if (mapSettings_1.group) {
12413
+ if (pinGroup_1) {
12339
12414
  spaceTableData.map(function (eachData) {
12340
- if (eachData[mapSettings_1.group] &&
12341
- !uniqueGroupList_1.includes(eachData[mapSettings_1.group])) {
12342
- uniqueGroupList_1.push(eachData[mapSettings_1.group]);
12415
+ if (eachData[pinGroup_1] &&
12416
+ !uniqueGroupList_1.includes(eachData[pinGroup_1])) {
12417
+ uniqueGroupList_1.push(eachData[pinGroup_1]);
12343
12418
  }
12344
12419
  return null;
12345
12420
  });
@@ -12348,21 +12423,47 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
12348
12423
  markerColorMap_1[group] = markerColorList_1[colorIndex];
12349
12424
  });
12350
12425
  }
12426
+ // INFO: a value the popup can show — a linked record or an
12427
+ // address by its name, other objects left out
12428
+ var handleGetPopupValue_1 = function (value) {
12429
+ var _a;
12430
+ if (value === undefined || value === null || value === "")
12431
+ return null;
12432
+ if (react_1.default.isValidElement(value))
12433
+ return value;
12434
+ if (typeof value === "object")
12435
+ return Array.isArray(value)
12436
+ ? value
12437
+ .map(function (each) { var _a; return typeof each === "object" ? ((_a = each === null || each === void 0 ? void 0 : each.name) !== null && _a !== void 0 ? _a : "") : each; })
12438
+ .join(", ") || null
12439
+ : ((_a = value.name) !== null && _a !== void 0 ? _a : null);
12440
+ return String(value);
12441
+ };
12442
+ // INFO: the stop's columns by name in the table's order, and the
12443
+ // same Edit as a Kanban card's pencil for those who can update
12351
12444
  var infoWindowContent = function (id, data) {
12352
- return (react_1.default.createElement("div", { key: id, className: "w-72 break-words font-normal" },
12353
- react_1.default.createElement("p", { className: "text-primary-500 font-semibold text-sm" }, data.group),
12445
+ var rows = structure
12446
+ .filter(function (eachModel) {
12447
+ return eachModel.id !== mapSettings_1.title &&
12448
+ eachModel.id !== mapSettings_1.address &&
12449
+ eachModel.id !== pinGroup_1;
12450
+ })
12451
+ .map(function (eachModel) { return ({
12452
+ id: eachModel.id,
12453
+ name: eachModel.name,
12454
+ value: handleGetPopupValue_1(data[eachModel.id]),
12455
+ }); })
12456
+ .filter(function (eachRow) { return eachRow.value !== null; });
12457
+ return (react_1.default.createElement("div", { key: id, "data-testid": "map-info-window", className: "w-72 break-words font-normal" },
12458
+ data.group && (react_1.default.createElement("p", { className: "text-primary-500 font-semibold text-sm" }, handleGetPopupValue_1(data.group))),
12354
12459
  react_1.default.createElement("p", { className: "text-sm" }, data.address),
12355
- react_1.default.createElement("hr", { className: "my-4" }),
12356
- Object.keys(data)
12357
- .filter(function (eachKey) {
12358
- return eachKey !== "title" &&
12359
- eachKey !== "address" &&
12360
- eachKey !== "group";
12361
- })
12362
- .map(function (eachKey) { return (react_1.default.createElement("p", { key: eachKey, className: "text-sm" },
12363
- eachKey,
12364
- ": ",
12365
- data[eachKey])); })));
12460
+ rows.length > 0 && react_1.default.createElement("hr", { className: "my-3" }),
12461
+ rows.map(function (eachRow) { return (react_1.default.createElement("p", { key: eachRow.id, className: "text-sm" },
12462
+ react_1.default.createElement("span", { className: "text-gray-500" },
12463
+ eachRow.name,
12464
+ ": "),
12465
+ eachRow.value)); }),
12466
+ recordEditAction && (react_1.default.createElement("button", { type: "button", "data-testid": "map-info-edit", className: "mt-3 w-full rounded-md bg-primary-500 px-3 py-1.5 text-sm font-medium text-white hover:bg-primary-600", onClick: function () { return recordEditAction(id); } }, "Edit"))));
12366
12467
  };
12367
12468
  var infoWindowHeaderComponent = function (_, data) {
12368
12469
  return (react_1.default.createElement("p", { className: "text-primary-500 font-semibold text-base" }, data.title));
@@ -12370,9 +12471,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
12370
12471
  spaceTableData.map(function (eachData) {
12371
12472
  var _a, _b, _c, _d, _e, _f, _g, _h;
12372
12473
  var eachMarkerColor = "white";
12373
- if (mapSettings_1.group) {
12374
- if (eachData[mapSettings_1.group]) {
12375
- eachMarkerColor = markerColorMap_1[eachData[mapSettings_1.group]];
12474
+ if (pinGroup_1) {
12475
+ if (eachData[pinGroup_1]) {
12476
+ eachMarkerColor = markerColorMap_1[eachData[pinGroup_1]];
12376
12477
  }
12377
12478
  }
12378
12479
  if (eachData[mapSettings_1.address]) {
@@ -12388,8 +12489,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
12388
12489
  ? ((_e = eachData[mapSettings_1.title]) !== null && _e !== void 0 ? _e : "")
12389
12490
  : "",
12390
12491
  address: (_g = (_f = eachData[mapSettings_1.address]) === null || _f === void 0 ? void 0 : _f.name) !== null && _g !== void 0 ? _g : "",
12391
- group: mapSettings_1.group
12392
- ? ((_h = eachData[mapSettings_1.group]) !== null && _h !== void 0 ? _h : "")
12492
+ group: pinGroup_1
12493
+ ? ((_h = eachData[pinGroup_1]) !== null && _h !== void 0 ? _h : "")
12393
12494
  : "",
12394
12495
  },
12395
12496
  };
@@ -12400,7 +12501,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
12400
12501
  eachKey !== "update" &&
12401
12502
  eachKey !== mapSettings_1.title &&
12402
12503
  eachKey !== mapSettings_1.address &&
12403
- eachKey !== mapSettings_1.group) {
12504
+ eachKey !== pinGroup_1) {
12404
12505
  markerData_1["data"][eachKey] = eachData[eachKey];
12405
12506
  }
12406
12507
  });
@@ -12409,7 +12510,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
12409
12510
  return null;
12410
12511
  });
12411
12512
  return (react_1.default.createElement("div", { className: "w-full h-[700px]" },
12412
- react_1.default.createElement(mapView_1.MapView, { ref: mapViewRef, markerList: mapMarkerList_1, routeList: (0, routes_1.handleBuildRoutesFromRows)(spaceTableData, mapMarkerList_1, mapSettings_1.routeBy, mapSettings_1.routeOrder), enableMapControl: true, enablePolygonSelect: canBatchUpdate || canDeleteRecord, infoWindowComponent: infoWindowContent, infoWindowHeaderComponent: infoWindowHeaderComponent, handleSelectPolygon: canBatchUpdate || canDeleteRecord
12513
+ react_1.default.createElement(mapView_1.MapView, { ref: mapViewRef, markerList: mapMarkerList_1, routeList: (0, routes_1.handleBuildRoutesFromRows)(spaceTableData, mapMarkerList_1, mapSettings_1.routeBy, mapSettings_1.routeOrder, mapSettings_1.routeStart, mapSettings_1.routeEnd), onChangeRoute: canUpdateRecord && mapSettings_1.routeBy
12514
+ ? function (change) {
12515
+ return handleSaveRecordChanges((0, routes_1.handleBuildRouteChanges)(spaceTableData, mapSettings_1.routeBy, mapSettings_1.routeOrder, change, [mapSettings_1.routeStart, mapSettings_1.routeEnd]));
12516
+ }
12517
+ : undefined, enableMapControl: true, enablePolygonSelect: canBatchUpdate || canDeleteRecord, infoWindowComponent: infoWindowContent, infoWindowHeaderComponent: infoWindowHeaderComponent, handleSelectPolygon: canBatchUpdate || canDeleteRecord
12413
12518
  ? function (ids) { return setSelectedIds(ids); }
12414
12519
  : undefined, handleUpdateOnClick: canBatchUpdate ? function () { return setBatchUpdateModal(true); } : undefined, handleDeleteOnClick: canDeleteRecord
12415
12520
  ? function () {
@@ -12455,7 +12560,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
12455
12560
  id: kanbanSettings.sortBy,
12456
12561
  type: kanbanSettings.sortType,
12457
12562
  }
12458
- : undefined, subGroupBy: (kanbanSettings === null || kanbanSettings === void 0 ? void 0 : kanbanSettings.subGroupBy) || undefined, renderSubGroupLabel: function (value, cards) { var _a, _b; return (_b = (_a = cards[0]) === null || _a === void 0 ? void 0 : _a.subGroupLabel) !== null && _b !== void 0 ? _b : value; }, draggable: canUpdateRecord, droppable: canUpdateRecord && kanbanDroppable, mobileView: (_58 = props.bareSettings) === null || _58 === void 0 ? void 0 : _58.bareListMobileView, onUpdateData: canUpdateRecord
12563
+ : undefined, subGroupBy: (kanbanSettings === null || kanbanSettings === void 0 ? void 0 : kanbanSettings.subGroupBy) || undefined, renderSubGroupLabel: function (value, cards) { var _a, _b; return (_b = (_a = cards[0]) === null || _a === void 0 ? void 0 : _a.subGroupLabel) !== null && _b !== void 0 ? _b : value; }, draggable: canUpdateRecord, droppable: canUpdateRecord && kanbanDroppable, onArrangeData: canUpdateRecord ? handleSaveRecordChanges : undefined, mobileView: (_58 = props.bareSettings) === null || _58 === void 0 ? void 0 : _58.bareListMobileView, onUpdateData: canUpdateRecord
12459
12564
  ? function (cardId, _fromCol, toCol) { return __awaiter(void 0, void 0, void 0, function () {
12460
12565
  var _a;
12461
12566
  return __generator(this, function (_b) {