@dexteel/mesf-core 6.2.0 → 6.2.2

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
- ".": "6.2.0"
2
+ ".": "6.2.2"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [6.2.2](https://github.com/dexteel/mesf-core-frontend/compare/mesf-core-v6.2.1...mesf-core-v6.2.2) (2025-10-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Create User:** enhance user creation process with password and profile management ([7e54340](https://github.com/dexteel/mesf-core-frontend/commit/7e54340c53a19276fcd11f536033bc7f3b24ae20))
9
+ * **Edit User:** streamline user update process and improve profile ID handling ([182ed68](https://github.com/dexteel/mesf-core-frontend/commit/182ed6814473176c3cd741a9e58133a4d9d4e3ad))
10
+
11
+ ## [6.2.1](https://github.com/dexteel/mesf-core-frontend/compare/mesf-core-v6.2.0...mesf-core-v6.2.1) (2025-10-28)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **logbook:** fix attachment download and delete dialog state management ([95c588e](https://github.com/dexteel/mesf-core-frontend/commit/95c588ef9071a1872fe201ea825e0f7e0636cf35))
17
+
3
18
  ## [6.2.0](https://github.com/dexteel/mesf-core-frontend/compare/mesf-core-v6.1.4...mesf-core-v6.2.0) (2025-10-27)
4
19
 
5
20
 
package/dist/index.esm.js CHANGED
@@ -8355,7 +8355,31 @@ var CreateUser = function (_a) {
8355
8355
  };
8356
8356
  var UserName = watch("UserName");
8357
8357
  var createUser = useMutation({
8358
- mutationFn: upsertUser,
8358
+ mutationFn: function (data) { return __awaiter(void 0, void 0, void 0, function () {
8359
+ var userId, passwordResult;
8360
+ return __generator(this, function (_a) {
8361
+ switch (_a.label) {
8362
+ case 0: return [4 /*yield*/, upsertUser(data)];
8363
+ case 1:
8364
+ userId = _a.sent();
8365
+ return [4 /*yield*/, setPassword(userId, data.UserName)];
8366
+ case 2:
8367
+ passwordResult = _a.sent();
8368
+ if (!passwordResult.ok) {
8369
+ throw new Error(passwordResult.message || "Error setting password");
8370
+ }
8371
+ if (!(data.ProfilesId && Array.isArray(data.ProfilesId))) return [3 /*break*/, 4];
8372
+ return [4 /*yield*/, setProfilesToUser({
8373
+ UserId: userId,
8374
+ profileIds: data.ProfilesId,
8375
+ })];
8376
+ case 3:
8377
+ _a.sent();
8378
+ _a.label = 4;
8379
+ case 4: return [2 /*return*/, userId];
8380
+ }
8381
+ });
8382
+ }); },
8359
8383
  onSuccess: function () {
8360
8384
  setOpen(true);
8361
8385
  onHide(true);
@@ -8821,38 +8845,45 @@ var EditUser = function (_a) {
8821
8845
  }
8822
8846
  setOpen(false);
8823
8847
  };
8824
- var setProfiles = useMutation({
8825
- mutationFn: setProfilesToUser,
8826
- onError: function (error) {
8827
- setError(error.message);
8828
- },
8829
- });
8830
8848
  var editUser = useMutation({
8831
- mutationFn: upsertUser,
8832
- onSuccess: function (userUpdatedId) { return __awaiter(void 0, void 0, void 0, function () {
8833
- var currentLoggedUserId, selectedArea;
8849
+ mutationFn: function (data) { return __awaiter(void 0, void 0, void 0, function () {
8850
+ var userUpdatedId, validProfileIds;
8834
8851
  return __generator(this, function (_a) {
8835
8852
  switch (_a.label) {
8836
- case 0: return [4 /*yield*/, setProfiles.mutate({
8837
- UserId: userUpdatedId,
8838
- profileIds: profilesIds,
8839
- })];
8853
+ case 0: return [4 /*yield*/, upsertUser(data)];
8840
8854
  case 1:
8855
+ userUpdatedId = _a.sent();
8856
+ validProfileIds = Array.isArray(profilesIds)
8857
+ ? profilesIds.filter(function (id) { return !isNaN(id) && id > 0; })
8858
+ : [];
8859
+ // Step 3: Set the profiles for the user
8860
+ return [4 /*yield*/, setProfilesToUser({
8861
+ UserId: userUpdatedId,
8862
+ profileIds: validProfileIds,
8863
+ })];
8864
+ case 2:
8865
+ // Step 3: Set the profiles for the user
8841
8866
  _a.sent();
8842
- currentLoggedUserId = getUserId();
8843
- if (currentLoggedUserId === userUpdatedId && defaultAssetId) {
8844
- selectedArea = areasList.find(function (area) { return (area === null || area === void 0 ? void 0 : area.AssetId) === defaultAssetId; });
8845
- if (selectedArea) {
8846
- setDefaultAreaId(defaultAssetId);
8847
- setDefaultAreaName(selectedArea.AssetName);
8848
- }
8849
- }
8850
- onHide(true);
8851
- setOpen(true);
8852
- return [2 /*return*/];
8867
+ return [2 /*return*/, userUpdatedId];
8853
8868
  }
8854
8869
  });
8855
8870
  }); },
8871
+ onSuccess: function (userUpdatedId) { return __awaiter(void 0, void 0, void 0, function () {
8872
+ var currentLoggedUserId, selectedArea;
8873
+ return __generator(this, function (_a) {
8874
+ currentLoggedUserId = getUserId();
8875
+ if (currentLoggedUserId === userUpdatedId && defaultAssetId) {
8876
+ selectedArea = areasList.find(function (area) { return (area === null || area === void 0 ? void 0 : area.AssetId) === defaultAssetId; });
8877
+ if (selectedArea) {
8878
+ setDefaultAreaId(defaultAssetId);
8879
+ setDefaultAreaName(selectedArea.AssetName);
8880
+ }
8881
+ }
8882
+ onHide(true);
8883
+ setOpen(true);
8884
+ return [2 /*return*/];
8885
+ });
8886
+ }); },
8856
8887
  onError: function (error) {
8857
8888
  setError(error.message);
8858
8889
  },
@@ -8879,7 +8910,13 @@ var EditUser = function (_a) {
8879
8910
  if (isSuccess) {
8880
8911
  var userSelected = rows ? rows[0] : null;
8881
8912
  if (userSelected) {
8882
- var profilesIds_1 = (((_a = userSelected.ProfilesId) === null || _a === void 0 ? void 0 : _a.toString()) || "").split(",") || [];
8913
+ var profilesIdsString = ((_a = userSelected.ProfilesId) === null || _a === void 0 ? void 0 : _a.toString()) || "";
8914
+ var profilesIds_1 = profilesIdsString
8915
+ .split(",")
8916
+ .map(function (pId) { return pId.trim(); })
8917
+ .filter(function (pId) { return pId !== ""; })
8918
+ .map(function (pId) { return parseInt(pId); })
8919
+ .filter(function (pId) { return !isNaN(pId); });
8883
8920
  setValue("UserId", userSelected.UserId);
8884
8921
  setValue("UserName", userSelected.UserName);
8885
8922
  setValue("FirstName", userSelected.FirstName);
@@ -8888,7 +8925,7 @@ var EditUser = function (_a) {
8888
8925
  setValue("IsActive", userSelected.IsActive);
8889
8926
  setValue("LastLogin", userSelected.LastLogin);
8890
8927
  setValue("DefaultAssetId", userSelected.DefaultAssetId);
8891
- setValue("ProfilesId", profilesIds_1.map(function (pId) { return parseInt(pId); }));
8928
+ setValue("ProfilesId", profilesIds_1);
8892
8929
  }
8893
8930
  }
8894
8931
  }
@@ -15441,16 +15478,14 @@ var useEntrySubmission = function (_a) {
15441
15478
 
15442
15479
  var DeleteAttachmentConfirmationDialog = function (_a) {
15443
15480
  var open = _a.open, attachmentName = _a.attachmentName, onClose = _a.onClose, _b = _a.isDeleting, isDeleting = _b === void 0 ? false : _b;
15444
- var _c = useState(false), isClosing = _c[0], setIsClosing = _c[1];
15445
15481
  var handleCancel = function () {
15446
- if (isClosing)
15482
+ if (isDeleting)
15447
15483
  return;
15448
15484
  onClose(false);
15449
15485
  };
15450
15486
  var handleConfirm = function () {
15451
- if (isClosing)
15487
+ if (isDeleting)
15452
15488
  return;
15453
- setIsClosing(true);
15454
15489
  onClose(true);
15455
15490
  };
15456
15491
  return (React__default.createElement(Dialog$1, { open: open, onClose: handleCancel, "aria-labelledby": "delete-attachment-dialog-title", "aria-describedby": "delete-attachment-dialog-description" },
@@ -15461,8 +15496,8 @@ var DeleteAttachmentConfirmationDialog = function (_a) {
15461
15496
  React__default.createElement("b", null, attachmentName),
15462
15497
  "? This action cannot be undone.")),
15463
15498
  React__default.createElement(DialogActions$1, null,
15464
- React__default.createElement(Button, { onClick: handleCancel, color: "default", disabled: isClosing }, "Cancel"),
15465
- React__default.createElement(Button, { onClick: handleConfirm, color: "secondary", variant: "contained", disabled: isClosing, startIcon: isDeleting && React__default.createElement(CircularProgress, { size: "1rem" }) }, "Delete"))));
15499
+ React__default.createElement(Button, { onClick: handleCancel, color: "default", disabled: isDeleting }, "Cancel"),
15500
+ React__default.createElement(Button, { onClick: handleConfirm, color: "secondary", variant: "contained", disabled: isDeleting, startIcon: isDeleting && React__default.createElement(CircularProgress, { size: "1rem" }) }, "Delete"))));
15466
15501
  };
15467
15502
 
15468
15503
  var useStyles$2 = makeStyles$1(function (theme) {
@@ -15739,36 +15774,17 @@ var AttachmentModal = function (_a) {
15739
15774
  var extension = fileName.toLowerCase().split(".").pop() || "";
15740
15775
  return PREVIEWABLE_EXTENSIONS.includes(extension);
15741
15776
  };
15742
- var handleDownloadAttachment = function (attachment) { return __awaiter(void 0, void 0, void 0, function () {
15743
- var response, blob, url, link, error_4;
15744
- return __generator(this, function (_a) {
15745
- switch (_a.label) {
15746
- case 0:
15747
- _a.trys.push([0, 3, , 4]);
15748
- return [4 /*yield*/, fetch(attachment.URL)];
15749
- case 1:
15750
- response = _a.sent();
15751
- return [4 /*yield*/, response.blob()];
15752
- case 2:
15753
- blob = _a.sent();
15754
- url = window.URL.createObjectURL(blob);
15755
- link = document.createElement("a");
15756
- link.href = url;
15757
- link.download = attachment.FileName || attachment.AttachmentName;
15758
- document.body.appendChild(link);
15759
- link.click();
15760
- document.body.removeChild(link);
15761
- window.URL.revokeObjectURL(url);
15762
- return [3 /*break*/, 4];
15763
- case 3:
15764
- error_4 = _a.sent();
15765
- console.error("Download failed:", error_4);
15766
- setError("Failed to download file: ".concat(error_4));
15767
- return [3 /*break*/, 4];
15768
- case 4: return [2 /*return*/];
15769
- }
15770
- });
15771
- }); };
15777
+ var handleDownloadAttachment = function (attachment) {
15778
+ var link = document.createElement("a");
15779
+ link.href = attachment.URL;
15780
+ console.log("attachment", attachment);
15781
+ console.log("attachment.URL", attachment.URL);
15782
+ console.log("link.href", link.href);
15783
+ link.setAttribute("target", "_blank");
15784
+ link.setAttribute("download", attachment.AttachmentName);
15785
+ document.body.appendChild(link);
15786
+ link.click();
15787
+ };
15772
15788
  var onDrop = useCallback(function (acceptedFiles) {
15773
15789
  if (isEditing) {
15774
15790
  handleFileUpload(acceptedFiles);
@@ -15806,7 +15822,7 @@ var AttachmentModal = function (_a) {
15806
15822
  React__default.createElement(AttachFile, null)),
15807
15823
  React__default.createElement(ListItemText, { primary: attachment.AttachmentName, secondary: "Added by ".concat(attachment.CreatedBy, " on ").concat(attachment.CreationTime.toLocaleDateString()) }),
15808
15824
  React__default.createElement(ListItemSecondaryAction, null,
15809
- isPreviewable(attachment.FileName || attachment.AttachmentName) && (React__default.createElement(IconButton$1, { component: "a", href: attachment.URL, target: "_blank", rel: "noopener noreferrer", title: "Preview", size: "small", style: { marginRight: 8 } },
15825
+ isPreviewable(attachment.AttachmentName) && (React__default.createElement(IconButton$1, { component: "a", href: attachment.URL, target: "_blank", rel: "noopener noreferrer", title: "Preview", size: "small", style: { marginRight: 8 } },
15810
15826
  React__default.createElement(Visibility, null))),
15811
15827
  React__default.createElement(IconButton$1, { onClick: function () { return handleDownloadAttachment(attachment); }, title: "Download", size: "small", style: { marginRight: isEditing ? 8 : 0 } },
15812
15828
  React__default.createElement(GetApp, null)),