@dexteel/mesf-core 7.8.1 → 7.9.0
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/controls/section-selector/SectionMultiSelect.d.ts +11 -0
- package/dist/controls/section-selector/SectionSelector.d.ts +11 -0
- package/dist/controls/section-selector/hooks/index.d.ts +2 -0
- package/dist/controls/section-selector/hooks/useSections.d.ts +7 -0
- package/dist/controls/section-selector/hooks/useTopSections.d.ts +6 -0
- package/dist/controls/section-selector/index.d.ts +5 -0
- package/dist/controls/section-selector/models/Section.d.ts +22 -0
- package/dist/controls/section-selector/repositories/SectionRepository.d.ts +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +2830 -240
- package/dist/index.esm.js.map +1 -1
- package/dist/pages/section-logbook/entry/LogbookPage.d.ts +3 -0
- package/dist/pages/section-logbook/entry/components/Logbook.d.ts +2 -0
- package/dist/pages/section-logbook/entry/components/attachments/AttachmentModal.d.ts +12 -0
- package/dist/pages/section-logbook/entry/components/attachments/AttachmentPlugin.d.ts +15 -0
- package/dist/pages/section-logbook/entry/components/attachments/DeleteAttachmentConfirmationDialog.d.ts +9 -0
- package/dist/pages/section-logbook/entry/components/dialog/DeleteEntryDialog.d.ts +9 -0
- package/dist/pages/section-logbook/entry/components/entry-viewer/ContentInput.d.ts +16 -0
- package/dist/pages/section-logbook/entry/components/entry-viewer/EntryViewer.d.ts +17 -0
- package/dist/pages/section-logbook/entry/components/filters/filters.d.ts +10 -0
- package/dist/pages/section-logbook/entry/hooks/useEntries.d.ts +8 -0
- package/dist/pages/section-logbook/entry/hooks/useEntrySubmission.d.ts +34 -0
- package/dist/pages/section-logbook/entry/hooks/useLogbookEntryOptionsFunctions.d.ts +12 -0
- package/dist/pages/section-logbook/entry/hooks/useTableData.d.ts +10 -0
- package/dist/pages/section-logbook/entry/index.d.ts +2 -0
- package/dist/pages/section-logbook/entry/models/Entry.d.ts +22 -0
- package/dist/pages/section-logbook/entry/models/EntryAttachment.d.ts +20 -0
- package/dist/pages/section-logbook/entry/repository/LogbookRepository.d.ts +34 -0
- package/dist/pages/section-logbook/index.d.ts +22 -0
- package/dist/pages/section-logbook/report/LogbookPage.d.ts +3 -0
- package/dist/pages/section-logbook/report/components/Logbook.d.ts +2 -0
- package/dist/pages/section-logbook/report/components/entry-viewer/EntryViewer.d.ts +13 -0
- package/dist/pages/section-logbook/report/components/filters/filters.d.ts +14 -0
- package/dist/pages/section-logbook/report/hooks/useEntriesReport.d.ts +10 -0
- package/dist/pages/section-logbook/report/hooks/useTableData.d.ts +8 -0
- package/dist/pages/section-logbook/report/index.d.ts +2 -0
- package/dist/pages/section-logbook/report/repository/LogbookRepository.d.ts +8 -0
- package/dist/pages/section-logbook/shared/LogbookSectionPage.d.ts +2 -0
- package/dist/pages/section-logbook/shared/components/LogbookSection.d.ts +2 -0
- package/dist/pages/section-logbook/shared/components/entry-viewer/SectionEntryViewer.d.ts +14 -0
- package/dist/pages/section-logbook/shared/components/entry-viewer/index.d.ts +1 -0
- package/dist/pages/section-logbook/shared/components/filters/SectionFilters.d.ts +15 -0
- package/dist/pages/section-logbook/shared/components/filters/index.d.ts +1 -0
- package/dist/pages/section-logbook/shared/hooks/index.d.ts +2 -0
- package/dist/pages/section-logbook/shared/hooks/useSectionEntries.d.ts +7 -0
- package/dist/pages/section-logbook/shared/hooks/useTableData.d.ts +11 -0
- package/dist/pages/section-logbook/shared/index.d.ts +6 -0
- package/dist/pages/section-logbook/shared/models/SectionEntry.d.ts +16 -0
- package/dist/pages/section-logbook/shared/repository/SectionRepository.d.ts +25 -0
- package/dist/pages/section-logbook/useGridDefinitions.d.ts +9 -0
- package/dist/reducers/LogbookSettingsReducer.d.ts +11 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -34,9 +34,9 @@ import { DataGrid, GridOverlay } from '@mui/x-data-grid';
|
|
|
34
34
|
import PropTypes from 'prop-types';
|
|
35
35
|
import GetAppIcon from '@mui/icons-material/GetApp';
|
|
36
36
|
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
37
|
-
import moment$
|
|
37
|
+
import moment$g from 'moment-timezone';
|
|
38
38
|
import { useParams, useNavigate, useSearchParams, Link, Navigate, Routes, Route, useLocation, BrowserRouter } from 'react-router-dom';
|
|
39
|
-
import moment$
|
|
39
|
+
import moment$f from 'moment';
|
|
40
40
|
import SkipNextIcon from '@mui/icons-material/SkipNext';
|
|
41
41
|
import PersonOutlineIcon from '@mui/icons-material/PersonOutline';
|
|
42
42
|
import LockIcon from '@mui/icons-material/Lock';
|
|
@@ -903,7 +903,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
903
903
|
data.dataBaseName = database;
|
|
904
904
|
data.parameters = formattedParameters;
|
|
905
905
|
Date.prototype.toJSON = function () {
|
|
906
|
-
return moment$
|
|
906
|
+
return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
|
|
907
907
|
}; // eslint-disable-line
|
|
908
908
|
isError = { ok: true };
|
|
909
909
|
return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + "/Execute", {
|
|
@@ -962,7 +962,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
962
962
|
data.method = procedure;
|
|
963
963
|
data.parameters = formattedParameters;
|
|
964
964
|
Date.prototype.toJSON = function () {
|
|
965
|
-
return moment$
|
|
965
|
+
return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
|
|
966
966
|
}; // eslint-disable-line
|
|
967
967
|
curatedMethod = procedure.replace(/[\[\]]/g, "");
|
|
968
968
|
_a.label = 1;
|
|
@@ -1017,7 +1017,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
1017
1017
|
data.dataBaseName = database;
|
|
1018
1018
|
data.parameters = formattedParameters;
|
|
1019
1019
|
Date.prototype.toJSON = function () {
|
|
1020
|
-
return moment$
|
|
1020
|
+
return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
|
|
1021
1021
|
}; // eslint-disable-line
|
|
1022
1022
|
isError = { ok: true };
|
|
1023
1023
|
return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + "/ExecuteJSON", {
|
|
@@ -1074,7 +1074,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
1074
1074
|
formattedParameters.push(formattedParameter);
|
|
1075
1075
|
});
|
|
1076
1076
|
Date.prototype.toJSON = function () {
|
|
1077
|
-
return moment$
|
|
1077
|
+
return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
|
|
1078
1078
|
}; // eslint-disable-line
|
|
1079
1079
|
isError = { ok: true };
|
|
1080
1080
|
files.forEach(function (element) {
|
|
@@ -1141,7 +1141,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
1141
1141
|
data.parameters = formattedParameters;
|
|
1142
1142
|
data.fileName = fileName || "Default.xlsx";
|
|
1143
1143
|
Date.prototype.toJSON = function () {
|
|
1144
|
-
return moment$
|
|
1144
|
+
return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
|
|
1145
1145
|
}; // eslint-disable-line
|
|
1146
1146
|
isError = { ok: true };
|
|
1147
1147
|
return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + "/Export", {
|
|
@@ -1219,7 +1219,7 @@ var MESApiService = /** @class */ (function () {
|
|
|
1219
1219
|
data.parameters = formattedParameters;
|
|
1220
1220
|
data.fileName = fileName || "Default.xlsx";
|
|
1221
1221
|
Date.prototype.toJSON = function () {
|
|
1222
|
-
return moment$
|
|
1222
|
+
return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
|
|
1223
1223
|
}; // eslint-disable-line
|
|
1224
1224
|
isError = { ok: true };
|
|
1225
1225
|
return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + "/ExportExcel", {
|
|
@@ -1771,7 +1771,7 @@ var TimeService = /** @class */ (function () {
|
|
|
1771
1771
|
else {
|
|
1772
1772
|
this.timeZone = timeZone;
|
|
1773
1773
|
}
|
|
1774
|
-
moment$
|
|
1774
|
+
moment$g.tz.setDefault(this.timeZone);
|
|
1775
1775
|
};
|
|
1776
1776
|
TimeService.prototype.toUTC = function (datetime, format$1) {
|
|
1777
1777
|
try {
|
|
@@ -1810,7 +1810,7 @@ var TimeService = /** @class */ (function () {
|
|
|
1810
1810
|
};
|
|
1811
1811
|
return TimeService;
|
|
1812
1812
|
}());
|
|
1813
|
-
var getMomentTz = function () { return moment$
|
|
1813
|
+
var getMomentTz = function () { return moment$g; };
|
|
1814
1814
|
var dxtServerTimeZone = function () {
|
|
1815
1815
|
return TimeService.getInstance().getServerTimeZone;
|
|
1816
1816
|
};
|
|
@@ -4322,7 +4322,7 @@ var useProfilesOptionsFunctions = function (_a) {
|
|
|
4322
4322
|
};
|
|
4323
4323
|
};
|
|
4324
4324
|
|
|
4325
|
-
var useTableData$
|
|
4325
|
+
var useTableData$7 = function (_a) {
|
|
4326
4326
|
var setProfileId = _a.setProfileId, setModalProceduresProfile = _a.setModalProceduresProfile, setModalDeleteProfile = _a.setModalDeleteProfile, showContextMenu = _a.showContextMenu;
|
|
4327
4327
|
var columnDefs = [
|
|
4328
4328
|
{
|
|
@@ -4441,7 +4441,7 @@ var TableProfiles = function () {
|
|
|
4441
4441
|
setModalProceduresProfile: setModalProceduresProfile,
|
|
4442
4442
|
}).getMenuOptions;
|
|
4443
4443
|
var _h = useContextMenuMESF(), showContextMenu = _h.showContextMenu, registerConfig = _h.registerConfig;
|
|
4444
|
-
var columnDefs = useTableData$
|
|
4444
|
+
var columnDefs = useTableData$7({
|
|
4445
4445
|
setModalDeleteProfile: setModalDeleteProfile,
|
|
4446
4446
|
setModalProceduresProfile: setModalProceduresProfile,
|
|
4447
4447
|
setProfileId: setProfile,
|
|
@@ -5272,7 +5272,7 @@ var buttonsCellRenderer = function (params) {
|
|
|
5272
5272
|
React__default.createElement(FormatListBulletedSharpIcon, { style: { height: "auto" }, color: "action" })))));
|
|
5273
5273
|
};
|
|
5274
5274
|
|
|
5275
|
-
var useTableData$
|
|
5275
|
+
var useTableData$6 = function (_a) {
|
|
5276
5276
|
var setUserId = _a.setUserId, setOpenModalEditDataUser = _a.setOpenModalEditDataUser, setOpenModalDeleteUser = _a.setOpenModalDeleteUser, setOpenModalChangePasswordd = _a.setOpenModalChangePasswordd, showContextMenu = _a.showContextMenu;
|
|
5277
5277
|
var columnDefs = [
|
|
5278
5278
|
{
|
|
@@ -5442,7 +5442,7 @@ var TableUsers = function () {
|
|
|
5442
5442
|
setShowChangePasswordModal: setOpenModalChangePasswordd,
|
|
5443
5443
|
}).getMenuOptions;
|
|
5444
5444
|
var _k = useContextMenuMESF(), showContextMenu = _k.showContextMenu, registerConfig = _k.registerConfig;
|
|
5445
|
-
var columnDefs = useTableData$
|
|
5445
|
+
var columnDefs = useTableData$6({
|
|
5446
5446
|
setUserId: setUserId,
|
|
5447
5447
|
setOpenModalEditDataUser: setOpenModalEditDataUser,
|
|
5448
5448
|
setOpenModalDeleteUser: setOpenModalDeleteUser,
|
|
@@ -6223,11 +6223,11 @@ var useShiftNavigatorManager = function () {
|
|
|
6223
6223
|
case 1:
|
|
6224
6224
|
resp = _a.sent();
|
|
6225
6225
|
if (resp.ok) {
|
|
6226
|
-
shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$
|
|
6226
|
+
shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$f
|
|
6227
6227
|
.utc(resp.data.CurrentProductionDate)
|
|
6228
|
-
.toDate(), CurrentStart: moment$
|
|
6228
|
+
.toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
|
|
6229
6229
|
.utc(resp.data.PreviousProductionDate)
|
|
6230
|
-
.toDate(), PreviousStart: moment$
|
|
6230
|
+
.toDate(), PreviousStart: moment$f.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$f.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$f.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$f.utc(resp.data.LastStart).toDate(), LastEnd: moment$f.utc(resp.data.LastEnd).toDate() });
|
|
6231
6231
|
setShiftInfo(shift);
|
|
6232
6232
|
return [2 /*return*/, shift];
|
|
6233
6233
|
}
|
|
@@ -6252,11 +6252,11 @@ var useShiftNavigatorManager = function () {
|
|
|
6252
6252
|
case 2:
|
|
6253
6253
|
resp = _a.sent();
|
|
6254
6254
|
if (resp.ok) {
|
|
6255
|
-
shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$
|
|
6255
|
+
shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$f
|
|
6256
6256
|
.utc(resp.data.CurrentProductionDate)
|
|
6257
|
-
.toDate(), CurrentStart: moment$
|
|
6257
|
+
.toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
|
|
6258
6258
|
.utc(resp.data.PreviousProductionDate)
|
|
6259
|
-
.toDate(), PreviousStart: moment$
|
|
6259
|
+
.toDate(), PreviousStart: moment$f.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$f.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$f.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$f.utc(resp.data.LastStart).toDate(), LastEnd: moment$f.utc(resp.data.LastEnd).toDate() });
|
|
6260
6260
|
setShiftInfo(shift);
|
|
6261
6261
|
return [2 /*return*/, shift];
|
|
6262
6262
|
}
|
|
@@ -6282,11 +6282,11 @@ var useShiftNavigatorManager = function () {
|
|
|
6282
6282
|
case 1:
|
|
6283
6283
|
resp = _a.sent();
|
|
6284
6284
|
if (resp.ok) {
|
|
6285
|
-
shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$
|
|
6285
|
+
shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$f
|
|
6286
6286
|
.utc(resp.data.CurrentProductionDate)
|
|
6287
|
-
.toDate(), CurrentStart: moment$
|
|
6287
|
+
.toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
|
|
6288
6288
|
.utc(resp.data.PreviousProductionDate)
|
|
6289
|
-
.toDate(), PreviousStart: moment$
|
|
6289
|
+
.toDate(), PreviousStart: moment$f.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$f.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$f.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$f.utc(resp.data.LastStart).toDate(), LastEnd: moment$f.utc(resp.data.LastEnd).toDate() });
|
|
6290
6290
|
setShiftInfo(shift);
|
|
6291
6291
|
return [2 /*return*/, shift];
|
|
6292
6292
|
}
|
|
@@ -6384,13 +6384,13 @@ var ShiftDayNavigatorControl = function (_a) {
|
|
|
6384
6384
|
case 2:
|
|
6385
6385
|
resp = _a.sent();
|
|
6386
6386
|
if (resp.ok) {
|
|
6387
|
-
shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$
|
|
6387
|
+
shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$g
|
|
6388
6388
|
.utc(resp.data.CurrentProductionDate)
|
|
6389
|
-
.toDate(), CurrentStart: moment$
|
|
6389
|
+
.toDate(), CurrentStart: moment$g.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$g.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$g
|
|
6390
6390
|
.utc(resp.data.PreviousProductionDate)
|
|
6391
|
-
.toDate(), PreviousStart: moment$
|
|
6391
|
+
.toDate(), PreviousStart: moment$g.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$g.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$g
|
|
6392
6392
|
.utc(resp.data.LastProductionDate)
|
|
6393
|
-
.toDate(), LastStart: moment$
|
|
6393
|
+
.toDate(), LastStart: moment$g.utc(resp.data.LastStart).toDate(), LastEnd: moment$g.utc(resp.data.LastEnd).toDate() });
|
|
6394
6394
|
setShiftInfoCopy(shift);
|
|
6395
6395
|
}
|
|
6396
6396
|
return [3 /*break*/, 4];
|
|
@@ -6434,7 +6434,7 @@ var ShiftDayNavigatorControl = function (_a) {
|
|
|
6434
6434
|
}, size: "small" },
|
|
6435
6435
|
React__default.createElement(ArrowBackRounded, null)))),
|
|
6436
6436
|
React__default.createElement(Grid2, { size: "auto" },
|
|
6437
|
-
React__default.createElement(DatePicker, { label: "Current Date", timezone: "UTC", format: "MM/DD/YYYY", maxDate: moment$
|
|
6437
|
+
React__default.createElement(DatePicker, { label: "Current Date", timezone: "UTC", format: "MM/DD/YYYY", maxDate: moment$g(), closeOnSelect: true, formatDensity: "dense", value: moment$g(shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentProductionDate), onChange: function (date) {
|
|
6438
6438
|
if (date) {
|
|
6439
6439
|
getShiftDataFromAPI(date.toDate(), 0).then(function () { });
|
|
6440
6440
|
}
|
|
@@ -6516,8 +6516,8 @@ var getShiftsRangeByParameters = function (period_1) {
|
|
|
6516
6516
|
if (resp.ok) {
|
|
6517
6517
|
data = resp.data;
|
|
6518
6518
|
data.tables[0].rows.map(function (shift) {
|
|
6519
|
-
shift.Start = moment$
|
|
6520
|
-
shift.End = moment$
|
|
6519
|
+
shift.Start = moment$g.utc(shift["Start"]).toDate();
|
|
6520
|
+
shift.End = moment$g.utc(shift["End"]).toDate();
|
|
6521
6521
|
});
|
|
6522
6522
|
return [2 /*return*/, {
|
|
6523
6523
|
ok: true,
|
|
@@ -6567,13 +6567,13 @@ var ShiftPeriodNavigatorControl = function (_a) {
|
|
|
6567
6567
|
case 1:
|
|
6568
6568
|
_a.trys.push([1, 6, , 7]);
|
|
6569
6569
|
if (!(direction === "prev" && (startShift === null || startShift === void 0 ? void 0 : startShift.Start))) return [3 /*break*/, 3];
|
|
6570
|
-
return [4 /*yield*/, searchShiftsRangeByParameters(period, moment$
|
|
6570
|
+
return [4 /*yield*/, searchShiftsRangeByParameters(period, moment$g(startShift.Start).toDate(), null, false, "prev")];
|
|
6571
6571
|
case 2:
|
|
6572
6572
|
_a.sent();
|
|
6573
6573
|
return [3 /*break*/, 5];
|
|
6574
6574
|
case 3:
|
|
6575
6575
|
if (!(direction === "next" && (endShift === null || endShift === void 0 ? void 0 : endShift.End))) return [3 /*break*/, 5];
|
|
6576
|
-
return [4 /*yield*/, searchShiftsRangeByParameters(period, null, moment$
|
|
6576
|
+
return [4 /*yield*/, searchShiftsRangeByParameters(period, null, moment$g(endShift.End).toDate(), false, "next")];
|
|
6577
6577
|
case 4:
|
|
6578
6578
|
_a.sent();
|
|
6579
6579
|
_a.label = 5;
|
|
@@ -6729,8 +6729,8 @@ var ShiftPeriodNavigatorControl = function (_a) {
|
|
|
6729
6729
|
newPeriod = event.target.value;
|
|
6730
6730
|
setPeriod(newPeriod);
|
|
6731
6731
|
if (!(newPeriod === "Custom")) return [3 /*break*/, 2];
|
|
6732
|
-
today = moment$
|
|
6733
|
-
yesterday = moment$
|
|
6732
|
+
today = moment$g();
|
|
6733
|
+
yesterday = moment$g().subtract(1, "day");
|
|
6734
6734
|
setCustomStartDate(yesterday);
|
|
6735
6735
|
setCustomEndDate(today);
|
|
6736
6736
|
return [4 /*yield*/, searchShiftsRangeByParameters("Custom", yesterday.toDate(), today.toDate(), false)];
|
|
@@ -6740,7 +6740,7 @@ var ShiftPeriodNavigatorControl = function (_a) {
|
|
|
6740
6740
|
case 2:
|
|
6741
6741
|
setCustomStartDate(null);
|
|
6742
6742
|
setCustomEndDate(null);
|
|
6743
|
-
return [4 /*yield*/, searchShiftsRangeByParameters(newPeriod, null, (endShift === null || endShift === void 0 ? void 0 : endShift.Start) ? moment$
|
|
6743
|
+
return [4 /*yield*/, searchShiftsRangeByParameters(newPeriod, null, (endShift === null || endShift === void 0 ? void 0 : endShift.Start) ? moment$g(endShift.Start).toDate() : null, false)];
|
|
6744
6744
|
case 3:
|
|
6745
6745
|
_a.sent();
|
|
6746
6746
|
_a.label = 4;
|
|
@@ -6804,10 +6804,10 @@ var ShiftPeriodNavigatorControl = function (_a) {
|
|
|
6804
6804
|
},
|
|
6805
6805
|
} },
|
|
6806
6806
|
React__default.createElement(DatePicker$1, { label: "Start", format: dateFormat, value: isCustomMode
|
|
6807
|
-
? customStartDate || moment$
|
|
6808
|
-
: moment$
|
|
6809
|
-
return handleDateChange(value ? moment$
|
|
6810
|
-
}, disabled: loadingShiftPeriodList, maxDate: isCustomMode ? moment$
|
|
6807
|
+
? customStartDate || moment$g().subtract(1, "day")
|
|
6808
|
+
: moment$g((startShift === null || startShift === void 0 ? void 0 : startShift.Start) || moment$g().subtract(1, "day")), onChange: function (value) {
|
|
6809
|
+
return handleDateChange(value ? moment$g(value) : null, "start");
|
|
6810
|
+
}, disabled: loadingShiftPeriodList, maxDate: isCustomMode ? moment$g() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
|
|
6811
6811
|
textField: function (props) { return (React__default.createElement(TextField, __assign({}, props, { size: "small", variant: "outlined", fullWidth: true, style: { width: "100%" }, InputProps: __assign(__assign({}, props.InputProps), { style: { paddingTop: "2px" } }) }))); },
|
|
6812
6812
|
openPickerIcon: function () { return (React__default.createElement("div", { style: {
|
|
6813
6813
|
display: "flex",
|
|
@@ -6849,10 +6849,10 @@ var ShiftPeriodNavigatorControl = function (_a) {
|
|
|
6849
6849
|
},
|
|
6850
6850
|
} },
|
|
6851
6851
|
React__default.createElement(DatePicker$1, { label: "End", format: dateFormat, value: isCustomMode
|
|
6852
|
-
? customEndDate || moment$
|
|
6853
|
-
: moment$
|
|
6854
|
-
return handleDateChange(value ? moment$
|
|
6855
|
-
}, disabled: loadingShiftPeriodList, minDate: isCustomMode && customStartDate ? customStartDate : undefined, maxDate: isCustomMode ? moment$
|
|
6852
|
+
? customEndDate || moment$g()
|
|
6853
|
+
: moment$g((endShift === null || endShift === void 0 ? void 0 : endShift.End) || (endShift === null || endShift === void 0 ? void 0 : endShift.Start) || moment$g()), onChange: function (value) {
|
|
6854
|
+
return handleDateChange(value ? moment$g(value) : null, "end");
|
|
6855
|
+
}, disabled: loadingShiftPeriodList, minDate: isCustomMode && customStartDate ? customStartDate : undefined, maxDate: isCustomMode ? moment$g() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
|
|
6856
6856
|
textField: function (props) { return (React__default.createElement(TextField, __assign({}, props, { size: "small", variant: "outlined", fullWidth: true, style: { width: "100%" }, InputProps: __assign(__assign({}, props.InputProps), { style: { paddingTop: "2px" } }) }))); },
|
|
6857
6857
|
openPickerIcon: function () { return (React__default.createElement("div", { style: {
|
|
6858
6858
|
display: "flex",
|
|
@@ -7532,15 +7532,15 @@ var getJobs = function () { return __awaiter(void 0, void 0, void 0, function ()
|
|
|
7532
7532
|
if (resp.ok) {
|
|
7533
7533
|
rows = get(resp, "data.tables[0].rows", []);
|
|
7534
7534
|
rows = rows.map(function (job) { return (__assign(__assign({}, job), { LastStarted: job.LastStarted
|
|
7535
|
-
? moment$
|
|
7535
|
+
? moment$f.utc(job["LastStarted"]).toDate()
|
|
7536
7536
|
: null, LastContact: job.LastContact
|
|
7537
|
-
? moment$
|
|
7537
|
+
? moment$f.utc(job["LastContact"]).toDate()
|
|
7538
7538
|
: null, LastCounter: job.LastCounter
|
|
7539
|
-
? moment$
|
|
7540
|
-
: null, StartTime: job.StartTime ? moment$
|
|
7541
|
-
? moment$
|
|
7539
|
+
? moment$f.utc(job["LastCounter"]).toDate()
|
|
7540
|
+
: null, StartTime: job.StartTime ? moment$f.utc(job["StartTime"]).toDate() : null, NextExecutionTime: job.NextExecutionTime
|
|
7541
|
+
? moment$f.utc(job["NextExecutionTime"]).toDate()
|
|
7542
7542
|
: null, LastExecutionTime: job.LastExecutionTime
|
|
7543
|
-
? moment$
|
|
7543
|
+
? moment$f.utc(job["LastExecutionTime"]).toDate()
|
|
7544
7544
|
: null })); });
|
|
7545
7545
|
return [2 /*return*/, rows];
|
|
7546
7546
|
}
|
|
@@ -7800,7 +7800,7 @@ var JobDetails = function (_a) {
|
|
|
7800
7800
|
React__default.createElement(Controller, { name: "StartTime", control: control, render: function (_a) {
|
|
7801
7801
|
var field = _a.field, error = _a.fieldState.error;
|
|
7802
7802
|
return (React__default.createElement(React__default.Fragment, null,
|
|
7803
|
-
React__default.createElement(DateTimePicker, { label: "Start Time", value: field.value ? moment$
|
|
7803
|
+
React__default.createElement(DateTimePicker, { label: "Start Time", value: field.value ? moment$g(field.value) : null, onChange: field.onChange, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), slotProps: {
|
|
7804
7804
|
textField: {
|
|
7805
7805
|
size: "small",
|
|
7806
7806
|
margin: "none",
|
|
@@ -7818,7 +7818,7 @@ var JobDetails = function (_a) {
|
|
|
7818
7818
|
React__default.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
7819
7819
|
React__default.createElement(Controller, { name: "LastExecutionTime", control: control, render: function (_a) {
|
|
7820
7820
|
var field = _a.field;
|
|
7821
|
-
return (React__default.createElement(DateTimePicker, { label: "Last Execution Time", value: field.value ? moment$
|
|
7821
|
+
return (React__default.createElement(DateTimePicker, { label: "Last Execution Time", value: field.value ? moment$g(field.value) : null, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), disabled: true, slotProps: {
|
|
7822
7822
|
textField: {
|
|
7823
7823
|
size: "small",
|
|
7824
7824
|
margin: "none",
|
|
@@ -7829,7 +7829,7 @@ var JobDetails = function (_a) {
|
|
|
7829
7829
|
React__default.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
7830
7830
|
React__default.createElement(Controller, { name: "NextExecutionTime", control: control, render: function (_a) {
|
|
7831
7831
|
var field = _a.field;
|
|
7832
|
-
return (React__default.createElement(DateTimePicker, { label: "Next Execution Time", value: field.value ? moment$
|
|
7832
|
+
return (React__default.createElement(DateTimePicker, { label: "Next Execution Time", value: field.value ? moment$g(field.value) : null, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), disabled: true, slotProps: {
|
|
7833
7833
|
textField: {
|
|
7834
7834
|
size: "small",
|
|
7835
7835
|
margin: "none",
|
|
@@ -7953,7 +7953,7 @@ var useJobsTableData = function (_a) {
|
|
|
7953
7953
|
headerName: "Next Execution",
|
|
7954
7954
|
valueFormatter: function (_a) {
|
|
7955
7955
|
var value = _a.value;
|
|
7956
|
-
return value === null ? "" : moment$
|
|
7956
|
+
return value === null ? "" : moment$f(value).format("DD/MM/YY HH:mm");
|
|
7957
7957
|
},
|
|
7958
7958
|
flex: 2,
|
|
7959
7959
|
},
|
|
@@ -8281,7 +8281,7 @@ var CodeFilter = function (_a) {
|
|
|
8281
8281
|
var DateFilter = function (_a) {
|
|
8282
8282
|
var date = _a.date, setDate = _a.setDate, _b = _a.label, label = _b === void 0 ? "Date" : _b, minDate = _a.minDate, maxDate = _a.maxDate;
|
|
8283
8283
|
return (React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
8284
|
-
React__default.createElement(DatePicker$1, { format: "MM/DD/YYYY", minDate: minDate ? moment$
|
|
8284
|
+
React__default.createElement(DatePicker$1, { format: "MM/DD/YYYY", minDate: minDate ? moment$f(minDate) : undefined, maxDate: maxDate ? moment$f(maxDate) : undefined, sx: {
|
|
8285
8285
|
minWidth: "100%",
|
|
8286
8286
|
borderTopLeftRadius: 3,
|
|
8287
8287
|
borderTopRightRadius: 3,
|
|
@@ -8291,7 +8291,7 @@ var DateFilter = function (_a) {
|
|
|
8291
8291
|
size: "small",
|
|
8292
8292
|
fullWidth: true,
|
|
8293
8293
|
},
|
|
8294
|
-
}, label: label, value: date ? moment$
|
|
8294
|
+
}, label: label, value: date ? moment$f(date) : null, onChange: function (newDate) { return setDate(newDate ? newDate.toDate() : null); } })));
|
|
8295
8295
|
};
|
|
8296
8296
|
|
|
8297
8297
|
var SearchFilter = function (_a) {
|
|
@@ -8403,7 +8403,7 @@ var getLogs = function (_a) { return __awaiter(void 0, [_a], void 0, function (_
|
|
|
8403
8403
|
resp = _c.sent();
|
|
8404
8404
|
if (resp.ok) {
|
|
8405
8405
|
rows = get(resp, "data.tables[0].rows", []);
|
|
8406
|
-
rows = rows.map(function (log) { return (__assign(__assign({}, log), { Timestamp: log.Timestamp ? moment$
|
|
8406
|
+
rows = rows.map(function (log) { return (__assign(__assign({}, log), { Timestamp: log.Timestamp ? moment$f.utc(log["Timestamp"]).toDate() : null })); });
|
|
8407
8407
|
return [2 /*return*/, rows];
|
|
8408
8408
|
}
|
|
8409
8409
|
else {
|
|
@@ -8532,8 +8532,8 @@ var getLogTypeByCodeId = function (logTypeCodeId) {
|
|
|
8532
8532
|
return get(LOG_TYPE_CODES, "".concat(logTypeCodeId, ".description"), " -");
|
|
8533
8533
|
};
|
|
8534
8534
|
var TableLogs = function () {
|
|
8535
|
-
var _a = useState(moment$
|
|
8536
|
-
var _b = useState(moment$
|
|
8535
|
+
var _a = useState(moment$f().add(-5, "days").hour(0).minute(0).second(0).toDate()), startDate = _a[0], setStartDate = _a[1];
|
|
8536
|
+
var _b = useState(moment$f().hour(23).minute(59).second(59).toDate()), endDate = _b[0], setEndDate = _b[1];
|
|
8537
8537
|
var _c = useState("UTC"), timezone = _c[0], setTimezone = _c[1];
|
|
8538
8538
|
var _d = useState(""), search = _d[0], setSearch = _d[1];
|
|
8539
8539
|
var _e = useState(["I", "W", "E"]), logTypeCode = _e[0], setLogTypeCode = _e[1];
|
|
@@ -8556,7 +8556,7 @@ var TableLogs = function () {
|
|
|
8556
8556
|
return ({
|
|
8557
8557
|
id: LogId,
|
|
8558
8558
|
Timestamp: timezone === "UTC"
|
|
8559
|
-
? moment$
|
|
8559
|
+
? moment$f(Timestamp).utc().format("YYYY-MM-DD HH:mm:ss z")
|
|
8560
8560
|
: dxtToLocalServerTime(Timestamp, "yyyy-MM-dd HH:mm:ss z"),
|
|
8561
8561
|
Source: Source,
|
|
8562
8562
|
Message: isNil(Message) ? "" : Message.replaceAll("Added", " Added"),
|
|
@@ -8582,8 +8582,8 @@ var TableLogs = function () {
|
|
|
8582
8582
|
var _m = useContextMenuMESF(), showContextMenu = _m.showContextMenu, registerConfig = _m.registerConfig;
|
|
8583
8583
|
var handleResetButtonClick = function () {
|
|
8584
8584
|
resetFilter();
|
|
8585
|
-
setStartDate(moment$
|
|
8586
|
-
setEndDate(moment$
|
|
8585
|
+
setStartDate(moment$f().add(-5, "days").hour(0).minute(0).second(0).toDate());
|
|
8586
|
+
setEndDate(moment$f().hour(23).minute(59).second(59).toDate());
|
|
8587
8587
|
setSearch("");
|
|
8588
8588
|
gridAPI === null || gridAPI === void 0 ? void 0 : gridAPI.setGridOption("quickFilterText", "");
|
|
8589
8589
|
setLogTypeCode(["I", "W", "E"]);
|
|
@@ -8592,8 +8592,8 @@ var TableLogs = function () {
|
|
|
8592
8592
|
};
|
|
8593
8593
|
// Btn reset data
|
|
8594
8594
|
var resetFilter = function () {
|
|
8595
|
-
setStartDate(moment$
|
|
8596
|
-
setEndDate(moment$
|
|
8595
|
+
setStartDate(moment$f().add(-5, "days").hour(0).minute(0).second(0).toDate());
|
|
8596
|
+
setEndDate(moment$f().hour(23).minute(59).second(59).toDate());
|
|
8597
8597
|
setSearch("");
|
|
8598
8598
|
gridAPI === null || gridAPI === void 0 ? void 0 : gridAPI.setGridOption("quickFilterText", "");
|
|
8599
8599
|
setLogTypeCode(["I", "W", "E"]);
|
|
@@ -8678,7 +8678,7 @@ var TableLogs = function () {
|
|
|
8678
8678
|
setEndDate(null);
|
|
8679
8679
|
}
|
|
8680
8680
|
else {
|
|
8681
|
-
setEndDate(moment$
|
|
8681
|
+
setEndDate(moment$f().hour(23).minute(59).second(59).toDate());
|
|
8682
8682
|
}
|
|
8683
8683
|
setAutoRefresh(checked);
|
|
8684
8684
|
} })),
|
|
@@ -8874,14 +8874,14 @@ var CreateShift = function (_a) {
|
|
|
8874
8874
|
minWidth: "100%",
|
|
8875
8875
|
borderTopLeftRadius: 3,
|
|
8876
8876
|
borderTopRightRadius: 3,
|
|
8877
|
-
}, label: "Start", value: value ? moment$
|
|
8877
|
+
}, label: "Start", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
|
|
8878
8878
|
textField: {
|
|
8879
8879
|
fullWidth: true,
|
|
8880
8880
|
variant: "standard",
|
|
8881
8881
|
},
|
|
8882
8882
|
} })),
|
|
8883
8883
|
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
8884
|
-
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$
|
|
8884
|
+
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
|
|
8885
8885
|
textField: {
|
|
8886
8886
|
fullWidth: true,
|
|
8887
8887
|
variant: "standard",
|
|
@@ -9104,7 +9104,7 @@ var DeleteShift = function (_a) {
|
|
|
9104
9104
|
minWidth: "100%",
|
|
9105
9105
|
borderTopLeftRadius: 3,
|
|
9106
9106
|
borderTopRightRadius: 3,
|
|
9107
|
-
}, label: "Start", value: value ? moment$
|
|
9107
|
+
}, label: "Start", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
|
|
9108
9108
|
textField: {
|
|
9109
9109
|
fullWidth: true,
|
|
9110
9110
|
variant: "standard",
|
|
@@ -9112,7 +9112,7 @@ var DeleteShift = function (_a) {
|
|
|
9112
9112
|
},
|
|
9113
9113
|
} })),
|
|
9114
9114
|
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
9115
|
-
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$
|
|
9115
|
+
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
|
|
9116
9116
|
textField: {
|
|
9117
9117
|
fullWidth: true,
|
|
9118
9118
|
variant: "standard",
|
|
@@ -9273,14 +9273,14 @@ var EditShift = function (_a) {
|
|
|
9273
9273
|
minWidth: "100%",
|
|
9274
9274
|
borderTopLeftRadius: 3,
|
|
9275
9275
|
borderTopRightRadius: 3,
|
|
9276
|
-
}, label: "Start", value: value ? moment$
|
|
9276
|
+
}, label: "Start", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
|
|
9277
9277
|
textField: {
|
|
9278
9278
|
fullWidth: true,
|
|
9279
9279
|
variant: "standard",
|
|
9280
9280
|
},
|
|
9281
9281
|
} })),
|
|
9282
9282
|
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
9283
|
-
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$
|
|
9283
|
+
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
|
|
9284
9284
|
textField: {
|
|
9285
9285
|
fullWidth: true,
|
|
9286
9286
|
variant: "standard",
|
|
@@ -9472,7 +9472,7 @@ var useShiftsOptionsFunctions = function (_a) {
|
|
|
9472
9472
|
};
|
|
9473
9473
|
};
|
|
9474
9474
|
|
|
9475
|
-
var useTableData$
|
|
9475
|
+
var useTableData$5 = function (_a) {
|
|
9476
9476
|
var setShiftSelected = _a.setShiftSelected, setOpenModalEditShift = _a.setOpenModalEditShift, setOpenModalDeleteShift = _a.setOpenModalDeleteShift, showContextMenu = _a.showContextMenu;
|
|
9477
9477
|
var columnDefs = [
|
|
9478
9478
|
{
|
|
@@ -9480,7 +9480,7 @@ var useTableData$3 = function (_a) {
|
|
|
9480
9480
|
headerName: "Pattern Start",
|
|
9481
9481
|
valueFormatter: function (_a) {
|
|
9482
9482
|
var value = _a.value;
|
|
9483
|
-
return "".concat(moment$
|
|
9483
|
+
return "".concat(moment$f(value).format("L"), ", ").concat(moment$f(value).format("LTS"));
|
|
9484
9484
|
},
|
|
9485
9485
|
minWidth: 180,
|
|
9486
9486
|
flex: 4,
|
|
@@ -9621,7 +9621,7 @@ var TableShiftsCrews = function () {
|
|
|
9621
9621
|
setShowEditModal: setOpenModalEditShift,
|
|
9622
9622
|
}).getMenuOptions;
|
|
9623
9623
|
var _g = useContextMenuMESF(), showContextMenu = _g.showContextMenu, registerConfig = _g.registerConfig;
|
|
9624
|
-
var columnDefs = useTableData$
|
|
9624
|
+
var columnDefs = useTableData$5({
|
|
9625
9625
|
setShiftSelected: setShiftSelected,
|
|
9626
9626
|
setOpenModalEditShift: setOpenModalEditShift,
|
|
9627
9627
|
setOpenModalDeleteShift: setOpenModalDeleteShift,
|
|
@@ -9837,6 +9837,16 @@ var LogbookSettingsInitialState = {
|
|
|
9837
9837
|
showShiftCrew: false,
|
|
9838
9838
|
exportToExcel: false,
|
|
9839
9839
|
},
|
|
9840
|
+
section: {
|
|
9841
|
+
schema: undefined,
|
|
9842
|
+
withAssetFilter: undefined,
|
|
9843
|
+
filterAssets: undefined,
|
|
9844
|
+
canEditAsset: false,
|
|
9845
|
+
allowAttachments: false,
|
|
9846
|
+
showShiftCrew: false,
|
|
9847
|
+
exportToExcel: false,
|
|
9848
|
+
topSectionsCount: 5,
|
|
9849
|
+
},
|
|
9840
9850
|
};
|
|
9841
9851
|
|
|
9842
9852
|
var LogbookSettingsContext = createContext(LogbookSettingsInitialState);
|
|
@@ -9847,6 +9857,7 @@ var LogbookSettingsProvider = function (_a) {
|
|
|
9847
9857
|
var settings = useMemo(function () { return ({
|
|
9848
9858
|
entry: __assign(__assign({}, LogbookSettingsInitialState.entry), (logbookSettings.entry || {})),
|
|
9849
9859
|
report: __assign(__assign({}, LogbookSettingsInitialState.report), (logbookSettings.report || {})),
|
|
9860
|
+
section: __assign(__assign({}, LogbookSettingsInitialState.section), (logbookSettings.section || {})),
|
|
9850
9861
|
}); }, [logbookSettings]);
|
|
9851
9862
|
return (React__default.createElement(LogbookSettingsContext.Provider, { value: settings }, children));
|
|
9852
9863
|
};
|
|
@@ -9904,7 +9915,7 @@ var useSettingsOptionsFunctions = function (_a) {
|
|
|
9904
9915
|
};
|
|
9905
9916
|
};
|
|
9906
9917
|
|
|
9907
|
-
var useTableData$
|
|
9918
|
+
var useTableData$4 = function (_a) {
|
|
9908
9919
|
var setOpenModalEditSetting = _a.setOpenModalEditSetting, setOpenModalDeleteSetting = _a.setOpenModalDeleteSetting, showContextMenu = _a.showContextMenu, setSettingSelected = _a.setSettingSelected;
|
|
9909
9920
|
var columnDefs = [
|
|
9910
9921
|
{
|
|
@@ -10327,7 +10338,7 @@ var TableSettings = function () {
|
|
|
10327
10338
|
setShowCreateModal: setOpenModalNew,
|
|
10328
10339
|
setShowEditModal: setOpenModalEditSetting,
|
|
10329
10340
|
}).getMenuOptions;
|
|
10330
|
-
var _k = useTableData$
|
|
10341
|
+
var _k = useTableData$4({
|
|
10331
10342
|
setOpenModalEditSetting: setOpenModalEditSetting,
|
|
10332
10343
|
setOpenModalDeleteSetting: setOpenModalDeleteSetting,
|
|
10333
10344
|
showContextMenu: showContextMenu,
|
|
@@ -11019,7 +11030,7 @@ var renderInput = function (param, onChange, disabled) {
|
|
|
11019
11030
|
}, disabled: disabled, fullWidth: true, size: "small", inputProps: { step: "any" } }));
|
|
11020
11031
|
}
|
|
11021
11032
|
if (["datetime", "datetime2", "date", "smalldatetime"].includes(type)) {
|
|
11022
|
-
return (React__default.createElement(DateTimePicker$1, { label: param.parameterName, value: param.value ? moment$
|
|
11033
|
+
return (React__default.createElement(DateTimePicker$1, { label: param.parameterName, value: param.value ? moment$f(param.value) : null, onChange: function (newValue) { return onChange((newValue === null || newValue === void 0 ? void 0 : newValue.toDate()) || null); }, disabled: disabled, slotProps: {
|
|
11023
11034
|
textField: {
|
|
11024
11035
|
fullWidth: true,
|
|
11025
11036
|
size: "small",
|
|
@@ -12124,21 +12135,21 @@ var dateNavigator = function (startDate, endDate, scope, operator, current) {
|
|
|
12124
12135
|
}
|
|
12125
12136
|
else {
|
|
12126
12137
|
var _a = scope.split(" "), quantity = _a[0], duration = _a[1];
|
|
12127
|
-
newStartDate = moment$
|
|
12138
|
+
newStartDate = moment$f(newEndDate)
|
|
12128
12139
|
.subtract(quantity, duration[0])
|
|
12129
12140
|
.toDate();
|
|
12130
12141
|
}
|
|
12131
12142
|
}
|
|
12132
12143
|
else {
|
|
12133
12144
|
if (scope === "custom") {
|
|
12134
|
-
var durationInMs = moment$
|
|
12135
|
-
newStartDate = moment$
|
|
12145
|
+
var durationInMs = moment$f(endDate).diff(moment$f(startDate));
|
|
12146
|
+
newStartDate = moment$f(startDate)[operator](durationInMs).toDate();
|
|
12136
12147
|
}
|
|
12137
12148
|
else {
|
|
12138
12149
|
var _b = scope.split(" "), quantity = _b[0], duration = _b[1];
|
|
12139
|
-
newStartDate = moment$
|
|
12150
|
+
newStartDate = moment$f(startDate)[operator](quantity, duration[0])
|
|
12140
12151
|
.toDate();
|
|
12141
|
-
newEndDate = moment$
|
|
12152
|
+
newEndDate = moment$f(endDate)[operator](quantity, duration[0])
|
|
12142
12153
|
.toDate();
|
|
12143
12154
|
}
|
|
12144
12155
|
}
|
|
@@ -12581,11 +12592,11 @@ var HeaderSectionV2 = React__default.memo(function (_a) {
|
|
|
12581
12592
|
};
|
|
12582
12593
|
var handlePartialDateNavigator = function (operator) {
|
|
12583
12594
|
// Calculate 20% of the current period
|
|
12584
|
-
var durationInMs = moment$
|
|
12595
|
+
var durationInMs = moment$f(timeScopeEnd).diff(moment$f(timeScopeStart));
|
|
12585
12596
|
var partialDuration = Math.round(durationInMs * 0.2);
|
|
12586
|
-
var newStartDate = moment$
|
|
12597
|
+
var newStartDate = moment$f(timeScopeStart)[operator](partialDuration, "milliseconds")
|
|
12587
12598
|
.toDate();
|
|
12588
|
-
var newEndDate = moment$
|
|
12599
|
+
var newEndDate = moment$f(timeScopeEnd)[operator](partialDuration, "milliseconds")
|
|
12589
12600
|
.toDate();
|
|
12590
12601
|
setTotalScope({
|
|
12591
12602
|
start: newStartDate,
|
|
@@ -12595,7 +12606,7 @@ var HeaderSectionV2 = React__default.memo(function (_a) {
|
|
|
12595
12606
|
};
|
|
12596
12607
|
var handleDateChange = function (newValue, key) {
|
|
12597
12608
|
var _a, _b;
|
|
12598
|
-
var newDate = moment$
|
|
12609
|
+
var newDate = moment$f(newValue).toDate();
|
|
12599
12610
|
// If scope is "custom", just update the changed date
|
|
12600
12611
|
if (scope === "custom") {
|
|
12601
12612
|
setTotalScope((_a = {}, _a[key] = newDate, _a));
|
|
@@ -12711,7 +12722,7 @@ var HeaderSectionV2 = React__default.memo(function (_a) {
|
|
|
12711
12722
|
React__default.createElement(FastRewind, { fontSize: "medium", sx: { color: "black" } })))),
|
|
12712
12723
|
React__default.createElement(Grid2, { size: { md: 3.5 } },
|
|
12713
12724
|
React__default.createElement(LocalizationProvider$1, { dateAdapter: AdapterMoment },
|
|
12714
|
-
React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$
|
|
12725
|
+
React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$f(timeScopeStart), onChange: function (newValue) {
|
|
12715
12726
|
if (newValue) {
|
|
12716
12727
|
handleDateChange(newValue.toDate(), "start");
|
|
12717
12728
|
}
|
|
@@ -12736,7 +12747,7 @@ var HeaderSectionV2 = React__default.memo(function (_a) {
|
|
|
12736
12747
|
React__default.createElement(MenuItem, { value: "custom" }, "Custom")))),
|
|
12737
12748
|
React__default.createElement(Grid2, { size: { md: 3.5 } },
|
|
12738
12749
|
React__default.createElement(LocalizationProvider$1, { dateAdapter: AdapterMoment },
|
|
12739
|
-
React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$
|
|
12750
|
+
React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$f(timeScopeEnd), onChange: function (newValue) {
|
|
12740
12751
|
if (newValue) {
|
|
12741
12752
|
handleDateChange(newValue.toDate(), "end");
|
|
12742
12753
|
}
|
|
@@ -16642,7 +16653,7 @@ const FORMATS = {
|
|
|
16642
16653
|
year: 'YYYY'
|
|
16643
16654
|
};
|
|
16644
16655
|
|
|
16645
|
-
_adapters._date.override(typeof moment$
|
|
16656
|
+
_adapters._date.override(typeof moment$f === 'function' ? {
|
|
16646
16657
|
_id: 'moment', // DEBUG ONLY
|
|
16647
16658
|
|
|
16648
16659
|
formats: function() {
|
|
@@ -16651,27 +16662,27 @@ _adapters._date.override(typeof moment$8 === 'function' ? {
|
|
|
16651
16662
|
|
|
16652
16663
|
parse: function(value, format) {
|
|
16653
16664
|
if (typeof value === 'string' && typeof format === 'string') {
|
|
16654
|
-
value = moment$
|
|
16655
|
-
} else if (!(value instanceof moment$
|
|
16656
|
-
value = moment$
|
|
16665
|
+
value = moment$f(value, format);
|
|
16666
|
+
} else if (!(value instanceof moment$f)) {
|
|
16667
|
+
value = moment$f(value);
|
|
16657
16668
|
}
|
|
16658
16669
|
return value.isValid() ? value.valueOf() : null;
|
|
16659
16670
|
},
|
|
16660
16671
|
|
|
16661
16672
|
format: function(time, format) {
|
|
16662
|
-
return moment$
|
|
16673
|
+
return moment$f(time).format(format);
|
|
16663
16674
|
},
|
|
16664
16675
|
|
|
16665
16676
|
add: function(time, amount, unit) {
|
|
16666
|
-
return moment$
|
|
16677
|
+
return moment$f(time).add(amount, unit).valueOf();
|
|
16667
16678
|
},
|
|
16668
16679
|
|
|
16669
16680
|
diff: function(max, min, unit) {
|
|
16670
|
-
return moment$
|
|
16681
|
+
return moment$f(max).diff(moment$f(min), unit);
|
|
16671
16682
|
},
|
|
16672
16683
|
|
|
16673
16684
|
startOf: function(time, unit, weekday) {
|
|
16674
|
-
time = moment$
|
|
16685
|
+
time = moment$f(time);
|
|
16675
16686
|
if (unit === 'isoWeek') {
|
|
16676
16687
|
weekday = Math.trunc(Math.min(Math.max(0, weekday), 6));
|
|
16677
16688
|
return time.isoWeekday(weekday).startOf('day').valueOf();
|
|
@@ -16680,7 +16691,7 @@ _adapters._date.override(typeof moment$8 === 'function' ? {
|
|
|
16680
16691
|
},
|
|
16681
16692
|
|
|
16682
16693
|
endOf: function(time, unit) {
|
|
16683
|
-
return moment$
|
|
16694
|
+
return moment$f(time).endOf(unit).valueOf();
|
|
16684
16695
|
}
|
|
16685
16696
|
} : {});
|
|
16686
16697
|
|
|
@@ -16735,7 +16746,7 @@ var ColorPicker = function (_a) {
|
|
|
16735
16746
|
};
|
|
16736
16747
|
|
|
16737
16748
|
var TrendingsInitialState = {
|
|
16738
|
-
timeScopeStart: moment$
|
|
16749
|
+
timeScopeStart: moment$f(new Date()).subtract(1, "days").toDate(),
|
|
16739
16750
|
timeScopeEnd: new Date(),
|
|
16740
16751
|
scope: "1 day",
|
|
16741
16752
|
graphPan: false,
|
|
@@ -16775,32 +16786,32 @@ var TrendingsReducer = createSlice({
|
|
|
16775
16786
|
if (payload.scope !== "custom") {
|
|
16776
16787
|
switch (payload.scope) {
|
|
16777
16788
|
case "10 min":
|
|
16778
|
-
state.timeScopeStart = moment$
|
|
16789
|
+
state.timeScopeStart = moment$f(state.timeScopeEnd)
|
|
16779
16790
|
.subtract(10, "minutes")
|
|
16780
16791
|
.toDate();
|
|
16781
16792
|
break;
|
|
16782
16793
|
case "1 hour":
|
|
16783
|
-
state.timeScopeStart = moment$
|
|
16794
|
+
state.timeScopeStart = moment$f(state.timeScopeEnd)
|
|
16784
16795
|
.subtract(1, "hours")
|
|
16785
16796
|
.toDate();
|
|
16786
16797
|
break;
|
|
16787
16798
|
case "4 hours":
|
|
16788
|
-
state.timeScopeStart = moment$
|
|
16799
|
+
state.timeScopeStart = moment$f(state.timeScopeEnd)
|
|
16789
16800
|
.subtract(4, "hours")
|
|
16790
16801
|
.toDate();
|
|
16791
16802
|
break;
|
|
16792
16803
|
case "12 hours":
|
|
16793
|
-
state.timeScopeStart = moment$
|
|
16804
|
+
state.timeScopeStart = moment$f(state.timeScopeEnd)
|
|
16794
16805
|
.subtract(12, "hours")
|
|
16795
16806
|
.toDate();
|
|
16796
16807
|
break;
|
|
16797
16808
|
case "1 day":
|
|
16798
|
-
state.timeScopeStart = moment$
|
|
16809
|
+
state.timeScopeStart = moment$f(state.timeScopeEnd)
|
|
16799
16810
|
.subtract(1, "days")
|
|
16800
16811
|
.toDate();
|
|
16801
16812
|
break;
|
|
16802
16813
|
case "10 days":
|
|
16803
|
-
state.timeScopeStart = moment$
|
|
16814
|
+
state.timeScopeStart = moment$f(state.timeScopeEnd)
|
|
16804
16815
|
.subtract(10, "days")
|
|
16805
16816
|
.toDate();
|
|
16806
16817
|
break;
|
|
@@ -16831,32 +16842,32 @@ var TrendingsReducer = createSlice({
|
|
|
16831
16842
|
if (state.scope !== "custom") {
|
|
16832
16843
|
switch (state.scope) {
|
|
16833
16844
|
case "10 min":
|
|
16834
|
-
state.timeScopeEnd = moment$
|
|
16845
|
+
state.timeScopeEnd = moment$f(payload.start)
|
|
16835
16846
|
.add(10, "minutes")
|
|
16836
16847
|
.toDate();
|
|
16837
16848
|
break;
|
|
16838
16849
|
case "1 hour":
|
|
16839
|
-
state.timeScopeEnd = moment$
|
|
16850
|
+
state.timeScopeEnd = moment$f(payload.start)
|
|
16840
16851
|
.add(1, "hours")
|
|
16841
16852
|
.toDate();
|
|
16842
16853
|
break;
|
|
16843
16854
|
case "4 hours":
|
|
16844
|
-
state.timeScopeEnd = moment$
|
|
16855
|
+
state.timeScopeEnd = moment$f(payload.start)
|
|
16845
16856
|
.add(4, "hours")
|
|
16846
16857
|
.toDate();
|
|
16847
16858
|
break;
|
|
16848
16859
|
case "12 hours":
|
|
16849
|
-
state.timeScopeEnd = moment$
|
|
16860
|
+
state.timeScopeEnd = moment$f(payload.start)
|
|
16850
16861
|
.add(12, "hours")
|
|
16851
16862
|
.toDate();
|
|
16852
16863
|
break;
|
|
16853
16864
|
case "1 day":
|
|
16854
|
-
state.timeScopeEnd = moment$
|
|
16865
|
+
state.timeScopeEnd = moment$f(payload.start)
|
|
16855
16866
|
.add(1, "days")
|
|
16856
16867
|
.toDate();
|
|
16857
16868
|
break;
|
|
16858
16869
|
case "10 days":
|
|
16859
|
-
state.timeScopeEnd = moment$
|
|
16870
|
+
state.timeScopeEnd = moment$f(payload.start)
|
|
16860
16871
|
.add(10, "days")
|
|
16861
16872
|
.toDate();
|
|
16862
16873
|
break;
|
|
@@ -16869,32 +16880,32 @@ var TrendingsReducer = createSlice({
|
|
|
16869
16880
|
if (state.scope !== "custom") {
|
|
16870
16881
|
switch (state.scope) {
|
|
16871
16882
|
case "10 min":
|
|
16872
|
-
state.timeScopeStart = moment$
|
|
16883
|
+
state.timeScopeStart = moment$f(payload.end)
|
|
16873
16884
|
.subtract(10, "minutes")
|
|
16874
16885
|
.toDate();
|
|
16875
16886
|
break;
|
|
16876
16887
|
case "1 hour":
|
|
16877
|
-
state.timeScopeStart = moment$
|
|
16888
|
+
state.timeScopeStart = moment$f(payload.end)
|
|
16878
16889
|
.subtract(1, "hours")
|
|
16879
16890
|
.toDate();
|
|
16880
16891
|
break;
|
|
16881
16892
|
case "4 hours":
|
|
16882
|
-
state.timeScopeStart = moment$
|
|
16893
|
+
state.timeScopeStart = moment$f(payload.end)
|
|
16883
16894
|
.subtract(4, "hours")
|
|
16884
16895
|
.toDate();
|
|
16885
16896
|
break;
|
|
16886
16897
|
case "12 hours":
|
|
16887
|
-
state.timeScopeStart = moment$
|
|
16898
|
+
state.timeScopeStart = moment$f(payload.end)
|
|
16888
16899
|
.subtract(12, "hours")
|
|
16889
16900
|
.toDate();
|
|
16890
16901
|
break;
|
|
16891
16902
|
case "1 day":
|
|
16892
|
-
state.timeScopeStart = moment$
|
|
16903
|
+
state.timeScopeStart = moment$f(payload.end)
|
|
16893
16904
|
.subtract(1, "days")
|
|
16894
16905
|
.toDate();
|
|
16895
16906
|
break;
|
|
16896
16907
|
case "10 days":
|
|
16897
|
-
state.timeScopeStart = moment$
|
|
16908
|
+
state.timeScopeStart = moment$f(payload.end)
|
|
16898
16909
|
.subtract(10, "days")
|
|
16899
16910
|
.toDate();
|
|
16900
16911
|
break;
|
|
@@ -18628,7 +18639,7 @@ var Header = React__default.memo(function (_a) {
|
|
|
18628
18639
|
var handleDateChange = function (newValue, key) {
|
|
18629
18640
|
var _a;
|
|
18630
18641
|
//@ts-ignore
|
|
18631
|
-
actions.setTotalScope((_a = {}, _a[key] = moment$
|
|
18642
|
+
actions.setTotalScope((_a = {}, _a[key] = moment$f(newValue).toDate(), _a));
|
|
18632
18643
|
};
|
|
18633
18644
|
var handleChangeScope = function (value) {
|
|
18634
18645
|
actions.setTotalScope({
|
|
@@ -18667,7 +18678,7 @@ var Header = React__default.memo(function (_a) {
|
|
|
18667
18678
|
} },
|
|
18668
18679
|
React__default.createElement(ChevronLeft, { fontSize: "medium" }))),
|
|
18669
18680
|
React__default.createElement(Grid2, { size: { md: 4 } },
|
|
18670
|
-
React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$
|
|
18681
|
+
React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$f(state.timeScopeStart), onChange: function (newValue) {
|
|
18671
18682
|
if (newValue) {
|
|
18672
18683
|
handleDateChange(newValue.toDate(), "start");
|
|
18673
18684
|
}
|
|
@@ -18691,7 +18702,7 @@ var Header = React__default.memo(function (_a) {
|
|
|
18691
18702
|
React__default.createElement(MenuItem, { value: "10 days" }, "10 days"),
|
|
18692
18703
|
React__default.createElement(MenuItem, { value: "custom" }, "Custom")))),
|
|
18693
18704
|
React__default.createElement(Grid2, { size: { md: 4 } },
|
|
18694
|
-
React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$
|
|
18705
|
+
React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$f(state.timeScopeEnd), onChange: function (newValue) {
|
|
18695
18706
|
if (newValue) {
|
|
18696
18707
|
handleDateChange(newValue.toDate(), "end");
|
|
18697
18708
|
}
|
|
@@ -19376,7 +19387,7 @@ var ProvidersLoader = function (_a) {
|
|
|
19376
19387
|
};
|
|
19377
19388
|
|
|
19378
19389
|
var timezone = TimeService.getInstance().getServerTimeZone();
|
|
19379
|
-
moment$
|
|
19390
|
+
moment$g.tz.setDefault(timezone);
|
|
19380
19391
|
var base = document.getElementsByTagName("base")[0].getAttribute("href") || "/";
|
|
19381
19392
|
var queryClient = new QueryClient({
|
|
19382
19393
|
defaultOptions: {
|
|
@@ -19396,7 +19407,7 @@ function MESFMain(_a) {
|
|
|
19396
19407
|
React__default.createElement(HelmetDexteelProvider, { navbarTitle: navbarTitle },
|
|
19397
19408
|
React__default.createElement(QueryClientProvider, { client: queryClient },
|
|
19398
19409
|
React__default.createElement(AuthProvider, { authConfig: authentication },
|
|
19399
|
-
React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment, dateLibInstance: moment$
|
|
19410
|
+
React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment, dateLibInstance: moment$g },
|
|
19400
19411
|
React__default.createElement(UserProvider, null,
|
|
19401
19412
|
React__default.createElement(UTLSettingsProvider, null,
|
|
19402
19413
|
React__default.createElement(ProvidersLoader, null,
|
|
@@ -19424,7 +19435,7 @@ var CustomStatusPanel = function (_a) {
|
|
|
19424
19435
|
React__default.createElement(PlaylistAddIcon, { style: { width: 30, height: 30 } })));
|
|
19425
19436
|
};
|
|
19426
19437
|
|
|
19427
|
-
var useGridDefinitions = function (_a) {
|
|
19438
|
+
var useGridDefinitions$1 = function (_a) {
|
|
19428
19439
|
_a.OnEdit; _a.OnSend;
|
|
19429
19440
|
var defaultColDef = {
|
|
19430
19441
|
flex: 1,
|
|
@@ -19448,8 +19459,8 @@ var useGridDefinitions = function (_a) {
|
|
|
19448
19459
|
};
|
|
19449
19460
|
};
|
|
19450
19461
|
|
|
19451
|
-
var moment$
|
|
19452
|
-
var getEntries = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
19462
|
+
var moment$e = getMomentTz();
|
|
19463
|
+
var getEntries$1 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
19453
19464
|
var apiService, parameters, resp, rows;
|
|
19454
19465
|
var shiftId = _b.shiftId, assetId = _b.assetId, signal = _b.signal;
|
|
19455
19466
|
return __generator(this, function (_c) {
|
|
@@ -19468,9 +19479,9 @@ var getEntries = function (_a) { return __awaiter(void 0, [_a], void 0, function
|
|
|
19468
19479
|
if (resp.ok) {
|
|
19469
19480
|
rows = get(resp, "data.tables[0].rows", []);
|
|
19470
19481
|
rows = rows.map(function (entry) { return (__assign(__assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
|
|
19471
|
-
? moment$
|
|
19482
|
+
? moment$e.utc(entry["CreateTimestamp"]).toDate()
|
|
19472
19483
|
: null, UpdateTimestamp: entry.UpdateTimestamp
|
|
19473
|
-
? moment$
|
|
19484
|
+
? moment$e.utc(entry["UpdateTimestamp"]).toDate()
|
|
19474
19485
|
: null })); });
|
|
19475
19486
|
return [2 /*return*/, rows];
|
|
19476
19487
|
}
|
|
@@ -19480,7 +19491,7 @@ var getEntries = function (_a) { return __awaiter(void 0, [_a], void 0, function
|
|
|
19480
19491
|
}
|
|
19481
19492
|
});
|
|
19482
19493
|
}); };
|
|
19483
|
-
var upsertEntry = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
19494
|
+
var upsertEntry$1 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
19484
19495
|
var apiService, parameters, resp;
|
|
19485
19496
|
var assetId = _b.assetId, entryId = _b.entryId, shiftId = _b.shiftId, title = _b.title, content = _b.content, createTimestamp = _b.createTimestamp, author = _b.author;
|
|
19486
19497
|
return __generator(this, function (_c) {
|
|
@@ -19517,7 +19528,7 @@ var upsertEntry = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
19517
19528
|
}
|
|
19518
19529
|
});
|
|
19519
19530
|
}); };
|
|
19520
|
-
var deleteEntry = function (EntryId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19531
|
+
var deleteEntry$1 = function (EntryId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19521
19532
|
var apiService, attachmentsToDelete, error_1, parameters, resp;
|
|
19522
19533
|
return __generator(this, function (_a) {
|
|
19523
19534
|
switch (_a.label) {
|
|
@@ -19528,7 +19539,7 @@ var deleteEntry = function (EntryId) { return __awaiter(void 0, void 0, void 0,
|
|
|
19528
19539
|
case 1:
|
|
19529
19540
|
_a.trys.push([1, 4, , 5]);
|
|
19530
19541
|
if (!EntryId) return [3 /*break*/, 3];
|
|
19531
|
-
return [4 /*yield*/, getEntryAttachments(EntryId)];
|
|
19542
|
+
return [4 /*yield*/, getEntryAttachments$1(EntryId)];
|
|
19532
19543
|
case 2:
|
|
19533
19544
|
attachmentsToDelete = _a.sent();
|
|
19534
19545
|
_a.label = 3;
|
|
@@ -19548,13 +19559,13 @@ var deleteEntry = function (EntryId) { return __awaiter(void 0, void 0, void 0,
|
|
|
19548
19559
|
}
|
|
19549
19560
|
// Delete associated files in background (don't block the UI)
|
|
19550
19561
|
if (attachmentsToDelete.length > 0) {
|
|
19551
|
-
deleteAttachedFilesInBackground(attachmentsToDelete);
|
|
19562
|
+
deleteAttachedFilesInBackground$1(attachmentsToDelete);
|
|
19552
19563
|
}
|
|
19553
19564
|
return [2 /*return*/];
|
|
19554
19565
|
}
|
|
19555
19566
|
});
|
|
19556
19567
|
}); };
|
|
19557
|
-
var deleteAttachedFilesInBackground = function (attachments) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19568
|
+
var deleteAttachedFilesInBackground$1 = function (attachments) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19558
19569
|
return __generator(this, function (_a) {
|
|
19559
19570
|
// Delete files in background without blocking the UI
|
|
19560
19571
|
Promise.all(attachments.map(function (attachment) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -19563,7 +19574,7 @@ var deleteAttachedFilesInBackground = function (attachments) { return __awaiter(
|
|
|
19563
19574
|
switch (_a.label) {
|
|
19564
19575
|
case 0:
|
|
19565
19576
|
_a.trys.push([0, 2, , 3]);
|
|
19566
|
-
return [4 /*yield*/, deleteUploadFile(attachment.UploadFileId)];
|
|
19577
|
+
return [4 /*yield*/, deleteUploadFile$1(attachment.UploadFileId)];
|
|
19567
19578
|
case 1:
|
|
19568
19579
|
_a.sent();
|
|
19569
19580
|
return [3 /*break*/, 3];
|
|
@@ -19581,7 +19592,7 @@ var deleteAttachedFilesInBackground = function (attachments) { return __awaiter(
|
|
|
19581
19592
|
return [2 /*return*/];
|
|
19582
19593
|
});
|
|
19583
19594
|
}); };
|
|
19584
|
-
var deleteUploadFile = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19595
|
+
var deleteUploadFile$1 = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19585
19596
|
var apiService, parameters, resp;
|
|
19586
19597
|
return __generator(this, function (_a) {
|
|
19587
19598
|
switch (_a.label) {
|
|
@@ -19601,7 +19612,7 @@ var deleteUploadFile = function (uploadFileId) { return __awaiter(void 0, void 0
|
|
|
19601
19612
|
});
|
|
19602
19613
|
}); };
|
|
19603
19614
|
// Attachment management functions
|
|
19604
|
-
var getEntryAttachments = function (entryId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19615
|
+
var getEntryAttachments$1 = function (entryId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19605
19616
|
var apiService, parameters, resp, rows;
|
|
19606
19617
|
return __generator(this, function (_a) {
|
|
19607
19618
|
switch (_a.label) {
|
|
@@ -19614,7 +19625,7 @@ var getEntryAttachments = function (entryId) { return __awaiter(void 0, void 0,
|
|
|
19614
19625
|
if (resp.ok) {
|
|
19615
19626
|
rows = get(resp, "data.tables[0].rows", []);
|
|
19616
19627
|
rows = rows.map(function (attachment) { return (__assign(__assign({}, attachment), { CreationTime: attachment.CreationTime
|
|
19617
|
-
? moment$
|
|
19628
|
+
? moment$e.utc(attachment.CreationTime).toDate()
|
|
19618
19629
|
: new Date() })); });
|
|
19619
19630
|
return [2 /*return*/, rows];
|
|
19620
19631
|
}
|
|
@@ -19624,7 +19635,7 @@ var getEntryAttachments = function (entryId) { return __awaiter(void 0, void 0,
|
|
|
19624
19635
|
}
|
|
19625
19636
|
});
|
|
19626
19637
|
}); };
|
|
19627
|
-
var upsertEntryAttachment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
19638
|
+
var upsertEntryAttachment$1 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
19628
19639
|
var apiService, parameters, resp, attachment;
|
|
19629
19640
|
var entryId = _b.entryId, uploadFileId = _b.uploadFileId, attachmentName = _b.attachmentName, attachmentURL = _b.attachmentURL;
|
|
19630
19641
|
return __generator(this, function (_c) {
|
|
@@ -19644,7 +19655,7 @@ var upsertEntryAttachment = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
19644
19655
|
attachment = get(resp, "data.tables[0].rows[0]", null);
|
|
19645
19656
|
if (attachment) {
|
|
19646
19657
|
return [2 /*return*/, __assign(__assign({}, attachment), { CreationTime: attachment.CreationTime
|
|
19647
|
-
? moment$
|
|
19658
|
+
? moment$e.utc(attachment.CreationTime).toDate()
|
|
19648
19659
|
: new Date() })];
|
|
19649
19660
|
}
|
|
19650
19661
|
return [2 /*return*/, null];
|
|
@@ -19655,7 +19666,7 @@ var upsertEntryAttachment = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
19655
19666
|
}
|
|
19656
19667
|
});
|
|
19657
19668
|
}); };
|
|
19658
|
-
var deleteEntryAttachment = function (entryAttachmentId, uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19669
|
+
var deleteEntryAttachment$1 = function (entryAttachmentId, uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19659
19670
|
var apiService, parameters, resp;
|
|
19660
19671
|
return __generator(this, function (_a) {
|
|
19661
19672
|
switch (_a.label) {
|
|
@@ -19672,19 +19683,19 @@ var deleteEntryAttachment = function (entryAttachmentId, uploadFileId) { return
|
|
|
19672
19683
|
}
|
|
19673
19684
|
// Delete the associated file in background if UploadFileId was provided
|
|
19674
19685
|
if (uploadFileId) {
|
|
19675
|
-
deleteUploadFileInBackground(uploadFileId);
|
|
19686
|
+
deleteUploadFileInBackground$1(uploadFileId);
|
|
19676
19687
|
}
|
|
19677
19688
|
return [2 /*return*/];
|
|
19678
19689
|
}
|
|
19679
19690
|
});
|
|
19680
19691
|
}); };
|
|
19681
|
-
var deleteUploadFileInBackground = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19692
|
+
var deleteUploadFileInBackground$1 = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19682
19693
|
var error_3;
|
|
19683
19694
|
return __generator(this, function (_a) {
|
|
19684
19695
|
switch (_a.label) {
|
|
19685
19696
|
case 0:
|
|
19686
19697
|
_a.trys.push([0, 2, , 3]);
|
|
19687
|
-
return [4 /*yield*/, deleteUploadFile(uploadFileId)];
|
|
19698
|
+
return [4 /*yield*/, deleteUploadFile$1(uploadFileId)];
|
|
19688
19699
|
case 1:
|
|
19689
19700
|
_a.sent();
|
|
19690
19701
|
return [3 /*break*/, 3];
|
|
@@ -19698,19 +19709,19 @@ var deleteUploadFileInBackground = function (uploadFileId) { return __awaiter(vo
|
|
|
19698
19709
|
});
|
|
19699
19710
|
}); };
|
|
19700
19711
|
|
|
19701
|
-
var useEntries = function (_a) {
|
|
19712
|
+
var useEntries$1 = function (_a) {
|
|
19702
19713
|
var shiftId = _a.shiftId, assetId = _a.assetId;
|
|
19703
19714
|
return useQuery({
|
|
19704
19715
|
queryKey: ["entries", shiftId, assetId],
|
|
19705
19716
|
queryFn: function (_a) {
|
|
19706
19717
|
var signal = _a.signal;
|
|
19707
|
-
return getEntries({ shiftId: shiftId, assetId: assetId, signal: signal });
|
|
19718
|
+
return getEntries$1({ shiftId: shiftId, assetId: assetId, signal: signal });
|
|
19708
19719
|
},
|
|
19709
19720
|
});
|
|
19710
19721
|
};
|
|
19711
|
-
var routeLogbookEntry = "/logbook/entry";
|
|
19722
|
+
var routeLogbookEntry$1 = "/logbook/entry";
|
|
19712
19723
|
|
|
19713
|
-
var useLogbookEntryOptionsFunctions = function (_a) {
|
|
19724
|
+
var useLogbookEntryOptionsFunctions$1 = function (_a) {
|
|
19714
19725
|
var setSelectedRowData = _a.setSelectedRowData, setShow = _a.setShow, setShowRemoveDialog = _a.setShowRemoveDialog, handleNewEntry = _a.handleNewEntry;
|
|
19715
19726
|
var getMenuOptions = function (data) {
|
|
19716
19727
|
var options = [];
|
|
@@ -19756,7 +19767,7 @@ var useLogbookEntryOptionsFunctions = function (_a) {
|
|
|
19756
19767
|
};
|
|
19757
19768
|
};
|
|
19758
19769
|
|
|
19759
|
-
var useTableData$
|
|
19770
|
+
var useTableData$3 = function (_a) {
|
|
19760
19771
|
var showContextMenu = _a.showContextMenu, allowAttachments = _a.allowAttachments, withAssetFilter = _a.withAssetFilter, showShiftCrew = _a.showShiftCrew;
|
|
19761
19772
|
var columnDefs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
19762
19773
|
{
|
|
@@ -19872,7 +19883,7 @@ var useTableData$1 = function (_a) {
|
|
|
19872
19883
|
return { columnDefs: columnDefs };
|
|
19873
19884
|
};
|
|
19874
19885
|
|
|
19875
|
-
var ENTRY_INITIAL_VALUES = {
|
|
19886
|
+
var ENTRY_INITIAL_VALUES$1 = {
|
|
19876
19887
|
EntryId: 0,
|
|
19877
19888
|
ShiftId: 0,
|
|
19878
19889
|
AssetId: null,
|
|
@@ -19888,7 +19899,7 @@ var ENTRY_INITIAL_VALUES = {
|
|
|
19888
19899
|
AttachmentCount: 0,
|
|
19889
19900
|
};
|
|
19890
19901
|
|
|
19891
|
-
var RemoveEntryDialog = function (_a) {
|
|
19902
|
+
var RemoveEntryDialog$1 = function (_a) {
|
|
19892
19903
|
var entry = _a.entry, show = _a.show, onHide = _a.onHide;
|
|
19893
19904
|
var navigate = useNavigate();
|
|
19894
19905
|
var _b = useState(false), isSubmitLoading = _b[0], setIsSubmitLoading = _b[1];
|
|
@@ -19899,14 +19910,14 @@ var RemoveEntryDialog = function (_a) {
|
|
|
19899
19910
|
onHide(false);
|
|
19900
19911
|
};
|
|
19901
19912
|
var queryClient = useQueryClient();
|
|
19902
|
-
var removeEntry = useMutation(deleteEntry, {
|
|
19913
|
+
var removeEntry = useMutation(deleteEntry$1, {
|
|
19903
19914
|
onSuccess: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
19904
19915
|
return __generator(this, function (_a) {
|
|
19905
19916
|
switch (_a.label) {
|
|
19906
19917
|
case 0: return [4 /*yield*/, queryClient.invalidateQueries({ queryKey: ["entries"] })];
|
|
19907
19918
|
case 1:
|
|
19908
19919
|
_a.sent();
|
|
19909
|
-
navigate("".concat(routeLogbookEntry), { replace: true });
|
|
19920
|
+
navigate("".concat(routeLogbookEntry$1), { replace: true });
|
|
19910
19921
|
setSuccessMessage("The entry was deleted succesfully");
|
|
19911
19922
|
onHide(true);
|
|
19912
19923
|
return [2 /*return*/];
|
|
@@ -19989,7 +20000,7 @@ var AssetsFilter = function (_a) {
|
|
|
19989
20000
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
19990
20001
|
};
|
|
19991
20002
|
|
|
19992
|
-
var moment$
|
|
20003
|
+
var moment$d = getMomentTz();
|
|
19993
20004
|
var getShifts = function (shiftId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
19994
20005
|
var apiService, parameters, resp, rows;
|
|
19995
20006
|
return __generator(this, function (_a) {
|
|
@@ -20008,26 +20019,26 @@ var getShifts = function (shiftId) { return __awaiter(void 0, void 0, void 0, fu
|
|
|
20008
20019
|
if (resp.ok) {
|
|
20009
20020
|
rows = get(resp, "data.tables[0].rows", []);
|
|
20010
20021
|
rows = rows.map(function (row) {
|
|
20011
|
-
(row.CurrentProductionDate = moment$
|
|
20022
|
+
(row.CurrentProductionDate = moment$d
|
|
20012
20023
|
.utc(row["CurrentProductionDate"])
|
|
20013
20024
|
.toDate()),
|
|
20014
|
-
(row.CurrentStart = moment$
|
|
20015
|
-
(row.CurrentEnd = moment$
|
|
20016
|
-
(row.PreviousProductionDate = moment$
|
|
20025
|
+
(row.CurrentStart = moment$d.utc(row["CurrentStart"]).toDate()),
|
|
20026
|
+
(row.CurrentEnd = moment$d.utc(row["CurrentEnd"]).toDate()),
|
|
20027
|
+
(row.PreviousProductionDate = moment$d
|
|
20017
20028
|
.utc(row["PreviousProductionDate"])
|
|
20018
20029
|
.toDate()),
|
|
20019
|
-
(row.PreviousStart = moment$
|
|
20020
|
-
(row.PreviousEnd = moment$
|
|
20021
|
-
(row.NextProductionDate = moment$
|
|
20030
|
+
(row.PreviousStart = moment$d.utc(row["PreviousStart"]).toDate()),
|
|
20031
|
+
(row.PreviousEnd = moment$d.utc(row["PreviousEnd"]).toDate()),
|
|
20032
|
+
(row.NextProductionDate = moment$d
|
|
20022
20033
|
.utc(row["NextProductionDate"])
|
|
20023
20034
|
.toDate()),
|
|
20024
|
-
(row.NextStart = moment$
|
|
20025
|
-
(row.NextEnd = moment$
|
|
20026
|
-
(row.LastProductionDate = moment$
|
|
20035
|
+
(row.NextStart = moment$d.utc(row["NextStart"]).toDate()),
|
|
20036
|
+
(row.NextEnd = moment$d.utc(row["NextEnd"]).toDate()),
|
|
20037
|
+
(row.LastProductionDate = moment$d
|
|
20027
20038
|
.utc(row["LastProductionDate"])
|
|
20028
20039
|
.toDate()),
|
|
20029
|
-
(row.LastStart = moment$
|
|
20030
|
-
(row.LastEnd = moment$
|
|
20040
|
+
(row.LastStart = moment$d.utc(row["LastStart"]).toDate()),
|
|
20041
|
+
(row.LastEnd = moment$d.utc(row["LastEnd"]).toDate());
|
|
20031
20042
|
return row;
|
|
20032
20043
|
});
|
|
20033
20044
|
return [2 /*return*/, rows];
|
|
@@ -20056,7 +20067,7 @@ var getShiftsAroundCurrent = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
20056
20067
|
resp = _c.sent();
|
|
20057
20068
|
if (resp.ok) {
|
|
20058
20069
|
rows = get(resp, "data.tables[0].rows", []);
|
|
20059
|
-
rows = rows.map(function (row) { return (__assign(__assign({}, row), { Start: moment$
|
|
20070
|
+
rows = rows.map(function (row) { return (__assign(__assign({}, row), { Start: moment$d.utc(row.Start).toDate(), End: moment$d.utc(row.End).toDate() })); });
|
|
20060
20071
|
return [2 /*return*/, rows];
|
|
20061
20072
|
}
|
|
20062
20073
|
else {
|
|
@@ -20066,7 +20077,7 @@ var getShiftsAroundCurrent = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
20066
20077
|
});
|
|
20067
20078
|
}); };
|
|
20068
20079
|
|
|
20069
|
-
var moment$
|
|
20080
|
+
var moment$c = getMomentTz();
|
|
20070
20081
|
var useShiftsAroundCurrent = function (_a) {
|
|
20071
20082
|
var currentShiftId = _a.currentShiftId, shiftsRange = _a.shiftsRange;
|
|
20072
20083
|
return useQuery({
|
|
@@ -20094,7 +20105,7 @@ var ShiftAutocomplete = function (_a) {
|
|
|
20094
20105
|
React__default.createElement(Grid2, { container: true },
|
|
20095
20106
|
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
20096
20107
|
React__default.createElement(Autocomplete, { loading: isLoading, options: rows || [], getOptionLabel: function (option) {
|
|
20097
|
-
return "".concat(moment$
|
|
20108
|
+
return "".concat(moment$c
|
|
20098
20109
|
.utc(option.ProductionDate)
|
|
20099
20110
|
.format("MM/DD/YYYY"), " - ").concat(option.Shift, " - ").concat(option.Crew);
|
|
20100
20111
|
}, value: selectedShift, onChange: function (event, newValue) {
|
|
@@ -20131,12 +20142,12 @@ var ShiftSelector = function (_a) {
|
|
|
20131
20142
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); }, title: "Error loading shifts" })));
|
|
20132
20143
|
};
|
|
20133
20144
|
|
|
20134
|
-
var useEntrySubmission = function (_a) {
|
|
20145
|
+
var useEntrySubmission$1 = function (_a) {
|
|
20135
20146
|
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;
|
|
20136
20147
|
var _e = useState(false), isSubmitLoading = _e[0], setIsSubmitLoading = _e[1];
|
|
20137
20148
|
var _f = useState(false), showConfirmationDialog = _f[0], setShowConfirmationDialog = _f[1];
|
|
20138
20149
|
var _g = useState(null), pendingSubmitData = _g[0], setPendingSubmitData = _g[1];
|
|
20139
|
-
var submit = useMutation(upsertEntry, {
|
|
20150
|
+
var submit = useMutation(upsertEntry$1, {
|
|
20140
20151
|
onSuccess: function (entry) { return __awaiter(void 0, void 0, void 0, function () {
|
|
20141
20152
|
return __generator(this, function (_a) {
|
|
20142
20153
|
if (entry && entry.EntryId) {
|
|
@@ -20213,7 +20224,7 @@ var useEntrySubmission = function (_a) {
|
|
|
20213
20224
|
};
|
|
20214
20225
|
};
|
|
20215
20226
|
|
|
20216
|
-
var DeleteAttachmentConfirmationDialog = function (_a) {
|
|
20227
|
+
var DeleteAttachmentConfirmationDialog$1 = function (_a) {
|
|
20217
20228
|
var open = _a.open, attachmentName = _a.attachmentName, onClose = _a.onClose, _b = _a.isDeleting, isDeleting = _b === void 0 ? false : _b;
|
|
20218
20229
|
var _c = useState(false), isClosing = _c[0], setIsClosing = _c[1];
|
|
20219
20230
|
var handleCancel = function () {
|
|
@@ -20239,7 +20250,7 @@ var DeleteAttachmentConfirmationDialog = function (_a) {
|
|
|
20239
20250
|
React__default.createElement(Button, { onClick: handleConfirm, color: "secondary", variant: "contained", disabled: isClosing, startIcon: isDeleting && React__default.createElement(CircularProgress, { size: "1rem" }) }, "Delete"))));
|
|
20240
20251
|
};
|
|
20241
20252
|
|
|
20242
|
-
var AttachmentModal = function (_a) {
|
|
20253
|
+
var AttachmentModal$1 = function (_a) {
|
|
20243
20254
|
var open = _a.open, onClose = _a.onClose, entryId = _a.entryId, isEditing = _a.isEditing, entryData = _a.entryData, onEntrySubmitted = _a.onEntrySubmitted;
|
|
20244
20255
|
var queryClient = useQueryClient();
|
|
20245
20256
|
var api = new MESApiService();
|
|
@@ -20251,7 +20262,7 @@ var AttachmentModal = function (_a) {
|
|
|
20251
20262
|
var _g = useState(null), attachmentToDelete = _g[0], setAttachmentToDelete = _g[1];
|
|
20252
20263
|
var pendingFilesRef = useRef([]);
|
|
20253
20264
|
// Entry submission hook for background saves
|
|
20254
|
-
var _h = useEntrySubmission({
|
|
20265
|
+
var _h = useEntrySubmission$1({
|
|
20255
20266
|
onSuccess: function (entry) {
|
|
20256
20267
|
setIsSubmittingEntry(false);
|
|
20257
20268
|
if (entry === null || entry === void 0 ? void 0 : entry.EntryId) {
|
|
@@ -20280,11 +20291,11 @@ var AttachmentModal = function (_a) {
|
|
|
20280
20291
|
// Query for fetching attachments
|
|
20281
20292
|
var _j = useQuery({
|
|
20282
20293
|
queryKey: ["entryAttachments", currentEntryId],
|
|
20283
|
-
queryFn: function () { return getEntryAttachments(currentEntryId); },
|
|
20294
|
+
queryFn: function () { return getEntryAttachments$1(currentEntryId); },
|
|
20284
20295
|
enabled: !!currentEntryId && currentEntryId > 0,
|
|
20285
20296
|
}), _k = _j.data, attachments = _k === void 0 ? [] : _k, isLoading = _j.isLoading, fetchError = _j.error;
|
|
20286
20297
|
// Mutations
|
|
20287
|
-
var uploadMutation = useMutation(upsertEntryAttachment, {
|
|
20298
|
+
var uploadMutation = useMutation(upsertEntryAttachment$1, {
|
|
20288
20299
|
onSuccess: function () {
|
|
20289
20300
|
queryClient.invalidateQueries(["entryAttachments", currentEntryId]);
|
|
20290
20301
|
queryClient.invalidateQueries(["entries"]);
|
|
@@ -20296,7 +20307,7 @@ var AttachmentModal = function (_a) {
|
|
|
20296
20307
|
});
|
|
20297
20308
|
var deleteMutation = useMutation(function (_a) {
|
|
20298
20309
|
var entryAttachmentId = _a.entryAttachmentId, uploadFileId = _a.uploadFileId;
|
|
20299
|
-
return deleteEntryAttachment(entryAttachmentId, uploadFileId);
|
|
20310
|
+
return deleteEntryAttachment$1(entryAttachmentId, uploadFileId);
|
|
20300
20311
|
}, {
|
|
20301
20312
|
onSuccess: function () {
|
|
20302
20313
|
queryClient.invalidateQueries(["entryAttachments", currentEntryId]);
|
|
@@ -20568,11 +20579,11 @@ var AttachmentModal = function (_a) {
|
|
|
20568
20579
|
" file(s)...")))),
|
|
20569
20580
|
React__default.createElement(DialogActions$1, null,
|
|
20570
20581
|
React__default.createElement(Button, { onClick: onClose, color: "primary" }, "Close"))),
|
|
20571
|
-
React__default.createElement(DeleteAttachmentConfirmationDialog, { open: showDeleteConfirmation, attachmentName: (attachmentToDelete === null || attachmentToDelete === void 0 ? void 0 : attachmentToDelete.name) || "", onClose: handleDeleteConfirmation, isDeleting: deleteMutation.isLoading }),
|
|
20582
|
+
React__default.createElement(DeleteAttachmentConfirmationDialog$1, { open: showDeleteConfirmation, attachmentName: (attachmentToDelete === null || attachmentToDelete === void 0 ? void 0 : attachmentToDelete.name) || "", onClose: handleDeleteConfirmation, isDeleting: deleteMutation.isLoading }),
|
|
20572
20583
|
React__default.createElement(ErrorModal, { error: error || (fetchError === null || fetchError === void 0 ? void 0 : fetchError.message), onHide: function () { return setError(null); } })));
|
|
20573
20584
|
};
|
|
20574
20585
|
|
|
20575
|
-
var AttachmentPlugin = /** @class */ (function (_super) {
|
|
20586
|
+
var AttachmentPlugin$1 = /** @class */ (function (_super) {
|
|
20576
20587
|
__extends(AttachmentPlugin, _super);
|
|
20577
20588
|
function AttachmentPlugin() {
|
|
20578
20589
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -20619,7 +20630,7 @@ var AttachmentPlugin = /** @class */ (function (_super) {
|
|
|
20619
20630
|
return AttachmentPlugin;
|
|
20620
20631
|
}(PluginComponent));
|
|
20621
20632
|
|
|
20622
|
-
var ContentInput = function (_a) {
|
|
20633
|
+
var ContentInput$1 = function (_a) {
|
|
20623
20634
|
var value = _a.value, onChange = _a.onChange, isEditing = _a.isEditing, UpdateTimestamp = _a.UpdateTimestamp, UpdatedBy = _a.UpdatedBy, isNewEntry = _a.isNewEntry, entryId = _a.entryId, entryData = _a.entryData, onEntrySubmitted = _a.onEntrySubmitted, _b = _a.allowAttachments, allowAttachments = _b === void 0 ? false : _b;
|
|
20624
20635
|
var mdParser = new MarkdownIt();
|
|
20625
20636
|
var api = new MESApiService();
|
|
@@ -20633,7 +20644,7 @@ var ContentInput = function (_a) {
|
|
|
20633
20644
|
// Query for fetching attachment count
|
|
20634
20645
|
var _f = useQuery({
|
|
20635
20646
|
queryKey: ["entryAttachments", effectiveEntryId],
|
|
20636
|
-
queryFn: function () { return getEntryAttachments(effectiveEntryId); },
|
|
20647
|
+
queryFn: function () { return getEntryAttachments$1(effectiveEntryId); },
|
|
20637
20648
|
enabled: !!effectiveEntryId && effectiveEntryId > 0,
|
|
20638
20649
|
retry: 1,
|
|
20639
20650
|
onError: function (err) {
|
|
@@ -20673,7 +20684,7 @@ var ContentInput = function (_a) {
|
|
|
20673
20684
|
}, [isEditing, attachmentCount]);
|
|
20674
20685
|
// Register the attachment plugin
|
|
20675
20686
|
useEffect(function () {
|
|
20676
|
-
MdEditor.use(AttachmentPlugin, {
|
|
20687
|
+
MdEditor.use(AttachmentPlugin$1, {
|
|
20677
20688
|
attachmentCount: attachmentCount,
|
|
20678
20689
|
onAttachmentClick: function () {
|
|
20679
20690
|
if (entryData.title && entryData.author) {
|
|
@@ -20791,12 +20802,12 @@ var ContentInput = function (_a) {
|
|
|
20791
20802
|
fontSize: "0.7rem",
|
|
20792
20803
|
},
|
|
20793
20804
|
} })))),
|
|
20794
|
-
React__default.createElement(AttachmentModal, { open: attachmentModalOpen, onClose: function () { return setAttachmentModalOpen(false); }, entryId: effectiveEntryId, isEditing: isEditing, entryData: entryData, onEntrySubmitted: onEntrySubmitted }),
|
|
20805
|
+
React__default.createElement(AttachmentModal$1, { open: attachmentModalOpen, onClose: function () { return setAttachmentModalOpen(false); }, entryId: effectiveEntryId, isEditing: isEditing, entryData: entryData, onEntrySubmitted: onEntrySubmitted }),
|
|
20795
20806
|
React__default.createElement(ErrorModal, { error: error || (attachmentError === null || attachmentError === void 0 ? void 0 : attachmentError.message), onHide: function () { return setError(""); } })));
|
|
20796
20807
|
};
|
|
20797
20808
|
|
|
20798
|
-
var moment$
|
|
20799
|
-
var EntryViewer$
|
|
20809
|
+
var moment$b = getMomentTz();
|
|
20810
|
+
var EntryViewer$3 = function (_a) {
|
|
20800
20811
|
var entry = _a.entry, show = _a.show, onChangeShow = _a.onChangeShow, onHide = _a.onHide, preselectedAssetId = _a.preselectedAssetId, withAssetFilter = _a.withAssetFilter, canEditAsset = _a.canEditAsset, canEditShift = _a.canEditShift, filterAssets = _a.filterAssets, allowAttachments = _a.allowAttachments, shiftsRange = _a.shiftsRange;
|
|
20801
20812
|
var settings = useUTLSettingsContext().state.settings;
|
|
20802
20813
|
var defaultAssetId = Number(get(settings, "DefaultAssetId", 15));
|
|
@@ -20835,7 +20846,7 @@ var EntryViewer$1 = function (_a) {
|
|
|
20835
20846
|
}, 1000); // 1000ms delay to ensure all processing is complete
|
|
20836
20847
|
};
|
|
20837
20848
|
// Use the shared entry submission hook
|
|
20838
|
-
var _g = useEntrySubmission({
|
|
20849
|
+
var _g = useEntrySubmission$1({
|
|
20839
20850
|
onSuccess: function (entry) {
|
|
20840
20851
|
setNotificationMessage(entryId === "new"
|
|
20841
20852
|
? "Entry created successfully"
|
|
@@ -20887,8 +20898,8 @@ var EntryViewer$1 = function (_a) {
|
|
|
20887
20898
|
useEffect(function () {
|
|
20888
20899
|
var _a, _b, _c;
|
|
20889
20900
|
if (shiftInfo || !isNewEntry) {
|
|
20890
|
-
var newEntry = __assign(__assign({}, ENTRY_INITIAL_VALUES), { ShiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId, Shift: (_a = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShift) !== null && _a !== void 0 ? _a : "", Crew: (_b = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentCrew) !== null && _b !== void 0 ? _b : "", CreateTimestamp: new Date(), AssetId: (_c = preselectedAssetId !== null && preselectedAssetId !== void 0 ? preselectedAssetId : defaultAssetId) !== null && _c !== void 0 ? _c : null });
|
|
20891
|
-
reset((isNewEntry ? newEntry : entry) || ENTRY_INITIAL_VALUES);
|
|
20901
|
+
var newEntry = __assign(__assign({}, ENTRY_INITIAL_VALUES$1), { ShiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId, Shift: (_a = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShift) !== null && _a !== void 0 ? _a : "", Crew: (_b = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentCrew) !== null && _b !== void 0 ? _b : "", CreateTimestamp: new Date(), AssetId: (_c = preselectedAssetId !== null && preselectedAssetId !== void 0 ? preselectedAssetId : defaultAssetId) !== null && _c !== void 0 ? _c : null });
|
|
20902
|
+
reset((isNewEntry ? newEntry : entry) || ENTRY_INITIAL_VALUES$1);
|
|
20892
20903
|
}
|
|
20893
20904
|
}, [entry, shiftInfo, entryId, reset, defaultAssetId]);
|
|
20894
20905
|
useEffect(function () {
|
|
@@ -20920,7 +20931,7 @@ var EntryViewer$1 = function (_a) {
|
|
|
20920
20931
|
React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
|
|
20921
20932
|
React__default.createElement(Controller, { name: "CreateTimestamp", control: control, render: function (_a) {
|
|
20922
20933
|
var value = _a.field.value;
|
|
20923
|
-
return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$
|
|
20934
|
+
return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$b(value) : null, disabled: true, slotProps: {
|
|
20924
20935
|
textField: {
|
|
20925
20936
|
variant: "outlined",
|
|
20926
20937
|
size: "small",
|
|
@@ -20981,7 +20992,7 @@ var EntryViewer$1 = function (_a) {
|
|
|
20981
20992
|
React__default.createElement(Grid2, { size: { md: 12 }, height: "100%", flexGrow: 1, overflow: "auto" },
|
|
20982
20993
|
React__default.createElement(Controller, { name: "Content", control: control, render: function (_a) {
|
|
20983
20994
|
var _b = _a.field, value = _b.value, onChange = _b.onChange;
|
|
20984
|
-
return (React__default.createElement(ContentInput, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return onChange(val); }, value: value, isEditing: show === "edit", isNewEntry: isNewEntry, entryId: entryIdValue, entryData: {
|
|
20995
|
+
return (React__default.createElement(ContentInput$1, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return onChange(val); }, value: value, isEditing: show === "edit", isNewEntry: isNewEntry, entryId: entryIdValue, entryData: {
|
|
20985
20996
|
assetId: assetId,
|
|
20986
20997
|
entryId: entryIdValue,
|
|
20987
20998
|
shiftId: shiftId,
|
|
@@ -21003,11 +21014,11 @@ var EntryViewer$1 = function (_a) {
|
|
|
21003
21014
|
React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
21004
21015
|
React__default.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React__default.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading || !isFormDirty, variant: "contained", color: "primary", type: "submit" }, isNewEntry ? "Create" : "Save"))))))) : null,
|
|
21005
21016
|
React__default.createElement(NotificationSnackBar, { message: notificationMessage, onHide: function () { return setNotificationMessage(""); } }),
|
|
21006
|
-
React__default.createElement(ConfirmationDialogRaw, { open: showConfirmationDialog, onClose: handleConfirmationClose, title: "Shift Submission Confirmation", message: "You are about to ".concat(isNewEntry ? "create" : "save", " an entry for ").concat(moment$
|
|
21017
|
+
React__default.createElement(ConfirmationDialogRaw, { open: showConfirmationDialog, onClose: handleConfirmationClose, title: "Shift Submission Confirmation", message: "You are about to ".concat(isNewEntry ? "create" : "save", " an entry for ").concat(moment$b(shiftTimestamp).format("MM/DD/YYYY"), " ").concat(shift, " - ").concat(crew, ". Are you sure you want to proceed?"), suffixTitle: "Logbook Entry" }),
|
|
21007
21018
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
21008
21019
|
};
|
|
21009
21020
|
|
|
21010
|
-
var Filters$
|
|
21021
|
+
var Filters$3 = function (_a) {
|
|
21011
21022
|
var withAssetFilter = _a.withAssetFilter, filterAssets = _a.filterAssets, assetId = _a.assetId, _b = _a.setAssetId, setAssetId = _b === void 0 ? function () { } : _b, quickFilter = _a.quickFilter, onQuickFilterChange = _a.onQuickFilterChange;
|
|
21012
21023
|
useMesfRealtime({
|
|
21013
21024
|
onReceiveMessage: function (author, message) {
|
|
@@ -21035,8 +21046,8 @@ var Filters$1 = function (_a) {
|
|
|
21035
21046
|
} }))));
|
|
21036
21047
|
};
|
|
21037
21048
|
|
|
21038
|
-
var moment$
|
|
21039
|
-
var Logbook$
|
|
21049
|
+
var moment$a = getMomentTz();
|
|
21050
|
+
var Logbook$3 = function () {
|
|
21040
21051
|
var entry = useLogbookSettings().entry;
|
|
21041
21052
|
var defaultAreaId = useUserContext().state.defaultAreaId;
|
|
21042
21053
|
var withAssetFilter = entry.withAssetFilter;
|
|
@@ -21065,17 +21076,17 @@ var Logbook$1 = function () {
|
|
|
21065
21076
|
var _f = useState(null), selectedRowData = _f[0], setSelectedRowData = _f[1];
|
|
21066
21077
|
var _g = useState(false), showRemoveDialog = _g[0], setShowRemoveDialog = _g[1];
|
|
21067
21078
|
var _h = useContextMenuMESF(), registerConfig = _h.registerConfig, showContextMenu = _h.showContextMenu;
|
|
21068
|
-
var _j = useEntries({
|
|
21079
|
+
var _j = useEntries$1({
|
|
21069
21080
|
shiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId,
|
|
21070
21081
|
assetId: withAssetFilter ? assetId : undefined,
|
|
21071
21082
|
}), rows = _j.data, isLoading = _j.isLoading, e = _j.error, isError = _j.isError, refetch = _j.refetch;
|
|
21072
|
-
var columnDefs = useTableData$
|
|
21083
|
+
var columnDefs = useTableData$3({
|
|
21073
21084
|
showContextMenu: showContextMenu,
|
|
21074
21085
|
allowAttachments: allowAttachments,
|
|
21075
21086
|
withAssetFilter: withAssetFilter,
|
|
21076
21087
|
showShiftCrew: showShiftCrew,
|
|
21077
21088
|
}).columnDefs;
|
|
21078
|
-
var defaultColDef = useGridDefinitions({}).defaultColDef;
|
|
21089
|
+
var defaultColDef = useGridDefinitions$1({}).defaultColDef;
|
|
21079
21090
|
var onQuickFilterChange = function (text) {
|
|
21080
21091
|
var _a;
|
|
21081
21092
|
setQuickFilter(text);
|
|
@@ -21084,8 +21095,8 @@ var Logbook$1 = function () {
|
|
|
21084
21095
|
var handleNewEntry = function () {
|
|
21085
21096
|
var _a;
|
|
21086
21097
|
(_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
|
|
21087
|
-
setSelectedRowData(__assign({}, ENTRY_INITIAL_VALUES));
|
|
21088
|
-
navigate("".concat(routeLogbookEntry, "/").concat(shiftIdRef.current, "?action=new"), {
|
|
21098
|
+
setSelectedRowData(__assign({}, ENTRY_INITIAL_VALUES$1));
|
|
21099
|
+
navigate("".concat(routeLogbookEntry$1, "/").concat(shiftIdRef.current, "?action=new"), {
|
|
21089
21100
|
replace: true,
|
|
21090
21101
|
});
|
|
21091
21102
|
setShow("edit");
|
|
@@ -21094,7 +21105,7 @@ var Logbook$1 = function () {
|
|
|
21094
21105
|
var _a;
|
|
21095
21106
|
var currentShiftId = shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId);
|
|
21096
21107
|
setSelectedRowData(event === null || event === void 0 ? void 0 : event.data);
|
|
21097
|
-
navigate("".concat(routeLogbookEntry, "/").concat(currentShiftId, "?entryId=").concat((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.EntryId, "&action=view"));
|
|
21108
|
+
navigate("".concat(routeLogbookEntry$1, "/").concat(currentShiftId, "?entryId=").concat((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.EntryId, "&action=view"));
|
|
21098
21109
|
setShow("view");
|
|
21099
21110
|
};
|
|
21100
21111
|
var onCellKeyDown = useCallback(function (event) {
|
|
@@ -21112,7 +21123,7 @@ var Logbook$1 = function () {
|
|
|
21112
21123
|
nextNode.setSelected(true);
|
|
21113
21124
|
api.ensureIndexVisible(nextRowIndex);
|
|
21114
21125
|
setSelectedRowData(nextNode.data);
|
|
21115
|
-
navigate("".concat(routeLogbookEntry, "/").concat(currentShiftId, "/?entryId=").concat(nextNode.data.EntryId, "&action=view"));
|
|
21126
|
+
navigate("".concat(routeLogbookEntry$1, "/").concat(currentShiftId, "/?entryId=").concat(nextNode.data.EntryId, "&action=view"));
|
|
21116
21127
|
}
|
|
21117
21128
|
}
|
|
21118
21129
|
}, [setSelectedRowData, shiftId, shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId]);
|
|
@@ -21126,7 +21137,7 @@ var Logbook$1 = function () {
|
|
|
21126
21137
|
}
|
|
21127
21138
|
return [];
|
|
21128
21139
|
}, [rows]);
|
|
21129
|
-
var getMenuOptions = useLogbookEntryOptionsFunctions({
|
|
21140
|
+
var getMenuOptions = useLogbookEntryOptionsFunctions$1({
|
|
21130
21141
|
setSelectedRowData: setSelectedRowData,
|
|
21131
21142
|
setShow: setShow,
|
|
21132
21143
|
setShowRemoveDialog: setShowRemoveDialog,
|
|
@@ -21149,7 +21160,7 @@ var Logbook$1 = function () {
|
|
|
21149
21160
|
],
|
|
21150
21161
|
processCellCallback: function (params) {
|
|
21151
21162
|
if (params.column.colId === "CreateTimestamp") {
|
|
21152
|
-
return moment$
|
|
21163
|
+
return moment$a(params.value).format("MM/DD/yy - HH:mm");
|
|
21153
21164
|
}
|
|
21154
21165
|
return params.value;
|
|
21155
21166
|
},
|
|
@@ -21218,10 +21229,10 @@ var Logbook$1 = function () {
|
|
|
21218
21229
|
if (entryId &&
|
|
21219
21230
|
(shiftIdRef.current == null ||
|
|
21220
21231
|
shiftIdRef.current === (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId))) {
|
|
21221
|
-
navigate("".concat(routeLogbookEntry, "/").concat(shiftInfo.CurrentShiftId, "?entryId=").concat(entryId, "&action=").concat(action));
|
|
21232
|
+
navigate("".concat(routeLogbookEntry$1, "/").concat(shiftInfo.CurrentShiftId, "?entryId=").concat(entryId, "&action=").concat(action));
|
|
21222
21233
|
}
|
|
21223
21234
|
else {
|
|
21224
|
-
navigate("".concat(routeLogbookEntry, "/").concat(shiftInfo.CurrentShiftId));
|
|
21235
|
+
navigate("".concat(routeLogbookEntry$1, "/").concat(shiftInfo.CurrentShiftId));
|
|
21225
21236
|
}
|
|
21226
21237
|
shiftIdRef.current = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId;
|
|
21227
21238
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -21276,7 +21287,7 @@ var Logbook$1 = function () {
|
|
|
21276
21287
|
} }, "LOGBOOK")),
|
|
21277
21288
|
React__default.createElement(Grid2, { container: true, size: { xs: 12, md: 5 }, spacing: 1 },
|
|
21278
21289
|
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
21279
|
-
React__default.createElement(Filters$
|
|
21290
|
+
React__default.createElement(Filters$3, { withAssetFilter: withAssetFilter, filterAssets: filterAssets, quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, assetId: assetId, setAssetId: setAssetId })),
|
|
21280
21291
|
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
21281
21292
|
React__default.createElement(Paper, { elevation: 1, style: {
|
|
21282
21293
|
height: "62vh",
|
|
@@ -21309,7 +21320,7 @@ var Logbook$1 = function () {
|
|
|
21309
21320
|
},
|
|
21310
21321
|
} })))),
|
|
21311
21322
|
React__default.createElement(Grid2, { size: { xs: 12, md: 7 } },
|
|
21312
|
-
React__default.createElement(EntryViewer$
|
|
21323
|
+
React__default.createElement(EntryViewer$3, { entry: selectedRowData, show: show, onChangeShow: function () {
|
|
21313
21324
|
var newShow = show === "view" ? "edit" : "view";
|
|
21314
21325
|
setShow(newShow);
|
|
21315
21326
|
if (entryId && entryId !== "new") {
|
|
@@ -21376,13 +21387,13 @@ var Logbook$1 = function () {
|
|
|
21376
21387
|
setShow("");
|
|
21377
21388
|
setSelectedRowData(null);
|
|
21378
21389
|
(_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
|
|
21379
|
-
navigate("".concat(routeLogbookEntry, "/").concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId)));
|
|
21390
|
+
navigate("".concat(routeLogbookEntry$1, "/").concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId)));
|
|
21380
21391
|
_b.label = 3;
|
|
21381
21392
|
case 3: return [2 /*return*/];
|
|
21382
21393
|
}
|
|
21383
21394
|
});
|
|
21384
21395
|
}); } }))),
|
|
21385
|
-
React__default.createElement(RemoveEntryDialog, { entry: selectedRowData, show: showRemoveDialog, onHide: function (shouldUpdate) {
|
|
21396
|
+
React__default.createElement(RemoveEntryDialog$1, { entry: selectedRowData, show: showRemoveDialog, onHide: function (shouldUpdate) {
|
|
21386
21397
|
if (shouldUpdate) {
|
|
21387
21398
|
refetch();
|
|
21388
21399
|
}
|
|
@@ -21393,19 +21404,19 @@ var Logbook$1 = function () {
|
|
|
21393
21404
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
21394
21405
|
};
|
|
21395
21406
|
|
|
21396
|
-
var LogbookPage$
|
|
21407
|
+
var LogbookPage$3 = function () {
|
|
21397
21408
|
return (React__default.createElement(React__default.Fragment, null,
|
|
21398
21409
|
React__default.createElement(HelmetDexteel, { title: "Logbook Entry" }),
|
|
21399
21410
|
React__default.createElement(Grid2, { container: true, style: { padding: "1.5rem" } },
|
|
21400
|
-
React__default.createElement(Logbook$
|
|
21411
|
+
React__default.createElement(Logbook$3, null))));
|
|
21401
21412
|
};
|
|
21402
21413
|
|
|
21403
|
-
var MESFLogbookEntry = function () {
|
|
21404
|
-
return React__default.createElement(LogbookPage$
|
|
21414
|
+
var MESFLogbookEntry$1 = function () {
|
|
21415
|
+
return React__default.createElement(LogbookPage$3, null);
|
|
21405
21416
|
};
|
|
21406
21417
|
|
|
21407
|
-
var moment$
|
|
21408
|
-
var getEntriesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
21418
|
+
var moment$9 = getMomentTz();
|
|
21419
|
+
var getEntriesReport$1 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
21409
21420
|
var apiService, parameters, resp, rows;
|
|
21410
21421
|
var startShiftId = _b.startShiftId, endShiftId = _b.endShiftId, assetId = _b.assetId;
|
|
21411
21422
|
return __generator(this, function (_c) {
|
|
@@ -21425,9 +21436,9 @@ var getEntriesReport = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
21425
21436
|
if (resp.ok) {
|
|
21426
21437
|
rows = get(resp, "data.tables[0].rows", []);
|
|
21427
21438
|
rows = rows.map(function (entry) { return (__assign(__assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
|
|
21428
|
-
? moment$
|
|
21439
|
+
? moment$9.utc(entry["CreateTimestamp"]).toDate()
|
|
21429
21440
|
: null, UpdateTimestamp: entry.UpdateTimestamp
|
|
21430
|
-
? moment$
|
|
21441
|
+
? moment$9.utc(entry["UpdateTimestamp"]).toDate()
|
|
21431
21442
|
: null })); });
|
|
21432
21443
|
return [2 /*return*/, rows];
|
|
21433
21444
|
}
|
|
@@ -21438,16 +21449,16 @@ var getEntriesReport = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
21438
21449
|
});
|
|
21439
21450
|
}); };
|
|
21440
21451
|
|
|
21441
|
-
var useEntriesReport = function (_a) {
|
|
21452
|
+
var useEntriesReport$1 = function (_a) {
|
|
21442
21453
|
var startShiftId = _a.startShiftId, endShiftId = _a.endShiftId, assetId = _a.assetId;
|
|
21443
21454
|
return useQuery({
|
|
21444
21455
|
queryKey: ["entriesReport", startShiftId, endShiftId, assetId],
|
|
21445
|
-
queryFn: function () { return getEntriesReport({ startShiftId: startShiftId, endShiftId: endShiftId, assetId: assetId }); },
|
|
21456
|
+
queryFn: function () { return getEntriesReport$1({ startShiftId: startShiftId, endShiftId: endShiftId, assetId: assetId }); },
|
|
21446
21457
|
});
|
|
21447
21458
|
};
|
|
21448
21459
|
var routeLogbookReport = "/logbook/report";
|
|
21449
21460
|
|
|
21450
|
-
var useTableData = function (_a) {
|
|
21461
|
+
var useTableData$2 = function (_a) {
|
|
21451
21462
|
var showAttachments = _a.showAttachments, showAsset = _a.showAsset, showShiftCrew = _a.showShiftCrew;
|
|
21452
21463
|
var columnDefs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
21453
21464
|
{
|
|
@@ -21540,8 +21551,8 @@ var useTableData = function (_a) {
|
|
|
21540
21551
|
return { columnDefs: columnDefs };
|
|
21541
21552
|
};
|
|
21542
21553
|
|
|
21543
|
-
var moment$
|
|
21544
|
-
var EntryViewer = function (_a) {
|
|
21554
|
+
var moment$8 = getMomentTz();
|
|
21555
|
+
var EntryViewer$2 = function (_a) {
|
|
21545
21556
|
var entry = _a.entry, show = _a.show, onHide = _a.onHide, filterAssets = _a.filterAssets, showAsset = _a.showAsset, _b = _a.showAttachments, showAttachments = _b === void 0 ? false : _b;
|
|
21546
21557
|
var _c = useState(""), error = _c[0], setError = _c[1];
|
|
21547
21558
|
var _d = useForm(), control = _d.control, setValue = _d.setValue, reset = _d.reset, watch = _d.watch; _d.getValues;
|
|
@@ -21555,7 +21566,7 @@ var EntryViewer = function (_a) {
|
|
|
21555
21566
|
var assetId = watch("AssetId");
|
|
21556
21567
|
var createTimestamp = watch("CreateTimestamp");
|
|
21557
21568
|
useEffect(function () {
|
|
21558
|
-
reset(entry || ENTRY_INITIAL_VALUES);
|
|
21569
|
+
reset(entry || ENTRY_INITIAL_VALUES$1);
|
|
21559
21570
|
}, [entry, show]);
|
|
21560
21571
|
return (React__default.createElement(React__default.Fragment, null,
|
|
21561
21572
|
(entry === null || entry === void 0 ? void 0 : entry.EntryId) && (React__default.createElement(HelmetDexteel, { title: "'".concat(entry === null || entry === void 0 ? void 0 : entry.Title, "' by ").concat(entry.Author, " - Logbook Report") })),
|
|
@@ -21575,7 +21586,7 @@ var EntryViewer = function (_a) {
|
|
|
21575
21586
|
React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
|
|
21576
21587
|
React__default.createElement(Controller, { name: "CreateTimestamp", control: control, render: function (_a) {
|
|
21577
21588
|
var value = _a.field.value;
|
|
21578
|
-
return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$
|
|
21589
|
+
return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$8(value) : null, disabled: true, slotProps: {
|
|
21579
21590
|
textField: {
|
|
21580
21591
|
variant: "outlined",
|
|
21581
21592
|
size: "small",
|
|
@@ -21606,7 +21617,7 @@ var EntryViewer = function (_a) {
|
|
|
21606
21617
|
React__default.createElement(Grid2, { size: { md: 12 }, height: "100%", flexGrow: 1, overflow: "auto" },
|
|
21607
21618
|
React__default.createElement(Controller, { name: "Content", control: control, render: function (_a) {
|
|
21608
21619
|
var _b = _a.field; _b.value; _b.onChange;
|
|
21609
|
-
return (React__default.createElement(ContentInput, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return setValue("Content", val); }, value: content, isEditing: false, isNewEntry: false, entryId: entryId, entryData: {
|
|
21620
|
+
return (React__default.createElement(ContentInput$1, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return setValue("Content", val); }, value: content, isEditing: false, isNewEntry: false, entryId: entryId, entryData: {
|
|
21610
21621
|
assetId: assetId,
|
|
21611
21622
|
entryId: entryId,
|
|
21612
21623
|
shiftId: shiftId,
|
|
@@ -21623,7 +21634,7 @@ var EntryViewer = function (_a) {
|
|
|
21623
21634
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
21624
21635
|
};
|
|
21625
21636
|
|
|
21626
|
-
var customPeriodOptions = [
|
|
21637
|
+
var customPeriodOptions$1 = [
|
|
21627
21638
|
{ value: "Day", label: "Day" },
|
|
21628
21639
|
{ value: "4Days", label: "4 Days" },
|
|
21629
21640
|
{ value: "Week", label: "Week" },
|
|
@@ -21650,7 +21661,7 @@ var buildTreeAssets = function (nodes) {
|
|
|
21650
21661
|
});
|
|
21651
21662
|
return root;
|
|
21652
21663
|
};
|
|
21653
|
-
var Filters = function (_a) {
|
|
21664
|
+
var Filters$2 = function (_a) {
|
|
21654
21665
|
var withAssetFilter = _a.withAssetFilter, filterAssets = _a.filterAssets, quickFilter = _a.quickFilter, onQuickFilterChange = _a.onQuickFilterChange, assetId = _a.assetId, setAssetId = _a.setAssetId, shiftPeriod = _a.shiftPeriod, onChangeShiftPeriod = _a.onChangeShiftPeriod, actualPeriod = _a.actualPeriod;
|
|
21655
21666
|
var handleShiftPeriodChange = function (value, period) {
|
|
21656
21667
|
onChangeShiftPeriod(value, period);
|
|
@@ -21676,7 +21687,7 @@ var Filters = function (_a) {
|
|
|
21676
21687
|
return (React__default.createElement(Paper, { elevation: 1, style: { padding: 8 } },
|
|
21677
21688
|
React__default.createElement(Grid2, { container: true, spacing: 1 },
|
|
21678
21689
|
React__default.createElement(Grid2, { size: { xs: 12 }, alignItems: "center", justifyContent: "center" },
|
|
21679
|
-
React__default.createElement(ShiftPeriodNavigatorControl, { onChange: handleShiftPeriodChange, value: shiftPeriod, actualPeriod: actualPeriod, showShiftAndCrews: false, dateFormat: "MM/DD/YYYY", periodOptions: customPeriodOptions })),
|
|
21690
|
+
React__default.createElement(ShiftPeriodNavigatorControl, { onChange: handleShiftPeriodChange, value: shiftPeriod, actualPeriod: actualPeriod, showShiftAndCrews: false, dateFormat: "MM/DD/YYYY", periodOptions: customPeriodOptions$1 })),
|
|
21680
21691
|
React__default.createElement(Grid2, { size: { xs: 12, md: withAssetFilter ? 6 : 12 } },
|
|
21681
21692
|
React__default.createElement(TextField, { fullWidth: true, label: "Search", variant: "outlined", size: "small", margin: "dense", value: quickFilter, onChange: function (event) {
|
|
21682
21693
|
onQuickFilterChange(event === null || event === void 0 ? void 0 : event.target.value);
|
|
@@ -21700,8 +21711,8 @@ var Filters = function (_a) {
|
|
|
21700
21711
|
}, filterAreaAssets: filterAssets === "area", isFilter: true }))))));
|
|
21701
21712
|
};
|
|
21702
21713
|
|
|
21703
|
-
var moment = getMomentTz();
|
|
21704
|
-
var Logbook = function () {
|
|
21714
|
+
var moment$7 = getMomentTz();
|
|
21715
|
+
var Logbook$2 = function () {
|
|
21705
21716
|
var report = useLogbookSettings().report;
|
|
21706
21717
|
var defaultAreaId = useUserContext().state.defaultAreaId;
|
|
21707
21718
|
var withAssetFilter = report.withAssetFilter;
|
|
@@ -21756,17 +21767,17 @@ var Logbook = function () {
|
|
|
21756
21767
|
}
|
|
21757
21768
|
setSearchParams(newParams);
|
|
21758
21769
|
};
|
|
21759
|
-
var _h = useEntriesReport({
|
|
21770
|
+
var _h = useEntriesReport$1({
|
|
21760
21771
|
startShiftId: shiftPeriod.StartShiftId,
|
|
21761
21772
|
endShiftId: shiftPeriod.EndShiftId,
|
|
21762
21773
|
assetId: assetId,
|
|
21763
21774
|
}), rows = _h.data, isLoading = _h.isLoading, e = _h.error, isError = _h.isError, refetch = _h.refetch;
|
|
21764
|
-
var columnDefs = useTableData({
|
|
21775
|
+
var columnDefs = useTableData$2({
|
|
21765
21776
|
showAttachments: showAttachments,
|
|
21766
21777
|
showAsset: showAsset,
|
|
21767
21778
|
showShiftCrew: showShiftCrew,
|
|
21768
21779
|
}).columnDefs;
|
|
21769
|
-
var defaultColDef = useGridDefinitions({}).defaultColDef;
|
|
21780
|
+
var defaultColDef = useGridDefinitions$1({}).defaultColDef;
|
|
21770
21781
|
var onQuickFilterChange = function (text) {
|
|
21771
21782
|
var _a;
|
|
21772
21783
|
setQuickFilter(text);
|
|
@@ -21814,7 +21825,7 @@ var Logbook = function () {
|
|
|
21814
21825
|
],
|
|
21815
21826
|
processCellCallback: function (params) {
|
|
21816
21827
|
if (params.column.colId === "CreateTimestamp") {
|
|
21817
|
-
return moment(params.value).format("MM/DD/yy - HH:mm");
|
|
21828
|
+
return moment$7(params.value).format("MM/DD/yy - HH:mm");
|
|
21818
21829
|
}
|
|
21819
21830
|
return params.value;
|
|
21820
21831
|
},
|
|
@@ -21898,7 +21909,7 @@ var Logbook = function () {
|
|
|
21898
21909
|
} }, "LOGBOOK REPORT")),
|
|
21899
21910
|
React__default.createElement(Grid2, { container: true, size: { xs: 12, md: 5 }, spacing: 1 },
|
|
21900
21911
|
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
21901
|
-
React__default.createElement(Filters, { withAssetFilter: withAssetFilter, filterAssets: filterAssets, quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, assetId: assetId, setAssetId: function (value) { return setAssetId(value); }, shiftPeriod: shiftPeriod, onChangeShiftPeriod: function (value, period) {
|
|
21912
|
+
React__default.createElement(Filters$2, { withAssetFilter: withAssetFilter, filterAssets: filterAssets, quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, assetId: assetId, setAssetId: function (value) { return setAssetId(value); }, shiftPeriod: shiftPeriod, onChangeShiftPeriod: function (value, period) {
|
|
21902
21913
|
setShiftPeriod(value);
|
|
21903
21914
|
updateUrl({
|
|
21904
21915
|
startShiftId: value.StartShiftId,
|
|
@@ -21936,7 +21947,7 @@ var Logbook = function () {
|
|
|
21936
21947
|
},
|
|
21937
21948
|
} })))),
|
|
21938
21949
|
React__default.createElement(Grid2, { size: { xs: 12, md: 7 } },
|
|
21939
|
-
React__default.createElement(EntryViewer, { entry: selectedRowData, show: show, onChangeShow: function () { return setShow(show === "view" ? "edit" : "view"); }, onHide: function () {
|
|
21950
|
+
React__default.createElement(EntryViewer$2, { entry: selectedRowData, show: show, onChangeShow: function () { return setShow(show === "view" ? "edit" : "view"); }, onHide: function () {
|
|
21940
21951
|
var _a;
|
|
21941
21952
|
setShow("");
|
|
21942
21953
|
setSelectedRowData(null);
|
|
@@ -21946,29 +21957,29 @@ var Logbook = function () {
|
|
|
21946
21957
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
21947
21958
|
};
|
|
21948
21959
|
|
|
21949
|
-
var LogbookPage = function () {
|
|
21960
|
+
var LogbookPage$2 = function () {
|
|
21950
21961
|
return (React__default.createElement(React__default.Fragment, null,
|
|
21951
21962
|
React__default.createElement(HelmetDexteel, { title: "Logbook Report" }),
|
|
21952
21963
|
React__default.createElement(Grid2, { container: true, style: { padding: "1.5rem" } },
|
|
21953
|
-
React__default.createElement(Logbook, null))));
|
|
21964
|
+
React__default.createElement(Logbook$2, null))));
|
|
21954
21965
|
};
|
|
21955
21966
|
|
|
21956
|
-
var MESFLogbookReport = function () {
|
|
21957
|
-
return React__default.createElement(LogbookPage, null);
|
|
21967
|
+
var MESFLogbookReport$1 = function () {
|
|
21968
|
+
return React__default.createElement(LogbookPage$2, null);
|
|
21958
21969
|
};
|
|
21959
21970
|
|
|
21960
21971
|
var logbookRoutesMESF = [
|
|
21961
21972
|
{
|
|
21962
21973
|
path: "/logbook/entry",
|
|
21963
|
-
element: React__default.createElement(MESFLogbookEntry),
|
|
21974
|
+
element: React__default.createElement(MESFLogbookEntry$1),
|
|
21964
21975
|
},
|
|
21965
21976
|
{
|
|
21966
21977
|
path: "/logbook/entry/:shiftId",
|
|
21967
|
-
element: React__default.createElement(MESFLogbookEntry),
|
|
21978
|
+
element: React__default.createElement(MESFLogbookEntry$1),
|
|
21968
21979
|
},
|
|
21969
21980
|
{
|
|
21970
21981
|
path: "/logbook/report",
|
|
21971
|
-
element: React__default.createElement(MESFLogbookReport),
|
|
21982
|
+
element: React__default.createElement(MESFLogbookReport$1),
|
|
21972
21983
|
},
|
|
21973
21984
|
];
|
|
21974
21985
|
var logbookNavbar = [
|
|
@@ -21988,6 +21999,2585 @@ var logbookNavbar = [
|
|
|
21988
21999
|
},
|
|
21989
22000
|
];
|
|
21990
22001
|
|
|
22002
|
+
var useGridDefinitions = function (_a) {
|
|
22003
|
+
_a.OnEdit; _a.OnSend;
|
|
22004
|
+
var defaultColDef = {
|
|
22005
|
+
flex: 1,
|
|
22006
|
+
filter: false,
|
|
22007
|
+
floatingFilter: false,
|
|
22008
|
+
sortable: false,
|
|
22009
|
+
editable: false,
|
|
22010
|
+
resizable: false,
|
|
22011
|
+
wrapText: false,
|
|
22012
|
+
autoHeight: false,
|
|
22013
|
+
wrapHeaderText: true,
|
|
22014
|
+
suppressHeaderMenuButton: true,
|
|
22015
|
+
cellStyle: {
|
|
22016
|
+
display: "flex",
|
|
22017
|
+
alignItems: "center",
|
|
22018
|
+
justifyContent: "center",
|
|
22019
|
+
},
|
|
22020
|
+
};
|
|
22021
|
+
return {
|
|
22022
|
+
defaultColDef: defaultColDef,
|
|
22023
|
+
};
|
|
22024
|
+
};
|
|
22025
|
+
|
|
22026
|
+
var moment$6 = getMomentTz();
|
|
22027
|
+
var getEntries = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
22028
|
+
var apiService, parameters, resp, rows;
|
|
22029
|
+
var shiftId = _b.shiftId, sectionIds = _b.sectionIds, signal = _b.signal;
|
|
22030
|
+
return __generator(this, function (_c) {
|
|
22031
|
+
switch (_c.label) {
|
|
22032
|
+
case 0:
|
|
22033
|
+
apiService = new MESApiService();
|
|
22034
|
+
parameters = [
|
|
22035
|
+
{ name: "ShiftId", value: shiftId },
|
|
22036
|
+
];
|
|
22037
|
+
// Pass comma-separated sectionIds for multi-select filter
|
|
22038
|
+
if (sectionIds && sectionIds.length > 0) {
|
|
22039
|
+
parameters.push({ name: "SectionIds", value: sectionIds.join(",") });
|
|
22040
|
+
}
|
|
22041
|
+
return [4 /*yield*/, apiService.callV2("[SWV].[GetSectionLogbookEntries]", parameters, signal)];
|
|
22042
|
+
case 1:
|
|
22043
|
+
resp = _c.sent();
|
|
22044
|
+
if (resp.ok) {
|
|
22045
|
+
rows = get(resp, "data.tables[0].rows", []);
|
|
22046
|
+
rows = rows.map(function (entry) { return (__assign(__assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
|
|
22047
|
+
? moment$6.utc(entry["CreateTimestamp"]).toDate()
|
|
22048
|
+
: null, UpdateTimestamp: entry.UpdateTimestamp
|
|
22049
|
+
? moment$6.utc(entry["UpdateTimestamp"]).toDate()
|
|
22050
|
+
: null })); });
|
|
22051
|
+
return [2 /*return*/, rows];
|
|
22052
|
+
}
|
|
22053
|
+
else {
|
|
22054
|
+
throw new Error(resp.message || "Error fetching entries");
|
|
22055
|
+
}
|
|
22056
|
+
}
|
|
22057
|
+
});
|
|
22058
|
+
}); };
|
|
22059
|
+
var upsertEntry = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
22060
|
+
var apiService, parameters, resp;
|
|
22061
|
+
var assetId = _b.assetId, entryId = _b.entryId, shiftId = _b.shiftId, title = _b.title, content = _b.content, createTimestamp = _b.createTimestamp, author = _b.author;
|
|
22062
|
+
return __generator(this, function (_c) {
|
|
22063
|
+
switch (_c.label) {
|
|
22064
|
+
case 0:
|
|
22065
|
+
apiService = new MESApiService();
|
|
22066
|
+
parameters = [
|
|
22067
|
+
{ name: "EntryId", value: entryId },
|
|
22068
|
+
{ name: "ShiftId", value: shiftId },
|
|
22069
|
+
{ name: "Title", value: title },
|
|
22070
|
+
{ name: "Content", value: content },
|
|
22071
|
+
{
|
|
22072
|
+
name: "CreateTimestamp",
|
|
22073
|
+
value: createTimestamp.toISOString(),
|
|
22074
|
+
},
|
|
22075
|
+
{
|
|
22076
|
+
name: "UpdateTimestamp",
|
|
22077
|
+
value: new Date().toISOString(),
|
|
22078
|
+
},
|
|
22079
|
+
{ name: "Author", value: author },
|
|
22080
|
+
];
|
|
22081
|
+
if (assetId || assetId === 0) {
|
|
22082
|
+
parameters.push({ name: "AssetId", value: assetId });
|
|
22083
|
+
}
|
|
22084
|
+
return [4 /*yield*/, apiService.callV2("[LB].[UpsertEntry]", parameters)];
|
|
22085
|
+
case 1:
|
|
22086
|
+
resp = _c.sent();
|
|
22087
|
+
if (resp.ok) {
|
|
22088
|
+
return [2 /*return*/, get(resp, "data.tables[0].rows[0]", null)];
|
|
22089
|
+
}
|
|
22090
|
+
{
|
|
22091
|
+
throw new Error(resp.message || "Error upserting entry");
|
|
22092
|
+
}
|
|
22093
|
+
}
|
|
22094
|
+
});
|
|
22095
|
+
}); };
|
|
22096
|
+
var deleteEntry = function (EntryId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22097
|
+
var apiService, attachmentsToDelete, error_1, parameters, resp;
|
|
22098
|
+
return __generator(this, function (_a) {
|
|
22099
|
+
switch (_a.label) {
|
|
22100
|
+
case 0:
|
|
22101
|
+
apiService = new MESApiService();
|
|
22102
|
+
attachmentsToDelete = [];
|
|
22103
|
+
_a.label = 1;
|
|
22104
|
+
case 1:
|
|
22105
|
+
_a.trys.push([1, 4, , 5]);
|
|
22106
|
+
if (!EntryId) return [3 /*break*/, 3];
|
|
22107
|
+
return [4 /*yield*/, getEntryAttachments(EntryId)];
|
|
22108
|
+
case 2:
|
|
22109
|
+
attachmentsToDelete = _a.sent();
|
|
22110
|
+
_a.label = 3;
|
|
22111
|
+
case 3: return [3 /*break*/, 5];
|
|
22112
|
+
case 4:
|
|
22113
|
+
error_1 = _a.sent();
|
|
22114
|
+
// If we can't get attachments, log but continue with entry deletion
|
|
22115
|
+
console.warn("Failed to get attachments for entry deletion:", error_1);
|
|
22116
|
+
return [3 /*break*/, 5];
|
|
22117
|
+
case 5:
|
|
22118
|
+
parameters = [{ name: "EntryId", value: EntryId }];
|
|
22119
|
+
return [4 /*yield*/, apiService.callV2("[LB].[DeleteEntry]", parameters)];
|
|
22120
|
+
case 6:
|
|
22121
|
+
resp = _a.sent();
|
|
22122
|
+
if (!resp.ok) {
|
|
22123
|
+
throw new Error(resp.message || "Error deleting entry");
|
|
22124
|
+
}
|
|
22125
|
+
// Delete associated files in background (don't block the UI)
|
|
22126
|
+
if (attachmentsToDelete.length > 0) {
|
|
22127
|
+
deleteAttachedFilesInBackground(attachmentsToDelete);
|
|
22128
|
+
}
|
|
22129
|
+
return [2 /*return*/];
|
|
22130
|
+
}
|
|
22131
|
+
});
|
|
22132
|
+
}); };
|
|
22133
|
+
var deleteAttachedFilesInBackground = function (attachments) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22134
|
+
return __generator(this, function (_a) {
|
|
22135
|
+
// Delete files in background without blocking the UI
|
|
22136
|
+
Promise.all(attachments.map(function (attachment) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22137
|
+
var error_2;
|
|
22138
|
+
return __generator(this, function (_a) {
|
|
22139
|
+
switch (_a.label) {
|
|
22140
|
+
case 0:
|
|
22141
|
+
_a.trys.push([0, 2, , 3]);
|
|
22142
|
+
return [4 /*yield*/, deleteUploadFile(attachment.UploadFileId)];
|
|
22143
|
+
case 1:
|
|
22144
|
+
_a.sent();
|
|
22145
|
+
return [3 /*break*/, 3];
|
|
22146
|
+
case 2:
|
|
22147
|
+
error_2 = _a.sent();
|
|
22148
|
+
// Log errors but don't fail the entire operation
|
|
22149
|
+
console.error("Failed to delete file ".concat(attachment.UploadFileId, ":"), error_2);
|
|
22150
|
+
return [3 /*break*/, 3];
|
|
22151
|
+
case 3: return [2 /*return*/];
|
|
22152
|
+
}
|
|
22153
|
+
});
|
|
22154
|
+
}); })).catch(function (error) {
|
|
22155
|
+
console.error("Background file deletion failed:", error);
|
|
22156
|
+
});
|
|
22157
|
+
return [2 /*return*/];
|
|
22158
|
+
});
|
|
22159
|
+
}); };
|
|
22160
|
+
var deleteUploadFile = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22161
|
+
var apiService, parameters, resp;
|
|
22162
|
+
return __generator(this, function (_a) {
|
|
22163
|
+
switch (_a.label) {
|
|
22164
|
+
case 0:
|
|
22165
|
+
apiService = new MESApiService();
|
|
22166
|
+
parameters = [
|
|
22167
|
+
{ name: "UploadFileId", value: uploadFileId },
|
|
22168
|
+
];
|
|
22169
|
+
return [4 /*yield*/, apiService.callV2("[SYSTEM].[DeleteUploadFile]", parameters)];
|
|
22170
|
+
case 1:
|
|
22171
|
+
resp = _a.sent();
|
|
22172
|
+
if (!resp.ok) {
|
|
22173
|
+
throw new Error(resp.message || "Error deleting upload file");
|
|
22174
|
+
}
|
|
22175
|
+
return [2 /*return*/];
|
|
22176
|
+
}
|
|
22177
|
+
});
|
|
22178
|
+
}); };
|
|
22179
|
+
// Attachment management functions
|
|
22180
|
+
var getEntryAttachments = function (entryId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22181
|
+
var apiService, parameters, resp, rows;
|
|
22182
|
+
return __generator(this, function (_a) {
|
|
22183
|
+
switch (_a.label) {
|
|
22184
|
+
case 0:
|
|
22185
|
+
apiService = new MESApiService();
|
|
22186
|
+
parameters = [{ name: "EntryId", value: entryId }];
|
|
22187
|
+
return [4 /*yield*/, apiService.callV2("[LB].[GetEntryAttachments]", parameters)];
|
|
22188
|
+
case 1:
|
|
22189
|
+
resp = _a.sent();
|
|
22190
|
+
if (resp.ok) {
|
|
22191
|
+
rows = get(resp, "data.tables[0].rows", []);
|
|
22192
|
+
rows = rows.map(function (attachment) { return (__assign(__assign({}, attachment), { CreationTime: attachment.CreationTime
|
|
22193
|
+
? moment$6.utc(attachment.CreationTime).toDate()
|
|
22194
|
+
: new Date() })); });
|
|
22195
|
+
return [2 /*return*/, rows];
|
|
22196
|
+
}
|
|
22197
|
+
else {
|
|
22198
|
+
throw new Error(resp.message || "Error fetching entry attachments");
|
|
22199
|
+
}
|
|
22200
|
+
}
|
|
22201
|
+
});
|
|
22202
|
+
}); };
|
|
22203
|
+
var upsertEntryAttachment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
22204
|
+
var apiService, parameters, resp, attachment;
|
|
22205
|
+
var entryId = _b.entryId, uploadFileId = _b.uploadFileId, attachmentName = _b.attachmentName, attachmentURL = _b.attachmentURL;
|
|
22206
|
+
return __generator(this, function (_c) {
|
|
22207
|
+
switch (_c.label) {
|
|
22208
|
+
case 0:
|
|
22209
|
+
apiService = new MESApiService();
|
|
22210
|
+
parameters = [
|
|
22211
|
+
{ name: "EntryId", value: entryId },
|
|
22212
|
+
{ name: "UploadFileId", value: uploadFileId },
|
|
22213
|
+
{ name: "AttachmentName", value: attachmentName },
|
|
22214
|
+
{ name: "AttachmentURL", value: attachmentURL },
|
|
22215
|
+
];
|
|
22216
|
+
return [4 /*yield*/, apiService.callV2("[LB].[UpsertEntryAttachment]", parameters)];
|
|
22217
|
+
case 1:
|
|
22218
|
+
resp = _c.sent();
|
|
22219
|
+
if (resp.ok) {
|
|
22220
|
+
attachment = get(resp, "data.tables[0].rows[0]", null);
|
|
22221
|
+
if (attachment) {
|
|
22222
|
+
return [2 /*return*/, __assign(__assign({}, attachment), { CreationTime: attachment.CreationTime
|
|
22223
|
+
? moment$6.utc(attachment.CreationTime).toDate()
|
|
22224
|
+
: new Date() })];
|
|
22225
|
+
}
|
|
22226
|
+
return [2 /*return*/, null];
|
|
22227
|
+
}
|
|
22228
|
+
else {
|
|
22229
|
+
throw new Error(resp.message || "Error creating entry attachment");
|
|
22230
|
+
}
|
|
22231
|
+
}
|
|
22232
|
+
});
|
|
22233
|
+
}); };
|
|
22234
|
+
var deleteEntryAttachment = function (entryAttachmentId, uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22235
|
+
var apiService, parameters, resp;
|
|
22236
|
+
return __generator(this, function (_a) {
|
|
22237
|
+
switch (_a.label) {
|
|
22238
|
+
case 0:
|
|
22239
|
+
apiService = new MESApiService();
|
|
22240
|
+
parameters = [
|
|
22241
|
+
{ name: "EntryAttachmentId", value: entryAttachmentId },
|
|
22242
|
+
];
|
|
22243
|
+
return [4 /*yield*/, apiService.callV2("[LB].[DeleteEntryAttachment]", parameters)];
|
|
22244
|
+
case 1:
|
|
22245
|
+
resp = _a.sent();
|
|
22246
|
+
if (!resp.ok) {
|
|
22247
|
+
throw new Error(resp.message || "Error deleting entry attachment");
|
|
22248
|
+
}
|
|
22249
|
+
// Delete the associated file in background if UploadFileId was provided
|
|
22250
|
+
if (uploadFileId) {
|
|
22251
|
+
deleteUploadFileInBackground(uploadFileId);
|
|
22252
|
+
}
|
|
22253
|
+
return [2 /*return*/];
|
|
22254
|
+
}
|
|
22255
|
+
});
|
|
22256
|
+
}); };
|
|
22257
|
+
var deleteUploadFileInBackground = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22258
|
+
var error_3;
|
|
22259
|
+
return __generator(this, function (_a) {
|
|
22260
|
+
switch (_a.label) {
|
|
22261
|
+
case 0:
|
|
22262
|
+
_a.trys.push([0, 2, , 3]);
|
|
22263
|
+
return [4 /*yield*/, deleteUploadFile(uploadFileId)];
|
|
22264
|
+
case 1:
|
|
22265
|
+
_a.sent();
|
|
22266
|
+
return [3 /*break*/, 3];
|
|
22267
|
+
case 2:
|
|
22268
|
+
error_3 = _a.sent();
|
|
22269
|
+
// Log errors but don't fail the operation
|
|
22270
|
+
console.error("Failed to delete file ".concat(uploadFileId, ":"), error_3);
|
|
22271
|
+
return [3 /*break*/, 3];
|
|
22272
|
+
case 3: return [2 /*return*/];
|
|
22273
|
+
}
|
|
22274
|
+
});
|
|
22275
|
+
}); };
|
|
22276
|
+
|
|
22277
|
+
var useEntries = function (_a) {
|
|
22278
|
+
var shiftId = _a.shiftId, sectionIds = _a.sectionIds;
|
|
22279
|
+
return useQuery({
|
|
22280
|
+
queryKey: ["entries", shiftId, sectionIds],
|
|
22281
|
+
queryFn: function (_a) {
|
|
22282
|
+
var signal = _a.signal;
|
|
22283
|
+
return getEntries({ shiftId: shiftId, sectionIds: sectionIds, signal: signal });
|
|
22284
|
+
},
|
|
22285
|
+
});
|
|
22286
|
+
};
|
|
22287
|
+
var routeLogbookEntry = "/logbook/entry";
|
|
22288
|
+
|
|
22289
|
+
var useLogbookEntryOptionsFunctions = function (_a) {
|
|
22290
|
+
var setSelectedRowData = _a.setSelectedRowData, setShow = _a.setShow, setShowRemoveDialog = _a.setShowRemoveDialog, handleNewEntry = _a.handleNewEntry;
|
|
22291
|
+
var getMenuOptions = function (data) {
|
|
22292
|
+
var options = [];
|
|
22293
|
+
options = options.concat([
|
|
22294
|
+
{
|
|
22295
|
+
name: "New Entry",
|
|
22296
|
+
key: "new_logbook_entry",
|
|
22297
|
+
onClick: function () { return handleNewEntry(); },
|
|
22298
|
+
icon: React__default.createElement(PlaylistAddIcon, null),
|
|
22299
|
+
},
|
|
22300
|
+
]);
|
|
22301
|
+
if (data) {
|
|
22302
|
+
options = options.concat([
|
|
22303
|
+
{
|
|
22304
|
+
name: "Edit Entry",
|
|
22305
|
+
key: "edit_logbook_entry",
|
|
22306
|
+
onClick: function () {
|
|
22307
|
+
setSelectedRowData(data);
|
|
22308
|
+
setShow("edit");
|
|
22309
|
+
},
|
|
22310
|
+
icon: React__default.createElement(EditIcon, null),
|
|
22311
|
+
},
|
|
22312
|
+
{
|
|
22313
|
+
name: "Delete Entry",
|
|
22314
|
+
key: "delete_logbook_entry",
|
|
22315
|
+
onClick: function () {
|
|
22316
|
+
setShowRemoveDialog(true);
|
|
22317
|
+
},
|
|
22318
|
+
icon: React__default.createElement(DeleteIcon, null),
|
|
22319
|
+
},
|
|
22320
|
+
]);
|
|
22321
|
+
}
|
|
22322
|
+
return options;
|
|
22323
|
+
};
|
|
22324
|
+
return {
|
|
22325
|
+
getMenuOptions: getMenuOptions,
|
|
22326
|
+
};
|
|
22327
|
+
};
|
|
22328
|
+
|
|
22329
|
+
var useTableData$1 = function (_a) {
|
|
22330
|
+
var showContextMenu = _a.showContextMenu, allowAttachments = _a.allowAttachments, showShiftCrew = _a.showShiftCrew;
|
|
22331
|
+
var columnDefs = __spreadArray(__spreadArray(__spreadArray([
|
|
22332
|
+
{
|
|
22333
|
+
field: "CreateTimestamp",
|
|
22334
|
+
headerName: "Created",
|
|
22335
|
+
flex: 2,
|
|
22336
|
+
valueGetter: function (params) {
|
|
22337
|
+
return dxtToLocalServerTime(params.data.CreateTimestamp, "MM/dd/yy HH:mm");
|
|
22338
|
+
},
|
|
22339
|
+
},
|
|
22340
|
+
{
|
|
22341
|
+
field: "AssetName",
|
|
22342
|
+
headerName: "Asset",
|
|
22343
|
+
sortable: true,
|
|
22344
|
+
flex: 2,
|
|
22345
|
+
minWidth: 70,
|
|
22346
|
+
},
|
|
22347
|
+
{
|
|
22348
|
+
field: "Title",
|
|
22349
|
+
headerName: "Title",
|
|
22350
|
+
flex: 4,
|
|
22351
|
+
},
|
|
22352
|
+
{
|
|
22353
|
+
field: "SectionName",
|
|
22354
|
+
headerName: "Section",
|
|
22355
|
+
flex: 2,
|
|
22356
|
+
},
|
|
22357
|
+
{
|
|
22358
|
+
field: "Author",
|
|
22359
|
+
headerName: "Created By",
|
|
22360
|
+
flex: 2,
|
|
22361
|
+
}
|
|
22362
|
+
], (showShiftCrew
|
|
22363
|
+
? [
|
|
22364
|
+
{
|
|
22365
|
+
field: "Shift",
|
|
22366
|
+
headerName: "Shift",
|
|
22367
|
+
sortable: false,
|
|
22368
|
+
flex: 1,
|
|
22369
|
+
minWidth: 60,
|
|
22370
|
+
maxWidth: 60,
|
|
22371
|
+
},
|
|
22372
|
+
{
|
|
22373
|
+
field: "Crew",
|
|
22374
|
+
headerName: "Crew",
|
|
22375
|
+
sortable: false,
|
|
22376
|
+
flex: 1,
|
|
22377
|
+
minWidth: 60,
|
|
22378
|
+
maxWidth: 60,
|
|
22379
|
+
},
|
|
22380
|
+
]
|
|
22381
|
+
: []), true), (allowAttachments
|
|
22382
|
+
? [
|
|
22383
|
+
{
|
|
22384
|
+
field: "AttachmentCount",
|
|
22385
|
+
headerName: "",
|
|
22386
|
+
flex: 1,
|
|
22387
|
+
headerComponent: function () { return (React__default.createElement("div", { style: {
|
|
22388
|
+
display: "flex",
|
|
22389
|
+
alignItems: "center",
|
|
22390
|
+
justifyContent: "center",
|
|
22391
|
+
height: "100%",
|
|
22392
|
+
width: "100%",
|
|
22393
|
+
textAlign: "center",
|
|
22394
|
+
} },
|
|
22395
|
+
React__default.createElement(AttachFile, { style: { fontSize: 18, color: "#666" } }))); },
|
|
22396
|
+
cellRenderer: function (params) {
|
|
22397
|
+
var count = params.data.AttachmentCount || 0;
|
|
22398
|
+
if (count === 0) {
|
|
22399
|
+
return null;
|
|
22400
|
+
}
|
|
22401
|
+
return (React__default.createElement("div", { style: {
|
|
22402
|
+
display: "flex",
|
|
22403
|
+
alignItems: "center",
|
|
22404
|
+
height: "100%",
|
|
22405
|
+
justifyContent: "center",
|
|
22406
|
+
} },
|
|
22407
|
+
React__default.createElement(Chip, { icon: React__default.createElement(AttachFile, { style: { fontSize: 16 } }), label: count, size: "small", variant: "outlined", color: "primary" })));
|
|
22408
|
+
},
|
|
22409
|
+
},
|
|
22410
|
+
]
|
|
22411
|
+
: []), true), [
|
|
22412
|
+
{
|
|
22413
|
+
field: "Content",
|
|
22414
|
+
headerName: "Content",
|
|
22415
|
+
hide: true,
|
|
22416
|
+
},
|
|
22417
|
+
{
|
|
22418
|
+
headerName: "",
|
|
22419
|
+
flex: 1,
|
|
22420
|
+
wrapText: false,
|
|
22421
|
+
autoHeight: false,
|
|
22422
|
+
cellRenderer: function (params) {
|
|
22423
|
+
return (React__default.createElement(Grid2, { container: true, style: {
|
|
22424
|
+
height: "100%",
|
|
22425
|
+
display: "flex",
|
|
22426
|
+
justifyContent: "center",
|
|
22427
|
+
alignItems: "center",
|
|
22428
|
+
} },
|
|
22429
|
+
React__default.createElement(Grid2, { size: { md: 12, xs: 12 }, style: {
|
|
22430
|
+
display: "flex",
|
|
22431
|
+
justifyContent: "center",
|
|
22432
|
+
alignItems: "center",
|
|
22433
|
+
} },
|
|
22434
|
+
React__default.createElement(Button, { fullWidth: true, onClick: function (e) {
|
|
22435
|
+
return showContextMenu(e, params.data, "logbookEntryContext");
|
|
22436
|
+
}, size: "small" },
|
|
22437
|
+
React__default.createElement(FormatListBulletedSharpIcon, { style: { height: "auto" }, color: "action" })))));
|
|
22438
|
+
},
|
|
22439
|
+
},
|
|
22440
|
+
], false);
|
|
22441
|
+
return { columnDefs: columnDefs };
|
|
22442
|
+
};
|
|
22443
|
+
|
|
22444
|
+
var ENTRY_INITIAL_VALUES = {
|
|
22445
|
+
EntryId: 0,
|
|
22446
|
+
ShiftId: 0,
|
|
22447
|
+
AssetId: null,
|
|
22448
|
+
Title: "",
|
|
22449
|
+
Content: "",
|
|
22450
|
+
CreateTimestamp: new Date(),
|
|
22451
|
+
UpdateTimestamp: new Date(),
|
|
22452
|
+
LogEntryTypeCode: "S", // Default 'S'
|
|
22453
|
+
Shift: null,
|
|
22454
|
+
Crew: null,
|
|
22455
|
+
Author: null,
|
|
22456
|
+
UpdatedBy: null,
|
|
22457
|
+
AttachmentCount: 0,
|
|
22458
|
+
// Section defaults
|
|
22459
|
+
SectionId: null,
|
|
22460
|
+
SectionName: undefined,
|
|
22461
|
+
SectionFamilyName: undefined,
|
|
22462
|
+
WeighUp: undefined,
|
|
22463
|
+
BreakIn: undefined,
|
|
22464
|
+
SectionNotes: undefined,
|
|
22465
|
+
};
|
|
22466
|
+
|
|
22467
|
+
var RemoveEntryDialog = function (_a) {
|
|
22468
|
+
var entry = _a.entry, show = _a.show, onHide = _a.onHide;
|
|
22469
|
+
var navigate = useNavigate();
|
|
22470
|
+
var _b = useState(false), isSubmitLoading = _b[0], setIsSubmitLoading = _b[1];
|
|
22471
|
+
var _c = useState(""); _c[0]; var setSuccessMessage = _c[1];
|
|
22472
|
+
var _d = useState(""), error = _d[0], setError = _d[1];
|
|
22473
|
+
var handleCancel = function () {
|
|
22474
|
+
setIsSubmitLoading(false);
|
|
22475
|
+
onHide(false);
|
|
22476
|
+
};
|
|
22477
|
+
var queryClient = useQueryClient();
|
|
22478
|
+
var removeEntry = useMutation(deleteEntry, {
|
|
22479
|
+
onSuccess: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
22480
|
+
return __generator(this, function (_a) {
|
|
22481
|
+
switch (_a.label) {
|
|
22482
|
+
case 0: return [4 /*yield*/, queryClient.invalidateQueries({ queryKey: ["entries"] })];
|
|
22483
|
+
case 1:
|
|
22484
|
+
_a.sent();
|
|
22485
|
+
navigate("".concat(routeLogbookEntry), { replace: true });
|
|
22486
|
+
setSuccessMessage("The entry was deleted succesfully");
|
|
22487
|
+
onHide(true);
|
|
22488
|
+
return [2 /*return*/];
|
|
22489
|
+
}
|
|
22490
|
+
});
|
|
22491
|
+
}); },
|
|
22492
|
+
onError: function (error) {
|
|
22493
|
+
setError(error.message);
|
|
22494
|
+
},
|
|
22495
|
+
onSettled: function () { return setIsSubmitLoading(false); },
|
|
22496
|
+
});
|
|
22497
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
22498
|
+
React__default.createElement(Dialog$1, { fullWidth: true, maxWidth: "md", open: show, onClose: function () { return handleCancel(); }, disableEnforceFocus: true, sx: {
|
|
22499
|
+
"& .input-group-text": {
|
|
22500
|
+
display: "none",
|
|
22501
|
+
},
|
|
22502
|
+
"& .MuiDialogContent-dividers": {
|
|
22503
|
+
padding: 0,
|
|
22504
|
+
},
|
|
22505
|
+
} },
|
|
22506
|
+
React__default.createElement(DialogTitle$1, { id: "responsive-dialog-title", style: { paddingBottom: 0 } }, "WARNING"),
|
|
22507
|
+
React__default.createElement(DialogContent$1, null,
|
|
22508
|
+
React__default.createElement(DialogContentText, { style: { padding: 0, margin: 0 } },
|
|
22509
|
+
"Be careful, you are about to delete: ",
|
|
22510
|
+
React__default.createElement("b", null, entry === null || entry === void 0 ? void 0 : entry.Title),
|
|
22511
|
+
". Once deleted you will not be able to recover this Entry. Are you sure you want to delete it?")),
|
|
22512
|
+
React__default.createElement(DialogActions$1, { style: { padding: "0 24px 16px" } },
|
|
22513
|
+
React__default.createElement(Button, { onClick: function () { return onHide(false); }, autoFocus: true, color: "inherit" }, "CANCEL"),
|
|
22514
|
+
React__default.createElement(Button, { autoFocus: true, color: "secondary", startIcon: isSubmitLoading && React__default.createElement(CircularProgress, { size: "1rem" }), onClick: function () { var _a; return removeEntry.mutate((_a = entry === null || entry === void 0 ? void 0 : entry.EntryId) !== null && _a !== void 0 ? _a : 0); } }, "Delete"))),
|
|
22515
|
+
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
22516
|
+
};
|
|
22517
|
+
|
|
22518
|
+
var moment$5 = getMomentTz();
|
|
22519
|
+
var getSections = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
22520
|
+
var apiService, parameters, resp;
|
|
22521
|
+
var schema = _b.schema, sectionFamilyId = _b.sectionFamilyId, searchText = _b.searchText, signal = _b.signal;
|
|
22522
|
+
return __generator(this, function (_c) {
|
|
22523
|
+
switch (_c.label) {
|
|
22524
|
+
case 0:
|
|
22525
|
+
apiService = new MESApiService();
|
|
22526
|
+
parameters = [];
|
|
22527
|
+
if (sectionFamilyId) {
|
|
22528
|
+
parameters.push({ name: "SectionFamilyId", value: sectionFamilyId });
|
|
22529
|
+
}
|
|
22530
|
+
if (searchText) {
|
|
22531
|
+
parameters.push({ name: "SearchText", value: searchText });
|
|
22532
|
+
}
|
|
22533
|
+
return [4 /*yield*/, apiService.callV2("[".concat(schema, "].[GetSections]"), parameters, signal)];
|
|
22534
|
+
case 1:
|
|
22535
|
+
resp = _c.sent();
|
|
22536
|
+
if (resp.ok) {
|
|
22537
|
+
return [2 /*return*/, get(resp, "data.tables[0].rows", [])];
|
|
22538
|
+
}
|
|
22539
|
+
else {
|
|
22540
|
+
throw new Error(resp.message || "Error fetching sections");
|
|
22541
|
+
}
|
|
22542
|
+
}
|
|
22543
|
+
});
|
|
22544
|
+
}); };
|
|
22545
|
+
var getTopUsedSections = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
22546
|
+
var apiService, parameters, resp, rows;
|
|
22547
|
+
var schema = _b.schema, _c = _b.top, top = _c === void 0 ? 5 : _c, signal = _b.signal;
|
|
22548
|
+
return __generator(this, function (_d) {
|
|
22549
|
+
switch (_d.label) {
|
|
22550
|
+
case 0:
|
|
22551
|
+
apiService = new MESApiService();
|
|
22552
|
+
parameters = [{ name: "Top", value: top }];
|
|
22553
|
+
return [4 /*yield*/, apiService.callV2("[".concat(schema, "].[GetTopUsedSections]"), parameters, signal)];
|
|
22554
|
+
case 1:
|
|
22555
|
+
resp = _d.sent();
|
|
22556
|
+
if (resp.ok) {
|
|
22557
|
+
rows = get(resp, "data.tables[0].rows", []);
|
|
22558
|
+
rows = rows.map(function (section) { return (__assign(__assign({}, section), { LastUsedTimestamp: section.LastUsedTimestamp
|
|
22559
|
+
? moment$5.utc(section.LastUsedTimestamp).toDate()
|
|
22560
|
+
: null })); });
|
|
22561
|
+
return [2 /*return*/, rows];
|
|
22562
|
+
}
|
|
22563
|
+
else {
|
|
22564
|
+
throw new Error(resp.message || "Error fetching top used sections");
|
|
22565
|
+
}
|
|
22566
|
+
}
|
|
22567
|
+
});
|
|
22568
|
+
}); };
|
|
22569
|
+
|
|
22570
|
+
var useSections = function (_a) {
|
|
22571
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.searchText, searchText = _c === void 0 ? null : _c, _d = _b.enabled, enabled = _d === void 0 ? true : _d;
|
|
22572
|
+
var section = useLogbookSettings().section;
|
|
22573
|
+
var schema = section === null || section === void 0 ? void 0 : section.schema;
|
|
22574
|
+
return useQuery({
|
|
22575
|
+
queryKey: ["sections", schema, searchText],
|
|
22576
|
+
queryFn: function (_a) {
|
|
22577
|
+
var signal = _a.signal;
|
|
22578
|
+
return getSections({ schema: schema, searchText: searchText, signal: signal });
|
|
22579
|
+
},
|
|
22580
|
+
enabled: enabled,
|
|
22581
|
+
});
|
|
22582
|
+
};
|
|
22583
|
+
|
|
22584
|
+
var useTopSections = function (_a) {
|
|
22585
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.top, top = _c === void 0 ? 5 : _c;
|
|
22586
|
+
var section = useLogbookSettings().section;
|
|
22587
|
+
var schema = section === null || section === void 0 ? void 0 : section.schema;
|
|
22588
|
+
return useQuery({
|
|
22589
|
+
queryKey: ["topSections", schema, top],
|
|
22590
|
+
queryFn: function (_a) {
|
|
22591
|
+
var signal = _a.signal;
|
|
22592
|
+
return getTopUsedSections({ schema: schema, top: top, signal: signal });
|
|
22593
|
+
},
|
|
22594
|
+
});
|
|
22595
|
+
};
|
|
22596
|
+
|
|
22597
|
+
var SectionSelector = function (_a) {
|
|
22598
|
+
var value = _a.value, onChange = _a.onChange, _b = _a.topSectionsCount, topSectionsCount = _b === void 0 ? 5 : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.label, label = _d === void 0 ? "Section" : _d;
|
|
22599
|
+
var _e = useState(false), open = _e[0], setOpen = _e[1];
|
|
22600
|
+
var _f = useState(""), inputValue = _f[0], setInputValue = _f[1];
|
|
22601
|
+
var _g = useTopSections({
|
|
22602
|
+
top: topSectionsCount,
|
|
22603
|
+
}), _h = _g.data, topSections = _h === void 0 ? [] : _h, loadingTop = _g.isLoading;
|
|
22604
|
+
var _j = useSections({
|
|
22605
|
+
searchText: inputValue || null,
|
|
22606
|
+
enabled: open,
|
|
22607
|
+
}), _k = _j.data, options = _k === void 0 ? [] : _k, loading = _j.isFetching;
|
|
22608
|
+
var handleChipClick = function (section) {
|
|
22609
|
+
if ((value === null || value === void 0 ? void 0 : value.SectionId) === section.SectionId) {
|
|
22610
|
+
onChange(null);
|
|
22611
|
+
}
|
|
22612
|
+
else {
|
|
22613
|
+
onChange(section);
|
|
22614
|
+
}
|
|
22615
|
+
};
|
|
22616
|
+
return (React__default.createElement(Box, { sx: {
|
|
22617
|
+
display: "flex",
|
|
22618
|
+
flexDirection: "row",
|
|
22619
|
+
alignItems: "center",
|
|
22620
|
+
gap: 1,
|
|
22621
|
+
flexWrap: "wrap",
|
|
22622
|
+
} },
|
|
22623
|
+
React__default.createElement(Autocomplete$1, { open: open, onOpen: function () { return setOpen(true); }, onClose: function () { return setOpen(false); }, value: value, onChange: function (_, newValue) { return onChange(newValue); }, inputValue: inputValue, onInputChange: function (_, newInputValue) { return setInputValue(newInputValue); }, options: options, loading: loading, disabled: disabled, getOptionLabel: function (option) { return option.SectionName; }, isOptionEqualToValue: function (option, value) {
|
|
22624
|
+
return option.SectionId === value.SectionId;
|
|
22625
|
+
}, sx: { minWidth: 120, maxWidth: 150 }, renderOption: function (props, option) { return (React__default.createElement(Box, __assign({ component: "li" }, props, { key: option.SectionId, sx: { display: "flex", justifyContent: "space-between" } }),
|
|
22626
|
+
React__default.createElement(Typography$1, { fontWeight: 500 }, option.SectionName))); }, renderInput: function (params) { return (React__default.createElement(TextField, __assign({}, params, { label: label, placeholder: "####", size: "small", slotProps: {
|
|
22627
|
+
input: __assign(__assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null,
|
|
22628
|
+
loading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 16 })) : null,
|
|
22629
|
+
params.InputProps.endAdornment)) }),
|
|
22630
|
+
} }))); } }),
|
|
22631
|
+
loadingTop ? (React__default.createElement(CircularProgress, { size: 14 })) : topSections.length > 0 ? (React__default.createElement(Box, { sx: {
|
|
22632
|
+
display: "flex",
|
|
22633
|
+
flexWrap: "wrap",
|
|
22634
|
+
gap: 0.5,
|
|
22635
|
+
alignItems: "center",
|
|
22636
|
+
} },
|
|
22637
|
+
React__default.createElement(Typography$1, { variant: "caption", color: "text.secondary", sx: { mr: 0.5 } }, "Top:"),
|
|
22638
|
+
topSections.map(function (section) { return (React__default.createElement(Chip, { key: section.SectionId, label: section.SectionName, size: "small", variant: (value === null || value === void 0 ? void 0 : value.SectionId) === section.SectionId ? "filled" : "outlined", color: (value === null || value === void 0 ? void 0 : value.SectionId) === section.SectionId ? "primary" : "default", onClick: function () { return handleChipClick(section); }, disabled: disabled, sx: {
|
|
22639
|
+
cursor: "pointer",
|
|
22640
|
+
height: 22,
|
|
22641
|
+
"& .MuiChip-label": { px: 1, fontSize: "0.75rem" },
|
|
22642
|
+
} })); }))) : null));
|
|
22643
|
+
};
|
|
22644
|
+
|
|
22645
|
+
var SectionMultiSelect = function (_a) {
|
|
22646
|
+
var value = _a.value, onChange = _a.onChange, _b = _a.topSectionsCount, topSectionsCount = _b === void 0 ? 5 : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.label, label = _d === void 0 ? "Sections" : _d;
|
|
22647
|
+
var _e = useState(false), open = _e[0], setOpen = _e[1];
|
|
22648
|
+
var _f = useState(""), inputValue = _f[0], setInputValue = _f[1];
|
|
22649
|
+
var _g = useTopSections({
|
|
22650
|
+
top: topSectionsCount,
|
|
22651
|
+
}), _h = _g.data, topSections = _h === void 0 ? [] : _h, loadingTop = _g.isLoading;
|
|
22652
|
+
var _j = useSections({
|
|
22653
|
+
searchText: inputValue || null,
|
|
22654
|
+
enabled: open,
|
|
22655
|
+
}), _k = _j.data, options = _k === void 0 ? [] : _k, loading = _j.isFetching;
|
|
22656
|
+
var handleChipClick = function (section) {
|
|
22657
|
+
var isSelected = value.some(function (s) { return s.SectionId === section.SectionId; });
|
|
22658
|
+
if (isSelected) {
|
|
22659
|
+
onChange(value.filter(function (s) { return s.SectionId !== section.SectionId; }));
|
|
22660
|
+
}
|
|
22661
|
+
else {
|
|
22662
|
+
onChange(__spreadArray(__spreadArray([], value, true), [section], false));
|
|
22663
|
+
}
|
|
22664
|
+
};
|
|
22665
|
+
return (React__default.createElement(Box, { sx: {
|
|
22666
|
+
display: "flex",
|
|
22667
|
+
flexDirection: "row",
|
|
22668
|
+
alignItems: "center",
|
|
22669
|
+
gap: 1,
|
|
22670
|
+
flexWrap: "wrap",
|
|
22671
|
+
} },
|
|
22672
|
+
React__default.createElement(Autocomplete$1, { multiple: true, open: open, onOpen: function () { return setOpen(true); }, onClose: function () { return setOpen(false); }, value: value, onChange: function (_, newValue) { return onChange(newValue); }, inputValue: inputValue, onInputChange: function (_, newInputValue) { return setInputValue(newInputValue); }, options: options, loading: loading, disabled: disabled, getOptionLabel: function (option) { return option.SectionName; }, isOptionEqualToValue: function (option, val) {
|
|
22673
|
+
return option.SectionId === val.SectionId;
|
|
22674
|
+
}, limitTags: 2, size: "small", sx: { minWidth: 200, flex: 1 }, renderOption: function (props, option) { return (React__default.createElement(Box, __assign({ component: "li" }, props, { key: option.SectionId, sx: { display: "flex", justifyContent: "space-between" } }),
|
|
22675
|
+
React__default.createElement(Typography$1, { fontWeight: 500 }, option.SectionName))); }, renderInput: function (params) { return (React__default.createElement(TextField, __assign({}, params, { label: label, placeholder: value.length === 0 ? "All sections" : "", size: "small", slotProps: {
|
|
22676
|
+
input: __assign(__assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null,
|
|
22677
|
+
loading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 16 })) : null,
|
|
22678
|
+
params.InputProps.endAdornment)) }),
|
|
22679
|
+
} }))); } }),
|
|
22680
|
+
loadingTop ? (React__default.createElement(CircularProgress, { size: 14 })) : topSections.length > 0 ? (React__default.createElement(Box, { sx: {
|
|
22681
|
+
display: "flex",
|
|
22682
|
+
flexWrap: "wrap",
|
|
22683
|
+
gap: 0.5,
|
|
22684
|
+
alignItems: "center",
|
|
22685
|
+
} },
|
|
22686
|
+
React__default.createElement(Typography$1, { variant: "caption", color: "text.secondary", sx: { mr: 0.5 } }, "Top:"),
|
|
22687
|
+
topSections.map(function (section) {
|
|
22688
|
+
var isSelected = value.some(function (s) { return s.SectionId === section.SectionId; });
|
|
22689
|
+
return (React__default.createElement(Chip, { key: section.SectionId, label: section.SectionName, size: "small", variant: isSelected ? "filled" : "outlined", color: isSelected ? "primary" : "default", onClick: function () { return handleChipClick(section); }, disabled: disabled, sx: {
|
|
22690
|
+
cursor: "pointer",
|
|
22691
|
+
height: 22,
|
|
22692
|
+
"& .MuiChip-label": { px: 1, fontSize: "0.75rem" },
|
|
22693
|
+
} }));
|
|
22694
|
+
}))) : null));
|
|
22695
|
+
};
|
|
22696
|
+
|
|
22697
|
+
var upsertSectionEntry = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
22698
|
+
var apiService, parameters, resp;
|
|
22699
|
+
var entryId = _b.entryId, sectionId = _b.sectionId, weighUp = _b.weighUp, breakIn = _b.breakIn, notes = _b.notes;
|
|
22700
|
+
return __generator(this, function (_c) {
|
|
22701
|
+
switch (_c.label) {
|
|
22702
|
+
case 0:
|
|
22703
|
+
apiService = new MESApiService();
|
|
22704
|
+
parameters = [
|
|
22705
|
+
{ name: "EntryId", value: entryId },
|
|
22706
|
+
{ name: "SectionId", value: sectionId },
|
|
22707
|
+
];
|
|
22708
|
+
if (weighUp !== undefined) {
|
|
22709
|
+
parameters.push({ name: "WeighUp", value: weighUp });
|
|
22710
|
+
}
|
|
22711
|
+
if (breakIn !== undefined) {
|
|
22712
|
+
parameters.push({ name: "BreakIn", value: breakIn });
|
|
22713
|
+
}
|
|
22714
|
+
if (notes !== undefined) {
|
|
22715
|
+
parameters.push({ name: "Notes", value: notes });
|
|
22716
|
+
}
|
|
22717
|
+
return [4 /*yield*/, apiService.callV2("[SWV].[UpsertLogSectionEntry]", parameters)];
|
|
22718
|
+
case 1:
|
|
22719
|
+
resp = _c.sent();
|
|
22720
|
+
if (resp.ok) {
|
|
22721
|
+
return [2 /*return*/, get(resp, "data.tables[0].rows[0]", null)];
|
|
22722
|
+
}
|
|
22723
|
+
else {
|
|
22724
|
+
throw new Error(resp.message || "Error upserting section entry");
|
|
22725
|
+
}
|
|
22726
|
+
}
|
|
22727
|
+
});
|
|
22728
|
+
}); };
|
|
22729
|
+
|
|
22730
|
+
var useEntrySubmission = function (_a) {
|
|
22731
|
+
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;
|
|
22732
|
+
var _e = useState(false), isSubmitLoading = _e[0], setIsSubmitLoading = _e[1];
|
|
22733
|
+
var _f = useState(false), showConfirmationDialog = _f[0], setShowConfirmationDialog = _f[1];
|
|
22734
|
+
var _g = useState(null), pendingSubmitData = _g[0], setPendingSubmitData = _g[1];
|
|
22735
|
+
var submit = useMutation(upsertEntry, {
|
|
22736
|
+
onSuccess: function (entry) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22737
|
+
return __generator(this, function (_a) {
|
|
22738
|
+
if (entry && entry.EntryId) {
|
|
22739
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(entry);
|
|
22740
|
+
}
|
|
22741
|
+
else {
|
|
22742
|
+
console.error("No EntryId received from API response", entry);
|
|
22743
|
+
onError === null || onError === void 0 ? void 0 : onError(new Error("Failed to get entry ID from server response"));
|
|
22744
|
+
}
|
|
22745
|
+
return [2 /*return*/];
|
|
22746
|
+
});
|
|
22747
|
+
}); },
|
|
22748
|
+
onError: function (error) {
|
|
22749
|
+
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
22750
|
+
},
|
|
22751
|
+
onSettled: function () { return setIsSubmitLoading(false); },
|
|
22752
|
+
});
|
|
22753
|
+
var submitEntry = function (formData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22754
|
+
var submissionData;
|
|
22755
|
+
var _a;
|
|
22756
|
+
return __generator(this, function (_b) {
|
|
22757
|
+
switch (_b.label) {
|
|
22758
|
+
case 0:
|
|
22759
|
+
setIsSubmitLoading(true);
|
|
22760
|
+
submissionData = __assign({}, formData);
|
|
22761
|
+
if (isNewEntry && !submissionData.createTimestamp) {
|
|
22762
|
+
submissionData.createTimestamp = new Date();
|
|
22763
|
+
}
|
|
22764
|
+
if (!(!submissionData.shiftId || submissionData.isForOtherShift)) return [3 /*break*/, 1];
|
|
22765
|
+
setPendingSubmitData(submissionData);
|
|
22766
|
+
setShowConfirmationDialog(true);
|
|
22767
|
+
setIsSubmitLoading(false);
|
|
22768
|
+
return [3 /*break*/, 3];
|
|
22769
|
+
case 1: return [4 /*yield*/, submit.mutate({
|
|
22770
|
+
assetId: submissionData.assetId,
|
|
22771
|
+
shiftId: submissionData.shiftId,
|
|
22772
|
+
entryId: submissionData.entryId,
|
|
22773
|
+
title: submissionData.title,
|
|
22774
|
+
content: submissionData.content,
|
|
22775
|
+
author: (_a = submissionData.author) !== null && _a !== void 0 ? _a : "",
|
|
22776
|
+
createTimestamp: submissionData.createTimestamp,
|
|
22777
|
+
})];
|
|
22778
|
+
case 2:
|
|
22779
|
+
_b.sent();
|
|
22780
|
+
_b.label = 3;
|
|
22781
|
+
case 3: return [2 /*return*/];
|
|
22782
|
+
}
|
|
22783
|
+
});
|
|
22784
|
+
}); };
|
|
22785
|
+
var handleConfirmationClose = function (value) {
|
|
22786
|
+
var _a;
|
|
22787
|
+
setShowConfirmationDialog(false);
|
|
22788
|
+
if (value === "OK" && pendingSubmitData) {
|
|
22789
|
+
onHide();
|
|
22790
|
+
submit.mutate({
|
|
22791
|
+
assetId: pendingSubmitData.assetId,
|
|
22792
|
+
shiftId: pendingSubmitData.shiftId,
|
|
22793
|
+
entryId: pendingSubmitData.entryId,
|
|
22794
|
+
title: pendingSubmitData.title,
|
|
22795
|
+
content: pendingSubmitData.content,
|
|
22796
|
+
author: (_a = pendingSubmitData.author) !== null && _a !== void 0 ? _a : "",
|
|
22797
|
+
createTimestamp: pendingSubmitData.createTimestamp,
|
|
22798
|
+
});
|
|
22799
|
+
}
|
|
22800
|
+
setPendingSubmitData(null);
|
|
22801
|
+
};
|
|
22802
|
+
return {
|
|
22803
|
+
submitEntry: submitEntry,
|
|
22804
|
+
isSubmitLoading: isSubmitLoading,
|
|
22805
|
+
showConfirmationDialog: showConfirmationDialog,
|
|
22806
|
+
pendingSubmitData: pendingSubmitData,
|
|
22807
|
+
handleConfirmationClose: handleConfirmationClose,
|
|
22808
|
+
mutation: submit,
|
|
22809
|
+
};
|
|
22810
|
+
};
|
|
22811
|
+
|
|
22812
|
+
var DeleteAttachmentConfirmationDialog = function (_a) {
|
|
22813
|
+
var open = _a.open, attachmentName = _a.attachmentName, onClose = _a.onClose, _b = _a.isDeleting, isDeleting = _b === void 0 ? false : _b;
|
|
22814
|
+
var _c = useState(false), isClosing = _c[0], setIsClosing = _c[1];
|
|
22815
|
+
var handleCancel = function () {
|
|
22816
|
+
if (isClosing)
|
|
22817
|
+
return;
|
|
22818
|
+
onClose(false);
|
|
22819
|
+
};
|
|
22820
|
+
var handleConfirm = function () {
|
|
22821
|
+
if (isClosing)
|
|
22822
|
+
return;
|
|
22823
|
+
setIsClosing(true);
|
|
22824
|
+
onClose(true);
|
|
22825
|
+
};
|
|
22826
|
+
return (React__default.createElement(Dialog$1, { open: open, onClose: handleCancel, "aria-labelledby": "delete-attachment-dialog-title", "aria-describedby": "delete-attachment-dialog-description" },
|
|
22827
|
+
React__default.createElement(DialogTitle$1, { id: "delete-attachment-dialog-title" }, "Delete Attachment"),
|
|
22828
|
+
React__default.createElement(DialogContent$1, null,
|
|
22829
|
+
React__default.createElement(DialogContentText, { id: "delete-attachment-dialog-description" },
|
|
22830
|
+
"Are you sure you want to delete ",
|
|
22831
|
+
React__default.createElement("b", null, attachmentName),
|
|
22832
|
+
"? This action cannot be undone.")),
|
|
22833
|
+
React__default.createElement(DialogActions$1, null,
|
|
22834
|
+
React__default.createElement(Button, { onClick: handleCancel, color: "inherit", disabled: isClosing }, "Cancel"),
|
|
22835
|
+
React__default.createElement(Button, { onClick: handleConfirm, color: "secondary", variant: "contained", disabled: isClosing, startIcon: isDeleting && React__default.createElement(CircularProgress, { size: "1rem" }) }, "Delete"))));
|
|
22836
|
+
};
|
|
22837
|
+
|
|
22838
|
+
var AttachmentModal = function (_a) {
|
|
22839
|
+
var open = _a.open, onClose = _a.onClose, entryId = _a.entryId, isEditing = _a.isEditing, entryData = _a.entryData, onEntrySubmitted = _a.onEntrySubmitted;
|
|
22840
|
+
var queryClient = useQueryClient();
|
|
22841
|
+
var api = new MESApiService();
|
|
22842
|
+
var _b = useState(null), error = _b[0], setError = _b[1];
|
|
22843
|
+
var _c = useState([]), uploadingFiles = _c[0], setUploadingFiles = _c[1];
|
|
22844
|
+
var _d = useState(entryId), currentEntryId = _d[0], setCurrentEntryId = _d[1];
|
|
22845
|
+
var _e = useState(false), isSubmittingEntry = _e[0], setIsSubmittingEntry = _e[1];
|
|
22846
|
+
var _f = useState(false), showDeleteConfirmation = _f[0], setShowDeleteConfirmation = _f[1];
|
|
22847
|
+
var _g = useState(null), attachmentToDelete = _g[0], setAttachmentToDelete = _g[1];
|
|
22848
|
+
var pendingFilesRef = useRef([]);
|
|
22849
|
+
// Entry submission hook for background saves
|
|
22850
|
+
var _h = useEntrySubmission({
|
|
22851
|
+
onSuccess: function (entry) {
|
|
22852
|
+
setIsSubmittingEntry(false);
|
|
22853
|
+
if (entry === null || entry === void 0 ? void 0 : entry.EntryId) {
|
|
22854
|
+
setCurrentEntryId(entry.EntryId);
|
|
22855
|
+
onEntrySubmitted === null || onEntrySubmitted === void 0 ? void 0 : onEntrySubmitted(entry.EntryId, entry);
|
|
22856
|
+
// If there are pending files, upload them now with the new entry ID
|
|
22857
|
+
if (pendingFilesRef.current.length > 0) {
|
|
22858
|
+
var filesToUpload = __spreadArray([], pendingFilesRef.current, true);
|
|
22859
|
+
pendingFilesRef.current = [];
|
|
22860
|
+
// Call upload directly with the new entry ID instead of relying on state
|
|
22861
|
+
uploadFilesWithEntryId(filesToUpload, entry.EntryId);
|
|
22862
|
+
}
|
|
22863
|
+
}
|
|
22864
|
+
},
|
|
22865
|
+
onError: function (error) {
|
|
22866
|
+
setIsSubmittingEntry(false);
|
|
22867
|
+
setError(error.message);
|
|
22868
|
+
pendingFilesRef.current = []; // Clear pending files on error
|
|
22869
|
+
},
|
|
22870
|
+
isNewEntry: !entryId || entryId <= 0,
|
|
22871
|
+
}), submitEntry = _h.submitEntry, isSubmitLoading = _h.isSubmitLoading;
|
|
22872
|
+
// Sync entryId prop with currentEntryId state
|
|
22873
|
+
useEffect(function () {
|
|
22874
|
+
setCurrentEntryId(entryId);
|
|
22875
|
+
}, [entryId]);
|
|
22876
|
+
// Query for fetching attachments
|
|
22877
|
+
var _j = useQuery({
|
|
22878
|
+
queryKey: ["entryAttachments", currentEntryId],
|
|
22879
|
+
queryFn: function () { return getEntryAttachments(currentEntryId); },
|
|
22880
|
+
enabled: !!currentEntryId && currentEntryId > 0,
|
|
22881
|
+
}), _k = _j.data, attachments = _k === void 0 ? [] : _k, isLoading = _j.isLoading, fetchError = _j.error;
|
|
22882
|
+
// Mutations
|
|
22883
|
+
var uploadMutation = useMutation(upsertEntryAttachment, {
|
|
22884
|
+
onSuccess: function () {
|
|
22885
|
+
queryClient.invalidateQueries(["entryAttachments", currentEntryId]);
|
|
22886
|
+
queryClient.invalidateQueries(["entries"]);
|
|
22887
|
+
queryClient.invalidateQueries(["entriesReport"]);
|
|
22888
|
+
},
|
|
22889
|
+
onError: function (error) {
|
|
22890
|
+
setError(error.message);
|
|
22891
|
+
},
|
|
22892
|
+
});
|
|
22893
|
+
var deleteMutation = useMutation(function (_a) {
|
|
22894
|
+
var entryAttachmentId = _a.entryAttachmentId, uploadFileId = _a.uploadFileId;
|
|
22895
|
+
return deleteEntryAttachment(entryAttachmentId, uploadFileId);
|
|
22896
|
+
}, {
|
|
22897
|
+
onSuccess: function () {
|
|
22898
|
+
queryClient.invalidateQueries(["entryAttachments", currentEntryId]);
|
|
22899
|
+
queryClient.invalidateQueries(["entries"]);
|
|
22900
|
+
queryClient.invalidateQueries(["entriesReport"]);
|
|
22901
|
+
},
|
|
22902
|
+
onError: function (error) {
|
|
22903
|
+
setError(error.message);
|
|
22904
|
+
},
|
|
22905
|
+
});
|
|
22906
|
+
// Function to upload files with a specific entry ID (used after background submission)
|
|
22907
|
+
var uploadFilesWithEntryId = useCallback(function (files, targetEntryId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22908
|
+
var _i, files_1, file, uploadResponse, uploadFileId, attachmentURL, error_1;
|
|
22909
|
+
var _a;
|
|
22910
|
+
return __generator(this, function (_b) {
|
|
22911
|
+
switch (_b.label) {
|
|
22912
|
+
case 0:
|
|
22913
|
+
setUploadingFiles(files);
|
|
22914
|
+
setError(null);
|
|
22915
|
+
_b.label = 1;
|
|
22916
|
+
case 1:
|
|
22917
|
+
_b.trys.push([1, 7, 8, 9]);
|
|
22918
|
+
_i = 0, files_1 = files;
|
|
22919
|
+
_b.label = 2;
|
|
22920
|
+
case 2:
|
|
22921
|
+
if (!(_i < files_1.length)) return [3 /*break*/, 6];
|
|
22922
|
+
file = files_1[_i];
|
|
22923
|
+
return [4 /*yield*/, api.uploadFiles([file], "logbook")];
|
|
22924
|
+
case 3:
|
|
22925
|
+
uploadResponse = _b.sent();
|
|
22926
|
+
if (!((_a = uploadResponse === null || uploadResponse === void 0 ? void 0 : uploadResponse.result) === null || _a === void 0 ? void 0 : _a[0])) return [3 /*break*/, 5];
|
|
22927
|
+
uploadFileId = uploadResponse.result[0].UploadFileId;
|
|
22928
|
+
attachmentURL = uploadResponse.result[0].URL;
|
|
22929
|
+
// Then create the attachment record
|
|
22930
|
+
return [4 /*yield*/, uploadMutation.mutateAsync({
|
|
22931
|
+
entryId: targetEntryId,
|
|
22932
|
+
uploadFileId: uploadFileId,
|
|
22933
|
+
attachmentName: file.name,
|
|
22934
|
+
attachmentURL: attachmentURL,
|
|
22935
|
+
})];
|
|
22936
|
+
case 4:
|
|
22937
|
+
// Then create the attachment record
|
|
22938
|
+
_b.sent();
|
|
22939
|
+
// Invalidate queries for the specific entry and the main entries lists
|
|
22940
|
+
queryClient.invalidateQueries(["entryAttachments", targetEntryId]);
|
|
22941
|
+
queryClient.invalidateQueries(["entries"]);
|
|
22942
|
+
queryClient.invalidateQueries(["entriesReport"]);
|
|
22943
|
+
_b.label = 5;
|
|
22944
|
+
case 5:
|
|
22945
|
+
_i++;
|
|
22946
|
+
return [3 /*break*/, 2];
|
|
22947
|
+
case 6: return [3 /*break*/, 9];
|
|
22948
|
+
case 7:
|
|
22949
|
+
error_1 = _b.sent();
|
|
22950
|
+
setError("Failed to upload files: ".concat(error_1));
|
|
22951
|
+
return [3 /*break*/, 9];
|
|
22952
|
+
case 8:
|
|
22953
|
+
setUploadingFiles([]);
|
|
22954
|
+
return [7 /*endfinally*/];
|
|
22955
|
+
case 9: return [2 /*return*/];
|
|
22956
|
+
}
|
|
22957
|
+
});
|
|
22958
|
+
}); }, [api, uploadMutation, queryClient]);
|
|
22959
|
+
var handleFileUpload = useCallback(function (files) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22960
|
+
var targetEntryId, error_2, _i, files_2, file, uploadResponse, uploadFileId, attachmentURL, error_3;
|
|
22961
|
+
var _a;
|
|
22962
|
+
return __generator(this, function (_b) {
|
|
22963
|
+
switch (_b.label) {
|
|
22964
|
+
case 0:
|
|
22965
|
+
targetEntryId = currentEntryId;
|
|
22966
|
+
if (!((!targetEntryId || targetEntryId <= 0) &&
|
|
22967
|
+
entryData &&
|
|
22968
|
+
!isSubmittingEntry)) return [3 /*break*/, 4];
|
|
22969
|
+
_b.label = 1;
|
|
22970
|
+
case 1:
|
|
22971
|
+
_b.trys.push([1, 3, , 4]);
|
|
22972
|
+
setError(null);
|
|
22973
|
+
setIsSubmittingEntry(true);
|
|
22974
|
+
// Store files to upload after entry is created
|
|
22975
|
+
pendingFilesRef.current = files;
|
|
22976
|
+
return [4 /*yield*/, submitEntry(entryData)];
|
|
22977
|
+
case 2:
|
|
22978
|
+
_b.sent();
|
|
22979
|
+
// The files will be uploaded in the success callback
|
|
22980
|
+
return [2 /*return*/];
|
|
22981
|
+
case 3:
|
|
22982
|
+
error_2 = _b.sent();
|
|
22983
|
+
setIsSubmittingEntry(false);
|
|
22984
|
+
setError("Failed to save entry before uploading files: ".concat(error_2));
|
|
22985
|
+
pendingFilesRef.current = [];
|
|
22986
|
+
return [2 /*return*/];
|
|
22987
|
+
case 4:
|
|
22988
|
+
if (!targetEntryId || targetEntryId <= 0) {
|
|
22989
|
+
setError("Entry must be saved before adding attachments");
|
|
22990
|
+
return [2 /*return*/];
|
|
22991
|
+
}
|
|
22992
|
+
setUploadingFiles(files);
|
|
22993
|
+
setError(null);
|
|
22994
|
+
_b.label = 5;
|
|
22995
|
+
case 5:
|
|
22996
|
+
_b.trys.push([5, 11, 12, 13]);
|
|
22997
|
+
_i = 0, files_2 = files;
|
|
22998
|
+
_b.label = 6;
|
|
22999
|
+
case 6:
|
|
23000
|
+
if (!(_i < files_2.length)) return [3 /*break*/, 10];
|
|
23001
|
+
file = files_2[_i];
|
|
23002
|
+
return [4 /*yield*/, api.uploadFiles([file], "logbook")];
|
|
23003
|
+
case 7:
|
|
23004
|
+
uploadResponse = _b.sent();
|
|
23005
|
+
if (!((_a = uploadResponse === null || uploadResponse === void 0 ? void 0 : uploadResponse.result) === null || _a === void 0 ? void 0 : _a[0])) return [3 /*break*/, 9];
|
|
23006
|
+
uploadFileId = uploadResponse.result[0].UploadFileId;
|
|
23007
|
+
attachmentURL = uploadResponse.result[0].URL;
|
|
23008
|
+
// Then create the attachment record
|
|
23009
|
+
return [4 /*yield*/, uploadMutation.mutateAsync({
|
|
23010
|
+
entryId: targetEntryId,
|
|
23011
|
+
uploadFileId: uploadFileId,
|
|
23012
|
+
attachmentName: file.name,
|
|
23013
|
+
attachmentURL: attachmentURL,
|
|
23014
|
+
})];
|
|
23015
|
+
case 8:
|
|
23016
|
+
// Then create the attachment record
|
|
23017
|
+
_b.sent();
|
|
23018
|
+
_b.label = 9;
|
|
23019
|
+
case 9:
|
|
23020
|
+
_i++;
|
|
23021
|
+
return [3 /*break*/, 6];
|
|
23022
|
+
case 10: return [3 /*break*/, 13];
|
|
23023
|
+
case 11:
|
|
23024
|
+
error_3 = _b.sent();
|
|
23025
|
+
setError("Failed to upload files: ".concat(error_3));
|
|
23026
|
+
return [3 /*break*/, 13];
|
|
23027
|
+
case 12:
|
|
23028
|
+
setUploadingFiles([]);
|
|
23029
|
+
return [7 /*endfinally*/];
|
|
23030
|
+
case 13: return [2 /*return*/];
|
|
23031
|
+
}
|
|
23032
|
+
});
|
|
23033
|
+
}); }, [
|
|
23034
|
+
currentEntryId,
|
|
23035
|
+
entryData,
|
|
23036
|
+
api,
|
|
23037
|
+
uploadMutation,
|
|
23038
|
+
submitEntry,
|
|
23039
|
+
isSubmittingEntry,
|
|
23040
|
+
]);
|
|
23041
|
+
var handleDeleteAttachment = function (attachmentId, uploadFileId, attachmentName) {
|
|
23042
|
+
setAttachmentToDelete({
|
|
23043
|
+
id: attachmentId,
|
|
23044
|
+
uploadFileId: uploadFileId,
|
|
23045
|
+
name: attachmentName,
|
|
23046
|
+
});
|
|
23047
|
+
setShowDeleteConfirmation(true);
|
|
23048
|
+
};
|
|
23049
|
+
var handleDeleteConfirmation = function (confirmed) {
|
|
23050
|
+
setShowDeleteConfirmation(false);
|
|
23051
|
+
if (confirmed && attachmentToDelete) {
|
|
23052
|
+
deleteMutation.mutate({
|
|
23053
|
+
entryAttachmentId: attachmentToDelete.id,
|
|
23054
|
+
uploadFileId: attachmentToDelete.uploadFileId,
|
|
23055
|
+
});
|
|
23056
|
+
}
|
|
23057
|
+
setAttachmentToDelete(null);
|
|
23058
|
+
};
|
|
23059
|
+
// This function is no longer needed as we're using direct anchor links
|
|
23060
|
+
// Keeping it as a reference in case it's needed elsewhere
|
|
23061
|
+
/*
|
|
23062
|
+
const handleDownloadAttachment = (attachment: EntryAttachment) => {
|
|
23063
|
+
// Use the URL property with proper encoding
|
|
23064
|
+
const encodedUrl = attachment.URL;
|
|
23065
|
+
const link = document.createElement("a");
|
|
23066
|
+
link.href = encodedUrl;
|
|
23067
|
+
link.download = attachment.AttachmentName;
|
|
23068
|
+
link.target = "_blank";
|
|
23069
|
+
document.body.appendChild(link);
|
|
23070
|
+
link.click();
|
|
23071
|
+
document.body.removeChild(link);
|
|
23072
|
+
};
|
|
23073
|
+
*/
|
|
23074
|
+
var onDrop = useCallback(function (acceptedFiles) {
|
|
23075
|
+
if (isEditing) {
|
|
23076
|
+
handleFileUpload(acceptedFiles);
|
|
23077
|
+
}
|
|
23078
|
+
}, [handleFileUpload, isEditing]);
|
|
23079
|
+
var _l = useDropzone({
|
|
23080
|
+
onDrop: onDrop,
|
|
23081
|
+
disabled: !isEditing,
|
|
23082
|
+
multiple: true,
|
|
23083
|
+
}), getRootProps = _l.getRootProps, getInputProps = _l.getInputProps, isDragActive = _l.isDragActive;
|
|
23084
|
+
var isUploading = uploadingFiles.length > 0 ||
|
|
23085
|
+
uploadMutation.isLoading ||
|
|
23086
|
+
isSubmitLoading ||
|
|
23087
|
+
isSubmittingEntry;
|
|
23088
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
23089
|
+
React__default.createElement(Dialog$1, { open: open, onClose: onClose, maxWidth: "md", fullWidth: true, "aria-labelledby": "attachment-dialog-title" },
|
|
23090
|
+
React__default.createElement(DialogTitle$1, { id: "attachment-dialog-title" },
|
|
23091
|
+
"Attachments (",
|
|
23092
|
+
attachments.length,
|
|
23093
|
+
")"),
|
|
23094
|
+
React__default.createElement(DialogContent$1, { dividers: true },
|
|
23095
|
+
isEditing ? (React__default.createElement(Box, { mb: 2 },
|
|
23096
|
+
React__default.createElement(Box, __assign({}, getRootProps(), { sx: {
|
|
23097
|
+
border: function (theme) { return "2px dashed ".concat(theme.palette.primary.main); },
|
|
23098
|
+
borderRadius: function (theme) { return theme.shape.borderRadius; },
|
|
23099
|
+
padding: function (theme) { return theme.spacing(3); },
|
|
23100
|
+
textAlign: "center",
|
|
23101
|
+
cursor: "pointer",
|
|
23102
|
+
marginBottom: function (theme) { return theme.spacing(2); },
|
|
23103
|
+
borderColor: function (theme) {
|
|
23104
|
+
return isDragActive
|
|
23105
|
+
? theme.palette.secondary.main
|
|
23106
|
+
: theme.palette.primary.main;
|
|
23107
|
+
},
|
|
23108
|
+
backgroundColor: function (theme) {
|
|
23109
|
+
return isDragActive
|
|
23110
|
+
? theme.palette.action.selected
|
|
23111
|
+
: theme.palette.background.default;
|
|
23112
|
+
},
|
|
23113
|
+
"&:hover": {
|
|
23114
|
+
backgroundColor: function (theme) { return theme.palette.action.hover; },
|
|
23115
|
+
},
|
|
23116
|
+
} }),
|
|
23117
|
+
React__default.createElement("input", __assign({}, getInputProps())),
|
|
23118
|
+
React__default.createElement(CloudUpload, { sx: {
|
|
23119
|
+
fontSize: 48,
|
|
23120
|
+
color: function (theme) { return theme.palette.primary.main; },
|
|
23121
|
+
marginBottom: function (theme) { return theme.spacing(1); },
|
|
23122
|
+
} }),
|
|
23123
|
+
React__default.createElement(Typography$1, { variant: "h6", gutterBottom: true }, isDragActive
|
|
23124
|
+
? "Drop files here..."
|
|
23125
|
+
: "Drag & drop files here, or click to select"),
|
|
23126
|
+
React__default.createElement(Typography$1, { variant: "body2", color: "textSecondary" }, "All file types are supported")))) : null,
|
|
23127
|
+
!currentEntryId || currentEntryId <= 0 ? (isEditing && entryData ? (React__default.createElement(Typography$1, { variant: "body1", color: "textSecondary", align: "center" }, isSubmitLoading || isSubmittingEntry
|
|
23128
|
+
? "Saving entry..."
|
|
23129
|
+
: "Upload files to automatically save and attach to this entry")) : (React__default.createElement(Typography$1, { variant: "body1", color: "textSecondary", align: "center" }, "Save the entry first to add attachments"))) : isLoading ? (React__default.createElement("div", { style: {
|
|
23130
|
+
display: "flex",
|
|
23131
|
+
justifyContent: "center",
|
|
23132
|
+
alignItems: "center",
|
|
23133
|
+
minHeight: 100,
|
|
23134
|
+
} },
|
|
23135
|
+
React__default.createElement(CircularProgress, null))) : attachments.length === 0 ? (React__default.createElement(Typography$1, { variant: "body1", color: "textSecondary", align: "center" }, "No attachments yet")) : (React__default.createElement(List, { sx: {
|
|
23136
|
+
maxHeight: 300,
|
|
23137
|
+
overflow: "auto",
|
|
23138
|
+
} }, attachments.map(function (attachment) { return (React__default.createElement(ListItem, { key: attachment.EntryAttachmentId, sx: {
|
|
23139
|
+
border: function (theme) { return "1px solid ".concat(theme.palette.divider); },
|
|
23140
|
+
borderRadius: function (theme) { return theme.shape.borderRadius; },
|
|
23141
|
+
marginBottom: function (theme) { return theme.spacing(1); },
|
|
23142
|
+
} },
|
|
23143
|
+
React__default.createElement(ListItemIcon, null,
|
|
23144
|
+
React__default.createElement(AttachFile, null)),
|
|
23145
|
+
React__default.createElement(ListItemText, { primary: attachment.AttachmentName, secondary: "Added by ".concat(attachment.CreatedBy, " on ").concat(attachment.CreationTime.toLocaleDateString()) }),
|
|
23146
|
+
React__default.createElement(ListItemSecondaryAction, null,
|
|
23147
|
+
React__default.createElement("a", { href: attachment.URL, target: "_blank", rel: "noopener noreferrer", title: "Download", style: {
|
|
23148
|
+
display: "inline-flex",
|
|
23149
|
+
padding: 8,
|
|
23150
|
+
borderRadius: "50%",
|
|
23151
|
+
color: "inherit",
|
|
23152
|
+
textDecoration: "none",
|
|
23153
|
+
}, className: "MuiButtonBase-root MuiIconButton-root" },
|
|
23154
|
+
React__default.createElement(GetApp, null)),
|
|
23155
|
+
isEditing && (React__default.createElement(IconButton$1, { edge: "end", onClick: function () {
|
|
23156
|
+
return handleDeleteAttachment(attachment.EntryAttachmentId, attachment.UploadFileId, attachment.AttachmentName);
|
|
23157
|
+
}, title: "Delete", disabled: deleteMutation.isLoading },
|
|
23158
|
+
React__default.createElement(Delete, null)))))); }))),
|
|
23159
|
+
isUploading && (React__default.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center", mt: 2 },
|
|
23160
|
+
React__default.createElement(CircularProgress, { size: 20 }),
|
|
23161
|
+
React__default.createElement(Typography$1, { variant: "body2", style: { marginLeft: 8 } },
|
|
23162
|
+
"Uploading ",
|
|
23163
|
+
uploadingFiles.length,
|
|
23164
|
+
" file(s)...")))),
|
|
23165
|
+
React__default.createElement(DialogActions$1, null,
|
|
23166
|
+
React__default.createElement(Button, { onClick: onClose, color: "primary" }, "Close"))),
|
|
23167
|
+
React__default.createElement(DeleteAttachmentConfirmationDialog, { open: showDeleteConfirmation, attachmentName: (attachmentToDelete === null || attachmentToDelete === void 0 ? void 0 : attachmentToDelete.name) || "", onClose: handleDeleteConfirmation, isDeleting: deleteMutation.isLoading }),
|
|
23168
|
+
React__default.createElement(ErrorModal, { error: error || (fetchError === null || fetchError === void 0 ? void 0 : fetchError.message), onHide: function () { return setError(null); } })));
|
|
23169
|
+
};
|
|
23170
|
+
|
|
23171
|
+
var AttachmentPlugin = /** @class */ (function (_super) {
|
|
23172
|
+
__extends(AttachmentPlugin, _super);
|
|
23173
|
+
function AttachmentPlugin() {
|
|
23174
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23175
|
+
}
|
|
23176
|
+
AttachmentPlugin.prototype.render = function () {
|
|
23177
|
+
var _a = this.props
|
|
23178
|
+
.config, attachmentCount = _a.attachmentCount, onAttachmentClick = _a.onAttachmentClick;
|
|
23179
|
+
return (React__default.createElement("span", { className: "button button-type-attachment", title: "Attachments (".concat(attachmentCount, ")"), onClick: onAttachmentClick, style: {
|
|
23180
|
+
display: "inline-flex",
|
|
23181
|
+
alignItems: "center",
|
|
23182
|
+
padding: "4px 8px",
|
|
23183
|
+
cursor: "pointer",
|
|
23184
|
+
borderRadius: "4px",
|
|
23185
|
+
backgroundColor: attachmentCount > 0 ? "#e3f2fd" : "transparent",
|
|
23186
|
+
border: attachmentCount > 0 ? "1px solid #2196f3" : "1px solid transparent",
|
|
23187
|
+
color: attachmentCount > 0 ? "#1976d2" : "#666",
|
|
23188
|
+
fontSize: "0.75rem",
|
|
23189
|
+
fontWeight: attachmentCount > 0 ? 600 : 400,
|
|
23190
|
+
transition: "all 0.2s ease-in-out",
|
|
23191
|
+
}, onMouseEnter: function (e) {
|
|
23192
|
+
e.currentTarget.style.backgroundColor = "#e3f2fd";
|
|
23193
|
+
e.currentTarget.style.borderColor = "#2196f3";
|
|
23194
|
+
}, onMouseLeave: function (e) {
|
|
23195
|
+
if (attachmentCount === 0) {
|
|
23196
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
23197
|
+
e.currentTarget.style.borderColor = "transparent";
|
|
23198
|
+
}
|
|
23199
|
+
} },
|
|
23200
|
+
React__default.createElement(AttachFile, { style: {
|
|
23201
|
+
fontSize: 16,
|
|
23202
|
+
marginRight: 4,
|
|
23203
|
+
color: attachmentCount > 0 ? "#1976d2" : "#666",
|
|
23204
|
+
} }),
|
|
23205
|
+
"Attachments (",
|
|
23206
|
+
attachmentCount,
|
|
23207
|
+
")"));
|
|
23208
|
+
};
|
|
23209
|
+
AttachmentPlugin.pluginName = "attachment";
|
|
23210
|
+
AttachmentPlugin.align = "left";
|
|
23211
|
+
AttachmentPlugin.defaultConfig = {
|
|
23212
|
+
start: 0,
|
|
23213
|
+
end: 0,
|
|
23214
|
+
};
|
|
23215
|
+
return AttachmentPlugin;
|
|
23216
|
+
}(PluginComponent));
|
|
23217
|
+
|
|
23218
|
+
var ContentInput = function (_a) {
|
|
23219
|
+
var value = _a.value, onChange = _a.onChange, isEditing = _a.isEditing, UpdateTimestamp = _a.UpdateTimestamp, UpdatedBy = _a.UpdatedBy, isNewEntry = _a.isNewEntry, entryId = _a.entryId, entryData = _a.entryData, onEntrySubmitted = _a.onEntrySubmitted, _b = _a.allowAttachments, allowAttachments = _b === void 0 ? false : _b;
|
|
23220
|
+
var mdParser = new MarkdownIt();
|
|
23221
|
+
var api = new MESApiService();
|
|
23222
|
+
var urlEntryId = useParams().entryId;
|
|
23223
|
+
var _c = useState(0), key = _c[0], setKey = _c[1];
|
|
23224
|
+
var _d = useState(null), error = _d[0], setError = _d[1];
|
|
23225
|
+
var _e = useState(false), attachmentModalOpen = _e[0], setAttachmentModalOpen = _e[1];
|
|
23226
|
+
// Use URL entryId as fallback when form entryId is not available yet
|
|
23227
|
+
var effectiveEntryId = entryId ||
|
|
23228
|
+
(urlEntryId && urlEntryId !== "new" ? parseInt(urlEntryId) : null);
|
|
23229
|
+
// Query for fetching attachment count
|
|
23230
|
+
var _f = useQuery({
|
|
23231
|
+
queryKey: ["entryAttachments", effectiveEntryId],
|
|
23232
|
+
queryFn: function () { return getEntryAttachments(effectiveEntryId); },
|
|
23233
|
+
enabled: !!effectiveEntryId && effectiveEntryId > 0,
|
|
23234
|
+
retry: 1,
|
|
23235
|
+
onError: function (err) {
|
|
23236
|
+
console.error("Failed to fetch attachments:", err);
|
|
23237
|
+
},
|
|
23238
|
+
}), _g = _f.data, attachments = _g === void 0 ? [] : _g, attachmentError = _f.error;
|
|
23239
|
+
var attachmentCount = attachments.length;
|
|
23240
|
+
var handleChange = function (_a) {
|
|
23241
|
+
var text = _a.text;
|
|
23242
|
+
onChange(text);
|
|
23243
|
+
};
|
|
23244
|
+
var onImageUpload = function (files) { return __awaiter(void 0, void 0, void 0, function () {
|
|
23245
|
+
var res;
|
|
23246
|
+
var _a;
|
|
23247
|
+
return __generator(this, function (_b) {
|
|
23248
|
+
switch (_b.label) {
|
|
23249
|
+
case 0:
|
|
23250
|
+
_b.trys.push([0, 2, , 3]);
|
|
23251
|
+
setError(null);
|
|
23252
|
+
return [4 /*yield*/, api.uploadFiles(files, "logbook")];
|
|
23253
|
+
case 1:
|
|
23254
|
+
res = _b.sent();
|
|
23255
|
+
if (res) {
|
|
23256
|
+
return [2 /*return*/, (_a = res.result[0]) === null || _a === void 0 ? void 0 : _a.URL];
|
|
23257
|
+
}
|
|
23258
|
+
return [3 /*break*/, 3];
|
|
23259
|
+
case 2:
|
|
23260
|
+
_b.sent();
|
|
23261
|
+
setError("Failed to upload files");
|
|
23262
|
+
return [2 /*return*/, ""];
|
|
23263
|
+
case 3: return [2 /*return*/];
|
|
23264
|
+
}
|
|
23265
|
+
});
|
|
23266
|
+
}); };
|
|
23267
|
+
useEffect(function () {
|
|
23268
|
+
setKey(function (prevKey) { return prevKey + 1; });
|
|
23269
|
+
}, [isEditing, attachmentCount]);
|
|
23270
|
+
// Register the attachment plugin
|
|
23271
|
+
useEffect(function () {
|
|
23272
|
+
MdEditor.use(AttachmentPlugin, {
|
|
23273
|
+
attachmentCount: attachmentCount,
|
|
23274
|
+
onAttachmentClick: function () {
|
|
23275
|
+
if (entryData.title && entryData.author) {
|
|
23276
|
+
setAttachmentModalOpen(true);
|
|
23277
|
+
}
|
|
23278
|
+
else {
|
|
23279
|
+
setError("Title and Author are required");
|
|
23280
|
+
}
|
|
23281
|
+
},
|
|
23282
|
+
});
|
|
23283
|
+
}, [attachmentCount, entryData.title, entryData.author]);
|
|
23284
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
23285
|
+
React__default.createElement(Box, { sx: {
|
|
23286
|
+
height: "100%",
|
|
23287
|
+
width: "100%",
|
|
23288
|
+
overflow: "hidden",
|
|
23289
|
+
display: "flex",
|
|
23290
|
+
flexDirection: "column",
|
|
23291
|
+
"& .MuiInput-underline:before": {
|
|
23292
|
+
borderBottom: "none",
|
|
23293
|
+
},
|
|
23294
|
+
"& .MuiInput-underline:after": {
|
|
23295
|
+
borderBottom: "none",
|
|
23296
|
+
},
|
|
23297
|
+
"& .MuiInput-underline:hover:not(.Mui-disabled):before": {
|
|
23298
|
+
borderBottom: "none",
|
|
23299
|
+
},
|
|
23300
|
+
} },
|
|
23301
|
+
React__default.createElement(Grid2, { sx: {
|
|
23302
|
+
flexGrow: 1,
|
|
23303
|
+
display: "flex",
|
|
23304
|
+
flexDirection: "column",
|
|
23305
|
+
overflow: "hidden",
|
|
23306
|
+
} },
|
|
23307
|
+
React__default.createElement(Box, { sx: {
|
|
23308
|
+
height: "100%",
|
|
23309
|
+
"& .rc-md-editor": {
|
|
23310
|
+
height: "100%",
|
|
23311
|
+
},
|
|
23312
|
+
"& .rc-md-navigation": {
|
|
23313
|
+
backgroundColor: function (theme) { return theme.palette.background.paper; },
|
|
23314
|
+
},
|
|
23315
|
+
"& .rc-md-editor, & .section-container": {
|
|
23316
|
+
height: "100%",
|
|
23317
|
+
},
|
|
23318
|
+
} },
|
|
23319
|
+
React__default.createElement(MdEditor, { key: key, style: { height: "100%", width: "100%" }, value: value || "", renderHTML: function (text) { return mdParser.render(text || ""); }, onChange: handleChange, view: {
|
|
23320
|
+
menu: allowAttachments ? true : isEditing, // Always show menu to display attachment button (if allowed)
|
|
23321
|
+
md: isEditing ? true : false,
|
|
23322
|
+
html: !isEditing,
|
|
23323
|
+
}, plugins: isEditing
|
|
23324
|
+
? [
|
|
23325
|
+
"header",
|
|
23326
|
+
"font-bold",
|
|
23327
|
+
"font-italic",
|
|
23328
|
+
"font-underline",
|
|
23329
|
+
"font-strikethrough",
|
|
23330
|
+
"list-unordered",
|
|
23331
|
+
"list-ordered",
|
|
23332
|
+
"block-quote",
|
|
23333
|
+
"block-wrap",
|
|
23334
|
+
"block-code-inline",
|
|
23335
|
+
"block-code-block",
|
|
23336
|
+
"table",
|
|
23337
|
+
"image",
|
|
23338
|
+
"link",
|
|
23339
|
+
"clear",
|
|
23340
|
+
"logger",
|
|
23341
|
+
"mode-toggle",
|
|
23342
|
+
"full-screen",
|
|
23343
|
+
"tab-insert",
|
|
23344
|
+
allowAttachments ? "attachment" : "",
|
|
23345
|
+
]
|
|
23346
|
+
: allowAttachments
|
|
23347
|
+
? [
|
|
23348
|
+
"attachment", // Only show attachment button in preview mode and with attachments allowed
|
|
23349
|
+
]
|
|
23350
|
+
: [], config: {
|
|
23351
|
+
attachment: allowAttachments
|
|
23352
|
+
? {
|
|
23353
|
+
attachmentCount: attachmentCount,
|
|
23354
|
+
onAttachmentClick: function () {
|
|
23355
|
+
if (entryData.title && entryData.author) {
|
|
23356
|
+
setAttachmentModalOpen(true);
|
|
23357
|
+
}
|
|
23358
|
+
else {
|
|
23359
|
+
setError("Title and Author are required");
|
|
23360
|
+
}
|
|
23361
|
+
},
|
|
23362
|
+
}
|
|
23363
|
+
: null,
|
|
23364
|
+
}, autoFocus: !isNewEntry, onImageUpload: function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
23365
|
+
var markdownImage;
|
|
23366
|
+
return __generator(this, function (_a) {
|
|
23367
|
+
switch (_a.label) {
|
|
23368
|
+
case 0: return [4 /*yield*/, onImageUpload([file])];
|
|
23369
|
+
case 1:
|
|
23370
|
+
markdownImage = _a.sent();
|
|
23371
|
+
return [2 /*return*/, markdownImage];
|
|
23372
|
+
}
|
|
23373
|
+
});
|
|
23374
|
+
}); } }))),
|
|
23375
|
+
(UpdatedBy === null || UpdatedBy === void 0 ? void 0 : UpdatedBy.length) > 0 && (React__default.createElement(Box, { sx: {
|
|
23376
|
+
backgroundColor: function (theme) { return theme.palette.background.paper; },
|
|
23377
|
+
borderTop: function (theme) { return "0px solid ".concat(theme.palette.divider); },
|
|
23378
|
+
paddingLeft: 10,
|
|
23379
|
+
} },
|
|
23380
|
+
React__default.createElement(TextField, { variant: "standard", disabled: true, value: "This entry was updated on ".concat(dxtToLocalServerTime(UpdateTimestamp, "MM/dd/yy hh:mm a"), " by ").concat(UpdatedBy), fullWidth: true, margin: "none", autoComplete: "off", InputProps: {
|
|
23381
|
+
style: {
|
|
23382
|
+
fontSize: "0.7rem",
|
|
23383
|
+
},
|
|
23384
|
+
disableUnderline: true,
|
|
23385
|
+
}, InputLabelProps: {
|
|
23386
|
+
style: {
|
|
23387
|
+
fontSize: "0.7rem",
|
|
23388
|
+
},
|
|
23389
|
+
} })))),
|
|
23390
|
+
React__default.createElement(AttachmentModal, { open: attachmentModalOpen, onClose: function () { return setAttachmentModalOpen(false); }, entryId: effectiveEntryId, isEditing: isEditing, entryData: entryData, onEntrySubmitted: onEntrySubmitted }),
|
|
23391
|
+
React__default.createElement(ErrorModal, { error: error || (attachmentError === null || attachmentError === void 0 ? void 0 : attachmentError.message), onHide: function () { return setError(""); } })));
|
|
23392
|
+
};
|
|
23393
|
+
|
|
23394
|
+
var moment$4 = getMomentTz();
|
|
23395
|
+
var EntryViewer$1 = function (_a) {
|
|
23396
|
+
var entry = _a.entry, show = _a.show, onChangeShow = _a.onChangeShow, onHide = _a.onHide, preselectedAssetId = _a.preselectedAssetId, withAssetFilter = _a.withAssetFilter, canEditAsset = _a.canEditAsset, canEditShift = _a.canEditShift, filterAssets = _a.filterAssets, allowAttachments = _a.allowAttachments, shiftsRange = _a.shiftsRange;
|
|
23397
|
+
var settings = useUTLSettingsContext().state.settings;
|
|
23398
|
+
var defaultAssetId = Number(get(settings, "DefaultAssetId", 15));
|
|
23399
|
+
var shiftIdParam = useParams().shiftId;
|
|
23400
|
+
var searchParams = useSearchParams()[0];
|
|
23401
|
+
var entryId = searchParams.get("entryId");
|
|
23402
|
+
var action = searchParams.get("action");
|
|
23403
|
+
var shiftInfo = useShiftNavigator().shiftInfo;
|
|
23404
|
+
var isNewEntry = action === "new";
|
|
23405
|
+
var _b = useState(""), notificationMessage = _b[0], setNotificationMessage = _b[1];
|
|
23406
|
+
var _c = useState(null), shiftTimestamp = _c[0], setShiftTimestamp = _c[1];
|
|
23407
|
+
var _d = useState(""), error = _d[0], setError = _d[1];
|
|
23408
|
+
// Section state
|
|
23409
|
+
var _e = useState(null), selectedSection = _e[0], setSelectedSection = _e[1];
|
|
23410
|
+
var _f = useForm(), control = _f.control, handleSubmit = _f.handleSubmit, reset = _f.reset, _g = _f.formState; _g.isValid; var dirtyFields = _g.dirtyFields, watch = _f.watch, setValue = _f.setValue;
|
|
23411
|
+
var isFormDirty = !(Object.keys(dirtyFields).length === 0);
|
|
23412
|
+
var updatedBy = watch("UpdatedBy");
|
|
23413
|
+
var updateTimestamp = watch("UpdateTimestamp");
|
|
23414
|
+
var createTimestamp = watch("CreateTimestamp");
|
|
23415
|
+
watch("Content");
|
|
23416
|
+
var entryIdValue = watch("EntryId");
|
|
23417
|
+
var title = watch("Title");
|
|
23418
|
+
var author = watch("Author");
|
|
23419
|
+
var shiftId = watch("ShiftId");
|
|
23420
|
+
var assetId = watch("AssetId");
|
|
23421
|
+
var shift = watch("Shift");
|
|
23422
|
+
var crew = watch("Crew");
|
|
23423
|
+
// Handler for when entry is submitted via attachment modal
|
|
23424
|
+
var handleEntrySubmitted = function (newEntryId, newEntryData) {
|
|
23425
|
+
setNotificationMessage("Entry created successfully");
|
|
23426
|
+
// If we have the new entry data, update the form immediately
|
|
23427
|
+
if (newEntryData) {
|
|
23428
|
+
reset(newEntryData);
|
|
23429
|
+
}
|
|
23430
|
+
// Add a setTimeout to delay navigation, giving the system time to process everything
|
|
23431
|
+
setTimeout(function () {
|
|
23432
|
+
onHide(newEntryId, true); // true = shouldStayInEditMode
|
|
23433
|
+
}, 1000); // 1000ms delay to ensure all processing is complete
|
|
23434
|
+
};
|
|
23435
|
+
// Use the shared entry submission hook
|
|
23436
|
+
var _h = useEntrySubmission({
|
|
23437
|
+
onSuccess: function (entry) { return __awaiter(void 0, void 0, void 0, function () {
|
|
23438
|
+
var err_1;
|
|
23439
|
+
return __generator(this, function (_a) {
|
|
23440
|
+
switch (_a.label) {
|
|
23441
|
+
case 0:
|
|
23442
|
+
if (!(entry && entry.EntryId)) return [3 /*break*/, 5];
|
|
23443
|
+
if (!selectedSection) return [3 /*break*/, 4];
|
|
23444
|
+
_a.label = 1;
|
|
23445
|
+
case 1:
|
|
23446
|
+
_a.trys.push([1, 3, , 4]);
|
|
23447
|
+
return [4 /*yield*/, upsertSectionEntry({
|
|
23448
|
+
entryId: entry.EntryId,
|
|
23449
|
+
sectionId: selectedSection.SectionId,
|
|
23450
|
+
})];
|
|
23451
|
+
case 2:
|
|
23452
|
+
_a.sent();
|
|
23453
|
+
return [3 /*break*/, 4];
|
|
23454
|
+
case 3:
|
|
23455
|
+
err_1 = _a.sent();
|
|
23456
|
+
console.error("Error saving section entry:", err_1);
|
|
23457
|
+
setError(err_1.message || "Error saving section data");
|
|
23458
|
+
return [2 /*return*/];
|
|
23459
|
+
case 4:
|
|
23460
|
+
setNotificationMessage(entryId === "new"
|
|
23461
|
+
? "Entry created successfully"
|
|
23462
|
+
: "Entry updated successfully");
|
|
23463
|
+
// Add a setTimeout to delay navigation
|
|
23464
|
+
setTimeout(function () {
|
|
23465
|
+
onHide(entry.EntryId);
|
|
23466
|
+
}, 1000);
|
|
23467
|
+
return [3 /*break*/, 6];
|
|
23468
|
+
case 5:
|
|
23469
|
+
console.error("No EntryId received from API response", entry);
|
|
23470
|
+
setError("Failed to get entry ID from server response");
|
|
23471
|
+
_a.label = 6;
|
|
23472
|
+
case 6: return [2 /*return*/];
|
|
23473
|
+
}
|
|
23474
|
+
});
|
|
23475
|
+
}); },
|
|
23476
|
+
onError: function (error) {
|
|
23477
|
+
setError(error.message);
|
|
23478
|
+
},
|
|
23479
|
+
isNewEntry: isNewEntry,
|
|
23480
|
+
onHide: function () { return onHide(); },
|
|
23481
|
+
}), submitEntry = _h.submitEntry, isSubmitLoading = _h.isSubmitLoading, showConfirmationDialog = _h.showConfirmationDialog, handleConfirmationClose = _h.handleConfirmationClose;
|
|
23482
|
+
var onSubmit = function (formData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
23483
|
+
var submissionData;
|
|
23484
|
+
var _a;
|
|
23485
|
+
return __generator(this, function (_b) {
|
|
23486
|
+
switch (_b.label) {
|
|
23487
|
+
case 0:
|
|
23488
|
+
setError("");
|
|
23489
|
+
submissionData = {
|
|
23490
|
+
assetId: formData.AssetId,
|
|
23491
|
+
entryId: formData.EntryId,
|
|
23492
|
+
shiftId: formData.ShiftId,
|
|
23493
|
+
isForOtherShift: (entry === null || entry === void 0 ? void 0 : entry.ShiftId)
|
|
23494
|
+
? entry.ShiftId !== formData.ShiftId
|
|
23495
|
+
: (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId) !== formData.ShiftId,
|
|
23496
|
+
title: formData.Title,
|
|
23497
|
+
content: formData.Content,
|
|
23498
|
+
author: (_a = formData.Author) !== null && _a !== void 0 ? _a : "",
|
|
23499
|
+
createTimestamp: isNewEntry ? new Date() : formData.CreateTimestamp,
|
|
23500
|
+
};
|
|
23501
|
+
return [4 /*yield*/, submitEntry(submissionData)];
|
|
23502
|
+
case 1:
|
|
23503
|
+
_b.sent();
|
|
23504
|
+
return [2 /*return*/];
|
|
23505
|
+
}
|
|
23506
|
+
});
|
|
23507
|
+
}); };
|
|
23508
|
+
useEffect(function () {
|
|
23509
|
+
var _a, _b, _c;
|
|
23510
|
+
if (shiftInfo || !isNewEntry) {
|
|
23511
|
+
var newEntry = __assign(__assign({}, ENTRY_INITIAL_VALUES), { ShiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId, Shift: (_a = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShift) !== null && _a !== void 0 ? _a : "", Crew: (_b = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentCrew) !== null && _b !== void 0 ? _b : "", CreateTimestamp: new Date(), AssetId: (_c = preselectedAssetId !== null && preselectedAssetId !== void 0 ? preselectedAssetId : defaultAssetId) !== null && _c !== void 0 ? _c : null });
|
|
23512
|
+
reset((isNewEntry ? newEntry : entry) || ENTRY_INITIAL_VALUES);
|
|
23513
|
+
}
|
|
23514
|
+
}, [entry, shiftInfo, entryId, reset, defaultAssetId]);
|
|
23515
|
+
useEffect(function () {
|
|
23516
|
+
var _a;
|
|
23517
|
+
if (isNewEntry) {
|
|
23518
|
+
setValue("AssetId", (_a = preselectedAssetId !== null && preselectedAssetId !== void 0 ? preselectedAssetId : defaultAssetId) !== null && _a !== void 0 ? _a : null);
|
|
23519
|
+
}
|
|
23520
|
+
}, [preselectedAssetId, defaultAssetId]);
|
|
23521
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
23522
|
+
isNewEntry || (entry === null || entry === void 0 ? void 0 : entry.EntryId) ? (React__default.createElement(HelmetDexteel, { title: "".concat(isNewEntry ? "New Entry" : "'".concat(entry === null || entry === void 0 ? void 0 : entry.Title, "' by ").concat(entry === null || entry === void 0 ? void 0 : entry.Author), " - Logbook Entry") })) : null,
|
|
23523
|
+
isNewEntry || (entry === null || entry === void 0 ? void 0 : entry.EntryId) ? (React__default.createElement(Paper, { elevation: 1, sx: {
|
|
23524
|
+
width: "100%",
|
|
23525
|
+
height: "100%",
|
|
23526
|
+
display: "flex",
|
|
23527
|
+
flexDirection: "column",
|
|
23528
|
+
} },
|
|
23529
|
+
React__default.createElement(Grid2, { container: true, spacing: 1, component: "form", onSubmit: handleSubmit(onSubmit), height: "100%", flexDirection: "column", flexWrap: "nowrap", p: 1 },
|
|
23530
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
23531
|
+
React__default.createElement(Controller, { name: "Title", control: control, rules: {
|
|
23532
|
+
required: "Title is required",
|
|
23533
|
+
validate: function (value) {
|
|
23534
|
+
return !!(value === null || value === void 0 ? void 0 : value.trim()) || "Title cannot be empty";
|
|
23535
|
+
},
|
|
23536
|
+
}, render: function (_a) {
|
|
23537
|
+
var _b = _a.field, value = _b.value, onChange = _b.onChange, error = _a.fieldState.error;
|
|
23538
|
+
return (React__default.createElement(TextField, { label: "Title", value: value !== null && value !== void 0 ? value : "", onChange: onChange, error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, autoFocus: isNewEntry, size: "medium" }));
|
|
23539
|
+
} })),
|
|
23540
|
+
React__default.createElement(Grid2, { container: true, size: { xs: 12 }, spacing: 2 },
|
|
23541
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
|
|
23542
|
+
React__default.createElement(Controller, { name: "CreateTimestamp", control: control, render: function (_a) {
|
|
23543
|
+
var value = _a.field.value;
|
|
23544
|
+
return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$4(value) : null, disabled: true, slotProps: {
|
|
23545
|
+
textField: {
|
|
23546
|
+
variant: "outlined",
|
|
23547
|
+
size: "small",
|
|
23548
|
+
fullWidth: true,
|
|
23549
|
+
InputLabelProps: {
|
|
23550
|
+
shrink: true,
|
|
23551
|
+
style: {
|
|
23552
|
+
fontSize: ".875rem",
|
|
23553
|
+
marginTop: -2,
|
|
23554
|
+
},
|
|
23555
|
+
},
|
|
23556
|
+
},
|
|
23557
|
+
} }));
|
|
23558
|
+
} })),
|
|
23559
|
+
canEditShift ? (React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
|
|
23560
|
+
React__default.createElement(Controller, { name: "ShiftId", control: control, render: function (_a) {
|
|
23561
|
+
var _b;
|
|
23562
|
+
var field = _a.field;
|
|
23563
|
+
return (React__default.createElement(ShiftAutocomplete, { currentShiftId: (_b = Number(shiftIdParam)) !== null && _b !== void 0 ? _b : shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId, onShiftSelected: function (selectedShift) {
|
|
23564
|
+
if (selectedShift) {
|
|
23565
|
+
setValue("Shift", selectedShift.Shift, {
|
|
23566
|
+
shouldDirty: true,
|
|
23567
|
+
});
|
|
23568
|
+
setValue("Crew", selectedShift.Crew, {
|
|
23569
|
+
shouldDirty: true,
|
|
23570
|
+
});
|
|
23571
|
+
setShiftTimestamp(new Date(selectedShift.Start));
|
|
23572
|
+
field.onChange(selectedShift.ShiftId);
|
|
23573
|
+
}
|
|
23574
|
+
else {
|
|
23575
|
+
setValue("Shift", null, { shouldDirty: true });
|
|
23576
|
+
setValue("Crew", null, { shouldDirty: true });
|
|
23577
|
+
setShiftTimestamp(null);
|
|
23578
|
+
field.onChange(null);
|
|
23579
|
+
}
|
|
23580
|
+
}, value: field.value, disabled: !isNewEntry && show !== "edit", shiftsRange: shiftsRange }));
|
|
23581
|
+
} }))) : (React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
|
|
23582
|
+
React__default.createElement(Controller, { name: "ShiftId", control: control, render: function (_a) {
|
|
23583
|
+
var field = _a.field;
|
|
23584
|
+
return (React__default.createElement(ShiftSelector, { onChange: field.onChange, value: field.value, disabled: true }));
|
|
23585
|
+
} }))),
|
|
23586
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: canEditAsset ? 2 : 6 } },
|
|
23587
|
+
React__default.createElement(Controller, { name: "Author", control: control, rules: {
|
|
23588
|
+
required: "Author is required",
|
|
23589
|
+
}, render: function (_a) {
|
|
23590
|
+
var _b = _a.field, value = _b.value, onChange = _b.onChange, error = _a.fieldState.error;
|
|
23591
|
+
return (React__default.createElement(TextField, { label: "Author", variant: "outlined", value: value !== null && value !== void 0 ? value : "", onChange: onChange, fullWidth: true, error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, disabled: !isNewEntry, size: "small" }));
|
|
23592
|
+
} })),
|
|
23593
|
+
canEditAsset ? (withAssetFilter === "tree" ? (React__default.createElement(Grid2, { size: { md: 4, xs: 12 } },
|
|
23594
|
+
React__default.createElement(Controller, { name: "AssetId", control: control, render: function (_a) {
|
|
23595
|
+
var field = _a.field;
|
|
23596
|
+
return (React__default.createElement(AssetTreePicker, { label: "Asset", value: field.value || 0, onChange: field.onChange }));
|
|
23597
|
+
} }))) : withAssetFilter === "selector" ? (React__default.createElement(Grid2, { size: { md: 4, xs: 12 } },
|
|
23598
|
+
React__default.createElement(Controller, { name: "AssetId", control: control, render: function (_a) {
|
|
23599
|
+
var field = _a.field;
|
|
23600
|
+
return (React__default.createElement(AssetsFilter, { value: field.value, onChange: field.onChange, filterAreaAssets: filterAssets === "area" }));
|
|
23601
|
+
} }))) : null) : null),
|
|
23602
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
23603
|
+
React__default.createElement(SectionSelector, { value: selectedSection, onChange: function (section) {
|
|
23604
|
+
setSelectedSection(section);
|
|
23605
|
+
if (section) {
|
|
23606
|
+
setValue("SectionId", section.SectionId, {
|
|
23607
|
+
shouldDirty: true,
|
|
23608
|
+
});
|
|
23609
|
+
setValue("SectionName", section.SectionName, {
|
|
23610
|
+
shouldDirty: true,
|
|
23611
|
+
});
|
|
23612
|
+
}
|
|
23613
|
+
else {
|
|
23614
|
+
setValue("SectionId", null, { shouldDirty: true });
|
|
23615
|
+
setValue("SectionName", undefined, {
|
|
23616
|
+
shouldDirty: true,
|
|
23617
|
+
});
|
|
23618
|
+
}
|
|
23619
|
+
}, disabled: !isNewEntry && show !== "edit" })),
|
|
23620
|
+
React__default.createElement(Grid2, { size: { md: 12 }, height: "100%", flexGrow: 1, overflow: "auto" },
|
|
23621
|
+
React__default.createElement(Controller, { name: "Content", control: control, render: function (_a) {
|
|
23622
|
+
var _b = _a.field, value = _b.value, onChange = _b.onChange;
|
|
23623
|
+
return (React__default.createElement(ContentInput, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return onChange(val); }, value: value, isEditing: show === "edit", isNewEntry: isNewEntry, entryId: entryIdValue, entryData: {
|
|
23624
|
+
assetId: assetId,
|
|
23625
|
+
entryId: entryIdValue,
|
|
23626
|
+
shiftId: shiftId,
|
|
23627
|
+
title: title,
|
|
23628
|
+
content: value,
|
|
23629
|
+
author: author,
|
|
23630
|
+
createTimestamp: isNewEntry
|
|
23631
|
+
? new Date()
|
|
23632
|
+
: createTimestamp,
|
|
23633
|
+
}, onEntrySubmitted: handleEntrySubmitted, allowAttachments: allowAttachments }));
|
|
23634
|
+
} })),
|
|
23635
|
+
React__default.createElement(Grid2, { container: true, size: { xs: 12 } },
|
|
23636
|
+
React__default.createElement(Grid2, { container: true, size: { md: 6, xs: 12 }, spacing: 1 },
|
|
23637
|
+
React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
23638
|
+
React__default.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: function () { return onHide(); } }, "Close")),
|
|
23639
|
+
React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
23640
|
+
React__default.createElement(Button, { fullWidth: true, variant: "contained", color: "primary", onClick: function () { return onChangeShow(); } }, show === "edit" ? "Preview" : "Edit"))),
|
|
23641
|
+
React__default.createElement(Grid2, { container: true, size: { md: 6, xs: 12 }, style: { display: "flex", justifyContent: "flex-end" } },
|
|
23642
|
+
React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
23643
|
+
React__default.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React__default.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading || !isFormDirty, variant: "contained", color: "primary", type: "submit" }, isNewEntry ? "Create" : "Save"))))))) : null,
|
|
23644
|
+
React__default.createElement(NotificationSnackBar, { message: notificationMessage, onHide: function () { return setNotificationMessage(""); } }),
|
|
23645
|
+
React__default.createElement(ConfirmationDialogRaw, { open: showConfirmationDialog, onClose: handleConfirmationClose, title: "Shift Submission Confirmation", message: "You are about to ".concat(isNewEntry ? "create" : "save", " an entry for ").concat(moment$4(shiftTimestamp).format("MM/DD/YYYY"), " ").concat(shift, " - ").concat(crew, ". Are you sure you want to proceed?"), suffixTitle: "Logbook Entry" }),
|
|
23646
|
+
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
23647
|
+
};
|
|
23648
|
+
|
|
23649
|
+
var Filters$1 = function (_a) {
|
|
23650
|
+
var quickFilter = _a.quickFilter, onQuickFilterChange = _a.onQuickFilterChange, selectedSections = _a.selectedSections, onSectionsChange = _a.onSectionsChange;
|
|
23651
|
+
useMesfRealtime({
|
|
23652
|
+
onReceiveMessage: function (author, message) {
|
|
23653
|
+
if (message.replaceAll("[", "").replaceAll("]", "") == "LB.GetEntries") ;
|
|
23654
|
+
},
|
|
23655
|
+
});
|
|
23656
|
+
return (React__default.createElement(Grid2, { container: true, justifyContent: "center", alignItems: "center", component: Paper, size: { md: 12 }, spacing: 1, p: 1 },
|
|
23657
|
+
React__default.createElement(Grid2, { maxWidth: "fit-content", justifyContent: "center" },
|
|
23658
|
+
React__default.createElement(ShiftDayNavigatorControl, { preventInit: true, withPaper: false })),
|
|
23659
|
+
React__default.createElement(Grid2, { size: { md: 4.5, xs: 12 } },
|
|
23660
|
+
React__default.createElement(TextField, { label: "Search", value: quickFilter, onChange: function (event) {
|
|
23661
|
+
onQuickFilterChange(event === null || event === void 0 ? void 0 : event.target.value);
|
|
23662
|
+
}, size: "small", fullWidth: true, slotProps: {
|
|
23663
|
+
input: {
|
|
23664
|
+
startAdornment: (React__default.createElement(InputAdornment, { position: "start" },
|
|
23665
|
+
React__default.createElement(SearchIcon, { fontSize: "small", sx: { color: "action.active" } }))),
|
|
23666
|
+
},
|
|
23667
|
+
} })),
|
|
23668
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
23669
|
+
React__default.createElement(SectionMultiSelect, { value: selectedSections, onChange: onSectionsChange, label: "Sections" }))));
|
|
23670
|
+
};
|
|
23671
|
+
|
|
23672
|
+
var moment$3 = getMomentTz();
|
|
23673
|
+
var Logbook$1 = function () {
|
|
23674
|
+
var entry = useLogbookSettings().entry;
|
|
23675
|
+
var allowAttachments = entry.allowAttachments;
|
|
23676
|
+
var canEditShift = entry.canEditShift;
|
|
23677
|
+
var showShiftCrew = entry.showShiftCrew;
|
|
23678
|
+
var exportToExcel = entry.exportToExcel;
|
|
23679
|
+
var shiftsRange = entry.shiftsRange;
|
|
23680
|
+
// Asset settings
|
|
23681
|
+
var withAssetFilter = entry.withAssetFilter;
|
|
23682
|
+
var canEditAsset = entry.canEditAsset;
|
|
23683
|
+
var filterAssets = entry.filterAssets;
|
|
23684
|
+
var navigate = useNavigate();
|
|
23685
|
+
var searchParams = useSearchParams()[0];
|
|
23686
|
+
var entryId = searchParams.get("entryId");
|
|
23687
|
+
var action = searchParams.get("action");
|
|
23688
|
+
var shiftId = useParams().shiftId;
|
|
23689
|
+
var _a = useShiftNavigator(), shiftInfo = _a.shiftInfo, getShiftDataFromAPI = _a.getShiftDataFromAPI;
|
|
23690
|
+
var isEditMode = action === "edit";
|
|
23691
|
+
var shiftIdRef = useRef(null);
|
|
23692
|
+
var gridApiRef = useRef(null);
|
|
23693
|
+
var _b = useState(""), error = _b[0], setError = _b[1];
|
|
23694
|
+
var _c = useState(""), show = _c[0], setShow = _c[1];
|
|
23695
|
+
var _d = useState(""), quickFilter = _d[0], setQuickFilter = _d[1];
|
|
23696
|
+
// Section filter state - multi-select
|
|
23697
|
+
var _e = useState([]), filterSections = _e[0], setFilterSections = _e[1];
|
|
23698
|
+
var _f = useState(null), selectedRowData = _f[0], setSelectedRowData = _f[1];
|
|
23699
|
+
var _g = useState(false), showRemoveDialog = _g[0], setShowRemoveDialog = _g[1];
|
|
23700
|
+
var _h = useContextMenuMESF(), registerConfig = _h.registerConfig, showContextMenu = _h.showContextMenu;
|
|
23701
|
+
var _j = useEntries({
|
|
23702
|
+
shiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId,
|
|
23703
|
+
sectionIds: filterSections.map(function (s) { return s.SectionId; }),
|
|
23704
|
+
}), rows = _j.data, isLoading = _j.isLoading, e = _j.error, isError = _j.isError, refetch = _j.refetch;
|
|
23705
|
+
var columnDefs = useTableData$1({
|
|
23706
|
+
showContextMenu: showContextMenu,
|
|
23707
|
+
allowAttachments: allowAttachments,
|
|
23708
|
+
showShiftCrew: showShiftCrew,
|
|
23709
|
+
}).columnDefs;
|
|
23710
|
+
var defaultColDef = useGridDefinitions({}).defaultColDef;
|
|
23711
|
+
var onQuickFilterChange = function (text) {
|
|
23712
|
+
var _a;
|
|
23713
|
+
setQuickFilter(text);
|
|
23714
|
+
(_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.setGridOption("quickFilterText", text);
|
|
23715
|
+
};
|
|
23716
|
+
var handleNewEntry = function () {
|
|
23717
|
+
var _a;
|
|
23718
|
+
(_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
|
|
23719
|
+
setSelectedRowData(__assign({}, ENTRY_INITIAL_VALUES));
|
|
23720
|
+
navigate("".concat(routeLogbookEntry, "/").concat(shiftIdRef.current, "?action=new"), {
|
|
23721
|
+
replace: true,
|
|
23722
|
+
});
|
|
23723
|
+
setShow("edit");
|
|
23724
|
+
};
|
|
23725
|
+
var rowClicked = function (event) {
|
|
23726
|
+
var _a;
|
|
23727
|
+
var currentShiftId = shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId);
|
|
23728
|
+
setSelectedRowData(event === null || event === void 0 ? void 0 : event.data);
|
|
23729
|
+
navigate("".concat(routeLogbookEntry, "/").concat(currentShiftId, "?entryId=").concat((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.EntryId, "&action=view"));
|
|
23730
|
+
setShow("view");
|
|
23731
|
+
};
|
|
23732
|
+
var onCellKeyDown = useCallback(function (event) {
|
|
23733
|
+
var api = event.api, node = event.node, keyEvent = event.event;
|
|
23734
|
+
if (!keyEvent)
|
|
23735
|
+
return;
|
|
23736
|
+
var key = keyEvent.key;
|
|
23737
|
+
if (key === "ArrowUp" || key === "ArrowDown") {
|
|
23738
|
+
keyEvent.preventDefault();
|
|
23739
|
+
var currentIndex = node.rowIndex !== null ? node.rowIndex : -1;
|
|
23740
|
+
var nextRowIndex = key === "ArrowUp" ? currentIndex - 1 : currentIndex + 1;
|
|
23741
|
+
var nextNode = api.getDisplayedRowAtIndex(nextRowIndex);
|
|
23742
|
+
if (nextNode) {
|
|
23743
|
+
var currentShiftId = shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId);
|
|
23744
|
+
nextNode.setSelected(true);
|
|
23745
|
+
api.ensureIndexVisible(nextRowIndex);
|
|
23746
|
+
setSelectedRowData(nextNode.data);
|
|
23747
|
+
navigate("".concat(routeLogbookEntry, "/").concat(currentShiftId, "/?entryId=").concat(nextNode.data.EntryId, "&action=view"));
|
|
23748
|
+
}
|
|
23749
|
+
}
|
|
23750
|
+
}, [setSelectedRowData, shiftId, shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId]);
|
|
23751
|
+
var getContextMenuItems = useCallback(function (params) {
|
|
23752
|
+
var _a, _b;
|
|
23753
|
+
var data = (_a = params.node) === null || _a === void 0 ? void 0 : _a.data;
|
|
23754
|
+
showContextMenu(event, data, "logbookEntryContext");
|
|
23755
|
+
if (data) {
|
|
23756
|
+
params.api.deselectAll();
|
|
23757
|
+
(_b = params.node) === null || _b === void 0 ? void 0 : _b.setSelected(true);
|
|
23758
|
+
}
|
|
23759
|
+
return [];
|
|
23760
|
+
}, [rows]);
|
|
23761
|
+
var getMenuOptions = useLogbookEntryOptionsFunctions({
|
|
23762
|
+
setSelectedRowData: setSelectedRowData,
|
|
23763
|
+
setShow: setShow,
|
|
23764
|
+
setShowRemoveDialog: setShowRemoveDialog,
|
|
23765
|
+
handleNewEntry: handleNewEntry,
|
|
23766
|
+
}).getMenuOptions;
|
|
23767
|
+
var handleExportToExcel = function () {
|
|
23768
|
+
if (!gridApiRef.current)
|
|
23769
|
+
return;
|
|
23770
|
+
var params = {
|
|
23771
|
+
fileName: "Logbook_Entries_Export.xlsx",
|
|
23772
|
+
columnKeys: [
|
|
23773
|
+
"AssetName",
|
|
23774
|
+
"CreateTimestamp",
|
|
23775
|
+
"Shift",
|
|
23776
|
+
"Crew",
|
|
23777
|
+
"Title",
|
|
23778
|
+
"CreatedBy",
|
|
23779
|
+
"Author",
|
|
23780
|
+
"Content",
|
|
23781
|
+
],
|
|
23782
|
+
processCellCallback: function (params) {
|
|
23783
|
+
if (params.column.colId === "CreateTimestamp") {
|
|
23784
|
+
return moment$3(params.value).format("MM/DD/yy - HH:mm");
|
|
23785
|
+
}
|
|
23786
|
+
return params.value;
|
|
23787
|
+
},
|
|
23788
|
+
};
|
|
23789
|
+
gridApiRef.current.exportDataAsExcel(params);
|
|
23790
|
+
};
|
|
23791
|
+
useEffect(function () {
|
|
23792
|
+
var _a, _b;
|
|
23793
|
+
if (!isLoading && entryId && entryId !== "new" && gridApiRef.current) {
|
|
23794
|
+
var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId);
|
|
23795
|
+
if (rowNode) {
|
|
23796
|
+
(_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(rowNode);
|
|
23797
|
+
rowNode.setSelected(true);
|
|
23798
|
+
setSelectedRowData(rowNode.data);
|
|
23799
|
+
setShow(isEditMode ? "edit" : "view");
|
|
23800
|
+
}
|
|
23801
|
+
else {
|
|
23802
|
+
// If the row node is not found, it might be a newly created entry
|
|
23803
|
+
// Try to refetch the data and then look for the entry
|
|
23804
|
+
setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
23805
|
+
var newRowNode;
|
|
23806
|
+
var _a, _b;
|
|
23807
|
+
return __generator(this, function (_c) {
|
|
23808
|
+
switch (_c.label) {
|
|
23809
|
+
case 0: return [4 /*yield*/, refetch()];
|
|
23810
|
+
case 1:
|
|
23811
|
+
_c.sent();
|
|
23812
|
+
newRowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId);
|
|
23813
|
+
if (newRowNode) {
|
|
23814
|
+
(_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(newRowNode);
|
|
23815
|
+
newRowNode.setSelected(true);
|
|
23816
|
+
setSelectedRowData(newRowNode.data);
|
|
23817
|
+
setShow(isEditMode ? "edit" : "view");
|
|
23818
|
+
}
|
|
23819
|
+
return [2 /*return*/];
|
|
23820
|
+
}
|
|
23821
|
+
});
|
|
23822
|
+
}); }, 500);
|
|
23823
|
+
}
|
|
23824
|
+
}
|
|
23825
|
+
}, [gridApiRef.current, isLoading, entryId, isEditMode, refetch]);
|
|
23826
|
+
useEffect(function () {
|
|
23827
|
+
registerConfig({
|
|
23828
|
+
id: "logbookEntryContext",
|
|
23829
|
+
getOptions: getMenuOptions,
|
|
23830
|
+
});
|
|
23831
|
+
}, []);
|
|
23832
|
+
useEffect(function () {
|
|
23833
|
+
if (isError) {
|
|
23834
|
+
setError(e.message);
|
|
23835
|
+
}
|
|
23836
|
+
}, [isError, e]);
|
|
23837
|
+
useEffect(function () {
|
|
23838
|
+
if (shiftInfo) {
|
|
23839
|
+
setShow("");
|
|
23840
|
+
setSelectedRowData(null);
|
|
23841
|
+
if (entryId &&
|
|
23842
|
+
(shiftIdRef.current == null ||
|
|
23843
|
+
shiftIdRef.current === (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId))) {
|
|
23844
|
+
navigate("".concat(routeLogbookEntry, "/").concat(shiftInfo.CurrentShiftId, "?entryId=").concat(entryId, "&action=").concat(action));
|
|
23845
|
+
}
|
|
23846
|
+
else {
|
|
23847
|
+
navigate("".concat(routeLogbookEntry, "/").concat(shiftInfo.CurrentShiftId));
|
|
23848
|
+
}
|
|
23849
|
+
shiftIdRef.current = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId;
|
|
23850
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
23851
|
+
return __generator(this, function (_a) {
|
|
23852
|
+
switch (_a.label) {
|
|
23853
|
+
case 0: return [4 /*yield*/, refetch()];
|
|
23854
|
+
case 1:
|
|
23855
|
+
_a.sent();
|
|
23856
|
+
return [2 /*return*/];
|
|
23857
|
+
}
|
|
23858
|
+
});
|
|
23859
|
+
}); })();
|
|
23860
|
+
}
|
|
23861
|
+
}, [shiftInfo]);
|
|
23862
|
+
useEffect(function () {
|
|
23863
|
+
if (shiftId) {
|
|
23864
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
23865
|
+
var shiftIdNumber;
|
|
23866
|
+
return __generator(this, function (_a) {
|
|
23867
|
+
switch (_a.label) {
|
|
23868
|
+
case 0:
|
|
23869
|
+
shiftIdNumber = Number(shiftId);
|
|
23870
|
+
return [4 /*yield*/, getShiftDataFromAPI(null, shiftIdNumber)];
|
|
23871
|
+
case 1:
|
|
23872
|
+
_a.sent();
|
|
23873
|
+
return [2 /*return*/];
|
|
23874
|
+
}
|
|
23875
|
+
});
|
|
23876
|
+
}); })();
|
|
23877
|
+
}
|
|
23878
|
+
else {
|
|
23879
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
23880
|
+
return __generator(this, function (_a) {
|
|
23881
|
+
switch (_a.label) {
|
|
23882
|
+
case 0: return [4 /*yield*/, getShiftDataFromAPI(null, 0)];
|
|
23883
|
+
case 1:
|
|
23884
|
+
_a.sent();
|
|
23885
|
+
return [2 /*return*/];
|
|
23886
|
+
}
|
|
23887
|
+
});
|
|
23888
|
+
}); })();
|
|
23889
|
+
}
|
|
23890
|
+
}, []);
|
|
23891
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
23892
|
+
React__default.createElement(Grid2, { container: true, size: {
|
|
23893
|
+
xs: 12,
|
|
23894
|
+
}, spacing: 2, justifyContent: "flex-start" },
|
|
23895
|
+
React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
23896
|
+
React__default.createElement(Typography$1, { variant: "h5", style: {
|
|
23897
|
+
fontWeight: 600,
|
|
23898
|
+
userSelect: "none",
|
|
23899
|
+
} }, "LOGBOOK")),
|
|
23900
|
+
React__default.createElement(Grid2, { container: true, size: { xs: 12, md: 5 }, spacing: 1 },
|
|
23901
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
23902
|
+
React__default.createElement(Filters$1, { quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, selectedSections: filterSections, onSectionsChange: setFilterSections })),
|
|
23903
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
23904
|
+
React__default.createElement(Paper, { elevation: 1, style: {
|
|
23905
|
+
height: "62vh",
|
|
23906
|
+
width: "100%",
|
|
23907
|
+
} },
|
|
23908
|
+
React__default.createElement(AgGridReact, { loading: isLoading, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 38, headerHeight: 42, loadingOverlayComponent: CenteredLazyLoading, animateRows: true, getContextMenuItems: getContextMenuItems, onRowClicked: rowClicked, onCellKeyDown: onCellKeyDown, onGridReady: function (params) { return (gridApiRef.current = params.api); }, getRowId: function (params) { return "".concat(params.data.EntryId); }, gridOptions: {
|
|
23909
|
+
rowSelection: {
|
|
23910
|
+
mode: "singleRow",
|
|
23911
|
+
checkboxes: false,
|
|
23912
|
+
enableClickSelection: true,
|
|
23913
|
+
},
|
|
23914
|
+
statusBar: {
|
|
23915
|
+
statusPanels: [
|
|
23916
|
+
exportToExcel
|
|
23917
|
+
? {
|
|
23918
|
+
statusPanel: function (params) { return (React__default.createElement("div", { style: {
|
|
23919
|
+
display: "flex",
|
|
23920
|
+
alignItems: "center",
|
|
23921
|
+
paddingTop: 5,
|
|
23922
|
+
} },
|
|
23923
|
+
React__default.createElement(ExcelButton, { handleExportToExcel: handleExportToExcel }))); },
|
|
23924
|
+
align: "right",
|
|
23925
|
+
}
|
|
23926
|
+
: {},
|
|
23927
|
+
{
|
|
23928
|
+
statusPanel: function (params) { return (React__default.createElement(CustomStatusPanel, { handleNew: handleNewEntry })); },
|
|
23929
|
+
align: "left",
|
|
23930
|
+
},
|
|
23931
|
+
],
|
|
23932
|
+
},
|
|
23933
|
+
} })))),
|
|
23934
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: 7 } },
|
|
23935
|
+
React__default.createElement(EntryViewer$1, { entry: selectedRowData, show: show, onChangeShow: function () {
|
|
23936
|
+
var newShow = show === "view" ? "edit" : "view";
|
|
23937
|
+
setShow(newShow);
|
|
23938
|
+
if (entryId && entryId !== "new") {
|
|
23939
|
+
var targetUrl = newShow === "edit"
|
|
23940
|
+
? "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=edit")
|
|
23941
|
+
: "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=view");
|
|
23942
|
+
navigate(targetUrl);
|
|
23943
|
+
}
|
|
23944
|
+
}, canEditShift: canEditShift, allowAttachments: allowAttachments, shiftsRange: shiftsRange, withAssetFilter: withAssetFilter, canEditAsset: canEditAsset, filterAssets: filterAssets, onHide: function (entryId, shouldStayInEditMode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
23945
|
+
var targetUrl;
|
|
23946
|
+
var _a;
|
|
23947
|
+
return __generator(this, function (_b) {
|
|
23948
|
+
switch (_b.label) {
|
|
23949
|
+
case 0:
|
|
23950
|
+
if (!entryId) return [3 /*break*/, 2];
|
|
23951
|
+
// First refetch to ensure we have the latest data
|
|
23952
|
+
return [4 /*yield*/, refetch()];
|
|
23953
|
+
case 1:
|
|
23954
|
+
// First refetch to ensure we have the latest data
|
|
23955
|
+
_b.sent();
|
|
23956
|
+
targetUrl = shouldStayInEditMode
|
|
23957
|
+
? "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=edit")
|
|
23958
|
+
: "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=view");
|
|
23959
|
+
navigate(targetUrl);
|
|
23960
|
+
setShow(shouldStayInEditMode ? "edit" : "view");
|
|
23961
|
+
// Additional delay to allow navigation and state updates to complete
|
|
23962
|
+
setTimeout(function () {
|
|
23963
|
+
var _a, _b;
|
|
23964
|
+
var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId.toString());
|
|
23965
|
+
if (rowNode) {
|
|
23966
|
+
(_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(rowNode);
|
|
23967
|
+
rowNode.setSelected(true);
|
|
23968
|
+
setSelectedRowData(rowNode.data);
|
|
23969
|
+
}
|
|
23970
|
+
else {
|
|
23971
|
+
// If still not found, try one more refetch
|
|
23972
|
+
setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
23973
|
+
var retryRowNode;
|
|
23974
|
+
var _a, _b, _c;
|
|
23975
|
+
return __generator(this, function (_d) {
|
|
23976
|
+
switch (_d.label) {
|
|
23977
|
+
case 0: return [4 /*yield*/, refetch()];
|
|
23978
|
+
case 1:
|
|
23979
|
+
_d.sent();
|
|
23980
|
+
retryRowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId.toString());
|
|
23981
|
+
if (retryRowNode) {
|
|
23982
|
+
(_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(retryRowNode);
|
|
23983
|
+
retryRowNode.setSelected(true);
|
|
23984
|
+
setSelectedRowData(retryRowNode.data);
|
|
23985
|
+
}
|
|
23986
|
+
else {
|
|
23987
|
+
setShow("");
|
|
23988
|
+
setSelectedRowData(null);
|
|
23989
|
+
(_c = gridApiRef.current) === null || _c === void 0 ? void 0 : _c.deselectAll();
|
|
23990
|
+
}
|
|
23991
|
+
return [2 /*return*/];
|
|
23992
|
+
}
|
|
23993
|
+
});
|
|
23994
|
+
}); }, 500);
|
|
23995
|
+
}
|
|
23996
|
+
}, 200);
|
|
23997
|
+
return [3 /*break*/, 3];
|
|
23998
|
+
case 2:
|
|
23999
|
+
setShow("");
|
|
24000
|
+
setSelectedRowData(null);
|
|
24001
|
+
(_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
|
|
24002
|
+
navigate("".concat(routeLogbookEntry, "/").concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId)));
|
|
24003
|
+
_b.label = 3;
|
|
24004
|
+
case 3: return [2 /*return*/];
|
|
24005
|
+
}
|
|
24006
|
+
});
|
|
24007
|
+
}); } }))),
|
|
24008
|
+
React__default.createElement(RemoveEntryDialog, { entry: selectedRowData, show: showRemoveDialog, onHide: function (shouldUpdate) {
|
|
24009
|
+
if (shouldUpdate) {
|
|
24010
|
+
refetch();
|
|
24011
|
+
}
|
|
24012
|
+
setShowRemoveDialog(false);
|
|
24013
|
+
setSelectedRowData(null);
|
|
24014
|
+
setShow("");
|
|
24015
|
+
} }),
|
|
24016
|
+
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
24017
|
+
};
|
|
24018
|
+
|
|
24019
|
+
var LogbookPage$1 = function () {
|
|
24020
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
24021
|
+
React__default.createElement(HelmetDexteel, { title: "Logbook Entry" }),
|
|
24022
|
+
React__default.createElement(Grid2, { container: true, style: { padding: "1.5rem" } },
|
|
24023
|
+
React__default.createElement(Logbook$1, null))));
|
|
24024
|
+
};
|
|
24025
|
+
|
|
24026
|
+
var MESFLogbookEntry = function () {
|
|
24027
|
+
return React__default.createElement(LogbookPage$1, null);
|
|
24028
|
+
};
|
|
24029
|
+
|
|
24030
|
+
var moment$2 = getMomentTz();
|
|
24031
|
+
var getEntriesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
24032
|
+
var apiService, parameters, resp, rows;
|
|
24033
|
+
var startShiftId = _b.startShiftId, endShiftId = _b.endShiftId, assetId = _b.assetId, sectionIds = _b.sectionIds, signal = _b.signal;
|
|
24034
|
+
return __generator(this, function (_c) {
|
|
24035
|
+
switch (_c.label) {
|
|
24036
|
+
case 0:
|
|
24037
|
+
apiService = new MESApiService();
|
|
24038
|
+
parameters = [
|
|
24039
|
+
{ name: "StartShiftId", value: startShiftId },
|
|
24040
|
+
{ name: "EndShiftId", value: endShiftId },
|
|
24041
|
+
];
|
|
24042
|
+
if (assetId) {
|
|
24043
|
+
parameters.push({ name: "AssetId", value: assetId });
|
|
24044
|
+
}
|
|
24045
|
+
// Pass comma-separated sectionIds for multi-select filter
|
|
24046
|
+
if (sectionIds && sectionIds.length > 0) {
|
|
24047
|
+
parameters.push({ name: "SectionIds", value: sectionIds.join(",") });
|
|
24048
|
+
}
|
|
24049
|
+
return [4 /*yield*/, apiService.callV2("[SWV].[GetSectionLogbookEntries]", parameters, signal)];
|
|
24050
|
+
case 1:
|
|
24051
|
+
resp = _c.sent();
|
|
24052
|
+
if (resp.ok) {
|
|
24053
|
+
rows = get(resp, "data.tables[0].rows", []);
|
|
24054
|
+
rows = rows.map(function (entry) { return (__assign(__assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
|
|
24055
|
+
? moment$2.utc(entry["CreateTimestamp"]).toDate()
|
|
24056
|
+
: null, UpdateTimestamp: entry.UpdateTimestamp
|
|
24057
|
+
? moment$2.utc(entry["UpdateTimestamp"]).toDate()
|
|
24058
|
+
: null })); });
|
|
24059
|
+
return [2 /*return*/, rows];
|
|
24060
|
+
}
|
|
24061
|
+
else {
|
|
24062
|
+
throw new Error(resp.message || "Error fetching entries");
|
|
24063
|
+
}
|
|
24064
|
+
}
|
|
24065
|
+
});
|
|
24066
|
+
}); };
|
|
24067
|
+
|
|
24068
|
+
var useEntriesReport = function (_a) {
|
|
24069
|
+
var startShiftId = _a.startShiftId, endShiftId = _a.endShiftId, assetId = _a.assetId, sectionIds = _a.sectionIds;
|
|
24070
|
+
return useQuery({
|
|
24071
|
+
queryKey: ["entriesReport", startShiftId, endShiftId, assetId, sectionIds],
|
|
24072
|
+
queryFn: function (_a) {
|
|
24073
|
+
var signal = _a.signal;
|
|
24074
|
+
return getEntriesReport({
|
|
24075
|
+
startShiftId: startShiftId,
|
|
24076
|
+
endShiftId: endShiftId,
|
|
24077
|
+
assetId: assetId,
|
|
24078
|
+
sectionIds: sectionIds,
|
|
24079
|
+
signal: signal,
|
|
24080
|
+
});
|
|
24081
|
+
},
|
|
24082
|
+
});
|
|
24083
|
+
};
|
|
24084
|
+
|
|
24085
|
+
var useTableData = function (_a) {
|
|
24086
|
+
var showAttachments = _a.showAttachments, showAsset = _a.showAsset, showShiftCrew = _a.showShiftCrew;
|
|
24087
|
+
var columnDefs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
24088
|
+
{
|
|
24089
|
+
field: "CreateTimestamp",
|
|
24090
|
+
headerName: "Created",
|
|
24091
|
+
flex: 2,
|
|
24092
|
+
valueGetter: function (params) {
|
|
24093
|
+
return dxtToLocalServerTime(params.data.CreateTimestamp, "MM/dd/yy HH:mm");
|
|
24094
|
+
},
|
|
24095
|
+
}
|
|
24096
|
+
], (showAsset
|
|
24097
|
+
? [
|
|
24098
|
+
{
|
|
24099
|
+
field: "AssetName",
|
|
24100
|
+
headerName: "Asset",
|
|
24101
|
+
sortable: true,
|
|
24102
|
+
flex: 2,
|
|
24103
|
+
minWidth: 70,
|
|
24104
|
+
wrapText: true,
|
|
24105
|
+
autoHeight: true,
|
|
24106
|
+
},
|
|
24107
|
+
]
|
|
24108
|
+
: []), true), [
|
|
24109
|
+
{
|
|
24110
|
+
field: "Title",
|
|
24111
|
+
headerName: "Title",
|
|
24112
|
+
flex: 4,
|
|
24113
|
+
},
|
|
24114
|
+
{
|
|
24115
|
+
field: "SectionName",
|
|
24116
|
+
headerName: "Section",
|
|
24117
|
+
flex: 2,
|
|
24118
|
+
},
|
|
24119
|
+
{
|
|
24120
|
+
field: "Author",
|
|
24121
|
+
headerName: "Created By",
|
|
24122
|
+
flex: 2,
|
|
24123
|
+
}
|
|
24124
|
+
], false), (showShiftCrew
|
|
24125
|
+
? [
|
|
24126
|
+
{
|
|
24127
|
+
field: "Shift",
|
|
24128
|
+
headerName: "Shift",
|
|
24129
|
+
sortable: false,
|
|
24130
|
+
flex: 1,
|
|
24131
|
+
minWidth: 60,
|
|
24132
|
+
maxWidth: 60,
|
|
24133
|
+
},
|
|
24134
|
+
{
|
|
24135
|
+
field: "Crew",
|
|
24136
|
+
headerName: "Crew",
|
|
24137
|
+
sortable: false,
|
|
24138
|
+
flex: 1,
|
|
24139
|
+
minWidth: 60,
|
|
24140
|
+
maxWidth: 60,
|
|
24141
|
+
},
|
|
24142
|
+
]
|
|
24143
|
+
: []), true), (showAttachments
|
|
24144
|
+
? [
|
|
24145
|
+
{
|
|
24146
|
+
field: "AttachmentCount",
|
|
24147
|
+
headerName: "",
|
|
24148
|
+
flex: 1,
|
|
24149
|
+
headerComponent: function () { return (React__default.createElement("div", { style: {
|
|
24150
|
+
display: "flex",
|
|
24151
|
+
alignItems: "center",
|
|
24152
|
+
justifyContent: "center",
|
|
24153
|
+
height: "100%",
|
|
24154
|
+
width: "100%",
|
|
24155
|
+
textAlign: "center",
|
|
24156
|
+
} },
|
|
24157
|
+
React__default.createElement(AttachFile, { style: { fontSize: 18, color: "#666" } }))); },
|
|
24158
|
+
cellRenderer: function (params) {
|
|
24159
|
+
var count = params.data.AttachmentCount || 0;
|
|
24160
|
+
if (count === 0) {
|
|
24161
|
+
return null;
|
|
24162
|
+
}
|
|
24163
|
+
return (React__default.createElement("div", { style: {
|
|
24164
|
+
display: "flex",
|
|
24165
|
+
alignItems: "center",
|
|
24166
|
+
height: "100%",
|
|
24167
|
+
justifyContent: "center",
|
|
24168
|
+
} },
|
|
24169
|
+
React__default.createElement(Chip, { icon: React__default.createElement(AttachFile, { style: { fontSize: 16 } }), label: count, size: "small", variant: "outlined", color: "primary" })));
|
|
24170
|
+
},
|
|
24171
|
+
},
|
|
24172
|
+
]
|
|
24173
|
+
: []), true), [
|
|
24174
|
+
{
|
|
24175
|
+
field: "Content",
|
|
24176
|
+
headerName: "Content",
|
|
24177
|
+
hide: true,
|
|
24178
|
+
},
|
|
24179
|
+
], false);
|
|
24180
|
+
return { columnDefs: columnDefs };
|
|
24181
|
+
};
|
|
24182
|
+
|
|
24183
|
+
var moment$1 = getMomentTz();
|
|
24184
|
+
var EntryViewer = function (_a) {
|
|
24185
|
+
var entry = _a.entry, show = _a.show, onHide = _a.onHide, showAsset = _a.showAsset, _b = _a.showAttachments, showAttachments = _b === void 0 ? false : _b, _c = _a.showSection, showSection = _c === void 0 ? false : _c;
|
|
24186
|
+
var _d = useState(""), error = _d[0], setError = _d[1];
|
|
24187
|
+
var _e = useForm(), control = _e.control, setValue = _e.setValue, reset = _e.reset, watch = _e.watch; _e.getValues;
|
|
24188
|
+
var content = watch("Content");
|
|
24189
|
+
var updatedBy = watch("UpdatedBy");
|
|
24190
|
+
var updateTimestamp = watch("UpdateTimestamp");
|
|
24191
|
+
var entryId = watch("EntryId");
|
|
24192
|
+
var title = watch("Title");
|
|
24193
|
+
var author = watch("Author");
|
|
24194
|
+
var shiftId = watch("ShiftId");
|
|
24195
|
+
var assetId = watch("AssetId");
|
|
24196
|
+
var createTimestamp = watch("CreateTimestamp");
|
|
24197
|
+
useEffect(function () {
|
|
24198
|
+
reset(entry || ENTRY_INITIAL_VALUES);
|
|
24199
|
+
}, [entry, show]);
|
|
24200
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
24201
|
+
(entry === null || entry === void 0 ? void 0 : entry.EntryId) && (React__default.createElement(HelmetDexteel, { title: "'".concat(entry === null || entry === void 0 ? void 0 : entry.Title, "' by ").concat(entry.Author, " - Logbook Report") })),
|
|
24202
|
+
(entry === null || entry === void 0 ? void 0 : entry.EntryId) ? (React__default.createElement(Paper, { elevation: 1, sx: {
|
|
24203
|
+
width: "100%",
|
|
24204
|
+
height: "100%",
|
|
24205
|
+
display: "flex",
|
|
24206
|
+
flexDirection: "column",
|
|
24207
|
+
} },
|
|
24208
|
+
React__default.createElement(Grid2, { container: true, spacing: 1, component: "form", height: "100%", flexDirection: "column", flexWrap: "nowrap", p: 1 },
|
|
24209
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
24210
|
+
React__default.createElement(Controller, { name: "Title", control: control, render: function (_a) {
|
|
24211
|
+
var value = _a.field.value;
|
|
24212
|
+
return (React__default.createElement(TextField, { label: "Title", value: value !== null && value !== void 0 ? value : "", size: "medium", disabled: true }));
|
|
24213
|
+
} })),
|
|
24214
|
+
React__default.createElement(Grid2, { container: true, size: { xs: 12 }, spacing: 2 },
|
|
24215
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
|
|
24216
|
+
React__default.createElement(Controller, { name: "CreateTimestamp", control: control, render: function (_a) {
|
|
24217
|
+
var value = _a.field.value;
|
|
24218
|
+
return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$1(value) : null, disabled: true, slotProps: {
|
|
24219
|
+
textField: {
|
|
24220
|
+
variant: "outlined",
|
|
24221
|
+
size: "small",
|
|
24222
|
+
fullWidth: true,
|
|
24223
|
+
InputLabelProps: {
|
|
24224
|
+
shrink: true,
|
|
24225
|
+
},
|
|
24226
|
+
},
|
|
24227
|
+
} }));
|
|
24228
|
+
} })),
|
|
24229
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
|
|
24230
|
+
React__default.createElement(Controller, { name: "ShiftId", control: control, render: function (_a) {
|
|
24231
|
+
var field = _a.field;
|
|
24232
|
+
return (React__default.createElement(ShiftSelector, { value: field.value, disabled: true }));
|
|
24233
|
+
} })),
|
|
24234
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: showAsset ? 2 : 6 } },
|
|
24235
|
+
React__default.createElement(Controller, { name: "Author", control: control, rules: {
|
|
24236
|
+
required: "Author is required",
|
|
24237
|
+
}, render: function (_a) {
|
|
24238
|
+
var value = _a.field.value; _a.fieldState.error;
|
|
24239
|
+
return (React__default.createElement(TextField, { label: "Author", variant: "outlined", value: value !== null && value !== void 0 ? value : "", fullWidth: true, disabled: true, size: "small" }));
|
|
24240
|
+
} })),
|
|
24241
|
+
showAsset ? (React__default.createElement(Grid2, { size: { md: 4, xs: 12 } },
|
|
24242
|
+
React__default.createElement(Controller, { name: "AssetId", control: control, render: function (_a) {
|
|
24243
|
+
var field = _a.field;
|
|
24244
|
+
return (React__default.createElement(AssetsFilter, { value: field.value, onChange: field.onChange, disabled: true }));
|
|
24245
|
+
} }))) : null),
|
|
24246
|
+
showSection && (entry === null || entry === void 0 ? void 0 : entry.SectionName) && (React__default.createElement(Grid2, { size: { xs: 12 }, sx: { display: "flex", alignItems: "center", gap: 1 } },
|
|
24247
|
+
React__default.createElement(Typography$1, { variant: "body2", color: "text.secondary" }, "Section:"),
|
|
24248
|
+
React__default.createElement(Chip, { label: entry.SectionName, size: "small", color: "primary", variant: "outlined" }))),
|
|
24249
|
+
React__default.createElement(Grid2, { size: { md: 12 }, height: "100%", flexGrow: 1, overflow: "auto" },
|
|
24250
|
+
React__default.createElement(Controller, { name: "Content", control: control, render: function (_a) {
|
|
24251
|
+
var _b = _a.field; _b.value; _b.onChange;
|
|
24252
|
+
return (React__default.createElement(ContentInput, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return setValue("Content", val); }, value: content, isEditing: false, isNewEntry: false, entryId: entryId, entryData: {
|
|
24253
|
+
assetId: assetId,
|
|
24254
|
+
entryId: entryId,
|
|
24255
|
+
shiftId: shiftId,
|
|
24256
|
+
title: title,
|
|
24257
|
+
content: content,
|
|
24258
|
+
author: author,
|
|
24259
|
+
createTimestamp: createTimestamp,
|
|
24260
|
+
}, onEntrySubmitted: undefined, allowAttachments: showAttachments }));
|
|
24261
|
+
} })),
|
|
24262
|
+
React__default.createElement(Grid2, { container: true, size: { xs: 12 } },
|
|
24263
|
+
React__default.createElement(Grid2, { container: true, size: { md: 6, xs: 12 }, spacing: 1 },
|
|
24264
|
+
React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
24265
|
+
React__default.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: function () { return onHide(); } }, "Close"))))))) : null,
|
|
24266
|
+
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
24267
|
+
};
|
|
24268
|
+
|
|
24269
|
+
var customPeriodOptions = [
|
|
24270
|
+
{ value: "Day", label: "Day" },
|
|
24271
|
+
{ value: "4Days", label: "4 Days" },
|
|
24272
|
+
{ value: "Week", label: "Week" },
|
|
24273
|
+
{ value: "Month", label: "Month" },
|
|
24274
|
+
{ value: "Custom", label: "Custom" },
|
|
24275
|
+
];
|
|
24276
|
+
var Filters = function (_a) {
|
|
24277
|
+
var quickFilter = _a.quickFilter, onQuickFilterChange = _a.onQuickFilterChange, shiftPeriod = _a.shiftPeriod, onChangeShiftPeriod = _a.onChangeShiftPeriod, actualPeriod = _a.actualPeriod, selectedSections = _a.selectedSections, onSectionsChange = _a.onSectionsChange;
|
|
24278
|
+
var handleShiftPeriodChange = function (value, period) {
|
|
24279
|
+
onChangeShiftPeriod(value, period);
|
|
24280
|
+
};
|
|
24281
|
+
useMesfRealtime({
|
|
24282
|
+
onReceiveMessage: function (author, message) {
|
|
24283
|
+
if (message.replaceAll("[", "").replaceAll("]", "") == "LB.GetEntries") ;
|
|
24284
|
+
},
|
|
24285
|
+
});
|
|
24286
|
+
return (React__default.createElement(Paper, { elevation: 1, style: { padding: 8 } },
|
|
24287
|
+
React__default.createElement(Grid2, { container: true, spacing: 1 },
|
|
24288
|
+
React__default.createElement(Grid2, { size: { xs: 12 }, alignItems: "center", justifyContent: "center" },
|
|
24289
|
+
React__default.createElement(ShiftPeriodNavigatorControl, { onChange: handleShiftPeriodChange, value: shiftPeriod, actualPeriod: actualPeriod, showShiftAndCrews: false, dateFormat: "MM/DD/YYYY", periodOptions: customPeriodOptions })),
|
|
24290
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
|
|
24291
|
+
React__default.createElement(TextField, { fullWidth: true, label: "Search", variant: "outlined", size: "small", value: quickFilter, onChange: function (event) {
|
|
24292
|
+
onQuickFilterChange(event === null || event === void 0 ? void 0 : event.target.value);
|
|
24293
|
+
}, InputProps: {
|
|
24294
|
+
startAdornment: (React__default.createElement(InputAdornment, { position: "start" },
|
|
24295
|
+
React__default.createElement(IconButton$1, { edge: "start", type: "submit" },
|
|
24296
|
+
React__default.createElement(SearchIcon, null)))),
|
|
24297
|
+
} })),
|
|
24298
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: 9 } },
|
|
24299
|
+
React__default.createElement(SectionMultiSelect, { value: selectedSections, onChange: onSectionsChange, label: "Sections" })))));
|
|
24300
|
+
};
|
|
24301
|
+
|
|
24302
|
+
var moment = getMomentTz();
|
|
24303
|
+
var Logbook = function () {
|
|
24304
|
+
var report = useLogbookSettings().report;
|
|
24305
|
+
var showAttachments = report.showAttachments;
|
|
24306
|
+
var showAsset = report.showAsset;
|
|
24307
|
+
var showShiftCrew = report.showShiftCrew;
|
|
24308
|
+
var exportToExcel = report.exportToExcel;
|
|
24309
|
+
var _a = useSearchParams(), searchParams = _a[0], setSearchParams = _a[1];
|
|
24310
|
+
var entryId = searchParams.get("entryId");
|
|
24311
|
+
var gridApiRef = useRef(null);
|
|
24312
|
+
var _b = useState(""), error = _b[0], setError = _b[1];
|
|
24313
|
+
var _c = useState(""), show = _c[0], setShow = _c[1];
|
|
24314
|
+
var _d = useState(function () {
|
|
24315
|
+
var startShiftIdParam = searchParams.get("startShiftId");
|
|
24316
|
+
var endShiftIdParam = searchParams.get("endShiftId");
|
|
24317
|
+
return {
|
|
24318
|
+
StartShiftId: startShiftIdParam ? Number(startShiftIdParam) : null,
|
|
24319
|
+
EndShiftId: endShiftIdParam ? Number(endShiftIdParam) : null,
|
|
24320
|
+
};
|
|
24321
|
+
}), shiftPeriod = _d[0], setShiftPeriod = _d[1];
|
|
24322
|
+
var _e = useState(""), quickFilter = _e[0], setQuickFilter = _e[1];
|
|
24323
|
+
var _f = useState(null), selectedRowData = _f[0], setSelectedRowData = _f[1];
|
|
24324
|
+
// Section filter state
|
|
24325
|
+
var _g = useState([]), filterSections = _g[0], setFilterSections = _g[1];
|
|
24326
|
+
var updateUrl = function (_a) {
|
|
24327
|
+
var startShiftId = _a.startShiftId, endShiftId = _a.endShiftId, period = _a.period, entryId = _a.entryId;
|
|
24328
|
+
var newParams = new URLSearchParams(searchParams);
|
|
24329
|
+
if (startShiftId) {
|
|
24330
|
+
newParams.set("startShiftId", startShiftId.toString());
|
|
24331
|
+
}
|
|
24332
|
+
else if (startShiftId === null) {
|
|
24333
|
+
newParams.delete("startShiftId");
|
|
24334
|
+
}
|
|
24335
|
+
if (endShiftId) {
|
|
24336
|
+
newParams.set("endShiftId", endShiftId.toString());
|
|
24337
|
+
}
|
|
24338
|
+
else if (endShiftId === null) {
|
|
24339
|
+
newParams.delete("endShiftId");
|
|
24340
|
+
}
|
|
24341
|
+
if (period) {
|
|
24342
|
+
newParams.set("period", period);
|
|
24343
|
+
}
|
|
24344
|
+
else if (period === null) {
|
|
24345
|
+
newParams.delete("period");
|
|
24346
|
+
}
|
|
24347
|
+
if (entryId) {
|
|
24348
|
+
newParams.set("entryId", entryId);
|
|
24349
|
+
}
|
|
24350
|
+
else if (entryId === null) {
|
|
24351
|
+
newParams.delete("entryId");
|
|
24352
|
+
}
|
|
24353
|
+
setSearchParams(newParams);
|
|
24354
|
+
};
|
|
24355
|
+
var _h = useEntriesReport({
|
|
24356
|
+
startShiftId: shiftPeriod.StartShiftId,
|
|
24357
|
+
endShiftId: shiftPeriod.EndShiftId,
|
|
24358
|
+
assetId: null,
|
|
24359
|
+
sectionIds: filterSections.map(function (s) { return s.SectionId; }),
|
|
24360
|
+
}), rows = _h.data, isLoading = _h.isLoading, e = _h.error, isError = _h.isError, refetch = _h.refetch;
|
|
24361
|
+
var columnDefs = useTableData({
|
|
24362
|
+
showAttachments: showAttachments,
|
|
24363
|
+
showAsset: showAsset,
|
|
24364
|
+
showShiftCrew: showShiftCrew,
|
|
24365
|
+
}).columnDefs;
|
|
24366
|
+
var defaultColDef = useGridDefinitions({}).defaultColDef;
|
|
24367
|
+
var onQuickFilterChange = function (text) {
|
|
24368
|
+
var _a;
|
|
24369
|
+
setQuickFilter(text);
|
|
24370
|
+
(_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.setGridOption("quickFilterText", text);
|
|
24371
|
+
};
|
|
24372
|
+
var rowClicked = function (event) {
|
|
24373
|
+
var _a, _b;
|
|
24374
|
+
setSelectedRowData(event === null || event === void 0 ? void 0 : event.data);
|
|
24375
|
+
updateUrl({ entryId: (_b = (_a = event.data) === null || _a === void 0 ? void 0 : _a.EntryId) === null || _b === void 0 ? void 0 : _b.toString() });
|
|
24376
|
+
setShow("view");
|
|
24377
|
+
};
|
|
24378
|
+
var onCellKeyDown = useCallback(function (event) {
|
|
24379
|
+
var _a, _b;
|
|
24380
|
+
var api = event.api, node = event.node, keyEvent = event.event;
|
|
24381
|
+
if (!keyEvent)
|
|
24382
|
+
return;
|
|
24383
|
+
var key = keyEvent.key;
|
|
24384
|
+
if (key === "ArrowUp" || key === "ArrowDown") {
|
|
24385
|
+
keyEvent.preventDefault();
|
|
24386
|
+
var currentIndex = node.rowIndex !== null ? node.rowIndex : -1;
|
|
24387
|
+
var nextRowIndex = key === "ArrowUp" ? currentIndex - 1 : currentIndex + 1;
|
|
24388
|
+
var nextNode = api.getDisplayedRowAtIndex(nextRowIndex);
|
|
24389
|
+
if (nextNode) {
|
|
24390
|
+
nextNode.setSelected(true);
|
|
24391
|
+
api.ensureIndexVisible(nextRowIndex);
|
|
24392
|
+
setSelectedRowData(nextNode.data);
|
|
24393
|
+
updateUrl({ entryId: (_b = (_a = nextNode.data) === null || _a === void 0 ? void 0 : _a.EntryId) === null || _b === void 0 ? void 0 : _b.toString() });
|
|
24394
|
+
}
|
|
24395
|
+
}
|
|
24396
|
+
}, [setSelectedRowData]);
|
|
24397
|
+
var handleExportToExcel = function () {
|
|
24398
|
+
if (!gridApiRef.current)
|
|
24399
|
+
return;
|
|
24400
|
+
var params = {
|
|
24401
|
+
fileName: "Logbook_Report_Export.xlsx",
|
|
24402
|
+
columnKeys: [
|
|
24403
|
+
"AssetName",
|
|
24404
|
+
"CreateTimestamp",
|
|
24405
|
+
"Shift",
|
|
24406
|
+
"Crew",
|
|
24407
|
+
"Title",
|
|
24408
|
+
"CreatedBy",
|
|
24409
|
+
"Author",
|
|
24410
|
+
"Content",
|
|
24411
|
+
],
|
|
24412
|
+
processCellCallback: function (params) {
|
|
24413
|
+
if (params.column.colId === "CreateTimestamp") {
|
|
24414
|
+
return moment(params.value).format("MM/DD/yy - HH:mm");
|
|
24415
|
+
}
|
|
24416
|
+
return params.value;
|
|
24417
|
+
},
|
|
24418
|
+
};
|
|
24419
|
+
gridApiRef.current.exportDataAsExcel(params);
|
|
24420
|
+
};
|
|
24421
|
+
useEffect(function () {
|
|
24422
|
+
var _a, _b, _c;
|
|
24423
|
+
if (!isLoading && entryId && gridApiRef.current) {
|
|
24424
|
+
var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId);
|
|
24425
|
+
if (rowNode) {
|
|
24426
|
+
(_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(rowNode);
|
|
24427
|
+
rowNode.setSelected(true);
|
|
24428
|
+
setSelectedRowData(rowNode.data);
|
|
24429
|
+
setShow("view");
|
|
24430
|
+
}
|
|
24431
|
+
}
|
|
24432
|
+
else if (!entryId) {
|
|
24433
|
+
setShow("");
|
|
24434
|
+
setSelectedRowData(null);
|
|
24435
|
+
(_c = gridApiRef.current) === null || _c === void 0 ? void 0 : _c.deselectAll();
|
|
24436
|
+
}
|
|
24437
|
+
}, [gridApiRef.current, isLoading, entryId]);
|
|
24438
|
+
useEffect(function () {
|
|
24439
|
+
if (isError) {
|
|
24440
|
+
setError(e.message);
|
|
24441
|
+
}
|
|
24442
|
+
}, [isError, e]);
|
|
24443
|
+
useEffect(function () {
|
|
24444
|
+
var _a;
|
|
24445
|
+
var startShiftIdParam = searchParams.get("startShiftId");
|
|
24446
|
+
var endShiftIdParam = searchParams.get("endShiftId");
|
|
24447
|
+
var entryIdParam = searchParams.get("entryId");
|
|
24448
|
+
if (startShiftIdParam || endShiftIdParam) {
|
|
24449
|
+
setShiftPeriod({
|
|
24450
|
+
StartShiftId: startShiftIdParam ? Number(startShiftIdParam) : null,
|
|
24451
|
+
EndShiftId: endShiftIdParam ? Number(endShiftIdParam) : null,
|
|
24452
|
+
});
|
|
24453
|
+
}
|
|
24454
|
+
// Handle entryId from URL on initial load
|
|
24455
|
+
if (entryIdParam && gridApiRef.current) {
|
|
24456
|
+
var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryIdParam);
|
|
24457
|
+
if (rowNode) {
|
|
24458
|
+
rowNode.setSelected(true);
|
|
24459
|
+
setSelectedRowData(rowNode.data);
|
|
24460
|
+
setShow("view");
|
|
24461
|
+
}
|
|
24462
|
+
}
|
|
24463
|
+
}, []);
|
|
24464
|
+
useEffect(function () {
|
|
24465
|
+
if (shiftPeriod.StartShiftId !== null || shiftPeriod.EndShiftId !== null) {
|
|
24466
|
+
setShow("");
|
|
24467
|
+
setSelectedRowData(null);
|
|
24468
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24469
|
+
return __generator(this, function (_a) {
|
|
24470
|
+
switch (_a.label) {
|
|
24471
|
+
case 0: return [4 /*yield*/, refetch()];
|
|
24472
|
+
case 1:
|
|
24473
|
+
_a.sent();
|
|
24474
|
+
return [2 /*return*/];
|
|
24475
|
+
}
|
|
24476
|
+
});
|
|
24477
|
+
}); })();
|
|
24478
|
+
}
|
|
24479
|
+
}, [shiftPeriod.StartShiftId, shiftPeriod.EndShiftId]);
|
|
24480
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
24481
|
+
React__default.createElement(Grid2, { container: true, size: {
|
|
24482
|
+
xs: 12,
|
|
24483
|
+
}, spacing: 2, justifyContent: "flex-start" },
|
|
24484
|
+
React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
24485
|
+
React__default.createElement(Typography$1, { variant: "h5", style: {
|
|
24486
|
+
fontWeight: 600,
|
|
24487
|
+
userSelect: "none",
|
|
24488
|
+
} }, "LOGBOOK REPORT")),
|
|
24489
|
+
React__default.createElement(Grid2, { container: true, size: { xs: 12, md: 5 }, spacing: 1 },
|
|
24490
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
24491
|
+
React__default.createElement(Filters, { quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, shiftPeriod: shiftPeriod, onChangeShiftPeriod: function (value, period) {
|
|
24492
|
+
setShiftPeriod(value);
|
|
24493
|
+
updateUrl({
|
|
24494
|
+
startShiftId: value.StartShiftId,
|
|
24495
|
+
endShiftId: value.EndShiftId,
|
|
24496
|
+
period: period,
|
|
24497
|
+
entryId: searchParams.get("entryId"),
|
|
24498
|
+
});
|
|
24499
|
+
}, actualPeriod: searchParams.get("period"), selectedSections: filterSections, onSectionsChange: setFilterSections })),
|
|
24500
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
24501
|
+
React__default.createElement(Paper, { elevation: 1, style: {
|
|
24502
|
+
height: "62vh",
|
|
24503
|
+
width: "100%",
|
|
24504
|
+
} },
|
|
24505
|
+
React__default.createElement(AgGridReact, { loading: isLoading, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 38, headerHeight: 42, loadingOverlayComponent: CenteredLazyLoading, animateRows: true, onRowClicked: rowClicked, onCellKeyDown: onCellKeyDown, onGridReady: function (params) { return (gridApiRef.current = params.api); }, getRowId: function (params) { return "".concat(params.data.EntryId); }, gridOptions: {
|
|
24506
|
+
rowSelection: {
|
|
24507
|
+
mode: "singleRow",
|
|
24508
|
+
checkboxes: false,
|
|
24509
|
+
enableClickSelection: true,
|
|
24510
|
+
},
|
|
24511
|
+
statusBar: {
|
|
24512
|
+
statusPanels: [
|
|
24513
|
+
exportToExcel
|
|
24514
|
+
? {
|
|
24515
|
+
statusPanel: function (params) { return (React__default.createElement("div", { style: {
|
|
24516
|
+
display: "flex",
|
|
24517
|
+
alignItems: "center",
|
|
24518
|
+
paddingTop: 1,
|
|
24519
|
+
paddingBottom: 1,
|
|
24520
|
+
} },
|
|
24521
|
+
React__default.createElement(ExcelButton, { handleExportToExcel: handleExportToExcel }))); },
|
|
24522
|
+
align: "right",
|
|
24523
|
+
}
|
|
24524
|
+
: {},
|
|
24525
|
+
],
|
|
24526
|
+
},
|
|
24527
|
+
} })))),
|
|
24528
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: 7 } },
|
|
24529
|
+
React__default.createElement(EntryViewer, { entry: selectedRowData, show: show, onChangeShow: function () { return setShow(show === "view" ? "edit" : "view"); }, onHide: function () {
|
|
24530
|
+
var _a;
|
|
24531
|
+
setShow("");
|
|
24532
|
+
setSelectedRowData(null);
|
|
24533
|
+
(_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
|
|
24534
|
+
updateUrl({ entryId: null });
|
|
24535
|
+
}, showAsset: showAsset, showAttachments: showAttachments, showSection: true }))),
|
|
24536
|
+
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
|
|
24537
|
+
};
|
|
24538
|
+
|
|
24539
|
+
var LogbookPage = function () {
|
|
24540
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
24541
|
+
React__default.createElement(HelmetDexteel, { title: "Logbook Report" }),
|
|
24542
|
+
React__default.createElement(Grid2, { container: true, style: { padding: "1.5rem" } },
|
|
24543
|
+
React__default.createElement(Logbook, null))));
|
|
24544
|
+
};
|
|
24545
|
+
|
|
24546
|
+
var MESFLogbookReport = function () {
|
|
24547
|
+
return React__default.createElement(LogbookPage, null);
|
|
24548
|
+
};
|
|
24549
|
+
|
|
24550
|
+
var sectionLogbookRoutesMESF = [
|
|
24551
|
+
{
|
|
24552
|
+
path: "/logbook/entry",
|
|
24553
|
+
element: React__default.createElement(MESFLogbookEntry),
|
|
24554
|
+
},
|
|
24555
|
+
{
|
|
24556
|
+
path: "/logbook/entry/:shiftId",
|
|
24557
|
+
element: React__default.createElement(MESFLogbookEntry),
|
|
24558
|
+
},
|
|
24559
|
+
{
|
|
24560
|
+
path: "/logbook/report",
|
|
24561
|
+
element: React__default.createElement(MESFLogbookReport),
|
|
24562
|
+
},
|
|
24563
|
+
];
|
|
24564
|
+
var sectionLogbookNavbar = [
|
|
24565
|
+
{
|
|
24566
|
+
id: "logbook",
|
|
24567
|
+
label: "Logbook",
|
|
24568
|
+
items: [
|
|
24569
|
+
{
|
|
24570
|
+
label: "Logbook Entry",
|
|
24571
|
+
to: "/logbook/entry",
|
|
24572
|
+
},
|
|
24573
|
+
{
|
|
24574
|
+
label: "Logbook Report",
|
|
24575
|
+
to: "/logbook/report",
|
|
24576
|
+
},
|
|
24577
|
+
],
|
|
24578
|
+
},
|
|
24579
|
+
];
|
|
24580
|
+
|
|
21991
24581
|
var AreaSelector = function () {
|
|
21992
24582
|
var _a = useState(false), open = _a[0], setOpen = _a[1];
|
|
21993
24583
|
var _b = useState(""), error = _b[0], setError = _b[1];
|
|
@@ -22116,5 +24706,5 @@ var areaSelector = /*#__PURE__*/Object.freeze({
|
|
|
22116
24706
|
AreaSelector: AreaSelector
|
|
22117
24707
|
});
|
|
22118
24708
|
|
|
22119
|
-
export { Account, AssetProvider, AssetTreePicker, AuthContext, AuthProvider, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CreateNewAssetDialog, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ENTRY_INITIAL_VALUES, EditAssetDialog, ErrorModal, ExcelIcon, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HelmetDexteel, IntegerFormatter, LogbookSettingsInitialState, LogbookSettingsProvider, Login, Logout, LongFilterPanel, MESApiService, MESFLogbookEntry, MESFLogbookReport, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, RemoveAssetDialog, SPExecutorPage, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, TimeAndUserMenu, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, TrendingsPage, USER_LABELS, UTLSettingsProvider, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getEntries, getError, getMomentTz, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUserPermissionsFromAPI, getUsers, logbookNavbar, logbookRoutesMESF, renewToken, routeLogbookEntry, routeLogbookReport, useSearchAssets as searchAssets, useSearchSeries as searchSeries, useSearchTagsTree as searchTagsTree, useSearchViewTags as searchViewTags, useSearchViews as searchViews, setPassword, setProfilesToUser, themeDXT, themeMESF, upsertUser, useAssetContext, useContextMenuMESF, useHasPermission, useHasProfile, useLogbookSettings, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useToken, useUTLSettingsContext, useUserContext };
|
|
24709
|
+
export { Account, AssetProvider, AssetTreePicker, AuthContext, AuthProvider, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CreateNewAssetDialog, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ENTRY_INITIAL_VALUES$1 as ENTRY_INITIAL_VALUES, EditAssetDialog, ErrorModal, ExcelIcon, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HelmetDexteel, IntegerFormatter, LogbookSettingsInitialState, LogbookSettingsProvider, Login, Logout, LongFilterPanel, MESApiService, MESFLogbookEntry$1 as MESFLogbookEntry, MESFLogbookReport$1 as MESFLogbookReport, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, RemoveAssetDialog, SPExecutorPage, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, TimeAndUserMenu, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, TrendingsPage, USER_LABELS, UTLSettingsProvider, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getEntries$1 as getEntries, getError, getMomentTz, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUserPermissionsFromAPI, getUsers, logbookNavbar, logbookRoutesMESF, renewToken, routeLogbookEntry$1 as routeLogbookEntry, routeLogbookReport, useSearchAssets as searchAssets, useSearchSeries as searchSeries, useSearchTagsTree as searchTagsTree, useSearchViewTags as searchViewTags, useSearchViews as searchViews, sectionLogbookNavbar, sectionLogbookRoutesMESF, setPassword, setProfilesToUser, themeDXT, themeMESF, upsertUser, useAssetContext, useContextMenuMESF, useHasPermission, useHasProfile, useLogbookSettings, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useToken, useUTLSettingsContext, useUserContext };
|
|
22120
24710
|
//# sourceMappingURL=index.esm.js.map
|