@plusscommunities/pluss-maintenance-web-a 1.3.2-beta.0 → 1.3.3-beta.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/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
2
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
2
  import { Component, useState, useEffect } from 'react';
4
3
  import { connect } from 'react-redux';
@@ -13,7 +12,7 @@ import { Link } from 'react-router-dom';
13
12
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
13
  import Textarea from 'react-textarea-autosize';
15
14
 
16
- var values = {
15
+ const values = {
17
16
  featureKey: "maintenanceA",
18
17
  aliases: ["maintenanceTrackingA", "maintenanceTypesA", "maintenancerequestA"],
19
18
  serviceKey: "maintenanceA",
@@ -81,7 +80,7 @@ var values = {
81
80
  };
82
81
 
83
82
  // import * as PlussCore from '../../pluss-core/src';
84
- var FeatureConfig = {
83
+ const FeatureConfig = {
85
84
  key: values.featureKey,
86
85
  aliases: values.aliases,
87
86
  singularName: values.textSingularName,
@@ -219,22 +218,22 @@ var FeatureConfig = {
219
218
  notificationPreference: values.notificationPreference
220
219
  };
221
220
 
222
- var JOBS_LOADED = values.actionJobsLoaded;
223
- var JOBS_LOADING = values.actionJobsLoading;
224
- var JOBS_REMOVED = values.actionJobsRemoved;
225
- var JOBS_TYPES_LOADED = values.actionJobsTypesLoaded;
226
- var JOBS_STATUSES_LOADED = values.actionJobsStatusesLoaded;
227
- var JOBS_HIDE_SEEN = values.actionJobsHideSeen;
221
+ const JOBS_LOADED = values.actionJobsLoaded;
222
+ const JOBS_LOADING = values.actionJobsLoading;
223
+ const JOBS_REMOVED = values.actionJobsRemoved;
224
+ const JOBS_TYPES_LOADED = values.actionJobsTypesLoaded;
225
+ const JOBS_STATUSES_LOADED = values.actionJobsStatusesLoaded;
226
+ const JOBS_HIDE_SEEN = values.actionJobsHideSeen;
228
227
 
229
228
  function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
230
229
  function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
231
- var {
230
+ const {
232
231
  Helper: Helper$6,
233
232
  Session: Session$9
234
233
  } = PlussCore;
235
- var maintenanceActions = {
234
+ const maintenanceActions = {
236
235
  getJobType: (site, typeId) => {
237
- var url = Helper$6.getUrl(values.serviceKey, "getjobtype");
236
+ let url = Helper$6.getUrl(values.serviceKey, "getjobtype");
238
237
  return Session$9.authedFunction({
239
238
  method: "POST",
240
239
  url,
@@ -245,7 +244,7 @@ var maintenanceActions = {
245
244
  });
246
245
  },
247
246
  getJobTypes: (site, id) => {
248
- var url = Helper$6.getUrl(values.serviceKey, "getjobtypes");
247
+ let url = Helper$6.getUrl(values.serviceKey, "getjobtypes");
249
248
  return Session$9.authedFunction({
250
249
  method: "POST",
251
250
  url,
@@ -255,7 +254,7 @@ var maintenanceActions = {
255
254
  });
256
255
  },
257
256
  getJob: (site, id) => {
258
- var url = Helper$6.getUrl(values.serviceKey, "getJob");
257
+ let url = Helper$6.getUrl(values.serviceKey, "getJob");
259
258
  return Session$9.authedFunction({
260
259
  method: "POST",
261
260
  url,
@@ -266,7 +265,7 @@ var maintenanceActions = {
266
265
  });
267
266
  },
268
267
  getJobByJobId: (site, jobId) => {
269
- var url = Helper$6.getUrl(values.serviceKey, "getJob");
268
+ let url = Helper$6.getUrl(values.serviceKey, "getJob");
270
269
  return Session$9.authedFunction({
271
270
  method: "POST",
272
271
  url,
@@ -276,9 +275,9 @@ var maintenanceActions = {
276
275
  }
277
276
  });
278
277
  },
279
- getJobs: function getJobs(site) {
280
- var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
281
- var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
278
+ getJobs: function (site) {
279
+ let status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
280
+ let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
282
281
  return Session$9.authedFunction({
283
282
  method: "POST",
284
283
  url: Helper$6.getUrl(values.serviceKey, "getJobs"),
@@ -290,7 +289,7 @@ var maintenanceActions = {
290
289
  });
291
290
  },
292
291
  getJobs2: (site, status, type, lastKey) => {
293
- var query = {
292
+ const query = {
294
293
  site
295
294
  };
296
295
  if (status) {
@@ -307,11 +306,11 @@ var maintenanceActions = {
307
306
  url: Helper$6.getUrl(values.serviceKey, "get/requests", query)
308
307
  });
309
308
  },
310
- getJobsRecursive: function getJobsRecursive(site, status, type, lastKey) {
311
- var jobs = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
309
+ getJobsRecursive: function (site, status, type, lastKey) {
310
+ let jobs = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
312
311
  return new Promise(resolve => {
313
312
  maintenanceActions.getJobs2(site, status, type, lastKey).then(jobRes => {
314
- var newJobs = [...jobs, ...jobRes.data.Items];
313
+ const newJobs = [...jobs, ...jobRes.data.Items];
315
314
  if (!jobRes.data.LastKey) {
316
315
  return resolve(newJobs);
317
316
  }
@@ -423,7 +422,7 @@ var maintenanceActions = {
423
422
  });
424
423
  },
425
424
  addJobType: (site, name, email, description, level, hasCustomFields, customFields) => {
426
- var data = {
425
+ const data = {
427
426
  site,
428
427
  name,
429
428
  email,
@@ -439,7 +438,7 @@ var maintenanceActions = {
439
438
  });
440
439
  },
441
440
  editJobType: (site, id, name, email, description, level, hasCustomFields, customFields) => {
442
- var data = {
441
+ const data = {
443
442
  site,
444
443
  id,
445
444
  name,
@@ -485,13 +484,13 @@ var maintenanceActions = {
485
484
  }
486
485
  };
487
486
 
488
- var {
487
+ const {
489
488
  Helper: Helper$5,
490
489
  Session: Session$8
491
490
  } = PlussCore;
492
- var reactionActions = {
491
+ const reactionActions = {
493
492
  addComment: (entityId, entityType, entityName, site, comment, image, parentId) => {
494
- var data = {
493
+ const data = {
495
494
  entityId,
496
495
  entityType,
497
496
  entityName,
@@ -518,7 +517,7 @@ var reactionActions = {
518
517
  // });
519
518
  // },
520
519
  getComments: (entityId, entityType, minTime) => {
521
- var query = {
520
+ const query = {
522
521
  entityId,
523
522
  entityType
524
523
  };
@@ -532,12 +531,12 @@ var reactionActions = {
532
531
  }
533
532
  };
534
533
 
535
- var {
534
+ const {
536
535
  Apis: Apis$2
537
536
  } = PlussCore;
538
- var analyticsActions = Apis$2.analyticsActions;
539
- var userActions = Apis$2.userActions;
540
- var stringActions = Apis$2.stringActions;
537
+ const analyticsActions = Apis$2.analyticsActions;
538
+ const userActions = Apis$2.userActions;
539
+ const stringActions = Apis$2.stringActions;
541
540
 
542
541
  var jobStatusOptions = [
543
542
  {
@@ -560,16 +559,16 @@ var jobStatusOptions = [
560
559
  }
561
560
  ];
562
561
 
563
- var {
562
+ const {
564
563
  Helper: Helper$4
565
564
  } = PlussCore;
566
- var jobsUpdate = (site, isdashboard) => {
565
+ const jobsUpdate = (site, isdashboard) => {
567
566
  return dispatch => {
568
567
  if (isdashboard) dispatch({
569
568
  type: JOBS_LOADING
570
569
  });
571
570
  maintenanceActions.getJobsRecursive(site).then(res => {
572
- var currentSite = Helper$4.readStorageWithCookie("site");
571
+ const currentSite = Helper$4.readStorageWithCookie("site");
573
572
  if (!_.isEmpty(res) && res[0].site === currentSite) {
574
573
  dispatch({
575
574
  type: JOBS_LOADED,
@@ -584,19 +583,19 @@ var jobsUpdate = (site, isdashboard) => {
584
583
  });
585
584
  };
586
585
  };
587
- var jobsLoaded = events => {
586
+ const jobsLoaded = events => {
588
587
  return {
589
588
  type: JOBS_LOADED,
590
589
  payload: events
591
590
  };
592
591
  };
593
- var removeJob = id => {
592
+ const removeJob = id => {
594
593
  return {
595
594
  type: JOBS_REMOVED,
596
595
  payload: id
597
596
  };
598
597
  };
599
- var jobTypesUpdate = site => {
598
+ const jobTypesUpdate = site => {
600
599
  return dispatch => {
601
600
  maintenanceActions.getJobTypes(site).then(res => {
602
601
  dispatch({
@@ -606,14 +605,14 @@ var jobTypesUpdate = site => {
606
605
  });
607
606
  };
608
607
  };
609
- var jobTypesLoaded = events => {
608
+ const jobTypesLoaded = events => {
610
609
  return {
611
610
  type: JOBS_TYPES_LOADED,
612
611
  payload: events
613
612
  };
614
613
  };
615
- var jobStatusesUpdate = function jobStatusesUpdate(site) {
616
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
614
+ const jobStatusesUpdate = function (site) {
615
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
617
616
  return dispatch => {
618
617
  stringActions.getString(site, values.stringConfigJobStatus).then(res => {
619
618
  dispatch({
@@ -630,14 +629,14 @@ var jobStatusesUpdate = function jobStatusesUpdate(site) {
630
629
  });
631
630
  };
632
631
  };
633
- var jobStatusesLoaded = statuses => {
632
+ const jobStatusesLoaded = statuses => {
634
633
  return {
635
634
  type: JOBS_STATUSES_LOADED,
636
635
  payload: statuses
637
636
  };
638
637
  };
639
- var jobHideSeenUpdate = function jobHideSeenUpdate(site) {
640
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
638
+ const jobHideSeenUpdate = function (site) {
639
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
641
640
  return dispatch => {
642
641
  stringActions.getString(site, values.stringConfigHideSeen).then(res => {
643
642
  dispatch({
@@ -654,7 +653,7 @@ var jobHideSeenUpdate = function jobHideSeenUpdate(site) {
654
653
  });
655
654
  };
656
655
  };
657
- var jobHideSeenLoaded = hide => {
656
+ const jobHideSeenLoaded = hide => {
658
657
  return {
659
658
  type: JOBS_HIDE_SEEN,
660
659
  payload: hide
@@ -710,31 +709,29 @@ var jobPriorityOptions = [
710
709
  }
711
710
  ];
712
711
 
713
- var STATUS_IMCOMPLETE = "All Incomplete";
714
- var STATUS_NOT_ACTIONED = "Not Actioned";
715
- var STATUS_IN_PROGRESS = "In Progress";
716
- var STATUS_COMPLETED = "Completed";
717
- var getDefaultPriority = () => jobPriorityOptions.find(p => p.default);
718
- var getJobPriority = priority => {
719
- var priorityOption = null;
712
+ const STATUS_IMCOMPLETE = "All Incomplete";
713
+ const STATUS_NOT_ACTIONED = "Not Actioned";
714
+ const STATUS_IN_PROGRESS = "In Progress";
715
+ const STATUS_COMPLETED = "Completed";
716
+ const getDefaultPriority = () => jobPriorityOptions.find(p => p.default);
717
+ const getJobPriority = priority => {
718
+ let priorityOption = null;
720
719
  if (priority) priorityOption = jobPriorityOptions.find(p => p.name === priority);
721
720
  return priorityOption || getDefaultPriority();
722
721
  };
723
722
 
724
723
  function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
725
724
  function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
726
- var {
725
+ const {
727
726
  Session: Session$7,
728
727
  Components: Components$7,
729
728
  Analytics: Analytics$2
730
729
  } = PlussCore;
731
730
  class JobList extends Component {
732
731
  constructor(props) {
733
- var _this;
734
732
  super(props);
735
- _this = this;
736
733
  _defineProperty(this, "setRequesters", jobs => {
737
- var requesters = _.orderBy(_.uniqBy(jobs.map(j => ({
734
+ const requesters = _.orderBy(_.uniqBy(jobs.map(j => ({
738
735
  id: j.userID,
739
736
  displayName: j.userName,
740
737
  profilePic: j.userProfilePic
@@ -743,32 +740,32 @@ class JobList extends Component {
743
740
  requesters
744
741
  });
745
742
  });
746
- _defineProperty(this, "getJobs", /*#__PURE__*/_asyncToGenerator(function* () {
747
- var {
743
+ _defineProperty(this, "getJobs", async () => {
744
+ const {
748
745
  auth
749
- } = _this.props;
746
+ } = this.props;
750
747
  try {
751
- var res = yield maintenanceActions.getJobsRecursive(auth.site);
748
+ const res = await maintenanceActions.getJobsRecursive(auth.site);
752
749
  if (!_.isEmpty(res) && res[0].site === auth.site) {
753
- _this.setRequesters(res);
754
- _this.props.jobsLoaded(res);
750
+ this.setRequesters(res);
751
+ this.props.jobsLoaded(res);
755
752
  }
756
753
  } catch (error) {
757
754
  console.error("getJobs", error);
758
755
  }
759
- }));
760
- _defineProperty(this, "getAssignees", /*#__PURE__*/_asyncToGenerator(function* () {
756
+ });
757
+ _defineProperty(this, "getAssignees", async () => {
761
758
  try {
762
- var res = yield maintenanceActions.getAssignees(_this.props.auth.site);
763
- _this.setState({
759
+ const res = await maintenanceActions.getAssignees(this.props.auth.site);
760
+ this.setState({
764
761
  assignees: res.data.Users
765
762
  });
766
763
  } catch (error) {
767
764
  console.error("getAssignees", error);
768
765
  }
769
- }));
766
+ });
770
767
  _defineProperty(this, "sortByCol", col => {
771
- var {
768
+ const {
772
769
  sortColumn,
773
770
  sortDesc
774
771
  } = this.state;
@@ -783,23 +780,18 @@ class JobList extends Component {
783
780
  });
784
781
  }
785
782
  });
786
- _defineProperty(this, "onRemoveRequest", /*#__PURE__*/function () {
787
- var _ref3 = _asyncToGenerator(function* (request) {
788
- if (window.confirm(values.textAreYouSureYouWantToDelete)) {
789
- _this.props.removeJob(request.id);
790
- try {
791
- yield maintenanceActions.deleteJob(_this.props.auth.site, request.id);
792
- _this.getJobs();
793
- } catch (error) {
794
- console.log("onRemoveRequest", error);
795
- alert("Something went wrong with the request. Please try again.");
796
- }
783
+ _defineProperty(this, "onRemoveRequest", async request => {
784
+ if (window.confirm(values.textAreYouSureYouWantToDelete)) {
785
+ this.props.removeJob(request.id);
786
+ try {
787
+ await maintenanceActions.deleteJob(this.props.auth.site, request.id);
788
+ this.getJobs();
789
+ } catch (error) {
790
+ console.log("onRemoveRequest", error);
791
+ alert("Something went wrong with the request. Please try again.");
797
792
  }
798
- });
799
- return function (_x) {
800
- return _ref3.apply(this, arguments);
801
- };
802
- }());
793
+ }
794
+ });
803
795
  _defineProperty(this, "openFilter", filter => {
804
796
  this.setState({
805
797
  filterOpen: filter
@@ -852,15 +844,15 @@ class JobList extends Component {
852
844
  if (!this.isValidTimeFilter()) {
853
845
  return;
854
846
  }
855
- var startTime = 0;
856
- var endTime = moment().endOf("d").valueOf();
857
- var text = "";
847
+ let startTime = 0;
848
+ let endTime = moment().endOf("d").valueOf();
849
+ let text = "";
858
850
  if (this.state.selectedTimeFilter.dayCount > 0) {
859
851
  startTime = moment().add(-this.state.selectedTimeFilter.dayCount, "d").startOf("d").valueOf();
860
852
  text = this.state.selectedTimeFilter.text;
861
853
  } else {
862
- var startDate = moment(this.state.timeFilterStart).startOf("d");
863
- var endDate = moment(this.state.timeFilterEnd).endOf("d");
854
+ const startDate = moment(this.state.timeFilterStart).startOf("d");
855
+ const endDate = moment(this.state.timeFilterEnd).endOf("d");
864
856
  startTime = startDate.valueOf();
865
857
  endTime = endDate.valueOf();
866
858
  text = "".concat(startDate.format("DD/MM/YYYY"), " to ").concat(endDate.format("DD/MM/YYYY"));
@@ -931,7 +923,7 @@ class JobList extends Component {
931
923
  this.closeFilter();
932
924
  });
933
925
  _defineProperty(this, "onHandleSearchChange", event => {
934
- var thisSearchTime = moment().valueOf();
926
+ const thisSearchTime = moment().valueOf();
935
927
  this.setState({
936
928
  search: event.target.value,
937
929
  lastSearch: thisSearchTime
@@ -946,7 +938,7 @@ class JobList extends Component {
946
938
  }, 500);
947
939
  });
948
940
  _defineProperty(this, "getSource", () => {
949
- var source = this.props.source;
941
+ let source = this.props.source;
950
942
 
951
943
  // filter by time
952
944
  if (this.state.selectedTimeFilterStart && this.state.selectedTimeFilterEnd) {
@@ -964,7 +956,7 @@ class JobList extends Component {
964
956
 
965
957
  // filter by priority
966
958
  if (this.state.selectedPriorityFilter) {
967
- var defaultPriority = getDefaultPriority().name;
959
+ const defaultPriority = getDefaultPriority().name;
968
960
  source = _.filter(source, r => {
969
961
  return r.priority === this.state.selectedPriorityFilter || this.state.selectedPriorityFilter === defaultPriority && _.isNil(r.priority);
970
962
  });
@@ -972,12 +964,12 @@ class JobList extends Component {
972
964
 
973
965
  // filter by status
974
966
  if (this.state.selectedStatusFilter) {
975
- var {
967
+ const {
976
968
  statusTypes
977
969
  } = this.props;
978
- var defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
970
+ const defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
979
971
  source = _.filter(source, r => {
980
- var status = statusTypes.find(s => s.text === r.status) || defaultStatus;
972
+ const status = statusTypes.find(s => s.text === r.status) || defaultStatus;
981
973
  if (this.state.selectedStatusFilter === STATUS_IMCOMPLETE) {
982
974
  return status.category !== STATUS_COMPLETED;
983
975
  }
@@ -1033,18 +1025,18 @@ class JobList extends Component {
1033
1025
  }
1034
1026
  });
1035
1027
  _defineProperty(this, "getCustomFields", (job, customColumns) => {
1036
- var {
1028
+ const {
1037
1029
  customFields,
1038
1030
  type
1039
1031
  } = job;
1040
- var customValues = {};
1032
+ const customValues = {};
1041
1033
  if (customFields && Array.isArray(customFields)) {
1042
1034
  customFields.forEach(field => {
1043
1035
  // Exclude un-exportable fields
1044
1036
  if (["image", "document", "staticTitle", "staticText"].includes(field.type)) return;
1045
- var fieldKey = "".concat(_.camelCase(type), ".").concat(_.camelCase(field.label));
1037
+ const fieldKey = "".concat(_.camelCase(type), ".").concat(_.camelCase(field.label));
1046
1038
  // Build custom columns
1047
- var exists = customColumns.find(c => c.key === fieldKey);
1039
+ const exists = customColumns.find(c => c.key === fieldKey);
1048
1040
  if (!exists) {
1049
1041
  customColumns.push({
1050
1042
  label: field.label,
@@ -1058,20 +1050,20 @@ class JobList extends Component {
1058
1050
  return customValues;
1059
1051
  });
1060
1052
  _defineProperty(this, "getExportSource", () => {
1061
- var customColumns = [];
1062
- var defaultPriority = getDefaultPriority().name;
1063
- var source = this.getSource().map(r => {
1064
- var history = r.history || [];
1065
- var progressEntry = _.find(history, e => {
1053
+ const customColumns = [];
1054
+ const defaultPriority = getDefaultPriority().name;
1055
+ const source = this.getSource().map(r => {
1056
+ const history = r.history || [];
1057
+ const progressEntry = _.find(history, e => {
1066
1058
  return e.status !== "Unassigned";
1067
1059
  });
1068
- var completedEntry = _.find(history, e => {
1060
+ const completedEntry = _.find(history, e => {
1069
1061
  return e.status === "Completed";
1070
1062
  });
1071
- var progressTime = null;
1072
- var completedTime = null;
1073
- var progressDuration = null;
1074
- var completedDuration = null;
1063
+ let progressTime = null;
1064
+ let completedTime = null;
1065
+ let progressDuration = null;
1066
+ let completedDuration = null;
1075
1067
  if (progressEntry) {
1076
1068
  progressTime = moment.utc(progressEntry.timestamp).format();
1077
1069
  progressDuration = moment.utc(progressEntry.timestamp).unix() - moment.utc(r.createdTime).unix();
@@ -1080,7 +1072,7 @@ class JobList extends Component {
1080
1072
  completedTime = moment.utc(completedEntry.timestamp).format();
1081
1073
  completedDuration = moment.utc(completedEntry.timestamp).unix() - moment.utc(r.createdTime).unix();
1082
1074
  }
1083
- var notes = "";
1075
+ let notes = "";
1084
1076
  (r.Notes || []).forEach((note, index) => {
1085
1077
  if (index > 0) {
1086
1078
  notes += "\n\n";
@@ -1093,8 +1085,8 @@ class JobList extends Component {
1093
1085
  }
1094
1086
  notes += note.Note;
1095
1087
  });
1096
- var customFieldValues = this.getCustomFields(r, customColumns);
1097
- var priority = r.priority || defaultPriority;
1088
+ const customFieldValues = this.getCustomFields(r, customColumns);
1089
+ const priority = r.priority || defaultPriority;
1098
1090
  return _objectSpread$7(_objectSpread$7(_objectSpread$7({}, r), customFieldValues), {}, {
1099
1091
  notes,
1100
1092
  progressTime,
@@ -1106,8 +1098,8 @@ class JobList extends Component {
1106
1098
  });
1107
1099
 
1108
1100
  // Compose revised columns list with custom fields
1109
- var index = this.exportColumns.findIndex(c => c.key === "notes");
1110
- var columns = [...this.exportColumns.slice(0, index), ...customColumns, ...this.exportColumns.slice(index)];
1101
+ const index = this.exportColumns.findIndex(c => c.key === "notes");
1102
+ const columns = [...this.exportColumns.slice(0, index), ...customColumns, ...this.exportColumns.slice(index)];
1111
1103
  return {
1112
1104
  columns,
1113
1105
  source
@@ -1237,7 +1229,7 @@ class JobList extends Component {
1237
1229
  });
1238
1230
  }
1239
1231
  if (this.state.filterOpen === "status") {
1240
- var {
1232
+ const {
1241
1233
  statusTypes
1242
1234
  } = this.props;
1243
1235
  return /*#__PURE__*/jsx(Components$7.Popup, {
@@ -1283,7 +1275,7 @@ class JobList extends Component {
1283
1275
  });
1284
1276
  }
1285
1277
  if (this.state.filterOpen === "user") {
1286
- var userContent = null;
1278
+ let userContent = null;
1287
1279
  if (this.state.selectedAssignee) {
1288
1280
  userContent = /*#__PURE__*/jsx("div", {
1289
1281
  children: /*#__PURE__*/jsx(Components$7.UserListing, {
@@ -1338,9 +1330,9 @@ class JobList extends Component {
1338
1330
  });
1339
1331
  }
1340
1332
  if (this.state.filterOpen === "requester") {
1341
- var _userContent = null;
1333
+ let userContent = null;
1342
1334
  if (this.state.selectedRequester) {
1343
- _userContent = /*#__PURE__*/jsx("div", {
1335
+ userContent = /*#__PURE__*/jsx("div", {
1344
1336
  children: /*#__PURE__*/jsx(Components$7.UserListing, {
1345
1337
  user: this.state.selectedRequester,
1346
1338
  rightContent: /*#__PURE__*/jsx(Icon, {
@@ -1354,7 +1346,7 @@ class JobList extends Component {
1354
1346
  }, this.state.selectedRequester.id)
1355
1347
  });
1356
1348
  } else {
1357
- _userContent = /*#__PURE__*/jsxs("div", {
1349
+ userContent = /*#__PURE__*/jsxs("div", {
1358
1350
  children: [/*#__PURE__*/jsx(Components$7.GenericInput, {
1359
1351
  id: "requesterSearch",
1360
1352
  type: "text"
@@ -1389,22 +1381,22 @@ class JobList extends Component {
1389
1381
  text: "Select",
1390
1382
  isActive: true
1391
1383
  }],
1392
- children: _userContent
1384
+ children: userContent
1393
1385
  });
1394
1386
  }
1395
1387
  return null;
1396
1388
  }
1397
1389
  renderRequests() {
1398
- var {
1390
+ const {
1399
1391
  statusTypes
1400
1392
  } = this.props;
1401
- var defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
1393
+ const defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
1402
1394
  return this.getSource().map((ev, index) => {
1403
1395
  if (!ev) {
1404
1396
  return null;
1405
1397
  }
1406
- var status = ev.status && statusTypes.find(s => s.text === ev.status) || defaultStatus;
1407
- var priority = getJobPriority(ev.priority);
1398
+ const status = ev.status && statusTypes.find(s => s.text === ev.status) || defaultStatus;
1399
+ const priority = getJobPriority(ev.priority);
1408
1400
  return /*#__PURE__*/jsxs("tr", {
1409
1401
  children: [/*#__PURE__*/jsx("td", {
1410
1402
  children: ev.jobId
@@ -1497,7 +1489,7 @@ class JobList extends Component {
1497
1489
  });
1498
1490
  }
1499
1491
  renderSort(col) {
1500
- var {
1492
+ const {
1501
1493
  sortColumn,
1502
1494
  sortDesc
1503
1495
  } = this.state;
@@ -1514,7 +1506,7 @@ class JobList extends Component {
1514
1506
  return " table--columnActive";
1515
1507
  }
1516
1508
  renderEmpty() {
1517
- var title = this.props.strings["".concat(values.featureKey, "_textTitleRequests")] || values.textTitleRequests;
1509
+ const title = this.props.strings["".concat(values.featureKey, "_textTitleRequests")] || values.textTitleRequests;
1518
1510
  return /*#__PURE__*/jsxs("div", {
1519
1511
  style: {
1520
1512
  display: "flex",
@@ -1653,42 +1645,42 @@ class JobList extends Component {
1653
1645
  });
1654
1646
  }
1655
1647
  renderFilters() {
1656
- var typeFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1648
+ let typeFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1657
1649
  className: "marginRight-10",
1658
1650
  onClick: () => {
1659
1651
  this.openFilter("type");
1660
1652
  },
1661
1653
  text: values.textJobType
1662
1654
  });
1663
- var statusFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1655
+ let statusFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1664
1656
  className: "marginRight-10",
1665
1657
  onClick: () => {
1666
1658
  this.openFilter("status");
1667
1659
  },
1668
1660
  text: "Status"
1669
1661
  });
1670
- var priorityFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1662
+ let priorityFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1671
1663
  className: "marginRight-10",
1672
1664
  onClick: () => {
1673
1665
  this.openFilter("priority");
1674
1666
  },
1675
1667
  text: "Priority"
1676
1668
  });
1677
- var timeFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1669
+ let timeFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1678
1670
  className: "marginRight-10",
1679
1671
  onClick: () => {
1680
1672
  this.openFilter("time");
1681
1673
  },
1682
1674
  text: "Time"
1683
1675
  });
1684
- var userFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1676
+ let userFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1685
1677
  className: "marginRight-10",
1686
1678
  onClick: () => {
1687
1679
  this.openFilter("user");
1688
1680
  },
1689
1681
  text: "Assigned To"
1690
1682
  });
1691
- var requesterFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1683
+ let requesterFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1692
1684
  className: "marginRight-10",
1693
1685
  onClick: () => {
1694
1686
  this.openFilter("requester");
@@ -1814,7 +1806,7 @@ class JobList extends Component {
1814
1806
  if (!this.state.exportCsvOpen) {
1815
1807
  return null;
1816
1808
  }
1817
- var {
1809
+ const {
1818
1810
  columns,
1819
1811
  source
1820
1812
  } = this.getExportSource();
@@ -1834,8 +1826,8 @@ class JobList extends Component {
1834
1826
  });
1835
1827
  }
1836
1828
  }
1837
- var mapStateToProps$7 = state => {
1838
- var {
1829
+ const mapStateToProps$7 = state => {
1830
+ const {
1839
1831
  auth
1840
1832
  } = state;
1841
1833
  return {
@@ -1851,27 +1843,25 @@ var JobList$1 = connect(mapStateToProps$7, {
1851
1843
  jobStatusesUpdate
1852
1844
  })(withRouter(JobList));
1853
1845
 
1854
- var {
1846
+ const {
1855
1847
  Session: Session$6,
1856
1848
  Components: Components$6
1857
1849
  } = PlussCore;
1858
1850
  class JobTypes extends Component {
1859
1851
  constructor(props) {
1860
- var _this;
1861
1852
  super(props);
1862
- _this = this;
1863
- _defineProperty(this, "getJobTypes", /*#__PURE__*/_asyncToGenerator(function* () {
1853
+ _defineProperty(this, "getJobTypes", async () => {
1864
1854
  try {
1865
- var res = yield maintenanceActions.getJobTypes(_this.props.auth.site);
1866
- if (res.data != null) _this.props.jobTypesLoaded(res.data);
1855
+ const res = await maintenanceActions.getJobTypes(this.props.auth.site);
1856
+ if (res.data != null) this.props.jobTypesLoaded(res.data);
1867
1857
  } catch (error) {
1868
1858
  console.error("getJobTypes", error);
1869
1859
  } finally {
1870
- _this.setState({
1860
+ this.setState({
1871
1861
  loading: false
1872
1862
  });
1873
1863
  }
1874
- }));
1864
+ });
1875
1865
  _defineProperty(this, "sortByCol", col => {
1876
1866
  if (this.state.sortColumn === col) {
1877
1867
  this.setState({
@@ -1884,28 +1874,23 @@ class JobTypes extends Component {
1884
1874
  });
1885
1875
  }
1886
1876
  });
1887
- _defineProperty(this, "onRemoveJobType", /*#__PURE__*/function () {
1888
- var _ref2 = _asyncToGenerator(function* (ev) {
1889
- if (!window.confirm("Are you sure you want to delete ".concat(ev.typeName, "?"))) return;
1890
- try {
1891
- yield maintenanceActions.deleteJobType(_this.props.auth.site, ev.id);
1892
- var index = _.findIndex(_this.state.jobList, job => {
1893
- return job != null && job.id === ev.id;
1894
- });
1895
- if (index > -1) {
1896
- var newJobTypes = [..._this.state.jobList];
1897
- newJobTypes[index].Deleted = true;
1898
- _this.props.jobTypesLoaded(newJobTypes);
1899
- }
1900
- } catch (error) {
1901
- console.error("onRemoveJobType", error);
1902
- alert("Something went wrong with the request. Please try again.");
1877
+ _defineProperty(this, "onRemoveJobType", async ev => {
1878
+ if (!window.confirm("Are you sure you want to delete ".concat(ev.typeName, "?"))) return;
1879
+ try {
1880
+ await maintenanceActions.deleteJobType(this.props.auth.site, ev.id);
1881
+ const index = _.findIndex(this.state.jobList, job => {
1882
+ return job != null && job.id === ev.id;
1883
+ });
1884
+ if (index > -1) {
1885
+ const newJobTypes = [...this.state.jobList];
1886
+ newJobTypes[index].Deleted = true;
1887
+ this.props.jobTypesLoaded(newJobTypes);
1903
1888
  }
1904
- });
1905
- return function (_x) {
1906
- return _ref2.apply(this, arguments);
1907
- };
1908
- }());
1889
+ } catch (error) {
1890
+ console.error("onRemoveJobType", error);
1891
+ alert("Something went wrong with the request. Please try again.");
1892
+ }
1893
+ });
1909
1894
  this.state = {
1910
1895
  jobList: [],
1911
1896
  sortColumn: "name",
@@ -1929,7 +1914,7 @@ class JobTypes extends Component {
1929
1914
  });
1930
1915
  }
1931
1916
  renderList() {
1932
- var source = _.sortBy(this.state.jobList, this.state.sortColumn);
1917
+ let source = _.sortBy(this.state.jobList, this.state.sortColumn);
1933
1918
  if (this.state.sortDesc) source.reverse();
1934
1919
  source = _.filter(source, ev => {
1935
1920
  if (!ev) return false;
@@ -2064,7 +2049,7 @@ class JobTypes extends Component {
2064
2049
  return this.renderView();
2065
2050
  }
2066
2051
  renderJobTypes() {
2067
- var {
2052
+ const {
2068
2053
  jobList,
2069
2054
  loading
2070
2055
  } = this.state;
@@ -2116,8 +2101,8 @@ class JobTypes extends Component {
2116
2101
  });
2117
2102
  }
2118
2103
  }
2119
- var mapStateToProps$6 = state => {
2120
- var {
2104
+ const mapStateToProps$6 = state => {
2105
+ const {
2121
2106
  auth
2122
2107
  } = state;
2123
2108
  return {
@@ -2132,7 +2117,7 @@ var JobTypes$1 = connect(mapStateToProps$6, {
2132
2117
 
2133
2118
  function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2134
2119
  function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2135
- var {
2120
+ const {
2136
2121
  Session: Session$5,
2137
2122
  Components: Components$5,
2138
2123
  Colours: Colours$3
@@ -2149,9 +2134,9 @@ class Configuration extends Component {
2149
2134
  return true;
2150
2135
  });
2151
2136
  _defineProperty(this, "onMoveStatus", function (index) {
2152
- var up = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2137
+ let up = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2153
2138
  if (_this.state.fetchingStatusTypes) return;
2154
- var statusTypes = _.cloneDeep(_this.state.statusTypes);
2139
+ const statusTypes = _.cloneDeep(_this.state.statusTypes);
2155
2140
  if (up && index > 0) {
2156
2141
  // Moving up
2157
2142
  [statusTypes[index - 1], statusTypes[index]] = [statusTypes[index], statusTypes[index - 1]];
@@ -2167,7 +2152,7 @@ class Configuration extends Component {
2167
2152
  });
2168
2153
  _defineProperty(this, "onEditStatus", index => {
2169
2154
  if (this.state.fetchingStatusTypes) return;
2170
- var status = this.state.statusTypes[index];
2155
+ const status = this.state.statusTypes[index];
2171
2156
  this.setState({
2172
2157
  showWarnings: false,
2173
2158
  showStatusPopup: true,
@@ -2179,14 +2164,14 @@ class Configuration extends Component {
2179
2164
  });
2180
2165
  _defineProperty(this, "onDeleteStatus", index => {
2181
2166
  if (this.state.fetchingStatusTypes) return;
2182
- var statusTypes = _.cloneDeep(this.state.statusTypes);
2167
+ const statusTypes = _.cloneDeep(this.state.statusTypes);
2183
2168
  statusTypes.splice(index, 1);
2184
2169
  this.setState({
2185
2170
  statusTypes
2186
2171
  });
2187
2172
  });
2188
2173
  _defineProperty(this, "onAddStatus", () => {
2189
- var defaultStatus = this.props.statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
2174
+ const defaultStatus = this.props.statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
2190
2175
  this.setState({
2191
2176
  showWarnings: false,
2192
2177
  showStatusPopup: true,
@@ -2197,13 +2182,13 @@ class Configuration extends Component {
2197
2182
  });
2198
2183
  });
2199
2184
  _defineProperty(this, "onSaveStatus", () => {
2200
- var {
2185
+ const {
2201
2186
  selectedStatusIndex,
2202
2187
  statusLabel,
2203
2188
  statusCategory,
2204
2189
  statusColour
2205
2190
  } = this.state;
2206
- var statusTypes = _.cloneDeep(this.state.statusTypes);
2191
+ const statusTypes = _.cloneDeep(this.state.statusTypes);
2207
2192
  if (selectedStatusIndex < 0) {
2208
2193
  statusTypes.push({
2209
2194
  text: statusLabel,
@@ -2212,7 +2197,7 @@ class Configuration extends Component {
2212
2197
  category: statusCategory
2213
2198
  });
2214
2199
  } else {
2215
- var status = statusTypes[selectedStatusIndex];
2200
+ const status = statusTypes[selectedStatusIndex];
2216
2201
  status.text = statusLabel;
2217
2202
  status.color = statusColour;
2218
2203
  status.category = statusCategory;
@@ -2244,30 +2229,30 @@ class Configuration extends Component {
2244
2229
  this.setState({
2245
2230
  success: false,
2246
2231
  submitting: true
2247
- }, /*#__PURE__*/_asyncToGenerator(function* () {
2232
+ }, async () => {
2248
2233
  try {
2249
- var {
2234
+ const {
2250
2235
  statusTypes,
2251
2236
  hideSeen
2252
- } = _this.state;
2253
- yield stringActions.setString(_this.props.auth.site, values.stringConfigJobStatus, statusTypes);
2254
- yield stringActions.setString(_this.props.auth.site, values.stringConfigHideSeen, hideSeen);
2255
- _this.props.jobStatusesLoaded(statusTypes);
2256
- _this.props.jobHideSeenLoaded(hideSeen);
2257
- _this.setState({
2237
+ } = this.state;
2238
+ await stringActions.setString(this.props.auth.site, values.stringConfigJobStatus, statusTypes);
2239
+ await stringActions.setString(this.props.auth.site, values.stringConfigHideSeen, hideSeen);
2240
+ this.props.jobStatusesLoaded(statusTypes);
2241
+ this.props.jobHideSeenLoaded(hideSeen);
2242
+ this.setState({
2258
2243
  success: true
2259
2244
  });
2260
2245
  } catch (error) {
2261
2246
  console.log("onSaveConfig - error", error);
2262
- _this.setState({
2247
+ this.setState({
2263
2248
  success: false
2264
2249
  });
2265
2250
  } finally {
2266
- _this.setState({
2251
+ this.setState({
2267
2252
  submitting: false
2268
2253
  });
2269
2254
  }
2270
- }));
2255
+ });
2271
2256
  });
2272
2257
  this.state = {
2273
2258
  success: false,
@@ -2301,15 +2286,15 @@ class Configuration extends Component {
2301
2286
  }
2302
2287
  }
2303
2288
  validateForm() {
2304
- var {
2289
+ const {
2305
2290
  submitting,
2306
2291
  statusTypes
2307
2292
  } = this.state;
2308
2293
  if (submitting) return false;
2309
2294
 
2310
2295
  // Validate statuses
2311
- var statusesValid = statusTypes.map(status => {
2312
- var {
2296
+ const statusesValid = statusTypes.map(status => {
2297
+ const {
2313
2298
  text,
2314
2299
  category,
2315
2300
  color
@@ -2320,7 +2305,7 @@ class Configuration extends Component {
2320
2305
  return true;
2321
2306
  }
2322
2307
  renderStatuses() {
2323
- var {
2308
+ const {
2324
2309
  statusTypes
2325
2310
  } = this.state;
2326
2311
  return /*#__PURE__*/jsxs("div", {
@@ -2432,7 +2417,7 @@ class Configuration extends Component {
2432
2417
  });
2433
2418
  }
2434
2419
  renderNewStatusPopup() {
2435
- var {
2420
+ const {
2436
2421
  submitting,
2437
2422
  showStatusPopup,
2438
2423
  showWarnings,
@@ -2442,7 +2427,7 @@ class Configuration extends Component {
2442
2427
  statusColour
2443
2428
  } = this.state;
2444
2429
  if (!showStatusPopup) return null;
2445
- var canSave = !submitting && this.isStatusValid(statusLabel, statusCategory, statusColour);
2430
+ const canSave = !submitting && this.isStatusValid(statusLabel, statusCategory, statusColour);
2446
2431
  return /*#__PURE__*/jsxs(Components$5.Popup, {
2447
2432
  maxWidth: 800,
2448
2433
  minWidth: 450,
@@ -2551,7 +2536,7 @@ class Configuration extends Component {
2551
2536
  });
2552
2537
  }
2553
2538
  }
2554
- var styles$6 = {
2539
+ const styles$6 = {
2555
2540
  statusCategoryHeading: {
2556
2541
  marginLeft: 130,
2557
2542
  width: 160,
@@ -2585,8 +2570,8 @@ var styles$6 = {
2585
2570
  marginLeft: 15
2586
2571
  }
2587
2572
  };
2588
- var mapStateToProps$5 = state => {
2589
- var {
2573
+ const mapStateToProps$5 = state => {
2574
+ const {
2590
2575
  auth
2591
2576
  } = state;
2592
2577
  return {
@@ -2602,27 +2587,25 @@ var Configuration$1 = connect(mapStateToProps$5, {
2602
2587
  jobHideSeenLoaded
2603
2588
  })(withRouter(Configuration));
2604
2589
 
2605
- var {
2590
+ const {
2606
2591
  Components: Components$4,
2607
2592
  Session: Session$4,
2608
2593
  Urls
2609
2594
  } = PlussCore;
2610
2595
  class RequestsHub extends Component {
2611
2596
  constructor(props) {
2612
- var _this;
2613
2597
  super(props);
2614
- _this = this;
2615
2598
  _defineProperty(this, "setData", () => {
2616
- var allList = [];
2599
+ const allList = [];
2617
2600
  this.state.allList.forEach(ev => {
2618
2601
  if (ev != null && !ev.Deleted) allList.push(ev);
2619
2602
  });
2620
- var upcoming = _.filter(allList, ev => {
2603
+ const upcoming = _.filter(allList, ev => {
2621
2604
  if (!ev) return false;
2622
2605
  if (ev.status && ev.status === "Completed") return false;
2623
2606
  return true;
2624
2607
  });
2625
- var completed = _.filter(allList, ev => {
2608
+ const completed = _.filter(allList, ev => {
2626
2609
  if (!ev) return false;
2627
2610
  if (ev.status && ev.status === "Completed") return true;
2628
2611
  return false;
@@ -2636,30 +2619,30 @@ class RequestsHub extends Component {
2636
2619
  });
2637
2620
  });
2638
2621
  _defineProperty(this, "getData", () => {
2639
- var {
2622
+ const {
2640
2623
  auth
2641
2624
  } = this.props;
2642
2625
  this.setState({
2643
2626
  loadingAll: true
2644
- }, /*#__PURE__*/_asyncToGenerator(function* () {
2627
+ }, async () => {
2645
2628
  try {
2646
- var res = yield maintenanceActions.getJobsRecursive(auth.site);
2647
- _this.setState({
2629
+ const res = await maintenanceActions.getJobsRecursive(auth.site);
2630
+ this.setState({
2648
2631
  loadingAll: false
2649
2632
  });
2650
2633
  if (!_.isEmpty(res) && res[0].site === auth.site) {
2651
- _this.props.jobsLoaded(res);
2634
+ this.props.jobsLoaded(res);
2652
2635
  }
2653
2636
  } catch (error) {
2654
2637
  console.error("getData", error);
2655
- _this.setState({
2638
+ this.setState({
2656
2639
  loadingAll: false
2657
2640
  });
2658
2641
  }
2659
- }));
2642
+ });
2660
2643
  });
2661
2644
  _defineProperty(this, "onAddNew", () => {
2662
- var {
2645
+ const {
2663
2646
  auth
2664
2647
  } = this.props;
2665
2648
  if (Session$4.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) {
@@ -2667,7 +2650,7 @@ class RequestsHub extends Component {
2667
2650
  }
2668
2651
  });
2669
2652
  _defineProperty(this, "onAddRequestType", () => {
2670
- var {
2653
+ const {
2671
2654
  auth
2672
2655
  } = this.props;
2673
2656
  if (Session$4.validateAccess(auth.site, values.permissionMaintenanceTypes, auth)) {
@@ -2675,7 +2658,7 @@ class RequestsHub extends Component {
2675
2658
  }
2676
2659
  });
2677
2660
  _defineProperty(this, "canAddNew", isClass => {
2678
- var {
2661
+ const {
2679
2662
  auth
2680
2663
  } = this.props;
2681
2664
  if (Session$4.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return isClass ? "" : true;
@@ -2719,7 +2702,7 @@ class RequestsHub extends Component {
2719
2702
  }, this.setData);
2720
2703
  }
2721
2704
  renderLeftBar() {
2722
- var sectionItems = [];
2705
+ const sectionItems = [];
2723
2706
  if (this.canAddNew()) {
2724
2707
  sectionItems.push({
2725
2708
  type: "newButton",
@@ -2767,7 +2750,7 @@ class RequestsHub extends Component {
2767
2750
  }
2768
2751
  });
2769
2752
  }
2770
- var helpGuide = values.hasHelpButton ? {
2753
+ const helpGuide = values.hasHelpButton ? {
2771
2754
  text: "Help with ".concat(values.textTitleRequests),
2772
2755
  url: values.helpGuideURL || Urls.HelpGuide.Maintenance
2773
2756
  } : null;
@@ -2804,7 +2787,7 @@ class RequestsHub extends Component {
2804
2787
  });
2805
2788
  }
2806
2789
  }
2807
- var styles$5 = {
2790
+ const styles$5 = {
2808
2791
  sideBarTitleSection: {
2809
2792
  lineHeight: "40px",
2810
2793
  marginTop: 30,
@@ -2827,8 +2810,8 @@ var styles$5 = {
2827
2810
  color: FeatureConfig.env.colourBrandingOff
2828
2811
  }
2829
2812
  };
2830
- var mapStateToProps$4 = state => {
2831
- var {
2813
+ const mapStateToProps$4 = state => {
2814
+ const {
2832
2815
  auth
2833
2816
  } = state;
2834
2817
  return {
@@ -2843,48 +2826,46 @@ var RequestsHub$1 = connect(mapStateToProps$4, {
2843
2826
 
2844
2827
  function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2845
2828
  function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2846
- var {
2829
+ const {
2847
2830
  Apis: Apis$1,
2848
2831
  Helper: Helper$3,
2849
2832
  Session: Session$3,
2850
2833
  Colours: Colours$2,
2851
2834
  Components: Components$3
2852
2835
  } = PlussCore;
2853
- var IMAGE_SIZE_NOTE = 72;
2836
+ const IMAGE_SIZE_NOTE = 72;
2854
2837
  class Job extends Component {
2855
2838
  constructor(props) {
2856
- var _this;
2857
2839
  super(props);
2858
- _this = this;
2859
- _defineProperty(this, "getJob", /*#__PURE__*/_asyncToGenerator(function* () {
2840
+ _defineProperty(this, "getJob", async () => {
2860
2841
  try {
2861
- var res = yield maintenanceActions.getJob(_this.props.auth.site, _this.state.jobId);
2862
- _this.setState({
2842
+ const res = await maintenanceActions.getJob(this.props.auth.site, this.state.jobId);
2843
+ this.setState({
2863
2844
  updating: false
2864
2845
  });
2865
2846
  res.data.location = res.data.site;
2866
- _this.setJob(res.data);
2847
+ this.setJob(res.data);
2867
2848
  } catch (error) {
2868
2849
  console.error("getJob", error);
2869
2850
  }
2870
- }));
2871
- _defineProperty(this, "getAssignees", /*#__PURE__*/_asyncToGenerator(function* () {
2851
+ });
2852
+ _defineProperty(this, "getAssignees", async () => {
2872
2853
  try {
2873
- var res = yield maintenanceActions.getAssignees(_this.props.auth.site);
2874
- _this.setState({
2854
+ const res = await maintenanceActions.getAssignees(this.props.auth.site);
2855
+ this.setState({
2875
2856
  assignees: res.data.Users
2876
2857
  });
2877
2858
  } catch (error) {
2878
2859
  console.error("getAssignees", error);
2879
2860
  }
2880
- }));
2881
- _defineProperty(this, "getExternalSync", /*#__PURE__*/_asyncToGenerator(function* () {
2861
+ });
2862
+ _defineProperty(this, "getExternalSync", async () => {
2882
2863
  try {
2883
- _this.setState({
2864
+ this.setState({
2884
2865
  loadingExternalSync: true
2885
2866
  });
2886
- var res = yield maintenanceActions.getExternalSync(_this.state.jobId);
2887
- _this.setState({
2867
+ const res = await maintenanceActions.getExternalSync(this.state.jobId);
2868
+ this.setState({
2888
2869
  externalSync: res.data,
2889
2870
  loadingExternalSync: false
2890
2871
  });
@@ -2893,44 +2874,44 @@ class Job extends Component {
2893
2874
  if (error && error.response && error.response.status !== 404) {
2894
2875
  console.error("getExternalSync", error);
2895
2876
  }
2896
- _this.setState({
2877
+ this.setState({
2897
2878
  loadingExternalSync: false
2898
2879
  });
2899
2880
  }
2900
- }));
2901
- _defineProperty(this, "onRetrySync", /*#__PURE__*/_asyncToGenerator(function* () {
2902
- var {
2881
+ });
2882
+ _defineProperty(this, "onRetrySync", async () => {
2883
+ const {
2903
2884
  job
2904
- } = _this.state;
2905
- if (!job || _this.state.retryingSync) return;
2906
- _this.setState({
2885
+ } = this.state;
2886
+ if (!job || this.state.retryingSync) return;
2887
+ this.setState({
2907
2888
  retryingSync: true,
2908
2889
  retrySyncError: null
2909
2890
  });
2910
2891
  try {
2911
- yield maintenanceActions.retrySync(job.id);
2892
+ await maintenanceActions.retrySync(job.id);
2912
2893
  // Refresh job data to get updated history
2913
- yield _this.getJob();
2914
- _this.setState({
2894
+ await this.getJob();
2895
+ this.setState({
2915
2896
  retryingSync: false,
2916
2897
  retrySyncInitiated: true
2917
2898
  });
2918
2899
  } catch (error) {
2919
2900
  console.error("onRetrySync", error);
2920
- var errorMessage = error && error.response && error.response.data && error.response.data.error || "Failed to retry sync. Please try again.";
2921
- _this.setState({
2901
+ const errorMessage = error && error.response && error.response.data && error.response.data.error || "Failed to retry sync. Please try again.";
2902
+ this.setState({
2922
2903
  retryingSync: false,
2923
2904
  retrySyncError: errorMessage
2924
2905
  });
2925
2906
  }
2926
- }));
2907
+ });
2927
2908
  _defineProperty(this, "getStatusType", status => {
2928
- var {
2909
+ const {
2929
2910
  statusTypes
2930
2911
  } = this.props;
2931
- var statusType = statusTypes.find(s => s.text === status);
2912
+ let statusType = statusTypes.find(s => s.text === status);
2932
2913
  if (!statusType) {
2933
- var defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
2914
+ const defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
2934
2915
  statusType = _objectSpread$5(_objectSpread$5({}, defaultStatus), {}, {
2935
2916
  text: status
2936
2917
  });
@@ -2952,7 +2933,7 @@ class Job extends Component {
2952
2933
  isEmpty: true
2953
2934
  }];
2954
2935
  }
2955
- var needToMarkSeen = false;
2936
+ let needToMarkSeen = false;
2956
2937
  if (!job.seen) {
2957
2938
  job.seen = true;
2958
2939
  needToMarkSeen = true;
@@ -2966,7 +2947,7 @@ class Job extends Component {
2966
2947
  });
2967
2948
  _defineProperty(this, "editJob", () => {});
2968
2949
  _defineProperty(this, "isReadyToSaveNote", () => {
2969
- var {
2950
+ const {
2970
2951
  noteAttachments,
2971
2952
  noteInput,
2972
2953
  noteImages
@@ -2981,7 +2962,7 @@ class Job extends Component {
2981
2962
  });
2982
2963
  });
2983
2964
  _defineProperty(this, "onCloseAddNote", () => {
2984
- var newState = {
2965
+ const newState = {
2985
2966
  addNoteOpen: false,
2986
2967
  editingNote: null
2987
2968
  };
@@ -3004,10 +2985,10 @@ class Job extends Component {
3004
2985
  }
3005
2986
  });
3006
2987
  _defineProperty(this, "onHandlePDFFileChange", event => {
3007
- var file = event.target.files[0];
2988
+ const file = event.target.files[0];
3008
2989
  if (!file || this.state.uploadingNoteAttachment) return;
3009
- var noteAttachments = [...this.state.noteAttachments];
3010
- var newAttachment = {
2990
+ const noteAttachments = [...this.state.noteAttachments];
2991
+ const newAttachment = {
3011
2992
  Uploading: true,
3012
2993
  Title: file.name
3013
2994
  };
@@ -3031,9 +3012,9 @@ class Job extends Component {
3031
3012
  event.target.value = "";
3032
3013
  });
3033
3014
  _defineProperty(this, "onRemoveAttachment", a => {
3034
- var index = this.state.noteAttachments.indexOf(a);
3015
+ const index = this.state.noteAttachments.indexOf(a);
3035
3016
  if (index > -1) {
3036
- var newAttachments = [...this.state.noteAttachments];
3017
+ const newAttachments = [...this.state.noteAttachments];
3037
3018
  newAttachments.splice(index, 1);
3038
3019
  this.setState({
3039
3020
  noteAttachments: newAttachments
@@ -3055,54 +3036,49 @@ class Job extends Component {
3055
3036
  selectedAssignee: user
3056
3037
  });
3057
3038
  });
3058
- _defineProperty(this, "onConfirmAssignee", /*#__PURE__*/_asyncToGenerator(function* () {
3059
- _this.setState({
3039
+ _defineProperty(this, "onConfirmAssignee", async () => {
3040
+ this.setState({
3060
3041
  confirmingAssignee: true
3061
3042
  });
3062
3043
  try {
3063
- if (_this.state.selectedAssignee) {
3064
- yield _this.onAssignUser(_this.state.selectedAssignee.id);
3044
+ if (this.state.selectedAssignee) {
3045
+ await this.onAssignUser(this.state.selectedAssignee.id);
3065
3046
  }
3066
- _this.onCloseSelectAssignee();
3047
+ this.onCloseSelectAssignee();
3067
3048
  } catch (error) {
3068
3049
  console.error("onConfirmAssignee", error);
3069
3050
  }
3070
- _this.setState({
3051
+ this.setState({
3071
3052
  confirmingAssignee: false
3072
3053
  });
3073
- }));
3054
+ });
3074
3055
  // Method to handle user assignment
3075
- _defineProperty(this, "onAssignUser", /*#__PURE__*/function () {
3076
- var _ref6 = _asyncToGenerator(function* (userId) {
3077
- try {
3078
- var res = yield maintenanceActions.assignJob(_this.state.jobId, userId);
3079
- _this.getJob();
3080
- } catch (err) {
3081
- console.error("onAssignUser", err);
3082
- }
3083
- });
3084
- return function (_x) {
3085
- return _ref6.apply(this, arguments);
3086
- };
3087
- }());
3088
- _defineProperty(this, "onConfirmAddNote", /*#__PURE__*/_asyncToGenerator(function* () {
3089
- if (!_this.isReadyToSaveNote()) return;
3056
+ _defineProperty(this, "onAssignUser", async userId => {
3090
3057
  try {
3091
- _this.setState({
3058
+ const res = await maintenanceActions.assignJob(this.state.jobId, userId);
3059
+ this.getJob();
3060
+ } catch (err) {
3061
+ console.error("onAssignUser", err);
3062
+ }
3063
+ });
3064
+ _defineProperty(this, "onConfirmAddNote", async () => {
3065
+ if (!this.isReadyToSaveNote()) return;
3066
+ try {
3067
+ this.setState({
3092
3068
  submittingNote: true
3093
3069
  });
3094
- var res = yield _this.state.editingNote ? maintenanceActions.editNote(_this.state.jobId, _this.state.editingNote, _this.state.noteInput, _this.state.noteAttachments.map(a => {
3070
+ const res = await (this.state.editingNote ? maintenanceActions.editNote(this.state.jobId, this.state.editingNote, this.state.noteInput, this.state.noteAttachments.map(a => {
3095
3071
  return {
3096
3072
  Title: a.Title,
3097
3073
  Source: a.Source
3098
3074
  };
3099
- }), _this.state.noteImages) : maintenanceActions.addNote(_this.state.jobId, _this.state.noteInput, _this.state.noteAttachments.map(a => {
3075
+ }), this.state.noteImages) : maintenanceActions.addNote(this.state.jobId, this.state.noteInput, this.state.noteAttachments.map(a => {
3100
3076
  return {
3101
3077
  Title: a.Title,
3102
3078
  Source: a.Source
3103
3079
  };
3104
- }), _this.state.noteImages);
3105
- _this.setState({
3080
+ }), this.state.noteImages));
3081
+ this.setState({
3106
3082
  job: res.data.job,
3107
3083
  submittingNote: false,
3108
3084
  addNoteOpen: false,
@@ -3111,12 +3087,12 @@ class Job extends Component {
3111
3087
  noteImages: [],
3112
3088
  editingNote: null
3113
3089
  }, () => {
3114
- _this.props.jobsLoaded([_this.state.job]);
3090
+ this.props.jobsLoaded([this.state.job]);
3115
3091
  });
3116
3092
  } catch (err) {
3117
3093
  console.error("onConfirmAddNote", err);
3118
3094
  }
3119
- }));
3095
+ });
3120
3096
  _defineProperty(this, "onDeleteNote", n => {
3121
3097
  if (!window.confirm(values.textAreYouSureYouWantToDeleteNote)) {
3122
3098
  this.setState({
@@ -3125,8 +3101,8 @@ class Job extends Component {
3125
3101
  return;
3126
3102
  }
3127
3103
  maintenanceActions.deleteNote(this.state.jobId, n.Id);
3128
- var newNotes = _.filter(this.state.job.Notes, note => note.Id !== n.Id);
3129
- var newJob = _objectSpread$5({}, this.state.job);
3104
+ const newNotes = _.filter(this.state.job.Notes, note => note.Id !== n.Id);
3105
+ const newJob = _objectSpread$5({}, this.state.job);
3130
3106
  newJob.Notes = newNotes;
3131
3107
  this.setState({
3132
3108
  job: newJob,
@@ -3144,10 +3120,10 @@ class Job extends Component {
3144
3120
  }, this.checkSetImage);
3145
3121
  });
3146
3122
  _defineProperty(this, "markSeen", () => {
3147
- var {
3123
+ const {
3148
3124
  job
3149
3125
  } = this.state;
3150
- var {
3126
+ const {
3151
3127
  auth
3152
3128
  } = this.props;
3153
3129
  // Must have maintenance permission and not the requester
@@ -3155,22 +3131,22 @@ class Job extends Component {
3155
3131
  if (auth.user.Id === job.userID) return;
3156
3132
  this.setState({
3157
3133
  updating: true
3158
- }, /*#__PURE__*/_asyncToGenerator(function* () {
3134
+ }, async () => {
3159
3135
  try {
3160
- var update = {
3136
+ const update = {
3161
3137
  id: job.id,
3162
3138
  seen: true,
3163
3139
  status: job.status || "Unassigned"
3164
3140
  };
3165
- yield maintenanceActions.editJob(update, auth.site);
3141
+ await maintenanceActions.editJob(update, auth.site);
3166
3142
  } catch (error) {
3167
- _this.setState({
3143
+ this.setState({
3168
3144
  updating: false
3169
3145
  });
3170
3146
  console.log("markSeen error", error);
3171
3147
  alert("Something went wrong with the request. Please try again.");
3172
3148
  }
3173
- }));
3149
+ });
3174
3150
  });
3175
3151
  _defineProperty(this, "getComments", () => {
3176
3152
  reactionActions.getComments(this.state.jobId, values.commentKey, 0).then(res => {
@@ -3179,25 +3155,25 @@ class Job extends Component {
3179
3155
  });
3180
3156
  });
3181
3157
  });
3182
- _defineProperty(this, "onAddComment", /*#__PURE__*/_asyncToGenerator(function* () {
3183
- var {
3158
+ _defineProperty(this, "onAddComment", async () => {
3159
+ const {
3184
3160
  commentInput,
3185
3161
  jobId,
3186
3162
  job,
3187
3163
  comments
3188
- } = _this.state;
3164
+ } = this.state;
3189
3165
  try {
3190
- _this.setState({
3166
+ this.setState({
3191
3167
  commentInput: ""
3192
3168
  });
3193
- var res = yield reactionActions.addComment(jobId, values.commentKey, job.title, job.site, commentInput);
3194
- _this.setState({
3169
+ const res = await reactionActions.addComment(jobId, values.commentKey, job.title, job.site, commentInput);
3170
+ this.setState({
3195
3171
  comments: [...comments, res.data]
3196
3172
  });
3197
3173
  } catch (error) {
3198
3174
  console.error("onAddComment", error);
3199
3175
  }
3200
- }));
3176
+ });
3201
3177
  _defineProperty(this, "onHandleChange", event => {
3202
3178
  var stateChange = {};
3203
3179
  stateChange[event.target.getAttribute("id")] = event.target.value;
@@ -3208,61 +3184,51 @@ class Job extends Component {
3208
3184
  priorityChangerOpen: !this.state.priorityChangerOpen
3209
3185
  });
3210
3186
  });
3211
- _defineProperty(this, "onSelectPriority", /*#__PURE__*/function () {
3212
- var _ref0 = _asyncToGenerator(function* (priority) {
3213
- _this.setState({
3214
- job: _objectSpread$5(_objectSpread$5({}, _this.state.job), {}, {
3215
- priority
3216
- }),
3217
- priorityChangerOpen: false
3218
- });
3219
- try {
3220
- var res = yield maintenanceActions.editJobPriority(_this.state.job.id, priority);
3221
- var {
3222
- job
3223
- } = res.data;
3224
- _this.props.jobsLoaded([job]);
3225
- _this.setState({
3226
- job
3227
- });
3228
- } catch (error) {
3229
- console.error("onSelectPriority", error);
3230
- }
3187
+ _defineProperty(this, "onSelectPriority", async priority => {
3188
+ this.setState({
3189
+ job: _objectSpread$5(_objectSpread$5({}, this.state.job), {}, {
3190
+ priority
3191
+ }),
3192
+ priorityChangerOpen: false
3231
3193
  });
3232
- return function (_x2) {
3233
- return _ref0.apply(this, arguments);
3234
- };
3235
- }());
3194
+ try {
3195
+ const res = await maintenanceActions.editJobPriority(this.state.job.id, priority);
3196
+ const {
3197
+ job
3198
+ } = res.data;
3199
+ this.props.jobsLoaded([job]);
3200
+ this.setState({
3201
+ job
3202
+ });
3203
+ } catch (error) {
3204
+ console.error("onSelectPriority", error);
3205
+ }
3206
+ });
3236
3207
  _defineProperty(this, "onToggleStatusChanger", () => {
3237
3208
  this.setState({
3238
3209
  statusChangerOpen: !this.state.statusChangerOpen
3239
3210
  });
3240
3211
  });
3241
- _defineProperty(this, "onSelectStatus", /*#__PURE__*/function () {
3242
- var _ref1 = _asyncToGenerator(function* (status) {
3243
- _this.setState({
3244
- job: _objectSpread$5(_objectSpread$5({}, _this.state.job), {}, {
3245
- status: status
3246
- }),
3247
- statusChangerOpen: false
3248
- });
3249
- try {
3250
- var res = yield maintenanceActions.editJobStatus(_this.state.job.id, status);
3251
- var {
3252
- job
3253
- } = res.data;
3254
- _this.props.jobsLoaded([job]);
3255
- _this.setState({
3256
- job
3257
- });
3258
- } catch (error) {
3259
- console.error("onSelectStatus", error);
3260
- }
3212
+ _defineProperty(this, "onSelectStatus", async status => {
3213
+ this.setState({
3214
+ job: _objectSpread$5(_objectSpread$5({}, this.state.job), {}, {
3215
+ status: status
3216
+ }),
3217
+ statusChangerOpen: false
3261
3218
  });
3262
- return function (_x3) {
3263
- return _ref1.apply(this, arguments);
3264
- };
3265
- }());
3219
+ try {
3220
+ const res = await maintenanceActions.editJobStatus(this.state.job.id, status);
3221
+ const {
3222
+ job
3223
+ } = res.data;
3224
+ this.props.jobsLoaded([job]);
3225
+ this.setState({
3226
+ job
3227
+ });
3228
+ } catch (error) {
3229
+ console.error("onSelectStatus", error);
3230
+ }
3231
+ });
3266
3232
  this.state = {
3267
3233
  jobId: Helper$3.safeReadParams(props, "jobId") ? props.match.params.jobId : null,
3268
3234
  job: null,
@@ -3324,15 +3290,15 @@ class Job extends Component {
3324
3290
  });
3325
3291
  }
3326
3292
  renderPriorityLabel() {
3327
- var {
3293
+ const {
3328
3294
  auth
3329
3295
  } = this.props;
3330
3296
  if (!Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
3331
- var {
3297
+ const {
3332
3298
  job
3333
3299
  } = this.state;
3334
3300
  if (!job) return null;
3335
- var selectedPriority = getJobPriority(job.priority);
3301
+ const selectedPriority = getJobPriority(job.priority);
3336
3302
  return /*#__PURE__*/jsxs("div", {
3337
3303
  className: "statusLabel marginTop-5 pointer",
3338
3304
  onClick: this.onTogglePriorityChanger,
@@ -3347,8 +3313,8 @@ class Job extends Component {
3347
3313
  }
3348
3314
  renderStatusLabel() {
3349
3315
  if (!this.state.job.status) return null;
3350
- var statusType = this.getStatusType(this.state.job.status);
3351
- var {
3316
+ const statusType = this.getStatusType(this.state.job.status);
3317
+ const {
3352
3318
  auth
3353
3319
  } = this.props;
3354
3320
  if (Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) {
@@ -3376,7 +3342,7 @@ class Job extends Component {
3376
3342
  });
3377
3343
  }
3378
3344
  renderNotesButton() {
3379
- var {
3345
+ const {
3380
3346
  auth
3381
3347
  } = this.props;
3382
3348
  if (!Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
@@ -3394,7 +3360,7 @@ class Job extends Component {
3394
3360
  });
3395
3361
  }
3396
3362
  renderAssignButton() {
3397
- var {
3363
+ const {
3398
3364
  auth
3399
3365
  } = this.props;
3400
3366
  if (!Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
@@ -3413,7 +3379,7 @@ class Job extends Component {
3413
3379
  }
3414
3380
  renderStatusChanger() {
3415
3381
  if (!this.state.statusChangerOpen) return null;
3416
- var {
3382
+ const {
3417
3383
  statusTypes
3418
3384
  } = this.props;
3419
3385
  return /*#__PURE__*/jsx("div", {
@@ -3473,8 +3439,8 @@ class Job extends Component {
3473
3439
  });
3474
3440
  }
3475
3441
  renderImageGrid(images) {
3476
- var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
3477
- var imagesToUse = images && images.length > 0 ? images : [];
3442
+ let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
3443
+ const imagesToUse = images && images.length > 0 ? images : [];
3478
3444
  return /*#__PURE__*/jsx("div", {
3479
3445
  className: "imageGrid",
3480
3446
  children: imagesToUse.map((image, i) => {
@@ -3495,7 +3461,7 @@ class Job extends Component {
3495
3461
  });
3496
3462
  }
3497
3463
  renderDocumentGrid(documents) {
3498
- var documentsToUse = documents && documents.length > 0 ? documents : [];
3464
+ const documentsToUse = documents && documents.length > 0 ? documents : [];
3499
3465
  return /*#__PURE__*/jsx("div", {
3500
3466
  className: "documentGrid",
3501
3467
  children: documentsToUse.map((doc, index) => /*#__PURE__*/jsx(Components$3.Attachment, {
@@ -3507,7 +3473,7 @@ class Job extends Component {
3507
3473
  }
3508
3474
  renderImages() {
3509
3475
  if (_.isEmpty(this.state.job.image) && _.isEmpty(this.state.job.images)) return null;
3510
- var imagesToUse = _.isEmpty(this.state.job.image) ? this.state.job.images : [this.state.job.image];
3476
+ const imagesToUse = _.isEmpty(this.state.job.image) ? this.state.job.images : [this.state.job.image];
3511
3477
  return /*#__PURE__*/jsxs("div", {
3512
3478
  className: "padding-60 paddingVertical-40 bottomDivideBorder",
3513
3479
  children: [/*#__PURE__*/jsx(Components$3.Text, {
@@ -3518,15 +3484,15 @@ class Job extends Component {
3518
3484
  });
3519
3485
  }
3520
3486
  renderCustomFields() {
3521
- var {
3487
+ const {
3522
3488
  job
3523
3489
  } = this.state;
3524
- var {
3490
+ const {
3525
3491
  customFields
3526
3492
  } = job;
3527
- var labelClass = "fieldLabel";
3528
- var answerClass = "fontRegular fontSize-16 text-dark marginTop-5";
3529
- var renderAnswer = field => {
3493
+ const labelClass = "fieldLabel";
3494
+ const answerClass = "fontRegular fontSize-16 text-dark marginTop-5";
3495
+ const renderAnswer = field => {
3530
3496
  switch (field.type) {
3531
3497
  case "date":
3532
3498
  return /*#__PURE__*/jsx("div", {
@@ -3576,10 +3542,10 @@ class Job extends Component {
3576
3542
  }
3577
3543
  renderInner() {
3578
3544
  if (this.state.job == null) return null;
3579
- var {
3545
+ const {
3580
3546
  customFields
3581
3547
  } = this.state.job;
3582
- var hasCustomFields = customFields && customFields.length > 0;
3548
+ const hasCustomFields = customFields && customFields.length > 0;
3583
3549
  return /*#__PURE__*/jsxs("div", {
3584
3550
  iconStyle: {
3585
3551
  paddingBottom: 40
@@ -3680,10 +3646,10 @@ class Job extends Component {
3680
3646
  });
3681
3647
  }
3682
3648
  renderHistoryEntry(e, i) {
3683
- var {
3649
+ const {
3684
3650
  job
3685
3651
  } = this.state;
3686
- var entryToUse = e || {
3652
+ const entryToUse = e || {
3687
3653
  timestamp: job.createdTime,
3688
3654
  status: "Unassigned",
3689
3655
  user: {
@@ -3692,7 +3658,7 @@ class Job extends Component {
3692
3658
  profilePic: job.userProfilePic
3693
3659
  }
3694
3660
  };
3695
- var statusType = this.getStatusType(entryToUse.status);
3661
+ const statusType = this.getStatusType(entryToUse.status);
3696
3662
  return /*#__PURE__*/jsxs("div", {
3697
3663
  className: "ticketHistoryEntry",
3698
3664
  children: [/*#__PURE__*/jsx("p", {
@@ -3756,7 +3722,7 @@ class Job extends Component {
3756
3722
  }, index);
3757
3723
  }
3758
3724
  renderAssignment() {
3759
- var {
3725
+ const {
3760
3726
  job
3761
3727
  } = this.state;
3762
3728
  if (!job) return null;
@@ -3804,8 +3770,8 @@ class Job extends Component {
3804
3770
  }, i);
3805
3771
  }
3806
3772
  renderExternalSyncEntry(e, i) {
3807
- var isSuccess = e.EntryType === "ExternalIDSet";
3808
- var backgroundColor = isSuccess ? Colours$2.COLOUR_GREEN : Colours$2.COLOUR_RED; // Green for success, red for failure
3773
+ const isSuccess = e.EntryType === "ExternalIDSet";
3774
+ const backgroundColor = isSuccess ? Colours$2.COLOUR_GREEN : Colours$2.COLOUR_RED; // Green for success, red for failure
3809
3775
 
3810
3776
  return /*#__PURE__*/jsxs("div", {
3811
3777
  className: "ticketHistoryEntry",
@@ -3825,7 +3791,7 @@ class Job extends Component {
3825
3791
  }, i);
3826
3792
  }
3827
3793
  renderPriority() {
3828
- var {
3794
+ const {
3829
3795
  auth
3830
3796
  } = this.props;
3831
3797
  if (!Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
@@ -3842,20 +3808,20 @@ class Job extends Component {
3842
3808
  });
3843
3809
  }
3844
3810
  hasSyncFailureWithoutSuccess() {
3845
- var {
3811
+ const {
3846
3812
  job
3847
3813
  } = this.state;
3848
3814
  if (!job || !job.history) return false;
3849
- var history = job.history || [];
3850
- var hasSuccess = history.some(entry => entry.EntryType === "ExternalIDSet");
3851
- var hasFailure = history.some(entry => entry.EntryType === "ExternalIDSetFailed");
3815
+ const history = job.history || [];
3816
+ const hasSuccess = history.some(entry => entry.EntryType === "ExternalIDSet");
3817
+ const hasFailure = history.some(entry => entry.EntryType === "ExternalIDSetFailed");
3852
3818
  return hasFailure && !hasSuccess;
3853
3819
  }
3854
3820
  renderRetrySyncButton() {
3855
- var {
3821
+ const {
3856
3822
  auth
3857
3823
  } = this.props;
3858
- var {
3824
+ const {
3859
3825
  retryingSync,
3860
3826
  retrySyncInitiated
3861
3827
  } = this.state;
@@ -3893,7 +3859,7 @@ class Job extends Component {
3893
3859
  });
3894
3860
  }
3895
3861
  renderExternalSyncStatus() {
3896
- var {
3862
+ const {
3897
3863
  retrySyncError,
3898
3864
  retrySyncInitiated
3899
3865
  } = this.state;
@@ -3942,14 +3908,14 @@ class Job extends Component {
3942
3908
  return null;
3943
3909
  }
3944
3910
  renderExternalSync() {
3945
- var {
3911
+ const {
3946
3912
  externalSync,
3947
3913
  loadingExternalSync
3948
3914
  } = this.state;
3949
3915
 
3950
3916
  // Check if we should show this section at all
3951
- var hasExternalSyncData = externalSync && !loadingExternalSync;
3952
- var hasSyncFailure = this.hasSyncFailureWithoutSuccess();
3917
+ const hasExternalSyncData = externalSync && !loadingExternalSync;
3918
+ const hasSyncFailure = this.hasSyncFailureWithoutSuccess();
3953
3919
 
3954
3920
  // Show section if we have sync data OR if there's a failure that can be retried
3955
3921
  if (!hasExternalSyncData && !hasSyncFailure) return null;
@@ -3989,11 +3955,11 @@ class Job extends Component {
3989
3955
  });
3990
3956
  }
3991
3957
  renderOverview() {
3992
- var {
3958
+ const {
3993
3959
  job
3994
3960
  } = this.state;
3995
3961
  if (!job || !job.history) return null;
3996
- var source = _.sortBy([...job.history.map(e => {
3962
+ const source = _.sortBy([...job.history.map(e => {
3997
3963
  return _objectSpread$5(_objectSpread$5({}, e), {}, {
3998
3964
  EntryType: e.EntryType || "status"
3999
3965
  });
@@ -4131,8 +4097,8 @@ class Job extends Component {
4131
4097
  children: "Add Attachment"
4132
4098
  })]
4133
4099
  }), /*#__PURE__*/jsx(Components$3.ImageInput, {
4134
- ref: _ref10 => {
4135
- this.imageInput = _ref10;
4100
+ ref: ref => {
4101
+ this.imageInput = ref;
4136
4102
  },
4137
4103
  multiple: true,
4138
4104
  refreshCallback: images => {
@@ -4144,7 +4110,7 @@ class Job extends Component {
4144
4110
  });
4145
4111
  }
4146
4112
  renderUsers() {
4147
- var content = null;
4113
+ let content = null;
4148
4114
  if (this.state.confirmingAssignee) {
4149
4115
  content = /*#__PURE__*/jsx("div", {
4150
4116
  className: "flex flex-center-row",
@@ -4238,8 +4204,8 @@ class Job extends Component {
4238
4204
  });
4239
4205
  }
4240
4206
  }
4241
- var mapStateToProps$3 = state => {
4242
- var {
4207
+ const mapStateToProps$3 = state => {
4208
+ const {
4243
4209
  auth
4244
4210
  } = state;
4245
4211
  return {
@@ -4254,7 +4220,7 @@ var Job$1 = connect(mapStateToProps$3, {
4254
4220
 
4255
4221
  function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4256
4222
  function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4257
- var {
4223
+ const {
4258
4224
  Actions,
4259
4225
  Components: Components$2,
4260
4226
  Helper: Helper$2,
@@ -4267,18 +4233,18 @@ class AddJob extends Component {
4267
4233
  var _this;
4268
4234
  super(props);
4269
4235
  _this = this;
4270
- _defineProperty(this, "getJob", /*#__PURE__*/_asyncToGenerator(function* () {
4236
+ _defineProperty(this, "getJob", async () => {
4271
4237
  try {
4272
- var res = yield maintenanceActions.getJob(_this.props.auth.site, _this.state.jobId);
4238
+ const res = await maintenanceActions.getJob(this.props.auth.site, this.state.jobId);
4273
4239
  res.data.location = res.data.site;
4274
- var {
4240
+ const {
4275
4241
  userID,
4276
4242
  userName,
4277
4243
  userProfilePic,
4278
4244
  type,
4279
4245
  customFields
4280
4246
  } = res.data;
4281
- _this.setState(_objectSpread$4(_objectSpread$4({}, res.data), {}, {
4247
+ this.setState(_objectSpread$4(_objectSpread$4({}, res.data), {}, {
4282
4248
  prevType: type,
4283
4249
  prevCustomFileds: customFields,
4284
4250
  type,
@@ -4289,39 +4255,39 @@ class AddJob extends Component {
4289
4255
  profilePic: userProfilePic
4290
4256
  }
4291
4257
  }));
4292
- _this.checkSetImages(_this.imageInput, res.data.images);
4258
+ this.checkSetImages(this.imageInput, res.data.images);
4293
4259
  if (customFields) {
4294
4260
  customFields.forEach((field, index) => {
4295
4261
  if (field.type === "image" && field.answer) {
4296
- _this.checkSetImages(_this.customImageInputs[index], field.answer);
4262
+ this.checkSetImages(this.customImageInputs[index], field.answer);
4297
4263
  }
4298
4264
  });
4299
4265
  }
4300
4266
  } catch (error) {
4301
4267
  console.error("getJob", error);
4302
4268
  }
4303
- }));
4304
- _defineProperty(this, "getJobTypes", /*#__PURE__*/_asyncToGenerator(function* () {
4269
+ });
4270
+ _defineProperty(this, "getJobTypes", async () => {
4305
4271
  try {
4306
- var res = yield maintenanceActions.getJobTypes(_this.props.auth.site);
4307
- _this.setState({
4272
+ const res = await maintenanceActions.getJobTypes(this.props.auth.site);
4273
+ this.setState({
4308
4274
  types: res.data
4309
4275
  });
4310
- _this.getDefaultJob();
4276
+ this.getDefaultJob();
4311
4277
  } catch (error) {
4312
4278
  console.error("getJobTypes", error);
4313
4279
  }
4314
- }));
4315
- _defineProperty(this, "getUsers", /*#__PURE__*/_asyncToGenerator(function* () {
4280
+ });
4281
+ _defineProperty(this, "getUsers", async () => {
4316
4282
  try {
4317
- var res = yield userActions.fetchUsers(_this.props.auth.site);
4283
+ const res = await userActions.fetchUsers(this.props.auth.site);
4318
4284
  if (res.userFetchFail) return;
4319
4285
  if (res.data != null && !_.isEmpty(res.data.results.Items)) {
4320
- var items = res.data.results.Items;
4321
- if (_this.props.optionOnlyForResidents) {
4286
+ let items = res.data.results.Items;
4287
+ if (this.props.optionOnlyForResidents) {
4322
4288
  items = _.filter(items, u => u.category === "resident");
4323
4289
  }
4324
- _this.setState({
4290
+ this.setState({
4325
4291
  users: _.sortBy(items, u => {
4326
4292
  return (u.displayName || "").toLowerCase();
4327
4293
  })
@@ -4330,15 +4296,15 @@ class AddJob extends Component {
4330
4296
  } catch (error) {
4331
4297
  console.error("getUsers", error);
4332
4298
  }
4333
- }));
4299
+ });
4334
4300
  _defineProperty(this, "getDefaultJob", () => {
4335
- var {
4301
+ const {
4336
4302
  types,
4337
4303
  jobId
4338
4304
  } = this.state;
4339
4305
  if (jobId == null) {
4340
4306
  if (types.length !== 0) {
4341
- var defaultType = types[0];
4307
+ const defaultType = types[0];
4342
4308
  this.setState({
4343
4309
  type: defaultType.typeName,
4344
4310
  customFields: defaultType.hasCustomFields && defaultType.customFields.length > 0 ? defaultType.customFields : []
@@ -4351,15 +4317,15 @@ class AddJob extends Component {
4351
4317
  }
4352
4318
  });
4353
4319
  _defineProperty(this, "onSelectType", (key, e) => {
4354
- var {
4320
+ const {
4355
4321
  types,
4356
4322
  prevType,
4357
4323
  prevCustomFileds
4358
4324
  } = this.state;
4359
- var selectedType = types.find(t => t.typeName === key);
4325
+ const selectedType = types.find(t => t.typeName === key);
4360
4326
  // If selected type had previously saved custom fields, use the previous version
4361
- var hasPrevCustomFields = prevType === selectedType.typeName && prevCustomFileds && prevCustomFileds.length > 0;
4362
- var update = {
4327
+ const hasPrevCustomFields = prevType === selectedType.typeName && prevCustomFileds && prevCustomFileds.length > 0;
4328
+ const update = {
4363
4329
  type: selectedType.typeName,
4364
4330
  customFields: hasPrevCustomFields ? prevCustomFileds : selectedType.hasCustomFields ? selectedType.customFields : []
4365
4331
  };
@@ -4384,7 +4350,7 @@ class AddJob extends Component {
4384
4350
  });
4385
4351
  });
4386
4352
  _defineProperty(this, "onSelectUser", user => {
4387
- var update = {
4353
+ const update = {
4388
4354
  selectedUser: user,
4389
4355
  userID: user.userId,
4390
4356
  userName: user.displayName,
@@ -4402,7 +4368,7 @@ class AddJob extends Component {
4402
4368
  // Fetch in background to avoid blocking UI
4403
4369
  userActions.fetchUser(this.props.auth.site, user.userId).then(response => {
4404
4370
  if (response.data && response.data.user) {
4405
- var contactUpdate = {};
4371
+ const contactUpdate = {};
4406
4372
  // Auto-populate phone and room from user profile
4407
4373
  if (response.data.user.phoneNumber) {
4408
4374
  contactUpdate.phone = response.data.user.phoneNumber;
@@ -4422,7 +4388,7 @@ class AddJob extends Component {
4422
4388
  });
4423
4389
  });
4424
4390
  _defineProperty(this, "onUnselectUser", () => {
4425
- var update = {
4391
+ const update = {
4426
4392
  selectedUser: null,
4427
4393
  userID: "",
4428
4394
  userName: "",
@@ -4435,78 +4401,78 @@ class AddJob extends Component {
4435
4401
  this.setState(update);
4436
4402
  });
4437
4403
  _defineProperty(this, "onChangeAnswer", (qId, answer) => {
4438
- var update = {
4404
+ const update = {
4439
4405
  customFields: _.cloneDeep(this.state.customFields)
4440
4406
  };
4441
- var field = update.customFields[qId];
4407
+ const field = update.customFields[qId];
4442
4408
  field.answer = answer;
4443
4409
  if (field.isTitle) update.title = field.answer;
4444
4410
  this.setState(update);
4445
4411
  });
4446
4412
  _defineProperty(this, "onChangeToggleAnswer", (qId, answer) => {
4447
- var update = {
4413
+ const update = {
4448
4414
  customFields: _.cloneDeep(this.state.customFields)
4449
4415
  };
4450
- var field = update.customFields[qId];
4416
+ const field = update.customFields[qId];
4451
4417
  field.answer = field.answer === answer ? undefined : answer;
4452
4418
  if (field.isTitle) update.title = field.answer;
4453
4419
  this.setState(update);
4454
4420
  });
4455
4421
  _defineProperty(this, "onChangeCheckboxAnswer", (qId, answer) => {
4456
- var update = {
4422
+ const update = {
4457
4423
  customFields: _.cloneDeep(this.state.customFields)
4458
4424
  };
4459
- var field = update.customFields[qId];
4425
+ const field = update.customFields[qId];
4460
4426
  field.answer = _.xor(field.answer || [], [answer]);
4461
4427
  if (field.isTitle) update.title = field.answer.join(", ");
4462
4428
  this.setState(update);
4463
4429
  });
4464
4430
  _defineProperty(this, "onChangeDateAnswer", function (qId, answer) {
4465
- var togglePicker = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
4466
- var update = {
4431
+ let togglePicker = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
4432
+ const update = {
4467
4433
  customFields: _.cloneDeep(_this.state.customFields)
4468
4434
  };
4469
- var field = update.customFields[qId];
4435
+ const field = update.customFields[qId];
4470
4436
  field.answer = answer;
4471
4437
  if (field.isTitle) update.title = moment(field.answer, "YYYY-MM-DD").format("DD-MMM-YYYY");
4472
4438
  _this.setState(update);
4473
4439
  if (togglePicker) _this.onToggleDatePicker(qId);
4474
4440
  });
4475
4441
  _defineProperty(this, "onChangeTimeAnswer", (qId, answer) => {
4476
- var update = {
4442
+ const update = {
4477
4443
  customFields: _.cloneDeep(this.state.customFields)
4478
4444
  };
4479
- var field = update.customFields[qId];
4445
+ const field = update.customFields[qId];
4480
4446
  field.answer = answer;
4481
4447
  if (field.isTitle) update.title = moment(field.answer, "HH:mm").format("h:mm a");
4482
4448
  this.setState(update);
4483
4449
  });
4484
4450
  _defineProperty(this, "onChangeImageAnswer", (qId, answer) => {
4485
- var update = {
4451
+ const update = {
4486
4452
  customFields: _.cloneDeep(this.state.customFields)
4487
4453
  };
4488
- var field = update.customFields[qId];
4454
+ const field = update.customFields[qId];
4489
4455
  field.answer = answer;
4490
4456
  this.setState(update);
4491
4457
  });
4492
4458
  _defineProperty(this, "onRemoveDocumentAnswer", (qId, document) => {
4493
- var update = {
4459
+ const update = {
4494
4460
  customFields: _.cloneDeep(this.state.customFields)
4495
4461
  };
4496
- var field = update.customFields[qId];
4462
+ const field = update.customFields[qId];
4497
4463
  field.answer = _.filter(field.answer, d => d.url !== document.url);
4498
4464
  this.setState(update);
4499
4465
  });
4500
4466
  _defineProperty(this, "onHandlePDFFileChange", (event, qId) => {
4501
- var file = event.target.files[0];
4467
+ const file = event.target.files[0];
4502
4468
  if (!file) return;
4503
- var update = {
4469
+ const update = {
4504
4470
  customFields: _.cloneDeep(this.state.customFields)
4505
4471
  };
4506
- var field = update.customFields[qId];
4507
- var attachments = field.answer || [];
4508
- var [name, ext] = file.name.split(".");
4509
- var newAttachment = {
4472
+ const field = update.customFields[qId];
4473
+ const attachments = field.answer || [];
4474
+ const [name, ext] = file.name.split(".");
4475
+ const newAttachment = {
4510
4476
  uploading: true,
4511
4477
  name,
4512
4478
  ext: ext.toLowerCase()
@@ -4526,7 +4492,7 @@ class AddJob extends Component {
4526
4492
  event.target.value = "";
4527
4493
  });
4528
4494
  _defineProperty(this, "onToggleDatePicker", qId => {
4529
- var showDate = _objectSpread$4({}, this.state.showDate);
4495
+ const showDate = _objectSpread$4({}, this.state.showDate);
4530
4496
  showDate[qId] = !showDate[qId];
4531
4497
  this.setState({
4532
4498
  showDate
@@ -4546,7 +4512,7 @@ class AddJob extends Component {
4546
4512
  this.setState({
4547
4513
  updating: true
4548
4514
  });
4549
- var job = {
4515
+ const job = {
4550
4516
  id: this.state.id,
4551
4517
  userID: this.state.userID,
4552
4518
  userName: this.state.userName,
@@ -4592,13 +4558,13 @@ class AddJob extends Component {
4592
4558
  }
4593
4559
  });
4594
4560
  _defineProperty(this, "isFieldValid", field => {
4595
- var {
4561
+ const {
4596
4562
  mandatory,
4597
4563
  type,
4598
4564
  answer
4599
4565
  } = field;
4600
4566
  if (["staticTitle", "staticText"].includes(type)) return true;
4601
- var checkMandatory = () => {
4567
+ const checkMandatory = () => {
4602
4568
  if (!mandatory) return true;
4603
4569
  switch (type) {
4604
4570
  case "yn":
@@ -4611,7 +4577,7 @@ class AddJob extends Component {
4611
4577
  return !_.isNil(answer) && !_.isEmpty(answer);
4612
4578
  }
4613
4579
  };
4614
- var checkFormat = () => {
4580
+ const checkFormat = () => {
4615
4581
  if (_.isNil(answer) || _.isEmpty(answer)) return true;
4616
4582
  switch (type) {
4617
4583
  case "email":
@@ -4624,12 +4590,12 @@ class AddJob extends Component {
4624
4590
  return true;
4625
4591
  }
4626
4592
  };
4627
- var valid = checkMandatory() && checkFormat();
4593
+ const valid = checkMandatory() && checkFormat();
4628
4594
  return valid;
4629
4595
  });
4630
4596
  _defineProperty(this, "getFieldContainerClass", function () {
4631
- var isValid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4632
- var showError = _this.state.showWarnings && !isValid;
4597
+ let isValid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4598
+ const showError = _this.state.showWarnings && !isValid;
4633
4599
  return "genericInputContainer ".concat(isValid ? "genericInput-valid" : "", " ").concat(showError ? "genericInput-error" : "").trim();
4634
4600
  });
4635
4601
  this.imageInput = null;
@@ -4689,7 +4655,7 @@ class AddJob extends Component {
4689
4655
  }
4690
4656
  }
4691
4657
  getTypeOptions() {
4692
- var {
4658
+ const {
4693
4659
  types
4694
4660
  } = this.state;
4695
4661
  return types.filter(Boolean).map(ev => ({
@@ -4699,7 +4665,7 @@ class AddJob extends Component {
4699
4665
  }
4700
4666
  renderSuccess() {
4701
4667
  if (!this.state.success) return null;
4702
- var title = this.props.strings["".concat(values.featureKey, "_textTitleRequests")] || values.textTitleRequests;
4668
+ const title = this.props.strings["".concat(values.featureKey, "_textTitleRequests")] || values.textTitleRequests;
4703
4669
  return /*#__PURE__*/jsx(Components$2.SuccessPopup, {
4704
4670
  text: "".concat(values.textEntityName, " has been ").concat(this.state.id != null ? "edited" : "added"),
4705
4671
  buttons: [{
@@ -4712,12 +4678,12 @@ class AddJob extends Component {
4712
4678
  });
4713
4679
  }
4714
4680
  validateCustomFields() {
4715
- var {
4681
+ const {
4716
4682
  customFields
4717
4683
  } = this.state;
4718
4684
  if (!customFields || customFields.length === 0) return true;
4719
4685
  return customFields.every(field => {
4720
- var isValid = this.isFieldValid(field);
4686
+ const isValid = this.isFieldValid(field);
4721
4687
  return isValid;
4722
4688
  });
4723
4689
  }
@@ -4757,11 +4723,11 @@ class AddJob extends Component {
4757
4723
  });
4758
4724
  }
4759
4725
  renderSelectUser() {
4760
- var {
4726
+ const {
4761
4727
  showWarnings,
4762
4728
  selectedUser
4763
4729
  } = this.state;
4764
- var isValid = !_.isNil(selectedUser);
4730
+ const isValid = !_.isNil(selectedUser);
4765
4731
  return /*#__PURE__*/jsxs("div", {
4766
4732
  className: this.getFieldContainerClass(isValid),
4767
4733
  children: [/*#__PURE__*/jsxs("div", {
@@ -4831,8 +4797,8 @@ class AddJob extends Component {
4831
4797
  className: "marginBottom-4",
4832
4798
  children: "Images"
4833
4799
  }), /*#__PURE__*/jsx(Components$2.ImageInput, {
4834
- ref: _ref4 => {
4835
- this.imageInput = _ref4;
4800
+ ref: ref => {
4801
+ this.imageInput = ref;
4836
4802
  },
4837
4803
  multiple: true,
4838
4804
  refreshCallback: images => {
@@ -5071,14 +5037,14 @@ class AddJob extends Component {
5071
5037
  className: "marginBottom-4",
5072
5038
  children: field.label
5073
5039
  }), /*#__PURE__*/jsx(Components$2.ImageInput, {
5074
- ref: _ref5 => this.customImageInputs[fieldId] = _ref5,
5040
+ ref: ref => this.customImageInputs[fieldId] = ref,
5075
5041
  multiple: true,
5076
5042
  refreshCallback: images => this.onChangeImageAnswer(fieldId, images)
5077
5043
  })]
5078
5044
  })]
5079
5045
  }, fieldId);
5080
5046
  case "document":
5081
- var documents = field.answer || [];
5047
+ const documents = field.answer || [];
5082
5048
  return /*#__PURE__*/jsxs("div", {
5083
5049
  className: this.getFieldContainerClass(this.isFieldValid(field)),
5084
5050
  style: styles$4.fieldContainer,
@@ -5123,7 +5089,7 @@ class AddJob extends Component {
5123
5089
  }
5124
5090
  }
5125
5091
  renderCustomFields() {
5126
- var {
5092
+ const {
5127
5093
  customFields
5128
5094
  } = this.state;
5129
5095
  if (!customFields || customFields.length === 0) return null;
@@ -5134,7 +5100,7 @@ class AddJob extends Component {
5134
5100
  });
5135
5101
  }
5136
5102
  renderMain() {
5137
- var {
5103
+ const {
5138
5104
  customFields
5139
5105
  } = this.state;
5140
5106
  return /*#__PURE__*/jsx("div", {
@@ -5185,7 +5151,7 @@ class AddJob extends Component {
5185
5151
  });
5186
5152
  }
5187
5153
  renderUserFilterPopup() {
5188
- var {
5154
+ const {
5189
5155
  userFilterOpen,
5190
5156
  userSearch,
5191
5157
  users
@@ -5225,7 +5191,7 @@ class AddJob extends Component {
5225
5191
  });
5226
5192
  }
5227
5193
  render() {
5228
- var {
5194
+ const {
5229
5195
  success
5230
5196
  } = this.state;
5231
5197
  return /*#__PURE__*/jsxs(Components$2.OverlayPage, {
@@ -5243,7 +5209,7 @@ class AddJob extends Component {
5243
5209
  });
5244
5210
  }
5245
5211
  }
5246
- var styles$4 = {
5212
+ const styles$4 = {
5247
5213
  userLabelContainer: {
5248
5214
  display: "flex",
5249
5215
  flexDirection: "row",
@@ -5257,8 +5223,8 @@ var styles$4 = {
5257
5223
  alignItems: "center"
5258
5224
  }
5259
5225
  };
5260
- var mapStateToProps$2 = state => {
5261
- var {
5226
+ const mapStateToProps$2 = state => {
5227
+ const {
5262
5228
  auth
5263
5229
  } = state;
5264
5230
  return {
@@ -5273,12 +5239,12 @@ var AddJob$1 = connect(mapStateToProps$2, {
5273
5239
  addRecentlyCreated: Actions.addRecentlyCreated
5274
5240
  })(withRouter(AddJob));
5275
5241
 
5276
- var {
5242
+ const {
5277
5243
  Components: Components$1,
5278
5244
  Session: Session$1,
5279
5245
  Helper: Helper$1
5280
5246
  } = PlussCore;
5281
- var DEFAULT_FIELD = {
5247
+ const DEFAULT_FIELD = {
5282
5248
  type: "text",
5283
5249
  label: "",
5284
5250
  mandatory: false,
@@ -5287,13 +5253,11 @@ var DEFAULT_FIELD = {
5287
5253
  };
5288
5254
  class AddJobType extends Component {
5289
5255
  constructor(props) {
5290
- var _this;
5291
5256
  super(props);
5292
- _this = this;
5293
- _defineProperty(this, "getJobType", /*#__PURE__*/_asyncToGenerator(function* () {
5257
+ _defineProperty(this, "getJobType", async () => {
5294
5258
  try {
5295
- var res = yield maintenanceActions.getJobType(_this.props.auth.site, _this.state.jobTypeId);
5296
- var {
5259
+ const res = await maintenanceActions.getJobType(this.props.auth.site, this.state.jobTypeId);
5260
+ const {
5297
5261
  typeName,
5298
5262
  email,
5299
5263
  description,
@@ -5301,7 +5265,7 @@ class AddJobType extends Component {
5301
5265
  hasCustomFields,
5302
5266
  customFields
5303
5267
  } = res.data;
5304
- _this.setState({
5268
+ this.setState({
5305
5269
  jobTypeName: typeName,
5306
5270
  jobTypeEmail: email,
5307
5271
  jobTypeDescription: description,
@@ -5312,19 +5276,19 @@ class AddJobType extends Component {
5312
5276
  } catch (error) {
5313
5277
  console.error("getJobType", error);
5314
5278
  }
5315
- }));
5279
+ });
5316
5280
  _defineProperty(this, "getFieldTypeTitle", type => {
5317
- var fieldType = this.fieldTypes.find(f => f.Key === type);
5281
+ const fieldType = this.fieldTypes.find(f => f.Key === type);
5318
5282
  return fieldType ? fieldType.Title : "";
5319
5283
  });
5320
5284
  _defineProperty(this, "validateEmail", () => {
5321
- var {
5285
+ const {
5322
5286
  jobTypeEmail
5323
5287
  } = this.state;
5324
5288
  return !_.isEmpty(jobTypeEmail) && Helper$1.isEmail(jobTypeEmail);
5325
5289
  });
5326
5290
  _defineProperty(this, "isJobTypeValid", () => {
5327
- var {
5291
+ const {
5328
5292
  jobTypeName,
5329
5293
  jobTypeDescription
5330
5294
  } = this.state;
@@ -5340,7 +5304,7 @@ class AddJobType extends Component {
5340
5304
  this.setState(stateChange);
5341
5305
  });
5342
5306
  _defineProperty(this, "onFieldTypeChanged", (fieldIndex, key) => {
5343
- var customFields = [...this.state.customFields];
5307
+ const customFields = [...this.state.customFields];
5344
5308
  if (customFields[fieldIndex].type === key) return;
5345
5309
  customFields[fieldIndex] = _.cloneDeep(DEFAULT_FIELD);
5346
5310
  customFields[fieldIndex].type = key;
@@ -5349,21 +5313,21 @@ class AddJobType extends Component {
5349
5313
  });
5350
5314
  });
5351
5315
  _defineProperty(this, "onFieldLabelChanged", (fieldIndex, event) => {
5352
- var customFields = [...this.state.customFields];
5316
+ const customFields = [...this.state.customFields];
5353
5317
  customFields[fieldIndex].label = event.target.value;
5354
5318
  this.setState({
5355
5319
  customFields
5356
5320
  });
5357
5321
  });
5358
5322
  _defineProperty(this, "onFieldPlaceHolderChanged", (fieldIndex, event) => {
5359
- var customFields = [...this.state.customFields];
5323
+ const customFields = [...this.state.customFields];
5360
5324
  customFields[fieldIndex].placeHolder = event.target.value;
5361
5325
  this.setState({
5362
5326
  customFields
5363
5327
  });
5364
5328
  });
5365
5329
  _defineProperty(this, "onFieldMandatoryChanged", fieldIndex => {
5366
- var customFields = [...this.state.customFields];
5330
+ const customFields = [...this.state.customFields];
5367
5331
  customFields[fieldIndex].mandatory = !customFields[fieldIndex].mandatory;
5368
5332
  if (!customFields[fieldIndex].mandatory) {
5369
5333
  // If a field is not mandatory, it cannot be a title field
@@ -5374,7 +5338,7 @@ class AddJobType extends Component {
5374
5338
  });
5375
5339
  });
5376
5340
  _defineProperty(this, "onFieldIsTitleChanged", fieldIndex => {
5377
- var customFields = [...this.state.customFields];
5341
+ const customFields = [...this.state.customFields];
5378
5342
  customFields[fieldIndex].isTitle = !customFields[fieldIndex].isTitle;
5379
5343
  if (customFields[fieldIndex].isTitle) {
5380
5344
  // If a field is title field, force mandatory
@@ -5385,33 +5349,33 @@ class AddJobType extends Component {
5385
5349
  });
5386
5350
  });
5387
5351
  _defineProperty(this, "onFieldOptionChanged", (fieldIndex, optionIndex, event) => {
5388
- var customFields = [...this.state.customFields];
5389
- var prevValue = customFields[fieldIndex].values[optionIndex];
5352
+ const customFields = [...this.state.customFields];
5353
+ const prevValue = customFields[fieldIndex].values[optionIndex];
5390
5354
  customFields[fieldIndex].values[optionIndex] = event.target.value;
5391
5355
  // Change corresponding validation if exists
5392
- var validations = customFields[fieldIndex].validation;
5393
- var validation = validations ? validations.find(val => val.value === prevValue) : null;
5356
+ const validations = customFields[fieldIndex].validation;
5357
+ let validation = validations ? validations.find(val => val.value === prevValue) : null;
5394
5358
  if (validation) validation.value = event.target.value;
5395
5359
  this.setState({
5396
5360
  customFields
5397
5361
  });
5398
5362
  });
5399
5363
  _defineProperty(this, "onAddNewOption", fieldIndex => {
5400
- var customFields = [...this.state.customFields];
5364
+ const customFields = [...this.state.customFields];
5401
5365
  customFields[fieldIndex].values.push("");
5402
5366
  this.setState({
5403
5367
  customFields
5404
5368
  });
5405
5369
  });
5406
5370
  _defineProperty(this, "onRemoveOption", (fieldIndex, optionIndex) => {
5407
- var customFields = [...this.state.customFields];
5371
+ const customFields = [...this.state.customFields];
5408
5372
  customFields[fieldIndex].values.splice(optionIndex, 1);
5409
5373
  this.setState({
5410
5374
  customFields
5411
5375
  });
5412
5376
  });
5413
5377
  _defineProperty(this, "onAddNewField", () => {
5414
- var customFields = [...this.state.customFields];
5378
+ const customFields = [...this.state.customFields];
5415
5379
  customFields.push(_.cloneDeep(DEFAULT_FIELD));
5416
5380
  this.setState({
5417
5381
  customFields
@@ -5419,17 +5383,17 @@ class AddJobType extends Component {
5419
5383
  });
5420
5384
  _defineProperty(this, "onMoveFieldPrev", fieldIndex => {
5421
5385
  if (fieldIndex === 0) return;
5422
- var customFields = [...this.state.customFields];
5423
- var item = customFields.splice(fieldIndex, 1)[0];
5386
+ const customFields = [...this.state.customFields];
5387
+ const item = customFields.splice(fieldIndex, 1)[0];
5424
5388
  customFields.splice(fieldIndex - 1, 0, item);
5425
5389
  this.setState({
5426
5390
  customFields
5427
5391
  });
5428
5392
  });
5429
5393
  _defineProperty(this, "onMoveFieldNext", fieldIndex => {
5430
- var customFields = [...this.state.customFields];
5394
+ const customFields = [...this.state.customFields];
5431
5395
  if (fieldIndex > customFields.length - 1) return;
5432
- var item = customFields.splice(fieldIndex, 1)[0];
5396
+ const item = customFields.splice(fieldIndex, 1)[0];
5433
5397
  customFields.splice(fieldIndex + 1, 0, item);
5434
5398
  this.setState({
5435
5399
  customFields
@@ -5439,10 +5403,10 @@ class AddJobType extends Component {
5439
5403
  window.history.back();
5440
5404
  });
5441
5405
  _defineProperty(this, "onSave", () => {
5442
- var {
5406
+ const {
5443
5407
  site
5444
5408
  } = this.props.auth;
5445
- var {
5409
+ const {
5446
5410
  submitting,
5447
5411
  jobTypeId,
5448
5412
  jobTypeName,
@@ -5461,26 +5425,26 @@ class AddJobType extends Component {
5461
5425
  }
5462
5426
  this.setState({
5463
5427
  submitting: true
5464
- }, /*#__PURE__*/_asyncToGenerator(function* () {
5428
+ }, async () => {
5465
5429
  try {
5466
5430
  if (jobTypeId) {
5467
- yield maintenanceActions.editJobType(site, jobTypeId, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel, hasCustomFields, customFields);
5431
+ await maintenanceActions.editJobType(site, jobTypeId, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel, hasCustomFields, customFields);
5468
5432
  } else {
5469
- yield maintenanceActions.addJobType(site, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel, hasCustomFields, customFields);
5433
+ await maintenanceActions.addJobType(site, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel, hasCustomFields, customFields);
5470
5434
  }
5471
- _this.props.jobTypesUpdate(site);
5472
- _this.setState({
5435
+ this.props.jobTypesUpdate(site);
5436
+ this.setState({
5473
5437
  submitting: false,
5474
5438
  success: true
5475
5439
  });
5476
5440
  } catch (error) {
5477
5441
  console.error("onSave", error);
5478
- _this.setState({
5442
+ this.setState({
5479
5443
  submitting: false
5480
5444
  });
5481
5445
  alert("Something went wrong with the request. Please try again.");
5482
5446
  }
5483
- }));
5447
+ });
5484
5448
  });
5485
5449
  this.fieldTypes = [{
5486
5450
  Title: "Text Input",
@@ -5541,7 +5505,7 @@ class AddJobType extends Component {
5541
5505
  if (this.state.jobTypeId) this.getJobType();
5542
5506
  }
5543
5507
  validateCustomFields() {
5544
- var {
5508
+ const {
5545
5509
  submitting,
5546
5510
  hasCustomFields,
5547
5511
  customFields
@@ -5549,13 +5513,13 @@ class AddJobType extends Component {
5549
5513
  if (submitting) return false;
5550
5514
 
5551
5515
  // Validate custom fields
5552
- var warnings = [];
5516
+ const warnings = [];
5553
5517
  if (hasCustomFields) {
5554
- var missingLabel = false;
5555
- var hasMandatoryField = false;
5556
- var titleFieldCount = 0;
5518
+ let missingLabel = false;
5519
+ let hasMandatoryField = false;
5520
+ let titleFieldCount = 0;
5557
5521
  customFields.forEach(field => {
5558
- var {
5522
+ const {
5559
5523
  type,
5560
5524
  label,
5561
5525
  values,
@@ -5587,7 +5551,7 @@ class AddJobType extends Component {
5587
5551
  return warnings.length === 0;
5588
5552
  }
5589
5553
  onRemoveField(fieldIndex) {
5590
- var customFields = [...this.state.customFields];
5554
+ const customFields = [...this.state.customFields];
5591
5555
  if (customFields.length < 2) return;
5592
5556
  customFields.splice(fieldIndex, 1);
5593
5557
  this.setState({
@@ -5595,7 +5559,7 @@ class AddJobType extends Component {
5595
5559
  });
5596
5560
  }
5597
5561
  renderBaseForm() {
5598
- var {
5562
+ const {
5599
5563
  success,
5600
5564
  jobTypeId,
5601
5565
  showWarnings,
@@ -5794,7 +5758,7 @@ class AddJobType extends Component {
5794
5758
  });
5795
5759
  }
5796
5760
  renderFieldMultiple(field, fieldIndex) {
5797
- var {
5761
+ const {
5798
5762
  customFields
5799
5763
  } = this.state;
5800
5764
  return /*#__PURE__*/jsxs("div", {
@@ -5865,7 +5829,7 @@ class AddJobType extends Component {
5865
5829
  });
5866
5830
  }
5867
5831
  renderFieldCheckbox(field, fieldIndex) {
5868
- var {
5832
+ const {
5869
5833
  customFields
5870
5834
  } = this.state;
5871
5835
  return /*#__PURE__*/jsxs("div", {
@@ -5960,10 +5924,10 @@ class AddJobType extends Component {
5960
5924
  });
5961
5925
  }
5962
5926
  renderField(field, fieldIndex) {
5963
- var {
5927
+ const {
5964
5928
  customFields
5965
5929
  } = this.state;
5966
- var renderFieldContent = () => {
5930
+ const renderFieldContent = () => {
5967
5931
  switch (field.type) {
5968
5932
  case "text":
5969
5933
  case "email":
@@ -6047,7 +6011,7 @@ class AddJobType extends Component {
6047
6011
  }, fieldIndex);
6048
6012
  }
6049
6013
  renderCustomForm() {
6050
- var {
6014
+ const {
6051
6015
  success,
6052
6016
  hasCustomFields,
6053
6017
  customFields
@@ -6082,7 +6046,7 @@ class AddJobType extends Component {
6082
6046
  });
6083
6047
  }
6084
6048
  renderWarnings() {
6085
- var {
6049
+ const {
6086
6050
  showWarnings,
6087
6051
  warnings
6088
6052
  } = this.state;
@@ -6104,7 +6068,7 @@ class AddJobType extends Component {
6104
6068
  });
6105
6069
  }
6106
6070
  renderSuccess() {
6107
- var {
6071
+ const {
6108
6072
  success,
6109
6073
  jobTypeId
6110
6074
  } = this.state;
@@ -6145,7 +6109,7 @@ class AddJobType extends Component {
6145
6109
  });
6146
6110
  }
6147
6111
  render() {
6148
- var {
6112
+ const {
6149
6113
  success
6150
6114
  } = this.state;
6151
6115
  return /*#__PURE__*/jsxs(Components$1.OverlayPage, {
@@ -6164,8 +6128,8 @@ class AddJobType extends Component {
6164
6128
  });
6165
6129
  }
6166
6130
  }
6167
- var mapStateToProps$1 = state => {
6168
- var {
6131
+ const mapStateToProps$1 = state => {
6132
+ const {
6169
6133
  auth
6170
6134
  } = state;
6171
6135
  return {
@@ -6179,14 +6143,14 @@ var AddJobType$1 = connect(mapStateToProps$1, {
6179
6143
 
6180
6144
  function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6181
6145
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6182
- var {
6146
+ const {
6183
6147
  Analytics: Analytics$1,
6184
6148
  Session,
6185
6149
  Components,
6186
6150
  Helper,
6187
6151
  Colours
6188
6152
  } = PlussCore;
6189
- var getInitialState = () => ({
6153
+ const getInitialState = () => ({
6190
6154
  requests: 0,
6191
6155
  prevRequests: 0,
6192
6156
  completedRequests: 0,
@@ -6197,8 +6161,8 @@ var getInitialState = () => ({
6197
6161
  });
6198
6162
 
6199
6163
  // AnalyticsHub Component
6200
- var AnalyticsHub = _ref => {
6201
- var {
6164
+ const AnalyticsHub = _ref => {
6165
+ let {
6202
6166
  startTime,
6203
6167
  endTime,
6204
6168
  auth,
@@ -6209,27 +6173,27 @@ var AnalyticsHub = _ref => {
6209
6173
  userCategory,
6210
6174
  selectedSites
6211
6175
  } = _ref;
6212
- var [analyticsData, setAnalyticsData] = useState(getInitialState());
6213
- var [isExportOpen, setIsExportOpen] = useState(false);
6214
- var [failedSites, setFailedSites] = useState([]);
6215
- var [comparisonData, setComparisonData] = useState({
6176
+ const [analyticsData, setAnalyticsData] = useState(getInitialState());
6177
+ const [isExportOpen, setIsExportOpen] = useState(false);
6178
+ const [failedSites, setFailedSites] = useState([]);
6179
+ const [comparisonData, setComparisonData] = useState({
6216
6180
  requests: [],
6217
6181
  completedRequests: [],
6218
6182
  comments: [],
6219
6183
  isLoading: true
6220
6184
  });
6221
- var comparisonMode = selectedSites && selectedSites.length > 1;
6222
- var hasAccess = Session.validateAccess(auth.site, values.permissionMaintenanceTracking, auth);
6185
+ const comparisonMode = selectedSites && selectedSites.length > 1;
6186
+ const hasAccess = Session.validateAccess(auth.site, values.permissionMaintenanceTracking, auth);
6223
6187
  if (!hasAccess) {
6224
6188
  return null;
6225
6189
  }
6226
- var featureTitle = (key => {
6190
+ const featureTitle = (key => {
6227
6191
  if (!strings || !strings.sideNav || !strings.sideNav[key]) {
6228
6192
  return values.textMenuTitle;
6229
6193
  }
6230
6194
  return strings.sideNav[key];
6231
6195
  })();
6232
- var exportColumns = [{
6196
+ const exportColumns = [{
6233
6197
  label: "Select All",
6234
6198
  key: ""
6235
6199
  }, ...(comparisonMode ? [{
@@ -6254,104 +6218,94 @@ var AnalyticsHub = _ref => {
6254
6218
  useEffect(() => {
6255
6219
  getData();
6256
6220
  }, [startTime, endTime, userType, userCategory, selectedSites]);
6257
- var getData = /*#__PURE__*/function () {
6258
- var _ref2 = _asyncToGenerator(function* () {
6259
- try {
6260
- setFailedSites([]);
6261
- if (comparisonMode) {
6262
- setComparisonData({
6263
- requests: [],
6264
- completedRequests: [],
6265
- comments: [],
6266
- isLoading: true
6267
- });
6268
- var multiSiteResultsObj = yield Analytics$1.fetchMultiSiteData(selectedSites, /*#__PURE__*/function () {
6269
- var _ref3 = _asyncToGenerator(function* (site) {
6270
- var {
6271
- data
6272
- } = yield analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime, endTime, true, {
6273
- userType,
6274
- userCategory
6275
- });
6276
- return data;
6277
- });
6278
- return function (_x) {
6279
- return _ref3.apply(this, arguments);
6280
- };
6281
- }());
6282
- var roles = auth.user.Roles;
6283
- var failed = Object.entries(multiSiteResultsObj).filter(_ref4 => {
6284
- var [, data] = _ref4;
6285
- return data === null;
6286
- }).map(_ref5 => {
6287
- var [site] = _ref5;
6288
- return Helper.getSiteNameFromRoles(site, roles);
6289
- });
6290
- setFailedSites(failed);
6291
- var multiSiteResults = Object.entries(multiSiteResultsObj).filter(_ref6 => {
6292
- var [, data] = _ref6;
6293
- return data !== null;
6294
- }).map(_ref7 => {
6295
- var [site, data] = _ref7;
6296
- return {
6297
- site,
6298
- data
6299
- };
6300
- });
6301
- var buildComparison = (activityKey, countType) => multiSiteResults.map(result => ({
6302
- name: Helper.getSiteNameFromRoles(result.site, roles),
6303
- value: Analytics$1.countActivities(result.data, activityKey, countType)
6304
- }));
6305
- setComparisonData({
6306
- requests: buildComparison("Request", "total"),
6307
- completedRequests: buildComparison("RequestCompleted", "unique"),
6308
- comments: buildComparison("Comment", "total"),
6309
- isLoading: false
6310
- });
6311
- } else {
6312
- setAnalyticsData(getInitialState());
6313
- var site = selectedSites && selectedSites.length === 1 ? selectedSites[0] : auth.site;
6314
- var timeDifference = endTime - startTime;
6315
- var [currentStatsResponse, prevStatsResponse] = yield Promise.all([analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime, endTime, true, {
6316
- userType,
6317
- userCategory
6318
- }), analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime - timeDifference, startTime, true, {
6221
+ const getData = async () => {
6222
+ try {
6223
+ setFailedSites([]);
6224
+ if (comparisonMode) {
6225
+ setComparisonData({
6226
+ requests: [],
6227
+ completedRequests: [],
6228
+ comments: [],
6229
+ isLoading: true
6230
+ });
6231
+ const multiSiteResultsObj = await Analytics$1.fetchMultiSiteData(selectedSites, async site => {
6232
+ const {
6233
+ data
6234
+ } = await analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime, endTime, true, {
6319
6235
  userType,
6320
6236
  userCategory
6321
- })]);
6322
- var data = {
6323
- requests: Analytics$1.countActivities(currentStatsResponse.data, "Request", "total"),
6324
- prevRequests: Analytics$1.countActivities(prevStatsResponse.data, "Request", "total"),
6325
- completedRequests: Analytics$1.countActivities(currentStatsResponse.data, "RequestCompleted", "unique"),
6326
- prevCompletedRequests: Analytics$1.countActivities(prevStatsResponse.data, "RequestCompleted", "unique"),
6327
- comments: Analytics$1.countActivities(currentStatsResponse.data, "Comment", "total"),
6328
- prevComments: Analytics$1.countActivities(prevStatsResponse.data, "Comment", "total"),
6329
- isLoading: false
6237
+ });
6238
+ return data;
6239
+ });
6240
+ const roles = auth.user.Roles;
6241
+ const failed = Object.entries(multiSiteResultsObj).filter(_ref2 => {
6242
+ let [, data] = _ref2;
6243
+ return data === null;
6244
+ }).map(_ref3 => {
6245
+ let [site] = _ref3;
6246
+ return Helper.getSiteNameFromRoles(site, roles);
6247
+ });
6248
+ setFailedSites(failed);
6249
+ const multiSiteResults = Object.entries(multiSiteResultsObj).filter(_ref4 => {
6250
+ let [, data] = _ref4;
6251
+ return data !== null;
6252
+ }).map(_ref5 => {
6253
+ let [site, data] = _ref5;
6254
+ return {
6255
+ site,
6256
+ data
6330
6257
  };
6331
- setAnalyticsData(data);
6332
- }
6333
- } catch (err) {
6334
- if (comparisonMode) {
6335
- setComparisonData(prev => _objectSpread$3(_objectSpread$3({}, prev), {}, {
6336
- isLoading: false
6337
- }));
6338
- } else {
6339
- setAnalyticsData(prev => _objectSpread$3(_objectSpread$3({}, prev), {}, {
6340
- isLoading: false
6341
- }));
6342
- }
6258
+ });
6259
+ const buildComparison = (activityKey, countType) => multiSiteResults.map(result => ({
6260
+ name: Helper.getSiteNameFromRoles(result.site, roles),
6261
+ value: Analytics$1.countActivities(result.data, activityKey, countType)
6262
+ }));
6263
+ setComparisonData({
6264
+ requests: buildComparison("Request", "total"),
6265
+ completedRequests: buildComparison("RequestCompleted", "unique"),
6266
+ comments: buildComparison("Comment", "total"),
6267
+ isLoading: false
6268
+ });
6269
+ } else {
6270
+ setAnalyticsData(getInitialState());
6271
+ const site = selectedSites && selectedSites.length === 1 ? selectedSites[0] : auth.site;
6272
+ const timeDifference = endTime - startTime;
6273
+ const [currentStatsResponse, prevStatsResponse] = await Promise.all([analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime, endTime, true, {
6274
+ userType,
6275
+ userCategory
6276
+ }), analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime - timeDifference, startTime, true, {
6277
+ userType,
6278
+ userCategory
6279
+ })]);
6280
+ const data = {
6281
+ requests: Analytics$1.countActivities(currentStatsResponse.data, "Request", "total"),
6282
+ prevRequests: Analytics$1.countActivities(prevStatsResponse.data, "Request", "total"),
6283
+ completedRequests: Analytics$1.countActivities(currentStatsResponse.data, "RequestCompleted", "unique"),
6284
+ prevCompletedRequests: Analytics$1.countActivities(prevStatsResponse.data, "RequestCompleted", "unique"),
6285
+ comments: Analytics$1.countActivities(currentStatsResponse.data, "Comment", "total"),
6286
+ prevComments: Analytics$1.countActivities(prevStatsResponse.data, "Comment", "total"),
6287
+ isLoading: false
6288
+ };
6289
+ setAnalyticsData(data);
6343
6290
  }
6344
- });
6345
- return function getData() {
6346
- return _ref2.apply(this, arguments);
6347
- };
6348
- }();
6349
- var isReadyToOpenCSV = () => {
6291
+ } catch (err) {
6292
+ if (comparisonMode) {
6293
+ setComparisonData(prev => _objectSpread$3(_objectSpread$3({}, prev), {}, {
6294
+ isLoading: false
6295
+ }));
6296
+ } else {
6297
+ setAnalyticsData(prev => _objectSpread$3(_objectSpread$3({}, prev), {}, {
6298
+ isLoading: false
6299
+ }));
6300
+ }
6301
+ }
6302
+ };
6303
+ const isReadyToOpenCSV = () => {
6350
6304
  return comparisonMode ? !comparisonData.isLoading : !analyticsData.isLoading;
6351
6305
  };
6352
- var getExportSource = () => {
6306
+ const getExportSource = () => {
6353
6307
  if (comparisonMode) {
6354
- var sites = comparisonData.requests || [];
6308
+ const sites = comparisonData.requests || [];
6355
6309
  return sites.map((site, i) => ({
6356
6310
  site: site.name,
6357
6311
  startDate: moment(startTime + 1).format("D-MM-YYYY"),
@@ -6369,12 +6323,12 @@ var AnalyticsHub = _ref => {
6369
6323
  comments: analyticsData.comments
6370
6324
  }];
6371
6325
  };
6372
- var csvPopup = () => {
6326
+ const csvPopup = () => {
6373
6327
  if (!isExportOpen) {
6374
6328
  return null;
6375
6329
  }
6376
- var source = getExportSource();
6377
- var filterSuffix = [userType, userCategory].filter(Boolean).map(f => f.toLowerCase().replace(/\s+/g, "-")).join("_");
6330
+ const source = getExportSource();
6331
+ const filterSuffix = [userType, userCategory].filter(Boolean).map(f => f.toLowerCase().replace(/\s+/g, "-")).join("_");
6378
6332
  return /*#__PURE__*/jsx(Components.ExportCsvPopup, {
6379
6333
  onClose: () => {
6380
6334
  setIsExportOpen(false);
@@ -6412,7 +6366,7 @@ var AnalyticsHub = _ref => {
6412
6366
  }), /*#__PURE__*/jsx("div", {
6413
6367
  className: "analyticsSection dashboardSection_content",
6414
6368
  children: (() => {
6415
- var chartSuffix = [selectedSites && selectedSites.length > 0 ? "&sites=".concat(selectedSites.join(",")) : "", userType ? "&userType=".concat(encodeURIComponent(userType)) : "", userCategory ? "&userCategory=".concat(encodeURIComponent(userCategory)) : ""].join("");
6369
+ const chartSuffix = [selectedSites && selectedSites.length > 0 ? "&sites=".concat(selectedSites.join(",")) : "", userType ? "&userType=".concat(encodeURIComponent(userType)) : "", userCategory ? "&userCategory=".concat(encodeURIComponent(userCategory)) : ""].join("");
6416
6370
  if (comparisonMode) {
6417
6371
  return /*#__PURE__*/jsxs("div", {
6418
6372
  style: {
@@ -6472,8 +6426,8 @@ var AnalyticsHub = _ref => {
6472
6426
  })]
6473
6427
  });
6474
6428
  };
6475
- var mapStateToProps = state => {
6476
- var {
6429
+ const mapStateToProps = state => {
6430
+ const {
6477
6431
  auth
6478
6432
  } = state;
6479
6433
  return {
@@ -6481,11 +6435,11 @@ var mapStateToProps = state => {
6481
6435
  strings: state.strings && state.strings.config || {}
6482
6436
  };
6483
6437
  };
6484
- var toExport = connect(mapStateToProps, {})(AnalyticsHub);
6438
+ const toExport = connect(mapStateToProps, {})(AnalyticsHub);
6485
6439
 
6486
6440
  function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6487
6441
  function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6488
- var INITIAL_STATE = {
6442
+ const INITIAL_STATE = {
6489
6443
  jobs: [],
6490
6444
  jobtypes: [],
6491
6445
  jobstatuses: jobStatusOptions,
@@ -6493,15 +6447,15 @@ var INITIAL_STATE = {
6493
6447
  hideSeen: false
6494
6448
  };
6495
6449
  var MaintenanceReducer = (function () {
6496
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_STATE;
6497
- var action = arguments.length > 1 ? arguments[1] : undefined;
6450
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_STATE;
6451
+ let action = arguments.length > 1 ? arguments[1] : undefined;
6498
6452
  switch (action.type) {
6499
6453
  case JOBS_LOADING:
6500
6454
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
6501
6455
  loading: true
6502
6456
  });
6503
6457
  case JOBS_LOADED:
6504
- var result = _.unionWith(action.payload, state.jobs, (v1, v2) => {
6458
+ const result = _.unionWith(action.payload, state.jobs, (v1, v2) => {
6505
6459
  return v1 != null && v2 != null && v1.id === v2.id;
6506
6460
  });
6507
6461
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
@@ -6511,11 +6465,11 @@ var MaintenanceReducer = (function () {
6511
6465
  loading: false
6512
6466
  });
6513
6467
  case JOBS_REMOVED:
6514
- var index = _.findIndex(state.jobs, event => {
6468
+ const index = _.findIndex(state.jobs, event => {
6515
6469
  return event != null && event.id === action.payload;
6516
6470
  });
6517
6471
  if (index > -1) {
6518
- var newJobs = [...state.jobs];
6472
+ const newJobs = [...state.jobs];
6519
6473
  newJobs.splice(index, 1);
6520
6474
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
6521
6475
  jobs: newJobs
@@ -6523,14 +6477,14 @@ var MaintenanceReducer = (function () {
6523
6477
  }
6524
6478
  return state;
6525
6479
  case JOBS_TYPES_LOADED:
6526
- var jobtypes = _.unionWith(action.payload, state.jobtypes, (v1, v2) => {
6480
+ const jobtypes = _.unionWith(action.payload, state.jobtypes, (v1, v2) => {
6527
6481
  return v1 != null && v2 != null && v1.id === v2.id;
6528
6482
  });
6529
6483
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
6530
6484
  jobtypes
6531
6485
  });
6532
6486
  case JOBS_STATUSES_LOADED:
6533
- var jobstatuses = _.orderBy(action.payload, "order", "asc");
6487
+ const jobstatuses = _.orderBy(action.payload, "order", "asc");
6534
6488
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
6535
6489
  jobstatuses
6536
6490
  });
@@ -6545,7 +6499,7 @@ var MaintenanceReducer = (function () {
6545
6499
 
6546
6500
  class ActivityText extends Component {
6547
6501
  render() {
6548
- var {
6502
+ const {
6549
6503
  data,
6550
6504
  classes,
6551
6505
  clickableClasses,
@@ -6621,7 +6575,7 @@ var img$3 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAxwAAAGGCAYAAADxZYcEA
6621
6575
 
6622
6576
  class ViewWidget extends Component {
6623
6577
  render() {
6624
- var src = img$3;
6578
+ let src = img$3;
6625
6579
  return /*#__PURE__*/jsx("img", {
6626
6580
  style: styles$3.image,
6627
6581
  src: src,
@@ -6629,7 +6583,7 @@ class ViewWidget extends Component {
6629
6583
  });
6630
6584
  }
6631
6585
  }
6632
- var styles$3 = {
6586
+ const styles$3 = {
6633
6587
  image: {
6634
6588
  width: 80
6635
6589
  }
@@ -6639,7 +6593,7 @@ var img$2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmAAAASICAYAAAC0rHMFA
6639
6593
 
6640
6594
  class ViewFull extends Component {
6641
6595
  render() {
6642
- var src = img$2;
6596
+ let src = img$2;
6643
6597
  return /*#__PURE__*/jsx("img", {
6644
6598
  style: styles$2.image,
6645
6599
  src: src,
@@ -6647,7 +6601,7 @@ class ViewFull extends Component {
6647
6601
  });
6648
6602
  }
6649
6603
  }
6650
- var styles$2 = {
6604
+ const styles$2 = {
6651
6605
  image: {
6652
6606
  width: "100%",
6653
6607
  height: "100%",
@@ -6661,12 +6615,12 @@ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
6661
6615
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6662
6616
  class PreviewWidget extends Component {
6663
6617
  render() {
6664
- var {
6618
+ const {
6665
6619
  backgroundColor,
6666
6620
  widgetTitle,
6667
6621
  titleClassName
6668
6622
  } = this.props;
6669
- var src = img$1;
6623
+ let src = img$1;
6670
6624
  return /*#__PURE__*/jsxs("div", {
6671
6625
  style: styles$1.container,
6672
6626
  children: [/*#__PURE__*/jsx("img", {
@@ -6683,7 +6637,7 @@ class PreviewWidget extends Component {
6683
6637
  });
6684
6638
  }
6685
6639
  }
6686
- var styles$1 = {
6640
+ const styles$1 = {
6687
6641
  container: {
6688
6642
  position: "relative"
6689
6643
  },
@@ -6698,12 +6652,12 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
6698
6652
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6699
6653
  class PreviewFull extends Component {
6700
6654
  render() {
6701
- var {
6655
+ const {
6702
6656
  backgroundColor,
6703
6657
  widgetTitle,
6704
6658
  titleClassName
6705
6659
  } = this.props;
6706
- var src = img;
6660
+ let src = img;
6707
6661
  return /*#__PURE__*/jsxs("div", {
6708
6662
  style: styles.container,
6709
6663
  children: [/*#__PURE__*/jsx("p", {
@@ -6719,7 +6673,7 @@ class PreviewFull extends Component {
6719
6673
  });
6720
6674
  }
6721
6675
  }
6722
- var styles = {
6676
+ const styles = {
6723
6677
  container: {
6724
6678
  position: "relative"
6725
6679
  },
@@ -6728,11 +6682,11 @@ var styles = {
6728
6682
  }
6729
6683
  };
6730
6684
 
6731
- var SVG_PATH = values.svgPathGridIcon;
6732
- var SVG_VIEWBOX = values.svgPathGridIconViewBox ;
6685
+ const SVG_PATH = values.svgPathGridIcon;
6686
+ const SVG_VIEWBOX = values.svgPathGridIconViewBox ;
6733
6687
  class PreviewGrid extends Component {
6734
6688
  render() {
6735
- var {
6689
+ const {
6736
6690
  colour
6737
6691
  } = this.props;
6738
6692
  if (Array.isArray(SVG_PATH)) {
@@ -6759,20 +6713,20 @@ class PreviewGrid extends Component {
6759
6713
  }
6760
6714
  }
6761
6715
 
6762
- var Reducers = (() => {
6763
- var reducers = {};
6716
+ const Reducers = (() => {
6717
+ const reducers = {};
6764
6718
  reducers[values.reducerKey] = MaintenanceReducer;
6765
6719
  return reducers;
6766
6720
  })();
6767
- var Screens = (() => {
6768
- var screens = {};
6721
+ const Screens = (() => {
6722
+ const screens = {};
6769
6723
  screens[values.screenRequestsHub] = RequestsHub$1;
6770
6724
  screens[values.screenJob] = Job$1;
6771
6725
  screens[values.screenAddJob] = AddJob$1;
6772
6726
  screens[values.screenAddJobType] = AddJobType$1;
6773
6727
  return screens;
6774
6728
  })();
6775
- var Analytics = [toExport];
6729
+ const Analytics = [toExport];
6776
6730
 
6777
6731
  export { ActivityText, Analytics, FeatureConfig as Config, PreviewFull, PreviewGrid, PreviewWidget, Reducers, Screens, ViewFull, ViewWidget };
6778
6732
  //# sourceMappingURL=index.js.map