@dexteel/mesf-core 7.7.0 → 7.8.1

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,3 +1,3 @@
1
1
  {
2
- ".": "7.7.0"
2
+ ".": "7.8.1"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [7.8.1](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.8.0...@dexteel/mesf-core-v7.8.1) (2025-12-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Create User:** enhance user creation process with password and profile management ([9400641](https://github.com/dexteel/mesf-core-frontend/commit/94006418d13d944364cacf410a94b385f48b6140))
9
+ * **Edit User:** streamline user update process and improve profile ID handling ([f1397e5](https://github.com/dexteel/mesf-core-frontend/commit/f1397e58496fa8e9f4d10bd4a4d84db2af3c08e8))
10
+
11
+ ## [7.8.0](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.7.0...@dexteel/mesf-core-v7.8.0) (2025-12-22)
12
+
13
+
14
+ ### Features
15
+
16
+ * **Trendings V2:** auto-scroll, select, and toast on tag search result click in Tags Tree V2 ([5b869fb](https://github.com/dexteel/mesf-core-frontend/commit/5b869fb6ef38b7f4f7ad8e9b8c101db774970b52))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **Trendings V2:** Fix wiping of views when saving ([33ca2d4](https://github.com/dexteel/mesf-core-frontend/commit/33ca2d413b4adddc48692f93eb1f3804339a9bc3))
22
+
3
23
  ## [7.7.0](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.6.0...@dexteel/mesf-core-v7.7.0) (2025-12-22)
4
24
 
5
25
 
package/dist/index.esm.js CHANGED
@@ -4578,36 +4578,36 @@ var CreateUser = function (_a) {
4578
4578
  setOpen(false);
4579
4579
  };
4580
4580
  var UserName = watch("UserName");
4581
- var profilesIds = watch("ProfilesId");
4582
- var setProfiles = useMutation({
4583
- mutationFn: setProfilesToUser,
4584
- onError: function (error) {
4585
- setError(error.message);
4586
- },
4587
- });
4588
4581
  var createUser = useMutation({
4589
- mutationFn: upsertUser,
4590
- onSuccess: function (userCreatedId) { return __awaiter(void 0, void 0, void 0, function () {
4582
+ mutationFn: function (data) { return __awaiter(void 0, void 0, void 0, function () {
4583
+ var userId, passwordResult;
4591
4584
  return __generator(this, function (_a) {
4592
4585
  switch (_a.label) {
4593
- case 0:
4594
- _a.trys.push([0, 2, , 3]);
4595
- return [4 /*yield*/, setProfiles.mutateAsync({
4596
- UserId: userCreatedId,
4597
- profileIds: profilesIds,
4598
- })];
4586
+ case 0: return [4 /*yield*/, upsertUser(data)];
4599
4587
  case 1:
4600
- _a.sent();
4601
- setOpen(true);
4602
- onHide(true);
4603
- return [3 /*break*/, 3];
4588
+ userId = _a.sent();
4589
+ return [4 /*yield*/, setPassword(userId, data.UserName)];
4604
4590
  case 2:
4591
+ passwordResult = _a.sent();
4592
+ if (!passwordResult.ok) {
4593
+ throw new Error(passwordResult.message || "Error setting password");
4594
+ }
4595
+ if (!(data.ProfilesId && Array.isArray(data.ProfilesId))) return [3 /*break*/, 4];
4596
+ return [4 /*yield*/, setProfilesToUser({
4597
+ UserId: userId,
4598
+ profileIds: data.ProfilesId,
4599
+ })];
4600
+ case 3:
4605
4601
  _a.sent();
4606
- return [3 /*break*/, 3];
4607
- case 3: return [2 /*return*/];
4602
+ _a.label = 4;
4603
+ case 4: return [2 /*return*/, userId];
4608
4604
  }
4609
4605
  });
4610
4606
  }); },
4607
+ onSuccess: function () {
4608
+ setOpen(true);
4609
+ onHide(true);
4610
+ },
4611
4611
  onError: function (error) {
4612
4612
  setError(error.message);
4613
4613
  },
@@ -5072,39 +5072,39 @@ var EditUser = function (_a) {
5072
5072
  }
5073
5073
  setOpen(false);
5074
5074
  };
5075
- var setProfiles = useMutation({
5076
- mutationFn: setProfilesToUser,
5077
- onError: function (error) {
5078
- setError(error.message);
5079
- },
5080
- });
5081
5075
  var editUser = useMutation({
5082
- mutationFn: upsertUser,
5083
- onSuccess: function (userUpdatedId) { return __awaiter(void 0, void 0, void 0, function () {
5084
- var currentLoggedUserId;
5076
+ mutationFn: function (data) { return __awaiter(void 0, void 0, void 0, function () {
5077
+ var userUpdatedId, validProfileIds;
5085
5078
  return __generator(this, function (_a) {
5086
5079
  switch (_a.label) {
5087
- case 0:
5088
- _a.trys.push([0, 2, , 3]);
5089
- return [4 /*yield*/, setProfiles.mutateAsync({
5080
+ case 0: return [4 /*yield*/, upsertUser(data)];
5081
+ case 1:
5082
+ userUpdatedId = _a.sent();
5083
+ validProfileIds = Array.isArray(profilesIds)
5084
+ ? profilesIds.filter(function (id) { return !isNaN(id) && id > 0; })
5085
+ : [];
5086
+ // Step 3: Set the profiles for the user
5087
+ return [4 /*yield*/, setProfilesToUser({
5090
5088
  UserId: userUpdatedId,
5091
- profileIds: profilesIds,
5089
+ profileIds: validProfileIds,
5092
5090
  })];
5093
- case 1:
5094
- _a.sent();
5095
- currentLoggedUserId = getUserId();
5096
- if (currentLoggedUserId === userUpdatedId) {
5097
- // Update context - the area-selector effect will update the name
5098
- setDefaultAreaId(defaultAssetId);
5099
- }
5100
- onHide(true);
5101
- setOpen(true);
5102
- return [3 /*break*/, 3];
5103
5091
  case 2:
5092
+ // Step 3: Set the profiles for the user
5104
5093
  _a.sent();
5105
- return [3 /*break*/, 3];
5106
- case 3: return [2 /*return*/];
5094
+ return [2 /*return*/, userUpdatedId];
5095
+ }
5096
+ });
5097
+ }); },
5098
+ onSuccess: function (userUpdatedId) { return __awaiter(void 0, void 0, void 0, function () {
5099
+ var currentLoggedUserId;
5100
+ return __generator(this, function (_a) {
5101
+ currentLoggedUserId = getUserId();
5102
+ if (currentLoggedUserId === userUpdatedId && defaultAssetId) {
5103
+ setDefaultAreaId(defaultAssetId);
5107
5104
  }
5105
+ onHide(true);
5106
+ setOpen(true);
5107
+ return [2 /*return*/];
5108
5108
  });
5109
5109
  }); },
5110
5110
  onError: function (error) {
@@ -5133,7 +5133,13 @@ var EditUser = function (_a) {
5133
5133
  if (isSuccess) {
5134
5134
  var userSelected = rows ? rows[0] : null;
5135
5135
  if (userSelected) {
5136
- var profilesIds_1 = (((_a = userSelected.ProfilesId) === null || _a === void 0 ? void 0 : _a.toString()) || "").split(",") || [];
5136
+ var profilesIdsString = ((_a = userSelected.ProfilesId) === null || _a === void 0 ? void 0 : _a.toString()) || "";
5137
+ var profilesIds_1 = profilesIdsString
5138
+ .split(",")
5139
+ .map(function (pId) { return pId.trim(); })
5140
+ .filter(function (pId) { return pId !== ""; })
5141
+ .map(function (pId) { return parseInt(pId); })
5142
+ .filter(function (pId) { return !isNaN(pId); });
5137
5143
  setValue("UserId", userSelected.UserId);
5138
5144
  setValue("UserName", userSelected.UserName);
5139
5145
  setValue("FirstName", userSelected.FirstName);
@@ -5142,7 +5148,7 @@ var EditUser = function (_a) {
5142
5148
  setValue("IsActive", userSelected.IsActive);
5143
5149
  setValue("LastLogin", userSelected.LastLogin);
5144
5150
  setValue("DefaultAssetId", userSelected.DefaultAssetId);
5145
- setValue("ProfilesId", profilesIds_1.map(function (pId) { return parseInt(pId); }));
5151
+ setValue("ProfilesId", profilesIds_1);
5146
5152
  }
5147
5153
  }
5148
5154
  }
@@ -12062,7 +12068,7 @@ var getViewTags = function (ViewId) { return __awaiter(void 0, void 0, void 0, f
12062
12068
  }); };
12063
12069
  var upsertViewTag = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
12064
12070
  var apiService, parameters, resp;
12065
- var viewId = _b.viewId, tagId = _b.tagId, color = _b.color, minScale = _b.minScale, maxScale = _b.maxScale, isVisible = _b.isVisible, isAutoScale = _b.isAutoScale, unit = _b.unit;
12071
+ var viewId = _b.viewId, tagId = _b.tagId, color = _b.color, minScale = _b.minScale, maxScale = _b.maxScale, isVisible = _b.isVisible, isAutoScale = _b.isAutoScale, unit = _b.unit; _b.order; _b.alias; _b.tagType; _b.sourceTagId; _b.bitIndex;
12066
12072
  return __generator(this, function (_c) {
12067
12073
  switch (_c.label) {
12068
12074
  case 0:
@@ -12158,6 +12164,37 @@ var ConfirmationDialogRaw = function (_a) {
12158
12164
  React__default.createElement(Button, { variant: "contained", size: "small", color: "primary", onClick: handleOk }, "Ok")))));
12159
12165
  };
12160
12166
 
12167
+ var STORAGE_PREFIX = "mesf_trending_view_v2_";
12168
+ var saveViewToLocal = function (viewId, viewTags) {
12169
+ try {
12170
+ var key = "".concat(STORAGE_PREFIX).concat(viewId);
12171
+ localStorage.setItem(key, JSON.stringify(viewTags));
12172
+ }
12173
+ catch (e) {
12174
+ console.error("Failed to save view to local storage", e);
12175
+ }
12176
+ };
12177
+ var getViewFromLocal = function (viewId) {
12178
+ try {
12179
+ var key = "".concat(STORAGE_PREFIX).concat(viewId);
12180
+ var data = localStorage.getItem(key);
12181
+ return data ? JSON.parse(data) : null;
12182
+ }
12183
+ catch (e) {
12184
+ console.error("Failed to load view from local storage", e);
12185
+ return null;
12186
+ }
12187
+ };
12188
+ var removeViewFromLocal = function (viewId) {
12189
+ try {
12190
+ var key = "".concat(STORAGE_PREFIX).concat(viewId);
12191
+ localStorage.removeItem(key);
12192
+ }
12193
+ catch (e) {
12194
+ console.error("Failed to remove view from local storage", e);
12195
+ }
12196
+ };
12197
+
12161
12198
  var SaveUpdateDeleteViewModalV2 = function (_a) {
12162
12199
  var _b, _c, _d;
12163
12200
  var open = _a.open, mode = _a.mode, handleClose = _a.handleClose, view = _a.view;
@@ -12195,7 +12232,7 @@ var SaveUpdateDeleteViewModalV2 = function (_a) {
12195
12232
  };
12196
12233
  var updateViewTag = useMutation({
12197
12234
  mutationFn: function (_a) {
12198
- var viewId = _a.viewId, tagId = _a.tagId, color = _a.color, minScale = _a.minScale, maxScale = _a.maxScale, isVisible = _a.isVisible, isAutoScale = _a.isAutoScale, unit = _a.unit;
12235
+ var viewId = _a.viewId, tagId = _a.tagId, color = _a.color, minScale = _a.minScale, maxScale = _a.maxScale, isVisible = _a.isVisible, isAutoScale = _a.isAutoScale, unit = _a.unit, order = _a.order, alias = _a.alias, tagType = _a.tagType, sourceTagId = _a.sourceTagId, bitIndex = _a.bitIndex;
12199
12236
  return upsertViewTag({
12200
12237
  viewId: viewId,
12201
12238
  tagId: tagId,
@@ -12205,6 +12242,11 @@ var SaveUpdateDeleteViewModalV2 = function (_a) {
12205
12242
  isVisible: isVisible,
12206
12243
  isAutoScale: isAutoScale,
12207
12244
  unit: unit,
12245
+ order: order,
12246
+ alias: alias,
12247
+ tagType: tagType,
12248
+ sourceTagId: sourceTagId,
12249
+ bitIndex: bitIndex,
12208
12250
  });
12209
12251
  },
12210
12252
  onError: function (error) {
@@ -12217,6 +12259,12 @@ var SaveUpdateDeleteViewModalV2 = function (_a) {
12217
12259
  return __generator(this, function (_a) {
12218
12260
  switch (_a.label) {
12219
12261
  case 0:
12262
+ if (view === null || view === void 0 ? void 0 : view.ViewId) {
12263
+ removeViewFromLocal(view.ViewId);
12264
+ }
12265
+ else if (viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId) {
12266
+ removeViewFromLocal(viewSelected.ViewId);
12267
+ }
12220
12268
  setSnackbarMessage("The view was deleted successfully");
12221
12269
  setSnackbarOpen(true);
12222
12270
  return [4 /*yield*/, queryClient.invalidateQueries({ queryKey: ["views-v2"] })];
@@ -12239,31 +12287,43 @@ var SaveUpdateDeleteViewModalV2 = function (_a) {
12239
12287
  });
12240
12288
  }); },
12241
12289
  onSuccess: function (viewId) { return __awaiter(void 0, void 0, void 0, function () {
12242
- var results, failed;
12290
+ var backendTags, results, failed;
12243
12291
  return __generator(this, function (_a) {
12244
12292
  switch (_a.label) {
12245
- case 0: return [4 /*yield*/, Promise.allSettled(Object.values(viewTags)
12246
- .sort(function (a, b) { return a.order - b.order; })
12247
- .map(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
12248
- var viewTag = _b.viewTag;
12249
- return __generator(this, function (_c) {
12250
- switch (_c.label) {
12251
- case 0: return [4 /*yield*/, updateViewTag.mutate({
12252
- viewId: viewId,
12253
- tagId: viewTag.TagId,
12254
- color: viewTag.Color,
12255
- minScale: viewTag.MinScale,
12256
- maxScale: viewTag.MaxScale,
12257
- isVisible: viewTag.IsVisible,
12258
- isAutoScale: viewTag.IsAutoScale,
12259
- unit: viewTag.Unit,
12260
- })];
12261
- case 1:
12262
- _c.sent();
12263
- return [2 /*return*/];
12264
- }
12265
- });
12266
- }); }))];
12293
+ case 0:
12294
+ // Save complete state to local storage (metadata + virtual tags)
12295
+ saveViewToLocal(viewId, viewTags);
12296
+ backendTags = Object.values(viewTags).filter(function (_a) {
12297
+ var viewTag = _a.viewTag;
12298
+ return !viewTag.IsBitExtracted;
12299
+ });
12300
+ return [4 /*yield*/, Promise.allSettled(backendTags
12301
+ .sort(function (a, b) { return a.order - b.order; })
12302
+ .map(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
12303
+ var viewTag = _b.viewTag, order = _b.order;
12304
+ return __generator(this, function (_c) {
12305
+ switch (_c.label) {
12306
+ case 0: return [4 /*yield*/, updateViewTag.mutateAsync({
12307
+ viewId: viewId,
12308
+ tagId: viewTag.TagId,
12309
+ color: viewTag.Color,
12310
+ minScale: viewTag.MinScale,
12311
+ maxScale: viewTag.MaxScale,
12312
+ isVisible: viewTag.IsVisible,
12313
+ isAutoScale: viewTag.IsAutoScale,
12314
+ unit: viewTag.Unit,
12315
+ order: order,
12316
+ alias: viewTag.Alias,
12317
+ tagType: viewTag.TagType,
12318
+ sourceTagId: viewTag.SourceTagId,
12319
+ bitIndex: viewTag.BitIndex,
12320
+ })];
12321
+ case 1:
12322
+ _c.sent();
12323
+ return [2 /*return*/];
12324
+ }
12325
+ });
12326
+ }); }))];
12267
12327
  case 1:
12268
12328
  results = _a.sent();
12269
12329
  failed = results.filter(function (r) { return r.status === "rejected"; });
@@ -12301,7 +12361,7 @@ var SaveUpdateDeleteViewModalV2 = function (_a) {
12301
12361
  setIsSubmitLoading(true);
12302
12362
  viewToDelete = view || viewSelected;
12303
12363
  if (!!isNil(viewToDelete)) return [3 /*break*/, 2];
12304
- return [4 /*yield*/, removeView.mutate(viewToDelete.ViewId)];
12364
+ return [4 /*yield*/, removeView.mutateAsync(viewToDelete.ViewId)];
12305
12365
  case 1:
12306
12366
  _a.sent();
12307
12367
  _a.label = 2;
@@ -12892,6 +12952,22 @@ var ColorPickerV2 = function (_a) {
12892
12952
  } }, tagColors.map(function (tagColor) { return (React__default.createElement(ColorSwatch, { key: tagColor, color: tagColor, onSelect: handleColorSelect })); })))));
12893
12953
  };
12894
12954
 
12955
+ var NotificationSnackBar = function (_a) {
12956
+ var message = _a.message, _b = _a.onHide, onHide = _b === void 0 ? function () { } : _b, _c = _a.severity, severity = _c === void 0 ? "success" : _c;
12957
+ var handleClose = function (event, reason) {
12958
+ if (reason === "clickaway") {
12959
+ return;
12960
+ }
12961
+ onHide();
12962
+ };
12963
+ var _d = useState(true), open = _d[0], setOpen = _d[1];
12964
+ useEffect(function () {
12965
+ setOpen(!!message);
12966
+ }, [message]);
12967
+ return (React__default.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
12968
+ React__default.createElement(Alert$3, { elevation: 6, variant: "filled", severity: severity, onClose: handleClose }, message)));
12969
+ };
12970
+
12895
12971
  var NewFolderModal = function (_a) {
12896
12972
  var open = _a.open, handleClose = _a.handleClose, tagNodeSelectedInTree = _a.tagNodeSelectedInTree;
12897
12973
  var _b = useState(), name = _b[0], setName = _b[1];
@@ -13129,7 +13205,7 @@ var TagFolderCustomNodeV2 = function (_a) {
13129
13205
  (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("contextmenu", handleContextMenu);
13130
13206
  };
13131
13207
  }, []);
13132
- return (React__default.createElement(Box, { onClick: onClickHandler, sx: {
13208
+ return (React__default.createElement(Box, { "data-node-id": node.id, onClick: onClickHandler, sx: {
13133
13209
  paddingInlineStart: depth * 2,
13134
13210
  cursor: "pointer",
13135
13211
  alignItems: "center",
@@ -13410,13 +13486,14 @@ var TagsTreeModalV2 = function (_a) {
13410
13486
  var open = _a.open, handleClose = _a.handleClose, onTagSelect = _a.onTagSelect;
13411
13487
  var _b = useState(false), isLoading = _b[0], setIsLoading = _b[1];
13412
13488
  var _c = useState(""), error = _c[0], setError = _c[1];
13413
- var _d = useState([]), tagsTreeData = _d[0], setTagsTreeData = _d[1];
13414
- var _e = useState(null), tagNodeSelectedInTree = _e[0], setTagNodeSelectedInTree = _e[1];
13415
- var _f = useState(null), anchorPoint = _f[0], setAnchorPoint = _f[1];
13416
- var _g = useState(false), showContextMenu = _g[0], setShowContextMenu = _g[1];
13489
+ var _d = useState(null), snackbarMessage = _d[0], setSnackbarMessage = _d[1];
13490
+ var _e = useState([]), tagsTreeData = _e[0], setTagsTreeData = _e[1];
13491
+ var _f = useState(null), tagNodeSelectedInTree = _f[0], setTagNodeSelectedInTree = _f[1];
13492
+ var _g = useState(null), anchorPoint = _g[0], setAnchorPoint = _g[1];
13493
+ var _h = useState(false), showContextMenu = _h[0], setShowContextMenu = _h[1];
13417
13494
  var backendOffset = 1000000;
13418
- var _h = useState({}), openTagFolders = _h[0], setOpenTagFolders = _h[1];
13419
- var _j = useState([]), selectedNodes = _j[0], setSelectedNodes = _j[1];
13495
+ var _j = useState({}), openTagFolders = _j[0], setOpenTagFolders = _j[1];
13496
+ var _k = useState([]), selectedNodes = _k[0], setSelectedNodes = _k[1];
13420
13497
  var handleContextMenu = function (data, e) {
13421
13498
  e.preventDefault();
13422
13499
  var top = e.clientY;
@@ -13429,7 +13506,7 @@ var TagsTreeModalV2 = function (_a) {
13429
13506
  setTagNodeSelectedInTree(selectedNode);
13430
13507
  }
13431
13508
  };
13432
- var _k = useSearchTagsTree$1(), tagsTree = _k.data, tagsTreeLoading = _k.isLoading, tagsTreeIsError = _k.isError, tagsTreeError = _k.error, tagsTreeIsSuccess = _k.isSuccess, tagsTreeIsFetched = _k.isFetched, refetch = _k.refetch;
13509
+ var _l = useSearchTagsTree$1(), tagsTree = _l.data, tagsTreeLoading = _l.isLoading, tagsTreeIsError = _l.isError, tagsTreeError = _l.error, tagsTreeIsSuccess = _l.isSuccess, tagsTreeIsFetched = _l.isFetched, refetch = _l.refetch;
13433
13510
  var updateTagFolder = useMutation({
13434
13511
  mutationFn: function (_a) {
13435
13512
  var tagFolderId = _a.tagFolderId, parentTagFolderId = _a.parentTagFolderId, tagFolderName = _a.tagFolderName, isActive = _a.isActive;
@@ -13528,6 +13605,10 @@ var TagsTreeModalV2 = function (_a) {
13528
13605
  });
13529
13606
  setOpenTagFolders(newOpenTagFolders);
13530
13607
  setSelectedNodes([result.node]);
13608
+ if (result.node.data && result.node.data.TagTypeCode !== "F") {
13609
+ onTagSelect(result.node.data);
13610
+ setSnackbarMessage("Tag \"".concat(result.node.data.TagName, "\" added"));
13611
+ }
13531
13612
  // Scroll to the node after expansion
13532
13613
  setTimeout(function () {
13533
13614
  var nodeElement = document.querySelector("[data-node-id=\"".concat(result.id, "\"]"));
@@ -13615,7 +13696,8 @@ var TagsTreeModalV2 = function (_a) {
13615
13696
  return (React__default.createElement(TagFolderCustomNodeV2, { setContextMenuOver: handleContextMenu, node: node, options: options, isSelected: selected, openTagFolders: openTagFolders, setOpenTagFolders: setOpenTagFolders, handleSelect: handleClick }));
13616
13697
  }, dragPreviewRender: function (monitorProps) { return React__default.createElement(CustomDragPreview, { monitorProps: monitorProps }); } })))))),
13617
13698
  React__default.createElement(ContextMenu, { anchorPoint: anchorPoint, isOpen: showContextMenu, setShowContextMenu: setShowContextMenu, tagNodeSelectedInTree: tagNodeSelectedInTree, getTagsTreeData: function () { return refetch(); } }),
13618
- React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })))));
13699
+ React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } }),
13700
+ React__default.createElement(NotificationSnackBar, { message: snackbarMessage, onHide: function () { return setSnackbarMessage(null); } })))));
13619
13701
  };
13620
13702
 
13621
13703
  var BitSelectorModal = function (_a) {
@@ -13962,20 +14044,31 @@ var TagsTableV2 = function () {
13962
14044
  var viewId = _a.viewId, viewName = _a.viewName, isPublic = _a.isPublic;
13963
14045
  return upsertView({ viewId: viewId, viewName: viewName, isPublic: isPublic });
13964
14046
  },
13965
- onSuccess: function () { return __awaiter(void 0, void 0, void 0, function () {
13966
- var results, failed;
14047
+ onSuccess: function (viewId) { return __awaiter(void 0, void 0, void 0, function () {
14048
+ var backendTags, results, failed;
13967
14049
  var _a;
13968
14050
  return __generator(this, function (_b) {
13969
14051
  switch (_b.label) {
13970
- case 0: return [4 /*yield*/, deleteAllViewTags.mutate((_a = viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId) !== null && _a !== void 0 ? _a : 0)];
14052
+ case 0:
14053
+ // Save complete state to local storage (metadata + virtual tags)
14054
+ if (viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId) {
14055
+ saveViewToLocal(viewSelected.ViewId, viewTags);
14056
+ }
14057
+ // Wait for delete to finish before inserting new tags
14058
+ return [4 /*yield*/, deleteAllViewTags.mutateAsync((_a = viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId) !== null && _a !== void 0 ? _a : 0)];
13971
14059
  case 1:
14060
+ // Wait for delete to finish before inserting new tags
13972
14061
  _b.sent();
13973
- return [4 /*yield*/, Promise.allSettled(Object.values(viewTags)
14062
+ backendTags = Object.values(viewTags).filter(function (_a) {
14063
+ var viewTag = _a.viewTag;
14064
+ return !viewTag.IsBitExtracted;
14065
+ });
14066
+ return [4 /*yield*/, Promise.allSettled(backendTags
13974
14067
  .sort(function (a, b) { return b.order - a.order; })
13975
14068
  .map(function (_a) {
13976
14069
  var _b;
13977
- var viewTag = _a.viewTag;
13978
- return upsertViewTag({
14070
+ var viewTag = _a.viewTag, order = _a.order;
14071
+ return updateViewTag.mutateAsync({
13979
14072
  viewId: (_b = viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId) !== null && _b !== void 0 ? _b : 0,
13980
14073
  tagId: viewTag.TagId,
13981
14074
  color: viewTag.Color,
@@ -13984,6 +14077,11 @@ var TagsTableV2 = function () {
13984
14077
  isVisible: viewTag.IsVisible,
13985
14078
  isAutoScale: viewTag.IsAutoScale,
13986
14079
  unit: viewTag.Unit,
14080
+ order: order,
14081
+ alias: viewTag.Alias,
14082
+ tagType: viewTag.TagType,
14083
+ sourceTagId: viewTag.SourceTagId,
14084
+ bitIndex: viewTag.BitIndex,
13987
14085
  });
13988
14086
  }))];
13989
14087
  case 2:
@@ -14005,7 +14103,7 @@ var TagsTableV2 = function () {
14005
14103
  });
14006
14104
  var updateViewTag = useMutation({
14007
14105
  mutationFn: function (_a) {
14008
- var viewId = _a.viewId, tagId = _a.tagId, color = _a.color, minScale = _a.minScale, maxScale = _a.maxScale, isVisible = _a.isVisible, isAutoScale = _a.isAutoScale, unit = _a.unit;
14106
+ var viewId = _a.viewId, tagId = _a.tagId, color = _a.color, minScale = _a.minScale, maxScale = _a.maxScale, isVisible = _a.isVisible, isAutoScale = _a.isAutoScale, unit = _a.unit, order = _a.order, alias = _a.alias, tagType = _a.tagType, sourceTagId = _a.sourceTagId, bitIndex = _a.bitIndex;
14009
14107
  return upsertViewTag({
14010
14108
  viewId: viewId,
14011
14109
  tagId: tagId,
@@ -14015,6 +14113,11 @@ var TagsTableV2 = function () {
14015
14113
  isVisible: isVisible,
14016
14114
  isAutoScale: isAutoScale,
14017
14115
  unit: unit,
14116
+ order: order,
14117
+ alias: alias,
14118
+ tagType: tagType,
14119
+ sourceTagId: sourceTagId,
14120
+ bitIndex: bitIndex,
14018
14121
  });
14019
14122
  },
14020
14123
  onError: function (error) {
@@ -16313,26 +16416,70 @@ var TrendingsPageV2 = function () {
16313
16416
  // This preserves local order changes (from drag-and-drop) until a new view is loaded
16314
16417
  var loadedViewIdRef = useRef(null);
16315
16418
  useEffect(function () {
16316
- if (!viewTagsSuccess || !viewTagsData || !Array.isArray(viewTagsData))
16419
+ if (!viewTagsSuccess ||
16420
+ !viewTagsData ||
16421
+ !Array.isArray(viewTagsData) ||
16422
+ viewId === null)
16317
16423
  return;
16318
16424
  // Only reset viewTags when viewId actually changes (loading a different view)
16319
16425
  // Do NOT reset if viewId is the same (data is just refetching)
16320
16426
  if (viewId === loadedViewIdRef.current)
16321
16427
  return;
16322
16428
  loadedViewIdRef.current = viewId;
16323
- var vTags = viewTagsData.reduce(function (carr, curr, idx) {
16324
- if (isNil(curr.Color)) {
16325
- curr.Color = getRandomColor();
16326
- }
16327
- carr[curr.TagId] = {
16328
- viewTag: curr,
16329
- order: idx,
16330
- };
16331
- return carr;
16332
- }, {});
16429
+ var backendTags = viewTagsData;
16430
+ var localViewTags = getViewFromLocal(viewId);
16431
+ var mergedTags = {};
16432
+ if (localViewTags) {
16433
+ // If local storage exists, use it as the source of truth for metadata (Order, Alias)
16434
+ // and for virtual tags (Bit Extracted)
16435
+ var backendTagIds_1 = new Set(backendTags.map(function (t) { return t.TagId; }));
16436
+ // 1. Process local tags
16437
+ Object.values(localViewTags).forEach(function (entry) {
16438
+ var viewTag = entry.viewTag;
16439
+ // If it's a backend tag, check if it still exists in the backend response
16440
+ // (Permission check or tag deletion check)
16441
+ if (!viewTag.IsBitExtracted) {
16442
+ if (backendTagIds_1.has(viewTag.TagId)) {
16443
+ mergedTags[viewTag.TagId] = entry;
16444
+ }
16445
+ }
16446
+ else {
16447
+ // Virtual tags are always added from local storage
16448
+ mergedTags[viewTag.TagId] = entry;
16449
+ }
16450
+ });
16451
+ // 2. Add any new backend tags that might be missing from local storage
16452
+ // (Rare case, but possible if added by another user/session)
16453
+ backendTags.forEach(function (backendTag) {
16454
+ if (!mergedTags[backendTag.TagId]) {
16455
+ // Add with default order at the end
16456
+ var maxOrder = Math.max.apply(Math, __spreadArray(__spreadArray([], Object.values(mergedTags).map(function (t) { return t.order; }), false), [0], false));
16457
+ if (isNil(backendTag.Color)) {
16458
+ backendTag.Color = getRandomColor();
16459
+ }
16460
+ mergedTags[backendTag.TagId] = {
16461
+ viewTag: backendTag,
16462
+ order: maxOrder + 1,
16463
+ };
16464
+ }
16465
+ });
16466
+ }
16467
+ else {
16468
+ // No local storage -> Use backend tags with default ordering
16469
+ mergedTags = backendTags.reduce(function (carr, curr, idx) {
16470
+ if (isNil(curr.Color)) {
16471
+ curr.Color = getRandomColor();
16472
+ }
16473
+ carr[curr.TagId] = {
16474
+ viewTag: curr,
16475
+ order: idx,
16476
+ };
16477
+ return carr;
16478
+ }, {});
16479
+ }
16333
16480
  // Reset stable ref when loading new view
16334
16481
  stableTagIdsRef.current = [];
16335
- setViewTagsAndRefetch(vTags);
16482
+ setViewTagsAndRefetch(mergedTags);
16336
16483
  }, [viewTagsSuccess, viewTagsData, setViewTagsAndRefetch, viewId]);
16337
16484
  // Update context with calculated min/max values
16338
16485
  // Use ref to prevent infinite loop from object reference changes
@@ -19984,22 +20131,6 @@ var ShiftSelector = function (_a) {
19984
20131
  React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); }, title: "Error loading shifts" })));
19985
20132
  };
19986
20133
 
19987
- var NotificationSnackBar = function (_a) {
19988
- var message = _a.message, _b = _a.onHide, onHide = _b === void 0 ? function () { } : _b, _c = _a.severity, severity = _c === void 0 ? "success" : _c;
19989
- var handleClose = function (event, reason) {
19990
- if (reason === "clickaway") {
19991
- return;
19992
- }
19993
- onHide();
19994
- };
19995
- var _d = useState(true), open = _d[0], setOpen = _d[1];
19996
- useEffect(function () {
19997
- setOpen(!!message);
19998
- }, [message]);
19999
- return (React__default.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
20000
- React__default.createElement(Alert$3, { elevation: 6, variant: "filled", severity: severity, onClose: handleClose }, message)));
20001
- };
20002
-
20003
20134
  var useEntrySubmission = function (_a) {
20004
20135
  var _b = _a === void 0 ? {} : _a, onSuccess = _b.onSuccess, onError = _b.onError, _c = _b.isNewEntry, isNewEntry = _c === void 0 ? false : _c, _d = _b.onHide, onHide = _d === void 0 ? function () { } : _d;
20005
20136
  var _e = useState(false), isSubmitLoading = _e[0], setIsSubmitLoading = _e[1];