@plusscommunities/pluss-maintenance-web 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: "maintenance",
18
17
  aliases: ["maintenanceTracking", "maintenanceTypes", "maintenancerequest"],
19
18
  serviceKey: "maintenance",
@@ -92,7 +91,7 @@ var values = {
92
91
  };
93
92
 
94
93
  // import * as PlussCore from '../../pluss-core/src';
95
- var FeatureConfig = {
94
+ const FeatureConfig = {
96
95
  key: values.featureKey,
97
96
  aliases: values.aliases,
98
97
  singularName: values.textSingularName,
@@ -230,22 +229,22 @@ var FeatureConfig = {
230
229
  notificationPreference: values.notificationPreference
231
230
  };
232
231
 
233
- var JOBS_LOADED = values.actionJobsLoaded;
234
- var JOBS_LOADING = values.actionJobsLoading;
235
- var JOBS_REMOVED = values.actionJobsRemoved;
236
- var JOBS_TYPES_LOADED = values.actionJobsTypesLoaded;
237
- var JOBS_STATUSES_LOADED = values.actionJobsStatusesLoaded;
238
- var JOBS_HIDE_SEEN = values.actionJobsHideSeen;
232
+ const JOBS_LOADED = values.actionJobsLoaded;
233
+ const JOBS_LOADING = values.actionJobsLoading;
234
+ const JOBS_REMOVED = values.actionJobsRemoved;
235
+ const JOBS_TYPES_LOADED = values.actionJobsTypesLoaded;
236
+ const JOBS_STATUSES_LOADED = values.actionJobsStatusesLoaded;
237
+ const JOBS_HIDE_SEEN = values.actionJobsHideSeen;
239
238
 
240
239
  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; }
241
240
  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; }
242
- var {
241
+ const {
243
242
  Helper: Helper$6,
244
243
  Session: Session$9
245
244
  } = PlussCore;
246
- var maintenanceActions = {
245
+ const maintenanceActions = {
247
246
  getJobType: (site, typeId) => {
248
- var url = Helper$6.getUrl(values.serviceKey, "getjobtype");
247
+ let url = Helper$6.getUrl(values.serviceKey, "getjobtype");
249
248
  return Session$9.authedFunction({
250
249
  method: "POST",
251
250
  url,
@@ -256,7 +255,7 @@ var maintenanceActions = {
256
255
  });
257
256
  },
258
257
  getJobTypes: (site, id) => {
259
- var url = Helper$6.getUrl(values.serviceKey, "getjobtypes");
258
+ let url = Helper$6.getUrl(values.serviceKey, "getjobtypes");
260
259
  return Session$9.authedFunction({
261
260
  method: "POST",
262
261
  url,
@@ -266,7 +265,7 @@ var maintenanceActions = {
266
265
  });
267
266
  },
268
267
  getJob: (site, id) => {
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,
@@ -277,7 +276,7 @@ var maintenanceActions = {
277
276
  });
278
277
  },
279
278
  getJobByJobId: (site, jobId) => {
280
- var url = Helper$6.getUrl(values.serviceKey, "getJob");
279
+ let url = Helper$6.getUrl(values.serviceKey, "getJob");
281
280
  return Session$9.authedFunction({
282
281
  method: "POST",
283
282
  url,
@@ -287,9 +286,9 @@ var maintenanceActions = {
287
286
  }
288
287
  });
289
288
  },
290
- getJobs: function getJobs(site) {
291
- var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
292
- var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
289
+ getJobs: function (site) {
290
+ let status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
291
+ let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
293
292
  return Session$9.authedFunction({
294
293
  method: "POST",
295
294
  url: Helper$6.getUrl(values.serviceKey, "getJobs"),
@@ -301,7 +300,7 @@ var maintenanceActions = {
301
300
  });
302
301
  },
303
302
  getJobs2: (site, status, type, lastKey) => {
304
- var query = {
303
+ const query = {
305
304
  site
306
305
  };
307
306
  if (status) {
@@ -318,11 +317,11 @@ var maintenanceActions = {
318
317
  url: Helper$6.getUrl(values.serviceKey, "get/requests", query)
319
318
  });
320
319
  },
321
- getJobsRecursive: function getJobsRecursive(site, status, type, lastKey) {
322
- var jobs = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
320
+ getJobsRecursive: function (site, status, type, lastKey) {
321
+ let jobs = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
323
322
  return new Promise(resolve => {
324
323
  maintenanceActions.getJobs2(site, status, type, lastKey).then(jobRes => {
325
- var newJobs = [...jobs, ...jobRes.data.Items];
324
+ const newJobs = [...jobs, ...jobRes.data.Items];
326
325
  if (!jobRes.data.LastKey) {
327
326
  return resolve(newJobs);
328
327
  }
@@ -434,7 +433,7 @@ var maintenanceActions = {
434
433
  });
435
434
  },
436
435
  addJobType: (site, name, email, description, level, hasCustomFields, customFields) => {
437
- var data = {
436
+ const data = {
438
437
  site,
439
438
  name,
440
439
  email,
@@ -450,7 +449,7 @@ var maintenanceActions = {
450
449
  });
451
450
  },
452
451
  editJobType: (site, id, name, email, description, level, hasCustomFields, customFields) => {
453
- var data = {
452
+ const data = {
454
453
  site,
455
454
  id,
456
455
  name,
@@ -496,13 +495,13 @@ var maintenanceActions = {
496
495
  }
497
496
  };
498
497
 
499
- var {
498
+ const {
500
499
  Helper: Helper$5,
501
500
  Session: Session$8
502
501
  } = PlussCore;
503
- var reactionActions = {
502
+ const reactionActions = {
504
503
  addComment: (entityId, entityType, entityName, site, comment, image, parentId) => {
505
- var data = {
504
+ const data = {
506
505
  entityId,
507
506
  entityType,
508
507
  entityName,
@@ -529,7 +528,7 @@ var reactionActions = {
529
528
  // });
530
529
  // },
531
530
  getComments: (entityId, entityType, minTime) => {
532
- var query = {
531
+ const query = {
533
532
  entityId,
534
533
  entityType
535
534
  };
@@ -543,12 +542,12 @@ var reactionActions = {
543
542
  }
544
543
  };
545
544
 
546
- var {
545
+ const {
547
546
  Apis: Apis$2
548
547
  } = PlussCore;
549
- var analyticsActions = Apis$2.analyticsActions;
550
- var userActions = Apis$2.userActions;
551
- var stringActions = Apis$2.stringActions;
548
+ const analyticsActions = Apis$2.analyticsActions;
549
+ const userActions = Apis$2.userActions;
550
+ const stringActions = Apis$2.stringActions;
552
551
 
553
552
  var jobStatusOptions = [
554
553
  {
@@ -571,16 +570,16 @@ var jobStatusOptions = [
571
570
  }
572
571
  ];
573
572
 
574
- var {
573
+ const {
575
574
  Helper: Helper$4
576
575
  } = PlussCore;
577
- var jobsUpdate = (site, isdashboard) => {
576
+ const jobsUpdate = (site, isdashboard) => {
578
577
  return dispatch => {
579
578
  if (isdashboard) dispatch({
580
579
  type: JOBS_LOADING
581
580
  });
582
581
  maintenanceActions.getJobsRecursive(site).then(res => {
583
- var currentSite = Helper$4.readStorageWithCookie("site");
582
+ const currentSite = Helper$4.readStorageWithCookie("site");
584
583
  if (!_.isEmpty(res) && res[0].site === currentSite) {
585
584
  dispatch({
586
585
  type: JOBS_LOADED,
@@ -595,19 +594,19 @@ var jobsUpdate = (site, isdashboard) => {
595
594
  });
596
595
  };
597
596
  };
598
- var jobsLoaded = events => {
597
+ const jobsLoaded = events => {
599
598
  return {
600
599
  type: JOBS_LOADED,
601
600
  payload: events
602
601
  };
603
602
  };
604
- var removeJob = id => {
603
+ const removeJob = id => {
605
604
  return {
606
605
  type: JOBS_REMOVED,
607
606
  payload: id
608
607
  };
609
608
  };
610
- var jobTypesUpdate = site => {
609
+ const jobTypesUpdate = site => {
611
610
  return dispatch => {
612
611
  maintenanceActions.getJobTypes(site).then(res => {
613
612
  dispatch({
@@ -617,14 +616,14 @@ var jobTypesUpdate = site => {
617
616
  });
618
617
  };
619
618
  };
620
- var jobTypesLoaded = events => {
619
+ const jobTypesLoaded = events => {
621
620
  return {
622
621
  type: JOBS_TYPES_LOADED,
623
622
  payload: events
624
623
  };
625
624
  };
626
- var jobStatusesUpdate = function jobStatusesUpdate(site) {
627
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
625
+ const jobStatusesUpdate = function (site) {
626
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
628
627
  return dispatch => {
629
628
  stringActions.getString(site, values.stringConfigJobStatus).then(res => {
630
629
  dispatch({
@@ -641,14 +640,14 @@ var jobStatusesUpdate = function jobStatusesUpdate(site) {
641
640
  });
642
641
  };
643
642
  };
644
- var jobStatusesLoaded = statuses => {
643
+ const jobStatusesLoaded = statuses => {
645
644
  return {
646
645
  type: JOBS_STATUSES_LOADED,
647
646
  payload: statuses
648
647
  };
649
648
  };
650
- var jobHideSeenUpdate = function jobHideSeenUpdate(site) {
651
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
649
+ const jobHideSeenUpdate = function (site) {
650
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
652
651
  return dispatch => {
653
652
  stringActions.getString(site, values.stringConfigHideSeen).then(res => {
654
653
  dispatch({
@@ -665,7 +664,7 @@ var jobHideSeenUpdate = function jobHideSeenUpdate(site) {
665
664
  });
666
665
  };
667
666
  };
668
- var jobHideSeenLoaded = hide => {
667
+ const jobHideSeenLoaded = hide => {
669
668
  return {
670
669
  type: JOBS_HIDE_SEEN,
671
670
  payload: hide
@@ -721,31 +720,29 @@ var jobPriorityOptions = [
721
720
  }
722
721
  ];
723
722
 
724
- var STATUS_IMCOMPLETE = "All Incomplete";
725
- var STATUS_NOT_ACTIONED = "Not Actioned";
726
- var STATUS_IN_PROGRESS = "In Progress";
727
- var STATUS_COMPLETED = "Completed";
728
- var getDefaultPriority = () => jobPriorityOptions.find(p => p.default);
729
- var getJobPriority = priority => {
730
- var priorityOption = null;
723
+ const STATUS_IMCOMPLETE = "All Incomplete";
724
+ const STATUS_NOT_ACTIONED = "Not Actioned";
725
+ const STATUS_IN_PROGRESS = "In Progress";
726
+ const STATUS_COMPLETED = "Completed";
727
+ const getDefaultPriority = () => jobPriorityOptions.find(p => p.default);
728
+ const getJobPriority = priority => {
729
+ let priorityOption = null;
731
730
  if (priority) priorityOption = jobPriorityOptions.find(p => p.name === priority);
732
731
  return priorityOption || getDefaultPriority();
733
732
  };
734
733
 
735
734
  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; }
736
735
  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; }
737
- var {
736
+ const {
738
737
  Session: Session$7,
739
738
  Components: Components$7,
740
739
  Analytics: Analytics$2
741
740
  } = PlussCore;
742
741
  class JobList extends Component {
743
742
  constructor(props) {
744
- var _this;
745
743
  super(props);
746
- _this = this;
747
744
  _defineProperty(this, "setRequesters", jobs => {
748
- var requesters = _.orderBy(_.uniqBy(jobs.map(j => ({
745
+ const requesters = _.orderBy(_.uniqBy(jobs.map(j => ({
749
746
  id: j.userID,
750
747
  displayName: j.userName,
751
748
  profilePic: j.userProfilePic
@@ -754,32 +751,32 @@ class JobList extends Component {
754
751
  requesters
755
752
  });
756
753
  });
757
- _defineProperty(this, "getJobs", /*#__PURE__*/_asyncToGenerator(function* () {
758
- var {
754
+ _defineProperty(this, "getJobs", async () => {
755
+ const {
759
756
  auth
760
- } = _this.props;
757
+ } = this.props;
761
758
  try {
762
- var res = yield maintenanceActions.getJobsRecursive(auth.site);
759
+ const res = await maintenanceActions.getJobsRecursive(auth.site);
763
760
  if (!_.isEmpty(res) && res[0].site === auth.site) {
764
- _this.setRequesters(res);
765
- _this.props.jobsLoaded(res);
761
+ this.setRequesters(res);
762
+ this.props.jobsLoaded(res);
766
763
  }
767
764
  } catch (error) {
768
765
  console.error("getJobs", error);
769
766
  }
770
- }));
771
- _defineProperty(this, "getAssignees", /*#__PURE__*/_asyncToGenerator(function* () {
767
+ });
768
+ _defineProperty(this, "getAssignees", async () => {
772
769
  try {
773
- var res = yield maintenanceActions.getAssignees(_this.props.auth.site);
774
- _this.setState({
770
+ const res = await maintenanceActions.getAssignees(this.props.auth.site);
771
+ this.setState({
775
772
  assignees: res.data.Users
776
773
  });
777
774
  } catch (error) {
778
775
  console.error("getAssignees", error);
779
776
  }
780
- }));
777
+ });
781
778
  _defineProperty(this, "sortByCol", col => {
782
- var {
779
+ const {
783
780
  sortColumn,
784
781
  sortDesc
785
782
  } = this.state;
@@ -794,23 +791,18 @@ class JobList extends Component {
794
791
  });
795
792
  }
796
793
  });
797
- _defineProperty(this, "onRemoveRequest", /*#__PURE__*/function () {
798
- var _ref3 = _asyncToGenerator(function* (request) {
799
- if (window.confirm(values.textAreYouSureYouWantToDelete)) {
800
- _this.props.removeJob(request.id);
801
- try {
802
- yield maintenanceActions.deleteJob(_this.props.auth.site, request.id);
803
- _this.getJobs();
804
- } catch (error) {
805
- console.log("onRemoveRequest", error);
806
- alert("Something went wrong with the request. Please try again.");
807
- }
794
+ _defineProperty(this, "onRemoveRequest", async request => {
795
+ if (window.confirm(values.textAreYouSureYouWantToDelete)) {
796
+ this.props.removeJob(request.id);
797
+ try {
798
+ await maintenanceActions.deleteJob(this.props.auth.site, request.id);
799
+ this.getJobs();
800
+ } catch (error) {
801
+ console.log("onRemoveRequest", error);
802
+ alert("Something went wrong with the request. Please try again.");
808
803
  }
809
- });
810
- return function (_x) {
811
- return _ref3.apply(this, arguments);
812
- };
813
- }());
804
+ }
805
+ });
814
806
  _defineProperty(this, "openFilter", filter => {
815
807
  this.setState({
816
808
  filterOpen: filter
@@ -863,15 +855,15 @@ class JobList extends Component {
863
855
  if (!this.isValidTimeFilter()) {
864
856
  return;
865
857
  }
866
- var startTime = 0;
867
- var endTime = moment().endOf("d").valueOf();
868
- var text = "";
858
+ let startTime = 0;
859
+ let endTime = moment().endOf("d").valueOf();
860
+ let text = "";
869
861
  if (this.state.selectedTimeFilter.dayCount > 0) {
870
862
  startTime = moment().add(-this.state.selectedTimeFilter.dayCount, "d").startOf("d").valueOf();
871
863
  text = this.state.selectedTimeFilter.text;
872
864
  } else {
873
- var startDate = moment(this.state.timeFilterStart).startOf("d");
874
- var endDate = moment(this.state.timeFilterEnd).endOf("d");
865
+ const startDate = moment(this.state.timeFilterStart).startOf("d");
866
+ const endDate = moment(this.state.timeFilterEnd).endOf("d");
875
867
  startTime = startDate.valueOf();
876
868
  endTime = endDate.valueOf();
877
869
  text = "".concat(startDate.format("DD/MM/YYYY"), " to ").concat(endDate.format("DD/MM/YYYY"));
@@ -942,7 +934,7 @@ class JobList extends Component {
942
934
  this.closeFilter();
943
935
  });
944
936
  _defineProperty(this, "onHandleSearchChange", event => {
945
- var thisSearchTime = moment().valueOf();
937
+ const thisSearchTime = moment().valueOf();
946
938
  this.setState({
947
939
  search: event.target.value,
948
940
  lastSearch: thisSearchTime
@@ -957,7 +949,7 @@ class JobList extends Component {
957
949
  }, 500);
958
950
  });
959
951
  _defineProperty(this, "getSource", () => {
960
- var source = this.props.source;
952
+ let source = this.props.source;
961
953
 
962
954
  // filter by time
963
955
  if (this.state.selectedTimeFilterStart && this.state.selectedTimeFilterEnd) {
@@ -975,7 +967,7 @@ class JobList extends Component {
975
967
 
976
968
  // filter by priority
977
969
  if (this.state.selectedPriorityFilter) {
978
- var defaultPriority = getDefaultPriority().name;
970
+ const defaultPriority = getDefaultPriority().name;
979
971
  source = _.filter(source, r => {
980
972
  return r.priority === this.state.selectedPriorityFilter || this.state.selectedPriorityFilter === defaultPriority && _.isNil(r.priority);
981
973
  });
@@ -983,12 +975,12 @@ class JobList extends Component {
983
975
 
984
976
  // filter by status
985
977
  if (this.state.selectedStatusFilter) {
986
- var {
978
+ const {
987
979
  statusTypes
988
980
  } = this.props;
989
- var defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
981
+ const defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
990
982
  source = _.filter(source, r => {
991
- var status = statusTypes.find(s => s.text === r.status) || defaultStatus;
983
+ const status = statusTypes.find(s => s.text === r.status) || defaultStatus;
992
984
  if (this.state.selectedStatusFilter === STATUS_IMCOMPLETE) {
993
985
  return status.category !== STATUS_COMPLETED;
994
986
  }
@@ -1044,18 +1036,18 @@ class JobList extends Component {
1044
1036
  }
1045
1037
  });
1046
1038
  _defineProperty(this, "getCustomFields", (job, customColumns) => {
1047
- var {
1039
+ const {
1048
1040
  customFields,
1049
1041
  type
1050
1042
  } = job;
1051
- var customValues = {};
1043
+ const customValues = {};
1052
1044
  if (customFields && Array.isArray(customFields)) {
1053
1045
  customFields.forEach(field => {
1054
1046
  // Exclude un-exportable fields
1055
1047
  if (["image", "document", "staticTitle", "staticText"].includes(field.type)) return;
1056
- var fieldKey = "".concat(_.camelCase(type), ".").concat(_.camelCase(field.label));
1048
+ const fieldKey = "".concat(_.camelCase(type), ".").concat(_.camelCase(field.label));
1057
1049
  // Build custom columns
1058
- var exists = customColumns.find(c => c.key === fieldKey);
1050
+ const exists = customColumns.find(c => c.key === fieldKey);
1059
1051
  if (!exists) {
1060
1052
  customColumns.push({
1061
1053
  label: field.label,
@@ -1069,20 +1061,20 @@ class JobList extends Component {
1069
1061
  return customValues;
1070
1062
  });
1071
1063
  _defineProperty(this, "getExportSource", () => {
1072
- var customColumns = [];
1073
- var defaultPriority = getDefaultPriority().name;
1074
- var source = this.getSource().map(r => {
1075
- var history = r.history || [];
1076
- var progressEntry = _.find(history, e => {
1064
+ const customColumns = [];
1065
+ const defaultPriority = getDefaultPriority().name;
1066
+ const source = this.getSource().map(r => {
1067
+ const history = r.history || [];
1068
+ const progressEntry = _.find(history, e => {
1077
1069
  return e.status !== "Unassigned";
1078
1070
  });
1079
- var completedEntry = _.find(history, e => {
1071
+ const completedEntry = _.find(history, e => {
1080
1072
  return e.status === "Completed";
1081
1073
  });
1082
- var progressTime = null;
1083
- var completedTime = null;
1084
- var progressDuration = null;
1085
- var completedDuration = null;
1074
+ let progressTime = null;
1075
+ let completedTime = null;
1076
+ let progressDuration = null;
1077
+ let completedDuration = null;
1086
1078
  if (progressEntry) {
1087
1079
  progressTime = moment.utc(progressEntry.timestamp).format();
1088
1080
  progressDuration = moment.utc(progressEntry.timestamp).unix() - moment.utc(r.createdTime).unix();
@@ -1091,7 +1083,7 @@ class JobList extends Component {
1091
1083
  completedTime = moment.utc(completedEntry.timestamp).format();
1092
1084
  completedDuration = moment.utc(completedEntry.timestamp).unix() - moment.utc(r.createdTime).unix();
1093
1085
  }
1094
- var notes = "";
1086
+ let notes = "";
1095
1087
  (r.Notes || []).forEach((note, index) => {
1096
1088
  if (index > 0) {
1097
1089
  notes += "\n\n";
@@ -1104,8 +1096,8 @@ class JobList extends Component {
1104
1096
  }
1105
1097
  notes += note.Note;
1106
1098
  });
1107
- var customFieldValues = this.getCustomFields(r, customColumns);
1108
- var priority = r.priority || defaultPriority;
1099
+ const customFieldValues = this.getCustomFields(r, customColumns);
1100
+ const priority = r.priority || defaultPriority;
1109
1101
  return _objectSpread$7(_objectSpread$7(_objectSpread$7({}, r), customFieldValues), {}, {
1110
1102
  notes,
1111
1103
  progressTime,
@@ -1117,8 +1109,8 @@ class JobList extends Component {
1117
1109
  });
1118
1110
 
1119
1111
  // Compose revised columns list with custom fields
1120
- var index = this.exportColumns.findIndex(c => c.key === "notes");
1121
- var columns = [...this.exportColumns.slice(0, index), ...customColumns, ...this.exportColumns.slice(index)];
1112
+ const index = this.exportColumns.findIndex(c => c.key === "notes");
1113
+ const columns = [...this.exportColumns.slice(0, index), ...customColumns, ...this.exportColumns.slice(index)];
1122
1114
  return {
1123
1115
  columns,
1124
1116
  source
@@ -1248,7 +1240,7 @@ class JobList extends Component {
1248
1240
  });
1249
1241
  }
1250
1242
  if (this.state.filterOpen === "status") {
1251
- var {
1243
+ const {
1252
1244
  statusTypes
1253
1245
  } = this.props;
1254
1246
  return /*#__PURE__*/jsx(Components$7.Popup, {
@@ -1294,7 +1286,7 @@ class JobList extends Component {
1294
1286
  });
1295
1287
  }
1296
1288
  if (this.state.filterOpen === "user") {
1297
- var userContent = null;
1289
+ let userContent = null;
1298
1290
  if (this.state.selectedAssignee) {
1299
1291
  userContent = /*#__PURE__*/jsx("div", {
1300
1292
  children: /*#__PURE__*/jsx(Components$7.UserListing, {
@@ -1349,9 +1341,9 @@ class JobList extends Component {
1349
1341
  });
1350
1342
  }
1351
1343
  if (this.state.filterOpen === "requester") {
1352
- var _userContent = null;
1344
+ let userContent = null;
1353
1345
  if (this.state.selectedRequester) {
1354
- _userContent = /*#__PURE__*/jsx("div", {
1346
+ userContent = /*#__PURE__*/jsx("div", {
1355
1347
  children: /*#__PURE__*/jsx(Components$7.UserListing, {
1356
1348
  user: this.state.selectedRequester,
1357
1349
  rightContent: /*#__PURE__*/jsx(Icon, {
@@ -1365,7 +1357,7 @@ class JobList extends Component {
1365
1357
  }, this.state.selectedRequester.id)
1366
1358
  });
1367
1359
  } else {
1368
- _userContent = /*#__PURE__*/jsxs("div", {
1360
+ userContent = /*#__PURE__*/jsxs("div", {
1369
1361
  children: [/*#__PURE__*/jsx(Components$7.GenericInput, {
1370
1362
  id: "requesterSearch",
1371
1363
  type: "text"
@@ -1400,22 +1392,22 @@ class JobList extends Component {
1400
1392
  text: "Select",
1401
1393
  isActive: true
1402
1394
  }],
1403
- children: _userContent
1395
+ children: userContent
1404
1396
  });
1405
1397
  }
1406
1398
  return null;
1407
1399
  }
1408
1400
  renderRequests() {
1409
- var {
1401
+ const {
1410
1402
  statusTypes
1411
1403
  } = this.props;
1412
- var defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
1404
+ const defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
1413
1405
  return this.getSource().map((ev, index) => {
1414
1406
  if (!ev) {
1415
1407
  return null;
1416
1408
  }
1417
- var status = ev.status && statusTypes.find(s => s.text === ev.status) || defaultStatus;
1418
- var priority = getJobPriority(ev.priority);
1409
+ const status = ev.status && statusTypes.find(s => s.text === ev.status) || defaultStatus;
1410
+ const priority = getJobPriority(ev.priority);
1419
1411
  return /*#__PURE__*/jsxs("tr", {
1420
1412
  children: [/*#__PURE__*/jsx("td", {
1421
1413
  children: ev.jobId
@@ -1508,7 +1500,7 @@ class JobList extends Component {
1508
1500
  });
1509
1501
  }
1510
1502
  renderSort(col) {
1511
- var {
1503
+ const {
1512
1504
  sortColumn,
1513
1505
  sortDesc
1514
1506
  } = this.state;
@@ -1525,7 +1517,7 @@ class JobList extends Component {
1525
1517
  return " table--columnActive";
1526
1518
  }
1527
1519
  renderEmpty() {
1528
- var title = this.props.strings["".concat(values.featureKey, "_textTitleRequests")] || values.textTitleRequests;
1520
+ const title = this.props.strings["".concat(values.featureKey, "_textTitleRequests")] || values.textTitleRequests;
1529
1521
  return /*#__PURE__*/jsxs("div", {
1530
1522
  style: {
1531
1523
  display: "flex",
@@ -1664,42 +1656,42 @@ class JobList extends Component {
1664
1656
  });
1665
1657
  }
1666
1658
  renderFilters() {
1667
- var typeFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1659
+ let typeFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1668
1660
  className: "marginRight-10",
1669
1661
  onClick: () => {
1670
1662
  this.openFilter("type");
1671
1663
  },
1672
1664
  text: values.textJobType
1673
1665
  });
1674
- var statusFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1666
+ let statusFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1675
1667
  className: "marginRight-10",
1676
1668
  onClick: () => {
1677
1669
  this.openFilter("status");
1678
1670
  },
1679
1671
  text: "Status"
1680
1672
  });
1681
- var priorityFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1673
+ let priorityFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1682
1674
  className: "marginRight-10",
1683
1675
  onClick: () => {
1684
1676
  this.openFilter("priority");
1685
1677
  },
1686
1678
  text: "Priority"
1687
1679
  });
1688
- var timeFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1680
+ let timeFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1689
1681
  className: "marginRight-10",
1690
1682
  onClick: () => {
1691
1683
  this.openFilter("time");
1692
1684
  },
1693
1685
  text: "Time"
1694
1686
  });
1695
- var userFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1687
+ let userFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1696
1688
  className: "marginRight-10",
1697
1689
  onClick: () => {
1698
1690
  this.openFilter("user");
1699
1691
  },
1700
1692
  text: "Assigned To"
1701
1693
  });
1702
- var requesterFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1694
+ let requesterFilter = /*#__PURE__*/jsx(Components$7.Tag, {
1703
1695
  className: "marginRight-10",
1704
1696
  onClick: () => {
1705
1697
  this.openFilter("requester");
@@ -1825,7 +1817,7 @@ class JobList extends Component {
1825
1817
  if (!this.state.exportCsvOpen) {
1826
1818
  return null;
1827
1819
  }
1828
- var {
1820
+ const {
1829
1821
  columns,
1830
1822
  source
1831
1823
  } = this.getExportSource();
@@ -1845,8 +1837,8 @@ class JobList extends Component {
1845
1837
  });
1846
1838
  }
1847
1839
  }
1848
- var mapStateToProps$7 = state => {
1849
- var {
1840
+ const mapStateToProps$7 = state => {
1841
+ const {
1850
1842
  auth
1851
1843
  } = state;
1852
1844
  return {
@@ -1862,27 +1854,25 @@ var JobList$1 = connect(mapStateToProps$7, {
1862
1854
  jobStatusesUpdate
1863
1855
  })(withRouter(JobList));
1864
1856
 
1865
- var {
1857
+ const {
1866
1858
  Session: Session$6,
1867
1859
  Components: Components$6
1868
1860
  } = PlussCore;
1869
1861
  class JobTypes extends Component {
1870
1862
  constructor(props) {
1871
- var _this;
1872
1863
  super(props);
1873
- _this = this;
1874
- _defineProperty(this, "getJobTypes", /*#__PURE__*/_asyncToGenerator(function* () {
1864
+ _defineProperty(this, "getJobTypes", async () => {
1875
1865
  try {
1876
- var res = yield maintenanceActions.getJobTypes(_this.props.auth.site);
1877
- if (res.data != null) _this.props.jobTypesLoaded(res.data);
1866
+ const res = await maintenanceActions.getJobTypes(this.props.auth.site);
1867
+ if (res.data != null) this.props.jobTypesLoaded(res.data);
1878
1868
  } catch (error) {
1879
1869
  console.error("getJobTypes", error);
1880
1870
  } finally {
1881
- _this.setState({
1871
+ this.setState({
1882
1872
  loading: false
1883
1873
  });
1884
1874
  }
1885
- }));
1875
+ });
1886
1876
  _defineProperty(this, "sortByCol", col => {
1887
1877
  if (this.state.sortColumn === col) {
1888
1878
  this.setState({
@@ -1895,28 +1885,23 @@ class JobTypes extends Component {
1895
1885
  });
1896
1886
  }
1897
1887
  });
1898
- _defineProperty(this, "onRemoveJobType", /*#__PURE__*/function () {
1899
- var _ref2 = _asyncToGenerator(function* (ev) {
1900
- if (!window.confirm("Are you sure you want to delete ".concat(ev.typeName, "?"))) return;
1901
- try {
1902
- yield maintenanceActions.deleteJobType(_this.props.auth.site, ev.id);
1903
- var index = _.findIndex(_this.state.jobList, job => {
1904
- return job != null && job.id === ev.id;
1905
- });
1906
- if (index > -1) {
1907
- var newJobTypes = [..._this.state.jobList];
1908
- newJobTypes[index].Deleted = true;
1909
- _this.props.jobTypesLoaded(newJobTypes);
1910
- }
1911
- } catch (error) {
1912
- console.error("onRemoveJobType", error);
1913
- alert("Something went wrong with the request. Please try again.");
1888
+ _defineProperty(this, "onRemoveJobType", async ev => {
1889
+ if (!window.confirm("Are you sure you want to delete ".concat(ev.typeName, "?"))) return;
1890
+ try {
1891
+ await maintenanceActions.deleteJobType(this.props.auth.site, ev.id);
1892
+ const index = _.findIndex(this.state.jobList, job => {
1893
+ return job != null && job.id === ev.id;
1894
+ });
1895
+ if (index > -1) {
1896
+ const newJobTypes = [...this.state.jobList];
1897
+ newJobTypes[index].Deleted = true;
1898
+ this.props.jobTypesLoaded(newJobTypes);
1914
1899
  }
1915
- });
1916
- return function (_x) {
1917
- return _ref2.apply(this, arguments);
1918
- };
1919
- }());
1900
+ } catch (error) {
1901
+ console.error("onRemoveJobType", error);
1902
+ alert("Something went wrong with the request. Please try again.");
1903
+ }
1904
+ });
1920
1905
  this.state = {
1921
1906
  jobList: [],
1922
1907
  sortColumn: "name",
@@ -1940,7 +1925,7 @@ class JobTypes extends Component {
1940
1925
  });
1941
1926
  }
1942
1927
  renderList() {
1943
- var source = _.sortBy(this.state.jobList, this.state.sortColumn);
1928
+ let source = _.sortBy(this.state.jobList, this.state.sortColumn);
1944
1929
  if (this.state.sortDesc) source.reverse();
1945
1930
  source = _.filter(source, ev => {
1946
1931
  if (!ev) return false;
@@ -2075,7 +2060,7 @@ class JobTypes extends Component {
2075
2060
  return this.renderView();
2076
2061
  }
2077
2062
  renderJobTypes() {
2078
- var {
2063
+ const {
2079
2064
  jobList,
2080
2065
  loading
2081
2066
  } = this.state;
@@ -2127,8 +2112,8 @@ class JobTypes extends Component {
2127
2112
  });
2128
2113
  }
2129
2114
  }
2130
- var mapStateToProps$6 = state => {
2131
- var {
2115
+ const mapStateToProps$6 = state => {
2116
+ const {
2132
2117
  auth
2133
2118
  } = state;
2134
2119
  return {
@@ -2143,7 +2128,7 @@ var JobTypes$1 = connect(mapStateToProps$6, {
2143
2128
 
2144
2129
  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; }
2145
2130
  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; }
2146
- var {
2131
+ const {
2147
2132
  Session: Session$5,
2148
2133
  Components: Components$5,
2149
2134
  Colours: Colours$3
@@ -2160,9 +2145,9 @@ class Configuration extends Component {
2160
2145
  return true;
2161
2146
  });
2162
2147
  _defineProperty(this, "onMoveStatus", function (index) {
2163
- var up = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2148
+ let up = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2164
2149
  if (_this.state.fetchingStatusTypes) return;
2165
- var statusTypes = _.cloneDeep(_this.state.statusTypes);
2150
+ const statusTypes = _.cloneDeep(_this.state.statusTypes);
2166
2151
  if (up && index > 0) {
2167
2152
  // Moving up
2168
2153
  [statusTypes[index - 1], statusTypes[index]] = [statusTypes[index], statusTypes[index - 1]];
@@ -2178,7 +2163,7 @@ class Configuration extends Component {
2178
2163
  });
2179
2164
  _defineProperty(this, "onEditStatus", index => {
2180
2165
  if (this.state.fetchingStatusTypes) return;
2181
- var status = this.state.statusTypes[index];
2166
+ const status = this.state.statusTypes[index];
2182
2167
  this.setState({
2183
2168
  showWarnings: false,
2184
2169
  showStatusPopup: true,
@@ -2190,14 +2175,14 @@ class Configuration extends Component {
2190
2175
  });
2191
2176
  _defineProperty(this, "onDeleteStatus", index => {
2192
2177
  if (this.state.fetchingStatusTypes) return;
2193
- var statusTypes = _.cloneDeep(this.state.statusTypes);
2178
+ const statusTypes = _.cloneDeep(this.state.statusTypes);
2194
2179
  statusTypes.splice(index, 1);
2195
2180
  this.setState({
2196
2181
  statusTypes
2197
2182
  });
2198
2183
  });
2199
2184
  _defineProperty(this, "onAddStatus", () => {
2200
- var defaultStatus = this.props.statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
2185
+ const defaultStatus = this.props.statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
2201
2186
  this.setState({
2202
2187
  showWarnings: false,
2203
2188
  showStatusPopup: true,
@@ -2208,13 +2193,13 @@ class Configuration extends Component {
2208
2193
  });
2209
2194
  });
2210
2195
  _defineProperty(this, "onSaveStatus", () => {
2211
- var {
2196
+ const {
2212
2197
  selectedStatusIndex,
2213
2198
  statusLabel,
2214
2199
  statusCategory,
2215
2200
  statusColour
2216
2201
  } = this.state;
2217
- var statusTypes = _.cloneDeep(this.state.statusTypes);
2202
+ const statusTypes = _.cloneDeep(this.state.statusTypes);
2218
2203
  if (selectedStatusIndex < 0) {
2219
2204
  statusTypes.push({
2220
2205
  text: statusLabel,
@@ -2223,7 +2208,7 @@ class Configuration extends Component {
2223
2208
  category: statusCategory
2224
2209
  });
2225
2210
  } else {
2226
- var status = statusTypes[selectedStatusIndex];
2211
+ const status = statusTypes[selectedStatusIndex];
2227
2212
  status.text = statusLabel;
2228
2213
  status.color = statusColour;
2229
2214
  status.category = statusCategory;
@@ -2255,30 +2240,30 @@ class Configuration extends Component {
2255
2240
  this.setState({
2256
2241
  success: false,
2257
2242
  submitting: true
2258
- }, /*#__PURE__*/_asyncToGenerator(function* () {
2243
+ }, async () => {
2259
2244
  try {
2260
- var {
2245
+ const {
2261
2246
  statusTypes,
2262
2247
  hideSeen
2263
- } = _this.state;
2264
- yield stringActions.setString(_this.props.auth.site, values.stringConfigJobStatus, statusTypes);
2265
- yield stringActions.setString(_this.props.auth.site, values.stringConfigHideSeen, hideSeen);
2266
- _this.props.jobStatusesLoaded(statusTypes);
2267
- _this.props.jobHideSeenLoaded(hideSeen);
2268
- _this.setState({
2248
+ } = this.state;
2249
+ await stringActions.setString(this.props.auth.site, values.stringConfigJobStatus, statusTypes);
2250
+ await stringActions.setString(this.props.auth.site, values.stringConfigHideSeen, hideSeen);
2251
+ this.props.jobStatusesLoaded(statusTypes);
2252
+ this.props.jobHideSeenLoaded(hideSeen);
2253
+ this.setState({
2269
2254
  success: true
2270
2255
  });
2271
2256
  } catch (error) {
2272
2257
  console.log("onSaveConfig - error", error);
2273
- _this.setState({
2258
+ this.setState({
2274
2259
  success: false
2275
2260
  });
2276
2261
  } finally {
2277
- _this.setState({
2262
+ this.setState({
2278
2263
  submitting: false
2279
2264
  });
2280
2265
  }
2281
- }));
2266
+ });
2282
2267
  });
2283
2268
  this.state = {
2284
2269
  success: false,
@@ -2312,15 +2297,15 @@ class Configuration extends Component {
2312
2297
  }
2313
2298
  }
2314
2299
  validateForm() {
2315
- var {
2300
+ const {
2316
2301
  submitting,
2317
2302
  statusTypes
2318
2303
  } = this.state;
2319
2304
  if (submitting) return false;
2320
2305
 
2321
2306
  // Validate statuses
2322
- var statusesValid = statusTypes.map(status => {
2323
- var {
2307
+ const statusesValid = statusTypes.map(status => {
2308
+ const {
2324
2309
  text,
2325
2310
  category,
2326
2311
  color
@@ -2331,7 +2316,7 @@ class Configuration extends Component {
2331
2316
  return true;
2332
2317
  }
2333
2318
  renderStatuses() {
2334
- var {
2319
+ const {
2335
2320
  statusTypes
2336
2321
  } = this.state;
2337
2322
  return /*#__PURE__*/jsxs("div", {
@@ -2443,7 +2428,7 @@ class Configuration extends Component {
2443
2428
  });
2444
2429
  }
2445
2430
  renderNewStatusPopup() {
2446
- var {
2431
+ const {
2447
2432
  submitting,
2448
2433
  showStatusPopup,
2449
2434
  showWarnings,
@@ -2453,7 +2438,7 @@ class Configuration extends Component {
2453
2438
  statusColour
2454
2439
  } = this.state;
2455
2440
  if (!showStatusPopup) return null;
2456
- var canSave = !submitting && this.isStatusValid(statusLabel, statusCategory, statusColour);
2441
+ const canSave = !submitting && this.isStatusValid(statusLabel, statusCategory, statusColour);
2457
2442
  return /*#__PURE__*/jsxs(Components$5.Popup, {
2458
2443
  maxWidth: 800,
2459
2444
  minWidth: 450,
@@ -2562,7 +2547,7 @@ class Configuration extends Component {
2562
2547
  });
2563
2548
  }
2564
2549
  }
2565
- var styles$6 = {
2550
+ const styles$6 = {
2566
2551
  statusCategoryHeading: {
2567
2552
  marginLeft: 130,
2568
2553
  width: 160,
@@ -2596,8 +2581,8 @@ var styles$6 = {
2596
2581
  marginLeft: 15
2597
2582
  }
2598
2583
  };
2599
- var mapStateToProps$5 = state => {
2600
- var {
2584
+ const mapStateToProps$5 = state => {
2585
+ const {
2601
2586
  auth
2602
2587
  } = state;
2603
2588
  return {
@@ -2613,27 +2598,25 @@ var Configuration$1 = connect(mapStateToProps$5, {
2613
2598
  jobHideSeenLoaded
2614
2599
  })(withRouter(Configuration));
2615
2600
 
2616
- var {
2601
+ const {
2617
2602
  Components: Components$4,
2618
2603
  Session: Session$4,
2619
2604
  Urls
2620
2605
  } = PlussCore;
2621
2606
  class RequestsHub extends Component {
2622
2607
  constructor(props) {
2623
- var _this;
2624
2608
  super(props);
2625
- _this = this;
2626
2609
  _defineProperty(this, "setData", () => {
2627
- var allList = [];
2610
+ const allList = [];
2628
2611
  this.state.allList.forEach(ev => {
2629
2612
  if (ev != null && !ev.Deleted) allList.push(ev);
2630
2613
  });
2631
- var upcoming = _.filter(allList, ev => {
2614
+ const upcoming = _.filter(allList, ev => {
2632
2615
  if (!ev) return false;
2633
2616
  if (ev.status && ev.status === "Completed") return false;
2634
2617
  return true;
2635
2618
  });
2636
- var completed = _.filter(allList, ev => {
2619
+ const completed = _.filter(allList, ev => {
2637
2620
  if (!ev) return false;
2638
2621
  if (ev.status && ev.status === "Completed") return true;
2639
2622
  return false;
@@ -2647,30 +2630,30 @@ class RequestsHub extends Component {
2647
2630
  });
2648
2631
  });
2649
2632
  _defineProperty(this, "getData", () => {
2650
- var {
2633
+ const {
2651
2634
  auth
2652
2635
  } = this.props;
2653
2636
  this.setState({
2654
2637
  loadingAll: true
2655
- }, /*#__PURE__*/_asyncToGenerator(function* () {
2638
+ }, async () => {
2656
2639
  try {
2657
- var res = yield maintenanceActions.getJobsRecursive(auth.site);
2658
- _this.setState({
2640
+ const res = await maintenanceActions.getJobsRecursive(auth.site);
2641
+ this.setState({
2659
2642
  loadingAll: false
2660
2643
  });
2661
2644
  if (!_.isEmpty(res) && res[0].site === auth.site) {
2662
- _this.props.jobsLoaded(res);
2645
+ this.props.jobsLoaded(res);
2663
2646
  }
2664
2647
  } catch (error) {
2665
2648
  console.error("getData", error);
2666
- _this.setState({
2649
+ this.setState({
2667
2650
  loadingAll: false
2668
2651
  });
2669
2652
  }
2670
- }));
2653
+ });
2671
2654
  });
2672
2655
  _defineProperty(this, "onAddNew", () => {
2673
- var {
2656
+ const {
2674
2657
  auth
2675
2658
  } = this.props;
2676
2659
  if (Session$4.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) {
@@ -2678,7 +2661,7 @@ class RequestsHub extends Component {
2678
2661
  }
2679
2662
  });
2680
2663
  _defineProperty(this, "onAddRequestType", () => {
2681
- var {
2664
+ const {
2682
2665
  auth
2683
2666
  } = this.props;
2684
2667
  if (Session$4.validateAccess(auth.site, values.permissionMaintenanceTypes, auth)) {
@@ -2686,7 +2669,7 @@ class RequestsHub extends Component {
2686
2669
  }
2687
2670
  });
2688
2671
  _defineProperty(this, "canAddNew", isClass => {
2689
- var {
2672
+ const {
2690
2673
  auth
2691
2674
  } = this.props;
2692
2675
  if (Session$4.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return isClass ? "" : true;
@@ -2730,7 +2713,7 @@ class RequestsHub extends Component {
2730
2713
  }, this.setData);
2731
2714
  }
2732
2715
  renderLeftBar() {
2733
- var sectionItems = [];
2716
+ const sectionItems = [];
2734
2717
  if (this.canAddNew()) {
2735
2718
  sectionItems.push({
2736
2719
  type: "newButton",
@@ -2778,7 +2761,7 @@ class RequestsHub extends Component {
2778
2761
  }
2779
2762
  });
2780
2763
  }
2781
- var helpGuide = {
2764
+ const helpGuide = {
2782
2765
  text: "Help with ".concat(values.textTitleRequests),
2783
2766
  url: Urls.HelpGuide.Maintenance
2784
2767
  } ;
@@ -2815,7 +2798,7 @@ class RequestsHub extends Component {
2815
2798
  });
2816
2799
  }
2817
2800
  }
2818
- var styles$5 = {
2801
+ const styles$5 = {
2819
2802
  sideBarTitleSection: {
2820
2803
  lineHeight: "40px",
2821
2804
  marginTop: 30,
@@ -2838,8 +2821,8 @@ var styles$5 = {
2838
2821
  color: FeatureConfig.env.colourBrandingOff
2839
2822
  }
2840
2823
  };
2841
- var mapStateToProps$4 = state => {
2842
- var {
2824
+ const mapStateToProps$4 = state => {
2825
+ const {
2843
2826
  auth
2844
2827
  } = state;
2845
2828
  return {
@@ -2854,48 +2837,46 @@ var RequestsHub$1 = connect(mapStateToProps$4, {
2854
2837
 
2855
2838
  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; }
2856
2839
  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; }
2857
- var {
2840
+ const {
2858
2841
  Apis: Apis$1,
2859
2842
  Helper: Helper$3,
2860
2843
  Session: Session$3,
2861
2844
  Colours: Colours$2,
2862
2845
  Components: Components$3
2863
2846
  } = PlussCore;
2864
- var IMAGE_SIZE_NOTE = 72;
2847
+ const IMAGE_SIZE_NOTE = 72;
2865
2848
  class Job extends Component {
2866
2849
  constructor(props) {
2867
- var _this;
2868
2850
  super(props);
2869
- _this = this;
2870
- _defineProperty(this, "getJob", /*#__PURE__*/_asyncToGenerator(function* () {
2851
+ _defineProperty(this, "getJob", async () => {
2871
2852
  try {
2872
- var res = yield maintenanceActions.getJob(_this.props.auth.site, _this.state.jobId);
2873
- _this.setState({
2853
+ const res = await maintenanceActions.getJob(this.props.auth.site, this.state.jobId);
2854
+ this.setState({
2874
2855
  updating: false
2875
2856
  });
2876
2857
  res.data.location = res.data.site;
2877
- _this.setJob(res.data);
2858
+ this.setJob(res.data);
2878
2859
  } catch (error) {
2879
2860
  console.error("getJob", error);
2880
2861
  }
2881
- }));
2882
- _defineProperty(this, "getAssignees", /*#__PURE__*/_asyncToGenerator(function* () {
2862
+ });
2863
+ _defineProperty(this, "getAssignees", async () => {
2883
2864
  try {
2884
- var res = yield maintenanceActions.getAssignees(_this.props.auth.site);
2885
- _this.setState({
2865
+ const res = await maintenanceActions.getAssignees(this.props.auth.site);
2866
+ this.setState({
2886
2867
  assignees: res.data.Users
2887
2868
  });
2888
2869
  } catch (error) {
2889
2870
  console.error("getAssignees", error);
2890
2871
  }
2891
- }));
2892
- _defineProperty(this, "getExternalSync", /*#__PURE__*/_asyncToGenerator(function* () {
2872
+ });
2873
+ _defineProperty(this, "getExternalSync", async () => {
2893
2874
  try {
2894
- _this.setState({
2875
+ this.setState({
2895
2876
  loadingExternalSync: true
2896
2877
  });
2897
- var res = yield maintenanceActions.getExternalSync(_this.state.jobId);
2898
- _this.setState({
2878
+ const res = await maintenanceActions.getExternalSync(this.state.jobId);
2879
+ this.setState({
2899
2880
  externalSync: res.data,
2900
2881
  loadingExternalSync: false
2901
2882
  });
@@ -2904,44 +2885,44 @@ class Job extends Component {
2904
2885
  if (error && error.response && error.response.status !== 404) {
2905
2886
  console.error("getExternalSync", error);
2906
2887
  }
2907
- _this.setState({
2888
+ this.setState({
2908
2889
  loadingExternalSync: false
2909
2890
  });
2910
2891
  }
2911
- }));
2912
- _defineProperty(this, "onRetrySync", /*#__PURE__*/_asyncToGenerator(function* () {
2913
- var {
2892
+ });
2893
+ _defineProperty(this, "onRetrySync", async () => {
2894
+ const {
2914
2895
  job
2915
- } = _this.state;
2916
- if (!job || _this.state.retryingSync) return;
2917
- _this.setState({
2896
+ } = this.state;
2897
+ if (!job || this.state.retryingSync) return;
2898
+ this.setState({
2918
2899
  retryingSync: true,
2919
2900
  retrySyncError: null
2920
2901
  });
2921
2902
  try {
2922
- yield maintenanceActions.retrySync(job.id);
2903
+ await maintenanceActions.retrySync(job.id);
2923
2904
  // Refresh job data to get updated history
2924
- yield _this.getJob();
2925
- _this.setState({
2905
+ await this.getJob();
2906
+ this.setState({
2926
2907
  retryingSync: false,
2927
2908
  retrySyncInitiated: true
2928
2909
  });
2929
2910
  } catch (error) {
2930
2911
  console.error("onRetrySync", error);
2931
- var errorMessage = error && error.response && error.response.data && error.response.data.error || "Failed to retry sync. Please try again.";
2932
- _this.setState({
2912
+ const errorMessage = error && error.response && error.response.data && error.response.data.error || "Failed to retry sync. Please try again.";
2913
+ this.setState({
2933
2914
  retryingSync: false,
2934
2915
  retrySyncError: errorMessage
2935
2916
  });
2936
2917
  }
2937
- }));
2918
+ });
2938
2919
  _defineProperty(this, "getStatusType", status => {
2939
- var {
2920
+ const {
2940
2921
  statusTypes
2941
2922
  } = this.props;
2942
- var statusType = statusTypes.find(s => s.text === status);
2923
+ let statusType = statusTypes.find(s => s.text === status);
2943
2924
  if (!statusType) {
2944
- var defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
2925
+ const defaultStatus = statusTypes.find(s => s.category === STATUS_NOT_ACTIONED);
2945
2926
  statusType = _objectSpread$5(_objectSpread$5({}, defaultStatus), {}, {
2946
2927
  text: status
2947
2928
  });
@@ -2963,7 +2944,7 @@ class Job extends Component {
2963
2944
  isEmpty: true
2964
2945
  }];
2965
2946
  }
2966
- var needToMarkSeen = false;
2947
+ let needToMarkSeen = false;
2967
2948
  if (!job.seen) {
2968
2949
  job.seen = true;
2969
2950
  needToMarkSeen = true;
@@ -2977,7 +2958,7 @@ class Job extends Component {
2977
2958
  });
2978
2959
  _defineProperty(this, "editJob", () => {});
2979
2960
  _defineProperty(this, "isReadyToSaveNote", () => {
2980
- var {
2961
+ const {
2981
2962
  noteAttachments,
2982
2963
  noteInput,
2983
2964
  noteImages
@@ -2992,7 +2973,7 @@ class Job extends Component {
2992
2973
  });
2993
2974
  });
2994
2975
  _defineProperty(this, "onCloseAddNote", () => {
2995
- var newState = {
2976
+ const newState = {
2996
2977
  addNoteOpen: false,
2997
2978
  editingNote: null
2998
2979
  };
@@ -3015,10 +2996,10 @@ class Job extends Component {
3015
2996
  }
3016
2997
  });
3017
2998
  _defineProperty(this, "onHandlePDFFileChange", event => {
3018
- var file = event.target.files[0];
2999
+ const file = event.target.files[0];
3019
3000
  if (!file || this.state.uploadingNoteAttachment) return;
3020
- var noteAttachments = [...this.state.noteAttachments];
3021
- var newAttachment = {
3001
+ const noteAttachments = [...this.state.noteAttachments];
3002
+ const newAttachment = {
3022
3003
  Uploading: true,
3023
3004
  Title: file.name
3024
3005
  };
@@ -3042,9 +3023,9 @@ class Job extends Component {
3042
3023
  event.target.value = "";
3043
3024
  });
3044
3025
  _defineProperty(this, "onRemoveAttachment", a => {
3045
- var index = this.state.noteAttachments.indexOf(a);
3026
+ const index = this.state.noteAttachments.indexOf(a);
3046
3027
  if (index > -1) {
3047
- var newAttachments = [...this.state.noteAttachments];
3028
+ const newAttachments = [...this.state.noteAttachments];
3048
3029
  newAttachments.splice(index, 1);
3049
3030
  this.setState({
3050
3031
  noteAttachments: newAttachments
@@ -3066,54 +3047,49 @@ class Job extends Component {
3066
3047
  selectedAssignee: user
3067
3048
  });
3068
3049
  });
3069
- _defineProperty(this, "onConfirmAssignee", /*#__PURE__*/_asyncToGenerator(function* () {
3070
- _this.setState({
3050
+ _defineProperty(this, "onConfirmAssignee", async () => {
3051
+ this.setState({
3071
3052
  confirmingAssignee: true
3072
3053
  });
3073
3054
  try {
3074
- if (_this.state.selectedAssignee) {
3075
- yield _this.onAssignUser(_this.state.selectedAssignee.id);
3055
+ if (this.state.selectedAssignee) {
3056
+ await this.onAssignUser(this.state.selectedAssignee.id);
3076
3057
  }
3077
- _this.onCloseSelectAssignee();
3058
+ this.onCloseSelectAssignee();
3078
3059
  } catch (error) {
3079
3060
  console.error("onConfirmAssignee", error);
3080
3061
  }
3081
- _this.setState({
3062
+ this.setState({
3082
3063
  confirmingAssignee: false
3083
3064
  });
3084
- }));
3065
+ });
3085
3066
  // Method to handle user assignment
3086
- _defineProperty(this, "onAssignUser", /*#__PURE__*/function () {
3087
- var _ref6 = _asyncToGenerator(function* (userId) {
3088
- try {
3089
- var res = yield maintenanceActions.assignJob(_this.state.jobId, userId);
3090
- _this.getJob();
3091
- } catch (err) {
3092
- console.error("onAssignUser", err);
3093
- }
3094
- });
3095
- return function (_x) {
3096
- return _ref6.apply(this, arguments);
3097
- };
3098
- }());
3099
- _defineProperty(this, "onConfirmAddNote", /*#__PURE__*/_asyncToGenerator(function* () {
3100
- if (!_this.isReadyToSaveNote()) return;
3067
+ _defineProperty(this, "onAssignUser", async userId => {
3101
3068
  try {
3102
- _this.setState({
3069
+ const res = await maintenanceActions.assignJob(this.state.jobId, userId);
3070
+ this.getJob();
3071
+ } catch (err) {
3072
+ console.error("onAssignUser", err);
3073
+ }
3074
+ });
3075
+ _defineProperty(this, "onConfirmAddNote", async () => {
3076
+ if (!this.isReadyToSaveNote()) return;
3077
+ try {
3078
+ this.setState({
3103
3079
  submittingNote: true
3104
3080
  });
3105
- var res = yield _this.state.editingNote ? maintenanceActions.editNote(_this.state.jobId, _this.state.editingNote, _this.state.noteInput, _this.state.noteAttachments.map(a => {
3081
+ const res = await (this.state.editingNote ? maintenanceActions.editNote(this.state.jobId, this.state.editingNote, this.state.noteInput, this.state.noteAttachments.map(a => {
3106
3082
  return {
3107
3083
  Title: a.Title,
3108
3084
  Source: a.Source
3109
3085
  };
3110
- }), _this.state.noteImages) : maintenanceActions.addNote(_this.state.jobId, _this.state.noteInput, _this.state.noteAttachments.map(a => {
3086
+ }), this.state.noteImages) : maintenanceActions.addNote(this.state.jobId, this.state.noteInput, this.state.noteAttachments.map(a => {
3111
3087
  return {
3112
3088
  Title: a.Title,
3113
3089
  Source: a.Source
3114
3090
  };
3115
- }), _this.state.noteImages);
3116
- _this.setState({
3091
+ }), this.state.noteImages));
3092
+ this.setState({
3117
3093
  job: res.data.job,
3118
3094
  submittingNote: false,
3119
3095
  addNoteOpen: false,
@@ -3122,12 +3098,12 @@ class Job extends Component {
3122
3098
  noteImages: [],
3123
3099
  editingNote: null
3124
3100
  }, () => {
3125
- _this.props.jobsLoaded([_this.state.job]);
3101
+ this.props.jobsLoaded([this.state.job]);
3126
3102
  });
3127
3103
  } catch (err) {
3128
3104
  console.error("onConfirmAddNote", err);
3129
3105
  }
3130
- }));
3106
+ });
3131
3107
  _defineProperty(this, "onDeleteNote", n => {
3132
3108
  if (!window.confirm(values.textAreYouSureYouWantToDeleteNote)) {
3133
3109
  this.setState({
@@ -3136,8 +3112,8 @@ class Job extends Component {
3136
3112
  return;
3137
3113
  }
3138
3114
  maintenanceActions.deleteNote(this.state.jobId, n.Id);
3139
- var newNotes = _.filter(this.state.job.Notes, note => note.Id !== n.Id);
3140
- var newJob = _objectSpread$5({}, this.state.job);
3115
+ const newNotes = _.filter(this.state.job.Notes, note => note.Id !== n.Id);
3116
+ const newJob = _objectSpread$5({}, this.state.job);
3141
3117
  newJob.Notes = newNotes;
3142
3118
  this.setState({
3143
3119
  job: newJob,
@@ -3155,10 +3131,10 @@ class Job extends Component {
3155
3131
  }, this.checkSetImage);
3156
3132
  });
3157
3133
  _defineProperty(this, "markSeen", () => {
3158
- var {
3134
+ const {
3159
3135
  job
3160
3136
  } = this.state;
3161
- var {
3137
+ const {
3162
3138
  auth
3163
3139
  } = this.props;
3164
3140
  // Must have maintenance permission and not the requester
@@ -3166,22 +3142,22 @@ class Job extends Component {
3166
3142
  if (auth.user.Id === job.userID) return;
3167
3143
  this.setState({
3168
3144
  updating: true
3169
- }, /*#__PURE__*/_asyncToGenerator(function* () {
3145
+ }, async () => {
3170
3146
  try {
3171
- var update = {
3147
+ const update = {
3172
3148
  id: job.id,
3173
3149
  seen: true,
3174
3150
  status: job.status || "Unassigned"
3175
3151
  };
3176
- yield maintenanceActions.editJob(update, auth.site);
3152
+ await maintenanceActions.editJob(update, auth.site);
3177
3153
  } catch (error) {
3178
- _this.setState({
3154
+ this.setState({
3179
3155
  updating: false
3180
3156
  });
3181
3157
  console.log("markSeen error", error);
3182
3158
  alert("Something went wrong with the request. Please try again.");
3183
3159
  }
3184
- }));
3160
+ });
3185
3161
  });
3186
3162
  _defineProperty(this, "getComments", () => {
3187
3163
  reactionActions.getComments(this.state.jobId, values.commentKey, 0).then(res => {
@@ -3190,25 +3166,25 @@ class Job extends Component {
3190
3166
  });
3191
3167
  });
3192
3168
  });
3193
- _defineProperty(this, "onAddComment", /*#__PURE__*/_asyncToGenerator(function* () {
3194
- var {
3169
+ _defineProperty(this, "onAddComment", async () => {
3170
+ const {
3195
3171
  commentInput,
3196
3172
  jobId,
3197
3173
  job,
3198
3174
  comments
3199
- } = _this.state;
3175
+ } = this.state;
3200
3176
  try {
3201
- _this.setState({
3177
+ this.setState({
3202
3178
  commentInput: ""
3203
3179
  });
3204
- var res = yield reactionActions.addComment(jobId, values.commentKey, job.title, job.site, commentInput);
3205
- _this.setState({
3180
+ const res = await reactionActions.addComment(jobId, values.commentKey, job.title, job.site, commentInput);
3181
+ this.setState({
3206
3182
  comments: [...comments, res.data]
3207
3183
  });
3208
3184
  } catch (error) {
3209
3185
  console.error("onAddComment", error);
3210
3186
  }
3211
- }));
3187
+ });
3212
3188
  _defineProperty(this, "onHandleChange", event => {
3213
3189
  var stateChange = {};
3214
3190
  stateChange[event.target.getAttribute("id")] = event.target.value;
@@ -3219,61 +3195,51 @@ class Job extends Component {
3219
3195
  priorityChangerOpen: !this.state.priorityChangerOpen
3220
3196
  });
3221
3197
  });
3222
- _defineProperty(this, "onSelectPriority", /*#__PURE__*/function () {
3223
- var _ref0 = _asyncToGenerator(function* (priority) {
3224
- _this.setState({
3225
- job: _objectSpread$5(_objectSpread$5({}, _this.state.job), {}, {
3226
- priority
3227
- }),
3228
- priorityChangerOpen: false
3229
- });
3230
- try {
3231
- var res = yield maintenanceActions.editJobPriority(_this.state.job.id, priority);
3232
- var {
3233
- job
3234
- } = res.data;
3235
- _this.props.jobsLoaded([job]);
3236
- _this.setState({
3237
- job
3238
- });
3239
- } catch (error) {
3240
- console.error("onSelectPriority", error);
3241
- }
3198
+ _defineProperty(this, "onSelectPriority", async priority => {
3199
+ this.setState({
3200
+ job: _objectSpread$5(_objectSpread$5({}, this.state.job), {}, {
3201
+ priority
3202
+ }),
3203
+ priorityChangerOpen: false
3242
3204
  });
3243
- return function (_x2) {
3244
- return _ref0.apply(this, arguments);
3245
- };
3246
- }());
3205
+ try {
3206
+ const res = await maintenanceActions.editJobPriority(this.state.job.id, priority);
3207
+ const {
3208
+ job
3209
+ } = res.data;
3210
+ this.props.jobsLoaded([job]);
3211
+ this.setState({
3212
+ job
3213
+ });
3214
+ } catch (error) {
3215
+ console.error("onSelectPriority", error);
3216
+ }
3217
+ });
3247
3218
  _defineProperty(this, "onToggleStatusChanger", () => {
3248
3219
  this.setState({
3249
3220
  statusChangerOpen: !this.state.statusChangerOpen
3250
3221
  });
3251
3222
  });
3252
- _defineProperty(this, "onSelectStatus", /*#__PURE__*/function () {
3253
- var _ref1 = _asyncToGenerator(function* (status) {
3254
- _this.setState({
3255
- job: _objectSpread$5(_objectSpread$5({}, _this.state.job), {}, {
3256
- status: status
3257
- }),
3258
- statusChangerOpen: false
3259
- });
3260
- try {
3261
- var res = yield maintenanceActions.editJobStatus(_this.state.job.id, status);
3262
- var {
3263
- job
3264
- } = res.data;
3265
- _this.props.jobsLoaded([job]);
3266
- _this.setState({
3267
- job
3268
- });
3269
- } catch (error) {
3270
- console.error("onSelectStatus", error);
3271
- }
3223
+ _defineProperty(this, "onSelectStatus", async status => {
3224
+ this.setState({
3225
+ job: _objectSpread$5(_objectSpread$5({}, this.state.job), {}, {
3226
+ status: status
3227
+ }),
3228
+ statusChangerOpen: false
3272
3229
  });
3273
- return function (_x3) {
3274
- return _ref1.apply(this, arguments);
3275
- };
3276
- }());
3230
+ try {
3231
+ const res = await maintenanceActions.editJobStatus(this.state.job.id, status);
3232
+ const {
3233
+ job
3234
+ } = res.data;
3235
+ this.props.jobsLoaded([job]);
3236
+ this.setState({
3237
+ job
3238
+ });
3239
+ } catch (error) {
3240
+ console.error("onSelectStatus", error);
3241
+ }
3242
+ });
3277
3243
  this.state = {
3278
3244
  jobId: Helper$3.safeReadParams(props, "jobId") ? props.match.params.jobId : null,
3279
3245
  job: null,
@@ -3335,15 +3301,15 @@ class Job extends Component {
3335
3301
  });
3336
3302
  }
3337
3303
  renderPriorityLabel() {
3338
- var {
3304
+ const {
3339
3305
  auth
3340
3306
  } = this.props;
3341
3307
  if (!Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
3342
- var {
3308
+ const {
3343
3309
  job
3344
3310
  } = this.state;
3345
3311
  if (!job) return null;
3346
- var selectedPriority = getJobPriority(job.priority);
3312
+ const selectedPriority = getJobPriority(job.priority);
3347
3313
  return /*#__PURE__*/jsxs("div", {
3348
3314
  className: "statusLabel marginTop-5 pointer",
3349
3315
  onClick: this.onTogglePriorityChanger,
@@ -3358,8 +3324,8 @@ class Job extends Component {
3358
3324
  }
3359
3325
  renderStatusLabel() {
3360
3326
  if (!this.state.job.status) return null;
3361
- var statusType = this.getStatusType(this.state.job.status);
3362
- var {
3327
+ const statusType = this.getStatusType(this.state.job.status);
3328
+ const {
3363
3329
  auth
3364
3330
  } = this.props;
3365
3331
  if (Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) {
@@ -3387,7 +3353,7 @@ class Job extends Component {
3387
3353
  });
3388
3354
  }
3389
3355
  renderNotesButton() {
3390
- var {
3356
+ const {
3391
3357
  auth
3392
3358
  } = this.props;
3393
3359
  if (!Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
@@ -3405,7 +3371,7 @@ class Job extends Component {
3405
3371
  });
3406
3372
  }
3407
3373
  renderAssignButton() {
3408
- var {
3374
+ const {
3409
3375
  auth
3410
3376
  } = this.props;
3411
3377
  if (!Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
@@ -3424,7 +3390,7 @@ class Job extends Component {
3424
3390
  }
3425
3391
  renderStatusChanger() {
3426
3392
  if (!this.state.statusChangerOpen) return null;
3427
- var {
3393
+ const {
3428
3394
  statusTypes
3429
3395
  } = this.props;
3430
3396
  return /*#__PURE__*/jsx("div", {
@@ -3484,8 +3450,8 @@ class Job extends Component {
3484
3450
  });
3485
3451
  }
3486
3452
  renderImageGrid(images) {
3487
- var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
3488
- var imagesToUse = images && images.length > 0 ? images : [];
3453
+ let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
3454
+ const imagesToUse = images && images.length > 0 ? images : [];
3489
3455
  return /*#__PURE__*/jsx("div", {
3490
3456
  className: "imageGrid",
3491
3457
  children: imagesToUse.map((image, i) => {
@@ -3506,7 +3472,7 @@ class Job extends Component {
3506
3472
  });
3507
3473
  }
3508
3474
  renderDocumentGrid(documents) {
3509
- var documentsToUse = documents && documents.length > 0 ? documents : [];
3475
+ const documentsToUse = documents && documents.length > 0 ? documents : [];
3510
3476
  return /*#__PURE__*/jsx("div", {
3511
3477
  className: "documentGrid",
3512
3478
  children: documentsToUse.map((doc, index) => /*#__PURE__*/jsx(Components$3.Attachment, {
@@ -3518,7 +3484,7 @@ class Job extends Component {
3518
3484
  }
3519
3485
  renderImages() {
3520
3486
  if (_.isEmpty(this.state.job.image) && _.isEmpty(this.state.job.images)) return null;
3521
- var imagesToUse = _.isEmpty(this.state.job.image) ? this.state.job.images : [this.state.job.image];
3487
+ const imagesToUse = _.isEmpty(this.state.job.image) ? this.state.job.images : [this.state.job.image];
3522
3488
  return /*#__PURE__*/jsxs("div", {
3523
3489
  className: "padding-60 paddingVertical-40 bottomDivideBorder",
3524
3490
  children: [/*#__PURE__*/jsx(Components$3.Text, {
@@ -3529,15 +3495,15 @@ class Job extends Component {
3529
3495
  });
3530
3496
  }
3531
3497
  renderCustomFields() {
3532
- var {
3498
+ const {
3533
3499
  job
3534
3500
  } = this.state;
3535
- var {
3501
+ const {
3536
3502
  customFields
3537
3503
  } = job;
3538
- var labelClass = "fieldLabel";
3539
- var answerClass = "fontRegular fontSize-16 text-dark marginTop-5";
3540
- var renderAnswer = field => {
3504
+ const labelClass = "fieldLabel";
3505
+ const answerClass = "fontRegular fontSize-16 text-dark marginTop-5";
3506
+ const renderAnswer = field => {
3541
3507
  switch (field.type) {
3542
3508
  case "date":
3543
3509
  return /*#__PURE__*/jsx("div", {
@@ -3587,10 +3553,10 @@ class Job extends Component {
3587
3553
  }
3588
3554
  renderInner() {
3589
3555
  if (this.state.job == null) return null;
3590
- var {
3556
+ const {
3591
3557
  customFields
3592
3558
  } = this.state.job;
3593
- var hasCustomFields = customFields && customFields.length > 0;
3559
+ const hasCustomFields = customFields && customFields.length > 0;
3594
3560
  return /*#__PURE__*/jsxs("div", {
3595
3561
  iconStyle: {
3596
3562
  paddingBottom: 40
@@ -3691,10 +3657,10 @@ class Job extends Component {
3691
3657
  });
3692
3658
  }
3693
3659
  renderHistoryEntry(e, i) {
3694
- var {
3660
+ const {
3695
3661
  job
3696
3662
  } = this.state;
3697
- var entryToUse = e || {
3663
+ const entryToUse = e || {
3698
3664
  timestamp: job.createdTime,
3699
3665
  status: "Unassigned",
3700
3666
  user: {
@@ -3703,7 +3669,7 @@ class Job extends Component {
3703
3669
  profilePic: job.userProfilePic
3704
3670
  }
3705
3671
  };
3706
- var statusType = this.getStatusType(entryToUse.status);
3672
+ const statusType = this.getStatusType(entryToUse.status);
3707
3673
  return /*#__PURE__*/jsxs("div", {
3708
3674
  className: "ticketHistoryEntry",
3709
3675
  children: [/*#__PURE__*/jsx("p", {
@@ -3767,7 +3733,7 @@ class Job extends Component {
3767
3733
  }, index);
3768
3734
  }
3769
3735
  renderAssignment() {
3770
- var {
3736
+ const {
3771
3737
  job
3772
3738
  } = this.state;
3773
3739
  if (!job) return null;
@@ -3815,8 +3781,8 @@ class Job extends Component {
3815
3781
  }, i);
3816
3782
  }
3817
3783
  renderExternalSyncEntry(e, i) {
3818
- var isSuccess = e.EntryType === "ExternalIDSet";
3819
- var backgroundColor = isSuccess ? Colours$2.COLOUR_GREEN : Colours$2.COLOUR_RED; // Green for success, red for failure
3784
+ const isSuccess = e.EntryType === "ExternalIDSet";
3785
+ const backgroundColor = isSuccess ? Colours$2.COLOUR_GREEN : Colours$2.COLOUR_RED; // Green for success, red for failure
3820
3786
 
3821
3787
  return /*#__PURE__*/jsxs("div", {
3822
3788
  className: "ticketHistoryEntry",
@@ -3836,7 +3802,7 @@ class Job extends Component {
3836
3802
  }, i);
3837
3803
  }
3838
3804
  renderPriority() {
3839
- var {
3805
+ const {
3840
3806
  auth
3841
3807
  } = this.props;
3842
3808
  if (!Session$3.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
@@ -3853,20 +3819,20 @@ class Job extends Component {
3853
3819
  });
3854
3820
  }
3855
3821
  hasSyncFailureWithoutSuccess() {
3856
- var {
3822
+ const {
3857
3823
  job
3858
3824
  } = this.state;
3859
3825
  if (!job || !job.history) return false;
3860
- var history = job.history || [];
3861
- var hasSuccess = history.some(entry => entry.EntryType === "ExternalIDSet");
3862
- var hasFailure = history.some(entry => entry.EntryType === "ExternalIDSetFailed");
3826
+ const history = job.history || [];
3827
+ const hasSuccess = history.some(entry => entry.EntryType === "ExternalIDSet");
3828
+ const hasFailure = history.some(entry => entry.EntryType === "ExternalIDSetFailed");
3863
3829
  return hasFailure && !hasSuccess;
3864
3830
  }
3865
3831
  renderRetrySyncButton() {
3866
- var {
3832
+ const {
3867
3833
  auth
3868
3834
  } = this.props;
3869
- var {
3835
+ const {
3870
3836
  retryingSync,
3871
3837
  retrySyncInitiated
3872
3838
  } = this.state;
@@ -3904,7 +3870,7 @@ class Job extends Component {
3904
3870
  });
3905
3871
  }
3906
3872
  renderExternalSyncStatus() {
3907
- var {
3873
+ const {
3908
3874
  retrySyncError,
3909
3875
  retrySyncInitiated
3910
3876
  } = this.state;
@@ -3953,14 +3919,14 @@ class Job extends Component {
3953
3919
  return null;
3954
3920
  }
3955
3921
  renderExternalSync() {
3956
- var {
3922
+ const {
3957
3923
  externalSync,
3958
3924
  loadingExternalSync
3959
3925
  } = this.state;
3960
3926
 
3961
3927
  // Check if we should show this section at all
3962
- var hasExternalSyncData = externalSync && !loadingExternalSync;
3963
- var hasSyncFailure = this.hasSyncFailureWithoutSuccess();
3928
+ const hasExternalSyncData = externalSync && !loadingExternalSync;
3929
+ const hasSyncFailure = this.hasSyncFailureWithoutSuccess();
3964
3930
 
3965
3931
  // Show section if we have sync data OR if there's a failure that can be retried
3966
3932
  if (!hasExternalSyncData && !hasSyncFailure) return null;
@@ -4000,11 +3966,11 @@ class Job extends Component {
4000
3966
  });
4001
3967
  }
4002
3968
  renderOverview() {
4003
- var {
3969
+ const {
4004
3970
  job
4005
3971
  } = this.state;
4006
3972
  if (!job || !job.history) return null;
4007
- var source = _.sortBy([...job.history.map(e => {
3973
+ const source = _.sortBy([...job.history.map(e => {
4008
3974
  return _objectSpread$5(_objectSpread$5({}, e), {}, {
4009
3975
  EntryType: e.EntryType || "status"
4010
3976
  });
@@ -4142,8 +4108,8 @@ class Job extends Component {
4142
4108
  children: "Add Attachment"
4143
4109
  })]
4144
4110
  }), /*#__PURE__*/jsx(Components$3.ImageInput, {
4145
- ref: _ref10 => {
4146
- this.imageInput = _ref10;
4111
+ ref: ref => {
4112
+ this.imageInput = ref;
4147
4113
  },
4148
4114
  multiple: true,
4149
4115
  refreshCallback: images => {
@@ -4155,7 +4121,7 @@ class Job extends Component {
4155
4121
  });
4156
4122
  }
4157
4123
  renderUsers() {
4158
- var content = null;
4124
+ let content = null;
4159
4125
  if (this.state.confirmingAssignee) {
4160
4126
  content = /*#__PURE__*/jsx("div", {
4161
4127
  className: "flex flex-center-row",
@@ -4249,8 +4215,8 @@ class Job extends Component {
4249
4215
  });
4250
4216
  }
4251
4217
  }
4252
- var mapStateToProps$3 = state => {
4253
- var {
4218
+ const mapStateToProps$3 = state => {
4219
+ const {
4254
4220
  auth
4255
4221
  } = state;
4256
4222
  return {
@@ -4265,7 +4231,7 @@ var Job$1 = connect(mapStateToProps$3, {
4265
4231
 
4266
4232
  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; }
4267
4233
  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; }
4268
- var {
4234
+ const {
4269
4235
  Actions,
4270
4236
  Components: Components$2,
4271
4237
  Helper: Helper$2,
@@ -4278,18 +4244,18 @@ class AddJob extends Component {
4278
4244
  var _this;
4279
4245
  super(props);
4280
4246
  _this = this;
4281
- _defineProperty(this, "getJob", /*#__PURE__*/_asyncToGenerator(function* () {
4247
+ _defineProperty(this, "getJob", async () => {
4282
4248
  try {
4283
- var res = yield maintenanceActions.getJob(_this.props.auth.site, _this.state.jobId);
4249
+ const res = await maintenanceActions.getJob(this.props.auth.site, this.state.jobId);
4284
4250
  res.data.location = res.data.site;
4285
- var {
4251
+ const {
4286
4252
  userID,
4287
4253
  userName,
4288
4254
  userProfilePic,
4289
4255
  type,
4290
4256
  customFields
4291
4257
  } = res.data;
4292
- _this.setState(_objectSpread$4(_objectSpread$4({}, res.data), {}, {
4258
+ this.setState(_objectSpread$4(_objectSpread$4({}, res.data), {}, {
4293
4259
  prevType: type,
4294
4260
  prevCustomFileds: customFields,
4295
4261
  type,
@@ -4300,39 +4266,39 @@ class AddJob extends Component {
4300
4266
  profilePic: userProfilePic
4301
4267
  }
4302
4268
  }));
4303
- _this.checkSetImages(_this.imageInput, res.data.images);
4269
+ this.checkSetImages(this.imageInput, res.data.images);
4304
4270
  if (customFields) {
4305
4271
  customFields.forEach((field, index) => {
4306
4272
  if (field.type === "image" && field.answer) {
4307
- _this.checkSetImages(_this.customImageInputs[index], field.answer);
4273
+ this.checkSetImages(this.customImageInputs[index], field.answer);
4308
4274
  }
4309
4275
  });
4310
4276
  }
4311
4277
  } catch (error) {
4312
4278
  console.error("getJob", error);
4313
4279
  }
4314
- }));
4315
- _defineProperty(this, "getJobTypes", /*#__PURE__*/_asyncToGenerator(function* () {
4280
+ });
4281
+ _defineProperty(this, "getJobTypes", async () => {
4316
4282
  try {
4317
- var res = yield maintenanceActions.getJobTypes(_this.props.auth.site);
4318
- _this.setState({
4283
+ const res = await maintenanceActions.getJobTypes(this.props.auth.site);
4284
+ this.setState({
4319
4285
  types: res.data
4320
4286
  });
4321
- _this.getDefaultJob();
4287
+ this.getDefaultJob();
4322
4288
  } catch (error) {
4323
4289
  console.error("getJobTypes", error);
4324
4290
  }
4325
- }));
4326
- _defineProperty(this, "getUsers", /*#__PURE__*/_asyncToGenerator(function* () {
4291
+ });
4292
+ _defineProperty(this, "getUsers", async () => {
4327
4293
  try {
4328
- var res = yield userActions.fetchUsers(_this.props.auth.site);
4294
+ const res = await userActions.fetchUsers(this.props.auth.site);
4329
4295
  if (res.userFetchFail) return;
4330
4296
  if (res.data != null && !_.isEmpty(res.data.results.Items)) {
4331
- var items = res.data.results.Items;
4332
- if (_this.props.optionOnlyForResidents) {
4297
+ let items = res.data.results.Items;
4298
+ if (this.props.optionOnlyForResidents) {
4333
4299
  items = _.filter(items, u => u.category === "resident");
4334
4300
  }
4335
- _this.setState({
4301
+ this.setState({
4336
4302
  users: _.sortBy(items, u => {
4337
4303
  return (u.displayName || "").toLowerCase();
4338
4304
  })
@@ -4341,15 +4307,15 @@ class AddJob extends Component {
4341
4307
  } catch (error) {
4342
4308
  console.error("getUsers", error);
4343
4309
  }
4344
- }));
4310
+ });
4345
4311
  _defineProperty(this, "getDefaultJob", () => {
4346
- var {
4312
+ const {
4347
4313
  types,
4348
4314
  jobId
4349
4315
  } = this.state;
4350
4316
  if (jobId == null) {
4351
4317
  if (types.length !== 0) {
4352
- var defaultType = types[0];
4318
+ const defaultType = types[0];
4353
4319
  this.setState({
4354
4320
  type: defaultType.typeName,
4355
4321
  customFields: defaultType.hasCustomFields && defaultType.customFields.length > 0 ? defaultType.customFields : []
@@ -4362,15 +4328,15 @@ class AddJob extends Component {
4362
4328
  }
4363
4329
  });
4364
4330
  _defineProperty(this, "onSelectType", (key, e) => {
4365
- var {
4331
+ const {
4366
4332
  types,
4367
4333
  prevType,
4368
4334
  prevCustomFileds
4369
4335
  } = this.state;
4370
- var selectedType = types.find(t => t.typeName === key);
4336
+ const selectedType = types.find(t => t.typeName === key);
4371
4337
  // If selected type had previously saved custom fields, use the previous version
4372
- var hasPrevCustomFields = prevType === selectedType.typeName && prevCustomFileds && prevCustomFileds.length > 0;
4373
- var update = {
4338
+ const hasPrevCustomFields = prevType === selectedType.typeName && prevCustomFileds && prevCustomFileds.length > 0;
4339
+ const update = {
4374
4340
  type: selectedType.typeName,
4375
4341
  customFields: hasPrevCustomFields ? prevCustomFileds : selectedType.hasCustomFields ? selectedType.customFields : []
4376
4342
  };
@@ -4395,7 +4361,7 @@ class AddJob extends Component {
4395
4361
  });
4396
4362
  });
4397
4363
  _defineProperty(this, "onSelectUser", user => {
4398
- var update = {
4364
+ const update = {
4399
4365
  selectedUser: user,
4400
4366
  userID: user.userId,
4401
4367
  userName: user.displayName,
@@ -4413,7 +4379,7 @@ class AddJob extends Component {
4413
4379
  // Fetch in background to avoid blocking UI
4414
4380
  userActions.fetchUser(this.props.auth.site, user.userId).then(response => {
4415
4381
  if (response.data && response.data.user) {
4416
- var contactUpdate = {};
4382
+ const contactUpdate = {};
4417
4383
  // Auto-populate phone and room from user profile
4418
4384
  if (response.data.user.phoneNumber) {
4419
4385
  contactUpdate.phone = response.data.user.phoneNumber;
@@ -4433,7 +4399,7 @@ class AddJob extends Component {
4433
4399
  });
4434
4400
  });
4435
4401
  _defineProperty(this, "onUnselectUser", () => {
4436
- var update = {
4402
+ const update = {
4437
4403
  selectedUser: null,
4438
4404
  userID: "",
4439
4405
  userName: "",
@@ -4446,78 +4412,78 @@ class AddJob extends Component {
4446
4412
  this.setState(update);
4447
4413
  });
4448
4414
  _defineProperty(this, "onChangeAnswer", (qId, answer) => {
4449
- var update = {
4415
+ const update = {
4450
4416
  customFields: _.cloneDeep(this.state.customFields)
4451
4417
  };
4452
- var field = update.customFields[qId];
4418
+ const field = update.customFields[qId];
4453
4419
  field.answer = answer;
4454
4420
  if (field.isTitle) update.title = field.answer;
4455
4421
  this.setState(update);
4456
4422
  });
4457
4423
  _defineProperty(this, "onChangeToggleAnswer", (qId, answer) => {
4458
- var update = {
4424
+ const update = {
4459
4425
  customFields: _.cloneDeep(this.state.customFields)
4460
4426
  };
4461
- var field = update.customFields[qId];
4427
+ const field = update.customFields[qId];
4462
4428
  field.answer = field.answer === answer ? undefined : answer;
4463
4429
  if (field.isTitle) update.title = field.answer;
4464
4430
  this.setState(update);
4465
4431
  });
4466
4432
  _defineProperty(this, "onChangeCheckboxAnswer", (qId, answer) => {
4467
- var update = {
4433
+ const update = {
4468
4434
  customFields: _.cloneDeep(this.state.customFields)
4469
4435
  };
4470
- var field = update.customFields[qId];
4436
+ const field = update.customFields[qId];
4471
4437
  field.answer = _.xor(field.answer || [], [answer]);
4472
4438
  if (field.isTitle) update.title = field.answer.join(", ");
4473
4439
  this.setState(update);
4474
4440
  });
4475
4441
  _defineProperty(this, "onChangeDateAnswer", function (qId, answer) {
4476
- var togglePicker = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
4477
- var update = {
4442
+ let togglePicker = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
4443
+ const update = {
4478
4444
  customFields: _.cloneDeep(_this.state.customFields)
4479
4445
  };
4480
- var field = update.customFields[qId];
4446
+ const field = update.customFields[qId];
4481
4447
  field.answer = answer;
4482
4448
  if (field.isTitle) update.title = moment(field.answer, "YYYY-MM-DD").format("DD-MMM-YYYY");
4483
4449
  _this.setState(update);
4484
4450
  if (togglePicker) _this.onToggleDatePicker(qId);
4485
4451
  });
4486
4452
  _defineProperty(this, "onChangeTimeAnswer", (qId, answer) => {
4487
- var update = {
4453
+ const update = {
4488
4454
  customFields: _.cloneDeep(this.state.customFields)
4489
4455
  };
4490
- var field = update.customFields[qId];
4456
+ const field = update.customFields[qId];
4491
4457
  field.answer = answer;
4492
4458
  if (field.isTitle) update.title = moment(field.answer, "HH:mm").format("h:mm a");
4493
4459
  this.setState(update);
4494
4460
  });
4495
4461
  _defineProperty(this, "onChangeImageAnswer", (qId, answer) => {
4496
- var update = {
4462
+ const update = {
4497
4463
  customFields: _.cloneDeep(this.state.customFields)
4498
4464
  };
4499
- var field = update.customFields[qId];
4465
+ const field = update.customFields[qId];
4500
4466
  field.answer = answer;
4501
4467
  this.setState(update);
4502
4468
  });
4503
4469
  _defineProperty(this, "onRemoveDocumentAnswer", (qId, document) => {
4504
- var update = {
4470
+ const update = {
4505
4471
  customFields: _.cloneDeep(this.state.customFields)
4506
4472
  };
4507
- var field = update.customFields[qId];
4473
+ const field = update.customFields[qId];
4508
4474
  field.answer = _.filter(field.answer, d => d.url !== document.url);
4509
4475
  this.setState(update);
4510
4476
  });
4511
4477
  _defineProperty(this, "onHandlePDFFileChange", (event, qId) => {
4512
- var file = event.target.files[0];
4478
+ const file = event.target.files[0];
4513
4479
  if (!file) return;
4514
- var update = {
4480
+ const update = {
4515
4481
  customFields: _.cloneDeep(this.state.customFields)
4516
4482
  };
4517
- var field = update.customFields[qId];
4518
- var attachments = field.answer || [];
4519
- var [name, ext] = file.name.split(".");
4520
- var newAttachment = {
4483
+ const field = update.customFields[qId];
4484
+ const attachments = field.answer || [];
4485
+ const [name, ext] = file.name.split(".");
4486
+ const newAttachment = {
4521
4487
  uploading: true,
4522
4488
  name,
4523
4489
  ext: ext.toLowerCase()
@@ -4537,7 +4503,7 @@ class AddJob extends Component {
4537
4503
  event.target.value = "";
4538
4504
  });
4539
4505
  _defineProperty(this, "onToggleDatePicker", qId => {
4540
- var showDate = _objectSpread$4({}, this.state.showDate);
4506
+ const showDate = _objectSpread$4({}, this.state.showDate);
4541
4507
  showDate[qId] = !showDate[qId];
4542
4508
  this.setState({
4543
4509
  showDate
@@ -4557,7 +4523,7 @@ class AddJob extends Component {
4557
4523
  this.setState({
4558
4524
  updating: true
4559
4525
  });
4560
- var job = {
4526
+ const job = {
4561
4527
  id: this.state.id,
4562
4528
  userID: this.state.userID,
4563
4529
  userName: this.state.userName,
@@ -4603,13 +4569,13 @@ class AddJob extends Component {
4603
4569
  }
4604
4570
  });
4605
4571
  _defineProperty(this, "isFieldValid", field => {
4606
- var {
4572
+ const {
4607
4573
  mandatory,
4608
4574
  type,
4609
4575
  answer
4610
4576
  } = field;
4611
4577
  if (["staticTitle", "staticText"].includes(type)) return true;
4612
- var checkMandatory = () => {
4578
+ const checkMandatory = () => {
4613
4579
  if (!mandatory) return true;
4614
4580
  switch (type) {
4615
4581
  case "yn":
@@ -4622,7 +4588,7 @@ class AddJob extends Component {
4622
4588
  return !_.isNil(answer) && !_.isEmpty(answer);
4623
4589
  }
4624
4590
  };
4625
- var checkFormat = () => {
4591
+ const checkFormat = () => {
4626
4592
  if (_.isNil(answer) || _.isEmpty(answer)) return true;
4627
4593
  switch (type) {
4628
4594
  case "email":
@@ -4635,12 +4601,12 @@ class AddJob extends Component {
4635
4601
  return true;
4636
4602
  }
4637
4603
  };
4638
- var valid = checkMandatory() && checkFormat();
4604
+ const valid = checkMandatory() && checkFormat();
4639
4605
  return valid;
4640
4606
  });
4641
4607
  _defineProperty(this, "getFieldContainerClass", function () {
4642
- var isValid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4643
- var showError = _this.state.showWarnings && !isValid;
4608
+ let isValid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4609
+ const showError = _this.state.showWarnings && !isValid;
4644
4610
  return "genericInputContainer ".concat(isValid ? "genericInput-valid" : "", " ").concat(showError ? "genericInput-error" : "").trim();
4645
4611
  });
4646
4612
  this.imageInput = null;
@@ -4700,7 +4666,7 @@ class AddJob extends Component {
4700
4666
  }
4701
4667
  }
4702
4668
  getTypeOptions() {
4703
- var {
4669
+ const {
4704
4670
  types
4705
4671
  } = this.state;
4706
4672
  return types.filter(Boolean).map(ev => ({
@@ -4710,7 +4676,7 @@ class AddJob extends Component {
4710
4676
  }
4711
4677
  renderSuccess() {
4712
4678
  if (!this.state.success) return null;
4713
- var title = this.props.strings["".concat(values.featureKey, "_textTitleRequests")] || values.textTitleRequests;
4679
+ const title = this.props.strings["".concat(values.featureKey, "_textTitleRequests")] || values.textTitleRequests;
4714
4680
  return /*#__PURE__*/jsx(Components$2.SuccessPopup, {
4715
4681
  text: "".concat(values.textEntityName, " has been ").concat(this.state.id != null ? "edited" : "added"),
4716
4682
  buttons: [{
@@ -4723,12 +4689,12 @@ class AddJob extends Component {
4723
4689
  });
4724
4690
  }
4725
4691
  validateCustomFields() {
4726
- var {
4692
+ const {
4727
4693
  customFields
4728
4694
  } = this.state;
4729
4695
  if (!customFields || customFields.length === 0) return true;
4730
4696
  return customFields.every(field => {
4731
- var isValid = this.isFieldValid(field);
4697
+ const isValid = this.isFieldValid(field);
4732
4698
  return isValid;
4733
4699
  });
4734
4700
  }
@@ -4768,11 +4734,11 @@ class AddJob extends Component {
4768
4734
  });
4769
4735
  }
4770
4736
  renderSelectUser() {
4771
- var {
4737
+ const {
4772
4738
  showWarnings,
4773
4739
  selectedUser
4774
4740
  } = this.state;
4775
- var isValid = !_.isNil(selectedUser);
4741
+ const isValid = !_.isNil(selectedUser);
4776
4742
  return /*#__PURE__*/jsxs("div", {
4777
4743
  className: this.getFieldContainerClass(isValid),
4778
4744
  children: [/*#__PURE__*/jsxs("div", {
@@ -4842,8 +4808,8 @@ class AddJob extends Component {
4842
4808
  className: "marginBottom-4",
4843
4809
  children: "Images"
4844
4810
  }), /*#__PURE__*/jsx(Components$2.ImageInput, {
4845
- ref: _ref4 => {
4846
- this.imageInput = _ref4;
4811
+ ref: ref => {
4812
+ this.imageInput = ref;
4847
4813
  },
4848
4814
  multiple: true,
4849
4815
  refreshCallback: images => {
@@ -5082,14 +5048,14 @@ class AddJob extends Component {
5082
5048
  className: "marginBottom-4",
5083
5049
  children: field.label
5084
5050
  }), /*#__PURE__*/jsx(Components$2.ImageInput, {
5085
- ref: _ref5 => this.customImageInputs[fieldId] = _ref5,
5051
+ ref: ref => this.customImageInputs[fieldId] = ref,
5086
5052
  multiple: true,
5087
5053
  refreshCallback: images => this.onChangeImageAnswer(fieldId, images)
5088
5054
  })]
5089
5055
  })]
5090
5056
  }, fieldId);
5091
5057
  case "document":
5092
- var documents = field.answer || [];
5058
+ const documents = field.answer || [];
5093
5059
  return /*#__PURE__*/jsxs("div", {
5094
5060
  className: this.getFieldContainerClass(this.isFieldValid(field)),
5095
5061
  style: styles$4.fieldContainer,
@@ -5134,7 +5100,7 @@ class AddJob extends Component {
5134
5100
  }
5135
5101
  }
5136
5102
  renderCustomFields() {
5137
- var {
5103
+ const {
5138
5104
  customFields
5139
5105
  } = this.state;
5140
5106
  if (!customFields || customFields.length === 0) return null;
@@ -5145,7 +5111,7 @@ class AddJob extends Component {
5145
5111
  });
5146
5112
  }
5147
5113
  renderMain() {
5148
- var {
5114
+ const {
5149
5115
  customFields
5150
5116
  } = this.state;
5151
5117
  return /*#__PURE__*/jsx("div", {
@@ -5196,7 +5162,7 @@ class AddJob extends Component {
5196
5162
  });
5197
5163
  }
5198
5164
  renderUserFilterPopup() {
5199
- var {
5165
+ const {
5200
5166
  userFilterOpen,
5201
5167
  userSearch,
5202
5168
  users
@@ -5236,7 +5202,7 @@ class AddJob extends Component {
5236
5202
  });
5237
5203
  }
5238
5204
  render() {
5239
- var {
5205
+ const {
5240
5206
  success
5241
5207
  } = this.state;
5242
5208
  return /*#__PURE__*/jsxs(Components$2.OverlayPage, {
@@ -5254,7 +5220,7 @@ class AddJob extends Component {
5254
5220
  });
5255
5221
  }
5256
5222
  }
5257
- var styles$4 = {
5223
+ const styles$4 = {
5258
5224
  userLabelContainer: {
5259
5225
  display: "flex",
5260
5226
  flexDirection: "row",
@@ -5268,8 +5234,8 @@ var styles$4 = {
5268
5234
  alignItems: "center"
5269
5235
  }
5270
5236
  };
5271
- var mapStateToProps$2 = state => {
5272
- var {
5237
+ const mapStateToProps$2 = state => {
5238
+ const {
5273
5239
  auth
5274
5240
  } = state;
5275
5241
  return {
@@ -5284,12 +5250,12 @@ var AddJob$1 = connect(mapStateToProps$2, {
5284
5250
  addRecentlyCreated: Actions.addRecentlyCreated
5285
5251
  })(withRouter(AddJob));
5286
5252
 
5287
- var {
5253
+ const {
5288
5254
  Components: Components$1,
5289
5255
  Session: Session$1,
5290
5256
  Helper: Helper$1
5291
5257
  } = PlussCore;
5292
- var DEFAULT_FIELD = {
5258
+ const DEFAULT_FIELD = {
5293
5259
  type: "text",
5294
5260
  label: "",
5295
5261
  mandatory: false,
@@ -5298,13 +5264,11 @@ var DEFAULT_FIELD = {
5298
5264
  };
5299
5265
  class AddJobType extends Component {
5300
5266
  constructor(props) {
5301
- var _this;
5302
5267
  super(props);
5303
- _this = this;
5304
- _defineProperty(this, "getJobType", /*#__PURE__*/_asyncToGenerator(function* () {
5268
+ _defineProperty(this, "getJobType", async () => {
5305
5269
  try {
5306
- var res = yield maintenanceActions.getJobType(_this.props.auth.site, _this.state.jobTypeId);
5307
- var {
5270
+ const res = await maintenanceActions.getJobType(this.props.auth.site, this.state.jobTypeId);
5271
+ const {
5308
5272
  typeName,
5309
5273
  email,
5310
5274
  description,
@@ -5312,7 +5276,7 @@ class AddJobType extends Component {
5312
5276
  hasCustomFields,
5313
5277
  customFields
5314
5278
  } = res.data;
5315
- _this.setState({
5279
+ this.setState({
5316
5280
  jobTypeName: typeName,
5317
5281
  jobTypeEmail: email,
5318
5282
  jobTypeDescription: description,
@@ -5323,19 +5287,19 @@ class AddJobType extends Component {
5323
5287
  } catch (error) {
5324
5288
  console.error("getJobType", error);
5325
5289
  }
5326
- }));
5290
+ });
5327
5291
  _defineProperty(this, "getFieldTypeTitle", type => {
5328
- var fieldType = this.fieldTypes.find(f => f.Key === type);
5292
+ const fieldType = this.fieldTypes.find(f => f.Key === type);
5329
5293
  return fieldType ? fieldType.Title : "";
5330
5294
  });
5331
5295
  _defineProperty(this, "validateEmail", () => {
5332
- var {
5296
+ const {
5333
5297
  jobTypeEmail
5334
5298
  } = this.state;
5335
5299
  return !_.isEmpty(jobTypeEmail) && Helper$1.isEmail(jobTypeEmail);
5336
5300
  });
5337
5301
  _defineProperty(this, "isJobTypeValid", () => {
5338
- var {
5302
+ const {
5339
5303
  jobTypeName,
5340
5304
  jobTypeDescription
5341
5305
  } = this.state;
@@ -5351,7 +5315,7 @@ class AddJobType extends Component {
5351
5315
  this.setState(stateChange);
5352
5316
  });
5353
5317
  _defineProperty(this, "onFieldTypeChanged", (fieldIndex, key) => {
5354
- var customFields = [...this.state.customFields];
5318
+ const customFields = [...this.state.customFields];
5355
5319
  if (customFields[fieldIndex].type === key) return;
5356
5320
  customFields[fieldIndex] = _.cloneDeep(DEFAULT_FIELD);
5357
5321
  customFields[fieldIndex].type = key;
@@ -5360,21 +5324,21 @@ class AddJobType extends Component {
5360
5324
  });
5361
5325
  });
5362
5326
  _defineProperty(this, "onFieldLabelChanged", (fieldIndex, event) => {
5363
- var customFields = [...this.state.customFields];
5327
+ const customFields = [...this.state.customFields];
5364
5328
  customFields[fieldIndex].label = event.target.value;
5365
5329
  this.setState({
5366
5330
  customFields
5367
5331
  });
5368
5332
  });
5369
5333
  _defineProperty(this, "onFieldPlaceHolderChanged", (fieldIndex, event) => {
5370
- var customFields = [...this.state.customFields];
5334
+ const customFields = [...this.state.customFields];
5371
5335
  customFields[fieldIndex].placeHolder = event.target.value;
5372
5336
  this.setState({
5373
5337
  customFields
5374
5338
  });
5375
5339
  });
5376
5340
  _defineProperty(this, "onFieldMandatoryChanged", fieldIndex => {
5377
- var customFields = [...this.state.customFields];
5341
+ const customFields = [...this.state.customFields];
5378
5342
  customFields[fieldIndex].mandatory = !customFields[fieldIndex].mandatory;
5379
5343
  if (!customFields[fieldIndex].mandatory) {
5380
5344
  // If a field is not mandatory, it cannot be a title field
@@ -5385,7 +5349,7 @@ class AddJobType extends Component {
5385
5349
  });
5386
5350
  });
5387
5351
  _defineProperty(this, "onFieldIsTitleChanged", fieldIndex => {
5388
- var customFields = [...this.state.customFields];
5352
+ const customFields = [...this.state.customFields];
5389
5353
  customFields[fieldIndex].isTitle = !customFields[fieldIndex].isTitle;
5390
5354
  if (customFields[fieldIndex].isTitle) {
5391
5355
  // If a field is title field, force mandatory
@@ -5396,33 +5360,33 @@ class AddJobType extends Component {
5396
5360
  });
5397
5361
  });
5398
5362
  _defineProperty(this, "onFieldOptionChanged", (fieldIndex, optionIndex, event) => {
5399
- var customFields = [...this.state.customFields];
5400
- var prevValue = customFields[fieldIndex].values[optionIndex];
5363
+ const customFields = [...this.state.customFields];
5364
+ const prevValue = customFields[fieldIndex].values[optionIndex];
5401
5365
  customFields[fieldIndex].values[optionIndex] = event.target.value;
5402
5366
  // Change corresponding validation if exists
5403
- var validations = customFields[fieldIndex].validation;
5404
- var validation = validations ? validations.find(val => val.value === prevValue) : null;
5367
+ const validations = customFields[fieldIndex].validation;
5368
+ let validation = validations ? validations.find(val => val.value === prevValue) : null;
5405
5369
  if (validation) validation.value = event.target.value;
5406
5370
  this.setState({
5407
5371
  customFields
5408
5372
  });
5409
5373
  });
5410
5374
  _defineProperty(this, "onAddNewOption", fieldIndex => {
5411
- var customFields = [...this.state.customFields];
5375
+ const customFields = [...this.state.customFields];
5412
5376
  customFields[fieldIndex].values.push("");
5413
5377
  this.setState({
5414
5378
  customFields
5415
5379
  });
5416
5380
  });
5417
5381
  _defineProperty(this, "onRemoveOption", (fieldIndex, optionIndex) => {
5418
- var customFields = [...this.state.customFields];
5382
+ const customFields = [...this.state.customFields];
5419
5383
  customFields[fieldIndex].values.splice(optionIndex, 1);
5420
5384
  this.setState({
5421
5385
  customFields
5422
5386
  });
5423
5387
  });
5424
5388
  _defineProperty(this, "onAddNewField", () => {
5425
- var customFields = [...this.state.customFields];
5389
+ const customFields = [...this.state.customFields];
5426
5390
  customFields.push(_.cloneDeep(DEFAULT_FIELD));
5427
5391
  this.setState({
5428
5392
  customFields
@@ -5430,17 +5394,17 @@ class AddJobType extends Component {
5430
5394
  });
5431
5395
  _defineProperty(this, "onMoveFieldPrev", fieldIndex => {
5432
5396
  if (fieldIndex === 0) return;
5433
- var customFields = [...this.state.customFields];
5434
- var item = customFields.splice(fieldIndex, 1)[0];
5397
+ const customFields = [...this.state.customFields];
5398
+ const item = customFields.splice(fieldIndex, 1)[0];
5435
5399
  customFields.splice(fieldIndex - 1, 0, item);
5436
5400
  this.setState({
5437
5401
  customFields
5438
5402
  });
5439
5403
  });
5440
5404
  _defineProperty(this, "onMoveFieldNext", fieldIndex => {
5441
- var customFields = [...this.state.customFields];
5405
+ const customFields = [...this.state.customFields];
5442
5406
  if (fieldIndex > customFields.length - 1) return;
5443
- var item = customFields.splice(fieldIndex, 1)[0];
5407
+ const item = customFields.splice(fieldIndex, 1)[0];
5444
5408
  customFields.splice(fieldIndex + 1, 0, item);
5445
5409
  this.setState({
5446
5410
  customFields
@@ -5450,10 +5414,10 @@ class AddJobType extends Component {
5450
5414
  window.history.back();
5451
5415
  });
5452
5416
  _defineProperty(this, "onSave", () => {
5453
- var {
5417
+ const {
5454
5418
  site
5455
5419
  } = this.props.auth;
5456
- var {
5420
+ const {
5457
5421
  submitting,
5458
5422
  jobTypeId,
5459
5423
  jobTypeName,
@@ -5472,26 +5436,26 @@ class AddJobType extends Component {
5472
5436
  }
5473
5437
  this.setState({
5474
5438
  submitting: true
5475
- }, /*#__PURE__*/_asyncToGenerator(function* () {
5439
+ }, async () => {
5476
5440
  try {
5477
5441
  if (jobTypeId) {
5478
- yield maintenanceActions.editJobType(site, jobTypeId, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel, hasCustomFields, customFields);
5442
+ await maintenanceActions.editJobType(site, jobTypeId, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel, hasCustomFields, customFields);
5479
5443
  } else {
5480
- yield maintenanceActions.addJobType(site, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel, hasCustomFields, customFields);
5444
+ await maintenanceActions.addJobType(site, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel, hasCustomFields, customFields);
5481
5445
  }
5482
- _this.props.jobTypesUpdate(site);
5483
- _this.setState({
5446
+ this.props.jobTypesUpdate(site);
5447
+ this.setState({
5484
5448
  submitting: false,
5485
5449
  success: true
5486
5450
  });
5487
5451
  } catch (error) {
5488
5452
  console.error("onSave", error);
5489
- _this.setState({
5453
+ this.setState({
5490
5454
  submitting: false
5491
5455
  });
5492
5456
  alert("Something went wrong with the request. Please try again.");
5493
5457
  }
5494
- }));
5458
+ });
5495
5459
  });
5496
5460
  this.fieldTypes = [{
5497
5461
  Title: "Text Input",
@@ -5552,7 +5516,7 @@ class AddJobType extends Component {
5552
5516
  if (this.state.jobTypeId) this.getJobType();
5553
5517
  }
5554
5518
  validateCustomFields() {
5555
- var {
5519
+ const {
5556
5520
  submitting,
5557
5521
  hasCustomFields,
5558
5522
  customFields
@@ -5560,13 +5524,13 @@ class AddJobType extends Component {
5560
5524
  if (submitting) return false;
5561
5525
 
5562
5526
  // Validate custom fields
5563
- var warnings = [];
5527
+ const warnings = [];
5564
5528
  if (hasCustomFields) {
5565
- var missingLabel = false;
5566
- var hasMandatoryField = false;
5567
- var titleFieldCount = 0;
5529
+ let missingLabel = false;
5530
+ let hasMandatoryField = false;
5531
+ let titleFieldCount = 0;
5568
5532
  customFields.forEach(field => {
5569
- var {
5533
+ const {
5570
5534
  type,
5571
5535
  label,
5572
5536
  values,
@@ -5598,7 +5562,7 @@ class AddJobType extends Component {
5598
5562
  return warnings.length === 0;
5599
5563
  }
5600
5564
  onRemoveField(fieldIndex) {
5601
- var customFields = [...this.state.customFields];
5565
+ const customFields = [...this.state.customFields];
5602
5566
  if (customFields.length < 2) return;
5603
5567
  customFields.splice(fieldIndex, 1);
5604
5568
  this.setState({
@@ -5606,7 +5570,7 @@ class AddJobType extends Component {
5606
5570
  });
5607
5571
  }
5608
5572
  renderBaseForm() {
5609
- var {
5573
+ const {
5610
5574
  success,
5611
5575
  jobTypeId,
5612
5576
  showWarnings,
@@ -5805,7 +5769,7 @@ class AddJobType extends Component {
5805
5769
  });
5806
5770
  }
5807
5771
  renderFieldMultiple(field, fieldIndex) {
5808
- var {
5772
+ const {
5809
5773
  customFields
5810
5774
  } = this.state;
5811
5775
  return /*#__PURE__*/jsxs("div", {
@@ -5876,7 +5840,7 @@ class AddJobType extends Component {
5876
5840
  });
5877
5841
  }
5878
5842
  renderFieldCheckbox(field, fieldIndex) {
5879
- var {
5843
+ const {
5880
5844
  customFields
5881
5845
  } = this.state;
5882
5846
  return /*#__PURE__*/jsxs("div", {
@@ -5971,10 +5935,10 @@ class AddJobType extends Component {
5971
5935
  });
5972
5936
  }
5973
5937
  renderField(field, fieldIndex) {
5974
- var {
5938
+ const {
5975
5939
  customFields
5976
5940
  } = this.state;
5977
- var renderFieldContent = () => {
5941
+ const renderFieldContent = () => {
5978
5942
  switch (field.type) {
5979
5943
  case "text":
5980
5944
  case "email":
@@ -6058,7 +6022,7 @@ class AddJobType extends Component {
6058
6022
  }, fieldIndex);
6059
6023
  }
6060
6024
  renderCustomForm() {
6061
- var {
6025
+ const {
6062
6026
  success,
6063
6027
  hasCustomFields,
6064
6028
  customFields
@@ -6093,7 +6057,7 @@ class AddJobType extends Component {
6093
6057
  });
6094
6058
  }
6095
6059
  renderWarnings() {
6096
- var {
6060
+ const {
6097
6061
  showWarnings,
6098
6062
  warnings
6099
6063
  } = this.state;
@@ -6115,7 +6079,7 @@ class AddJobType extends Component {
6115
6079
  });
6116
6080
  }
6117
6081
  renderSuccess() {
6118
- var {
6082
+ const {
6119
6083
  success,
6120
6084
  jobTypeId
6121
6085
  } = this.state;
@@ -6156,7 +6120,7 @@ class AddJobType extends Component {
6156
6120
  });
6157
6121
  }
6158
6122
  render() {
6159
- var {
6123
+ const {
6160
6124
  success
6161
6125
  } = this.state;
6162
6126
  return /*#__PURE__*/jsxs(Components$1.OverlayPage, {
@@ -6175,8 +6139,8 @@ class AddJobType extends Component {
6175
6139
  });
6176
6140
  }
6177
6141
  }
6178
- var mapStateToProps$1 = state => {
6179
- var {
6142
+ const mapStateToProps$1 = state => {
6143
+ const {
6180
6144
  auth
6181
6145
  } = state;
6182
6146
  return {
@@ -6190,14 +6154,14 @@ var AddJobType$1 = connect(mapStateToProps$1, {
6190
6154
 
6191
6155
  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; }
6192
6156
  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; }
6193
- var {
6157
+ const {
6194
6158
  Analytics: Analytics$1,
6195
6159
  Session,
6196
6160
  Components,
6197
6161
  Helper,
6198
6162
  Colours
6199
6163
  } = PlussCore;
6200
- var getInitialState = () => ({
6164
+ const getInitialState = () => ({
6201
6165
  requests: 0,
6202
6166
  prevRequests: 0,
6203
6167
  completedRequests: 0,
@@ -6208,8 +6172,8 @@ var getInitialState = () => ({
6208
6172
  });
6209
6173
 
6210
6174
  // AnalyticsHub Component
6211
- var AnalyticsHub = _ref => {
6212
- var {
6175
+ const AnalyticsHub = _ref => {
6176
+ let {
6213
6177
  startTime,
6214
6178
  endTime,
6215
6179
  auth,
@@ -6220,27 +6184,27 @@ var AnalyticsHub = _ref => {
6220
6184
  userCategory,
6221
6185
  selectedSites
6222
6186
  } = _ref;
6223
- var [analyticsData, setAnalyticsData] = useState(getInitialState());
6224
- var [isExportOpen, setIsExportOpen] = useState(false);
6225
- var [failedSites, setFailedSites] = useState([]);
6226
- var [comparisonData, setComparisonData] = useState({
6187
+ const [analyticsData, setAnalyticsData] = useState(getInitialState());
6188
+ const [isExportOpen, setIsExportOpen] = useState(false);
6189
+ const [failedSites, setFailedSites] = useState([]);
6190
+ const [comparisonData, setComparisonData] = useState({
6227
6191
  requests: [],
6228
6192
  completedRequests: [],
6229
6193
  comments: [],
6230
6194
  isLoading: true
6231
6195
  });
6232
- var comparisonMode = selectedSites && selectedSites.length > 1;
6233
- var hasAccess = Session.validateAccess(auth.site, values.permissionMaintenanceTracking, auth);
6196
+ const comparisonMode = selectedSites && selectedSites.length > 1;
6197
+ const hasAccess = Session.validateAccess(auth.site, values.permissionMaintenanceTracking, auth);
6234
6198
  if (!hasAccess) {
6235
6199
  return null;
6236
6200
  }
6237
- var featureTitle = (key => {
6201
+ const featureTitle = (key => {
6238
6202
  if (!strings || !strings.sideNav || !strings.sideNav[key]) {
6239
6203
  return values.textMenuTitle;
6240
6204
  }
6241
6205
  return strings.sideNav[key];
6242
6206
  })();
6243
- var exportColumns = [{
6207
+ const exportColumns = [{
6244
6208
  label: "Select All",
6245
6209
  key: ""
6246
6210
  }, ...(comparisonMode ? [{
@@ -6265,104 +6229,94 @@ var AnalyticsHub = _ref => {
6265
6229
  useEffect(() => {
6266
6230
  getData();
6267
6231
  }, [startTime, endTime, userType, userCategory, selectedSites]);
6268
- var getData = /*#__PURE__*/function () {
6269
- var _ref2 = _asyncToGenerator(function* () {
6270
- try {
6271
- setFailedSites([]);
6272
- if (comparisonMode) {
6273
- setComparisonData({
6274
- requests: [],
6275
- completedRequests: [],
6276
- comments: [],
6277
- isLoading: true
6278
- });
6279
- var multiSiteResultsObj = yield Analytics$1.fetchMultiSiteData(selectedSites, /*#__PURE__*/function () {
6280
- var _ref3 = _asyncToGenerator(function* (site) {
6281
- var {
6282
- data
6283
- } = yield analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime, endTime, true, {
6284
- userType,
6285
- userCategory
6286
- });
6287
- return data;
6288
- });
6289
- return function (_x) {
6290
- return _ref3.apply(this, arguments);
6291
- };
6292
- }());
6293
- var roles = auth.user.Roles;
6294
- var failed = Object.entries(multiSiteResultsObj).filter(_ref4 => {
6295
- var [, data] = _ref4;
6296
- return data === null;
6297
- }).map(_ref5 => {
6298
- var [site] = _ref5;
6299
- return Helper.getSiteNameFromRoles(site, roles);
6300
- });
6301
- setFailedSites(failed);
6302
- var multiSiteResults = Object.entries(multiSiteResultsObj).filter(_ref6 => {
6303
- var [, data] = _ref6;
6304
- return data !== null;
6305
- }).map(_ref7 => {
6306
- var [site, data] = _ref7;
6307
- return {
6308
- site,
6309
- data
6310
- };
6311
- });
6312
- var buildComparison = (activityKey, countType) => multiSiteResults.map(result => ({
6313
- name: Helper.getSiteNameFromRoles(result.site, roles),
6314
- value: Analytics$1.countActivities(result.data, activityKey, countType)
6315
- }));
6316
- setComparisonData({
6317
- requests: buildComparison("Request", "total"),
6318
- completedRequests: buildComparison("RequestCompleted", "unique"),
6319
- comments: buildComparison("Comment", "total"),
6320
- isLoading: false
6321
- });
6322
- } else {
6323
- setAnalyticsData(getInitialState());
6324
- var site = selectedSites && selectedSites.length === 1 ? selectedSites[0] : auth.site;
6325
- var timeDifference = endTime - startTime;
6326
- var [currentStatsResponse, prevStatsResponse] = yield Promise.all([analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime, endTime, true, {
6327
- userType,
6328
- userCategory
6329
- }), analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime - timeDifference, startTime, true, {
6232
+ const getData = async () => {
6233
+ try {
6234
+ setFailedSites([]);
6235
+ if (comparisonMode) {
6236
+ setComparisonData({
6237
+ requests: [],
6238
+ completedRequests: [],
6239
+ comments: [],
6240
+ isLoading: true
6241
+ });
6242
+ const multiSiteResultsObj = await Analytics$1.fetchMultiSiteData(selectedSites, async site => {
6243
+ const {
6244
+ data
6245
+ } = await analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime, endTime, true, {
6330
6246
  userType,
6331
6247
  userCategory
6332
- })]);
6333
- var data = {
6334
- requests: Analytics$1.countActivities(currentStatsResponse.data, "Request", "total"),
6335
- prevRequests: Analytics$1.countActivities(prevStatsResponse.data, "Request", "total"),
6336
- completedRequests: Analytics$1.countActivities(currentStatsResponse.data, "RequestCompleted", "unique"),
6337
- prevCompletedRequests: Analytics$1.countActivities(prevStatsResponse.data, "RequestCompleted", "unique"),
6338
- comments: Analytics$1.countActivities(currentStatsResponse.data, "Comment", "total"),
6339
- prevComments: Analytics$1.countActivities(prevStatsResponse.data, "Comment", "total"),
6340
- isLoading: false
6248
+ });
6249
+ return data;
6250
+ });
6251
+ const roles = auth.user.Roles;
6252
+ const failed = Object.entries(multiSiteResultsObj).filter(_ref2 => {
6253
+ let [, data] = _ref2;
6254
+ return data === null;
6255
+ }).map(_ref3 => {
6256
+ let [site] = _ref3;
6257
+ return Helper.getSiteNameFromRoles(site, roles);
6258
+ });
6259
+ setFailedSites(failed);
6260
+ const multiSiteResults = Object.entries(multiSiteResultsObj).filter(_ref4 => {
6261
+ let [, data] = _ref4;
6262
+ return data !== null;
6263
+ }).map(_ref5 => {
6264
+ let [site, data] = _ref5;
6265
+ return {
6266
+ site,
6267
+ data
6341
6268
  };
6342
- setAnalyticsData(data);
6343
- }
6344
- } catch (err) {
6345
- if (comparisonMode) {
6346
- setComparisonData(prev => _objectSpread$3(_objectSpread$3({}, prev), {}, {
6347
- isLoading: false
6348
- }));
6349
- } else {
6350
- setAnalyticsData(prev => _objectSpread$3(_objectSpread$3({}, prev), {}, {
6351
- isLoading: false
6352
- }));
6353
- }
6269
+ });
6270
+ const buildComparison = (activityKey, countType) => multiSiteResults.map(result => ({
6271
+ name: Helper.getSiteNameFromRoles(result.site, roles),
6272
+ value: Analytics$1.countActivities(result.data, activityKey, countType)
6273
+ }));
6274
+ setComparisonData({
6275
+ requests: buildComparison("Request", "total"),
6276
+ completedRequests: buildComparison("RequestCompleted", "unique"),
6277
+ comments: buildComparison("Comment", "total"),
6278
+ isLoading: false
6279
+ });
6280
+ } else {
6281
+ setAnalyticsData(getInitialState());
6282
+ const site = selectedSites && selectedSites.length === 1 ? selectedSites[0] : auth.site;
6283
+ const timeDifference = endTime - startTime;
6284
+ const [currentStatsResponse, prevStatsResponse] = await Promise.all([analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime, endTime, true, {
6285
+ userType,
6286
+ userCategory
6287
+ }), analyticsActions.getAggregateEntityStats(site, values.analyticsKey, startTime - timeDifference, startTime, true, {
6288
+ userType,
6289
+ userCategory
6290
+ })]);
6291
+ const data = {
6292
+ requests: Analytics$1.countActivities(currentStatsResponse.data, "Request", "total"),
6293
+ prevRequests: Analytics$1.countActivities(prevStatsResponse.data, "Request", "total"),
6294
+ completedRequests: Analytics$1.countActivities(currentStatsResponse.data, "RequestCompleted", "unique"),
6295
+ prevCompletedRequests: Analytics$1.countActivities(prevStatsResponse.data, "RequestCompleted", "unique"),
6296
+ comments: Analytics$1.countActivities(currentStatsResponse.data, "Comment", "total"),
6297
+ prevComments: Analytics$1.countActivities(prevStatsResponse.data, "Comment", "total"),
6298
+ isLoading: false
6299
+ };
6300
+ setAnalyticsData(data);
6354
6301
  }
6355
- });
6356
- return function getData() {
6357
- return _ref2.apply(this, arguments);
6358
- };
6359
- }();
6360
- var isReadyToOpenCSV = () => {
6302
+ } catch (err) {
6303
+ if (comparisonMode) {
6304
+ setComparisonData(prev => _objectSpread$3(_objectSpread$3({}, prev), {}, {
6305
+ isLoading: false
6306
+ }));
6307
+ } else {
6308
+ setAnalyticsData(prev => _objectSpread$3(_objectSpread$3({}, prev), {}, {
6309
+ isLoading: false
6310
+ }));
6311
+ }
6312
+ }
6313
+ };
6314
+ const isReadyToOpenCSV = () => {
6361
6315
  return comparisonMode ? !comparisonData.isLoading : !analyticsData.isLoading;
6362
6316
  };
6363
- var getExportSource = () => {
6317
+ const getExportSource = () => {
6364
6318
  if (comparisonMode) {
6365
- var sites = comparisonData.requests || [];
6319
+ const sites = comparisonData.requests || [];
6366
6320
  return sites.map((site, i) => ({
6367
6321
  site: site.name,
6368
6322
  startDate: moment(startTime + 1).format("D-MM-YYYY"),
@@ -6380,12 +6334,12 @@ var AnalyticsHub = _ref => {
6380
6334
  comments: analyticsData.comments
6381
6335
  }];
6382
6336
  };
6383
- var csvPopup = () => {
6337
+ const csvPopup = () => {
6384
6338
  if (!isExportOpen) {
6385
6339
  return null;
6386
6340
  }
6387
- var source = getExportSource();
6388
- var filterSuffix = [userType, userCategory].filter(Boolean).map(f => f.toLowerCase().replace(/\s+/g, "-")).join("_");
6341
+ const source = getExportSource();
6342
+ const filterSuffix = [userType, userCategory].filter(Boolean).map(f => f.toLowerCase().replace(/\s+/g, "-")).join("_");
6389
6343
  return /*#__PURE__*/jsx(Components.ExportCsvPopup, {
6390
6344
  onClose: () => {
6391
6345
  setIsExportOpen(false);
@@ -6423,7 +6377,7 @@ var AnalyticsHub = _ref => {
6423
6377
  }), /*#__PURE__*/jsx("div", {
6424
6378
  className: "analyticsSection dashboardSection_content",
6425
6379
  children: (() => {
6426
- var chartSuffix = [selectedSites && selectedSites.length > 0 ? "&sites=".concat(selectedSites.join(",")) : "", userType ? "&userType=".concat(encodeURIComponent(userType)) : "", userCategory ? "&userCategory=".concat(encodeURIComponent(userCategory)) : ""].join("");
6380
+ const chartSuffix = [selectedSites && selectedSites.length > 0 ? "&sites=".concat(selectedSites.join(",")) : "", userType ? "&userType=".concat(encodeURIComponent(userType)) : "", userCategory ? "&userCategory=".concat(encodeURIComponent(userCategory)) : ""].join("");
6427
6381
  if (comparisonMode) {
6428
6382
  return /*#__PURE__*/jsxs("div", {
6429
6383
  style: {
@@ -6483,8 +6437,8 @@ var AnalyticsHub = _ref => {
6483
6437
  })]
6484
6438
  });
6485
6439
  };
6486
- var mapStateToProps = state => {
6487
- var {
6440
+ const mapStateToProps = state => {
6441
+ const {
6488
6442
  auth
6489
6443
  } = state;
6490
6444
  return {
@@ -6492,11 +6446,11 @@ var mapStateToProps = state => {
6492
6446
  strings: state.strings && state.strings.config || {}
6493
6447
  };
6494
6448
  };
6495
- var toExport = connect(mapStateToProps, {})(AnalyticsHub);
6449
+ const toExport = connect(mapStateToProps, {})(AnalyticsHub);
6496
6450
 
6497
6451
  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; }
6498
6452
  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; }
6499
- var INITIAL_STATE = {
6453
+ const INITIAL_STATE = {
6500
6454
  jobs: [],
6501
6455
  jobtypes: [],
6502
6456
  jobstatuses: jobStatusOptions,
@@ -6504,15 +6458,15 @@ var INITIAL_STATE = {
6504
6458
  hideSeen: false
6505
6459
  };
6506
6460
  var MaintenanceReducer = (function () {
6507
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_STATE;
6508
- var action = arguments.length > 1 ? arguments[1] : undefined;
6461
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_STATE;
6462
+ let action = arguments.length > 1 ? arguments[1] : undefined;
6509
6463
  switch (action.type) {
6510
6464
  case JOBS_LOADING:
6511
6465
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
6512
6466
  loading: true
6513
6467
  });
6514
6468
  case JOBS_LOADED:
6515
- var result = _.unionWith(action.payload, state.jobs, (v1, v2) => {
6469
+ const result = _.unionWith(action.payload, state.jobs, (v1, v2) => {
6516
6470
  return v1 != null && v2 != null && v1.id === v2.id;
6517
6471
  });
6518
6472
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
@@ -6522,11 +6476,11 @@ var MaintenanceReducer = (function () {
6522
6476
  loading: false
6523
6477
  });
6524
6478
  case JOBS_REMOVED:
6525
- var index = _.findIndex(state.jobs, event => {
6479
+ const index = _.findIndex(state.jobs, event => {
6526
6480
  return event != null && event.id === action.payload;
6527
6481
  });
6528
6482
  if (index > -1) {
6529
- var newJobs = [...state.jobs];
6483
+ const newJobs = [...state.jobs];
6530
6484
  newJobs.splice(index, 1);
6531
6485
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
6532
6486
  jobs: newJobs
@@ -6534,14 +6488,14 @@ var MaintenanceReducer = (function () {
6534
6488
  }
6535
6489
  return state;
6536
6490
  case JOBS_TYPES_LOADED:
6537
- var jobtypes = _.unionWith(action.payload, state.jobtypes, (v1, v2) => {
6491
+ const jobtypes = _.unionWith(action.payload, state.jobtypes, (v1, v2) => {
6538
6492
  return v1 != null && v2 != null && v1.id === v2.id;
6539
6493
  });
6540
6494
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
6541
6495
  jobtypes
6542
6496
  });
6543
6497
  case JOBS_STATUSES_LOADED:
6544
- var jobstatuses = _.orderBy(action.payload, "order", "asc");
6498
+ const jobstatuses = _.orderBy(action.payload, "order", "asc");
6545
6499
  return _objectSpread$2(_objectSpread$2({}, state), {}, {
6546
6500
  jobstatuses
6547
6501
  });
@@ -6556,7 +6510,7 @@ var MaintenanceReducer = (function () {
6556
6510
 
6557
6511
  class ActivityText extends Component {
6558
6512
  render() {
6559
- var {
6513
+ const {
6560
6514
  data,
6561
6515
  classes,
6562
6516
  clickableClasses,
@@ -6632,7 +6586,7 @@ var img$3 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAxwAAAGGCAYAAADxZYcEA
6632
6586
 
6633
6587
  class ViewWidget extends Component {
6634
6588
  render() {
6635
- var src = img$3;
6589
+ let src = img$3;
6636
6590
  return /*#__PURE__*/jsx("img", {
6637
6591
  style: styles$3.image,
6638
6592
  src: src,
@@ -6640,7 +6594,7 @@ class ViewWidget extends Component {
6640
6594
  });
6641
6595
  }
6642
6596
  }
6643
- var styles$3 = {
6597
+ const styles$3 = {
6644
6598
  image: {
6645
6599
  width: 80
6646
6600
  }
@@ -6650,7 +6604,7 @@ var img$2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmAAAASICAYAAAC0rHMFA
6650
6604
 
6651
6605
  class ViewFull extends Component {
6652
6606
  render() {
6653
- var src = img$2;
6607
+ let src = img$2;
6654
6608
  return /*#__PURE__*/jsx("img", {
6655
6609
  style: styles$2.image,
6656
6610
  src: src,
@@ -6658,7 +6612,7 @@ class ViewFull extends Component {
6658
6612
  });
6659
6613
  }
6660
6614
  }
6661
- var styles$2 = {
6615
+ const styles$2 = {
6662
6616
  image: {
6663
6617
  width: "100%",
6664
6618
  height: "100%",
@@ -6672,12 +6626,12 @@ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
6672
6626
  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; }
6673
6627
  class PreviewWidget extends Component {
6674
6628
  render() {
6675
- var {
6629
+ const {
6676
6630
  backgroundColor,
6677
6631
  widgetTitle,
6678
6632
  titleClassName
6679
6633
  } = this.props;
6680
- var src = img$1;
6634
+ let src = img$1;
6681
6635
  return /*#__PURE__*/jsxs("div", {
6682
6636
  style: styles$1.container,
6683
6637
  children: [/*#__PURE__*/jsx("img", {
@@ -6694,7 +6648,7 @@ class PreviewWidget extends Component {
6694
6648
  });
6695
6649
  }
6696
6650
  }
6697
- var styles$1 = {
6651
+ const styles$1 = {
6698
6652
  container: {
6699
6653
  position: "relative"
6700
6654
  },
@@ -6709,12 +6663,12 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
6709
6663
  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; }
6710
6664
  class PreviewFull extends Component {
6711
6665
  render() {
6712
- var {
6666
+ const {
6713
6667
  backgroundColor,
6714
6668
  widgetTitle,
6715
6669
  titleClassName
6716
6670
  } = this.props;
6717
- var src = img;
6671
+ let src = img;
6718
6672
  return /*#__PURE__*/jsxs("div", {
6719
6673
  style: styles.container,
6720
6674
  children: [/*#__PURE__*/jsx("p", {
@@ -6730,7 +6684,7 @@ class PreviewFull extends Component {
6730
6684
  });
6731
6685
  }
6732
6686
  }
6733
- var styles = {
6687
+ const styles = {
6734
6688
  container: {
6735
6689
  position: "relative"
6736
6690
  },
@@ -6739,11 +6693,11 @@ var styles = {
6739
6693
  }
6740
6694
  };
6741
6695
 
6742
- var SVG_PATH = values.svgPathGridIcon;
6743
- var SVG_VIEWBOX = values.svgPathGridIconViewBox ;
6696
+ const SVG_PATH = values.svgPathGridIcon;
6697
+ const SVG_VIEWBOX = values.svgPathGridIconViewBox ;
6744
6698
  class PreviewGrid extends Component {
6745
6699
  render() {
6746
- var {
6700
+ const {
6747
6701
  colour
6748
6702
  } = this.props;
6749
6703
  if (Array.isArray(SVG_PATH)) {
@@ -6770,20 +6724,20 @@ class PreviewGrid extends Component {
6770
6724
  }
6771
6725
  }
6772
6726
 
6773
- var Reducers = (() => {
6774
- var reducers = {};
6727
+ const Reducers = (() => {
6728
+ const reducers = {};
6775
6729
  reducers[values.reducerKey] = MaintenanceReducer;
6776
6730
  return reducers;
6777
6731
  })();
6778
- var Screens = (() => {
6779
- var screens = {};
6732
+ const Screens = (() => {
6733
+ const screens = {};
6780
6734
  screens[values.screenRequestsHub] = RequestsHub$1;
6781
6735
  screens[values.screenJob] = Job$1;
6782
6736
  screens[values.screenAddJob] = AddJob$1;
6783
6737
  screens[values.screenAddJobType] = AddJobType$1;
6784
6738
  return screens;
6785
6739
  })();
6786
- var Analytics = [toExport];
6740
+ const Analytics = [toExport];
6787
6741
 
6788
6742
  export { ActivityText, Analytics, FeatureConfig as Config, PreviewFull, PreviewGrid, PreviewWidget, Reducers, Screens, ViewFull, ViewWidget };
6789
6743
  //# sourceMappingURL=index.js.map