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