@plusscommunities/pluss-maintenance-app 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,6 +62,7 @@ class MaintenanceRequest extends Component {
62
62
 
63
63
  customFields: [],
64
64
  customFieldImages: {},
65
+ customFieldDocuments: {},
65
66
  isDateTimePickerVisible: false,
66
67
  popUpType: 'date',
67
68
  dateFieldId: null,
@@ -150,7 +151,7 @@ class MaintenanceRequest extends Component {
150
151
  this.setState(update);
151
152
  };
152
153
 
153
- onUploadStarted = (uploadUri, imageUri) => {
154
+ onUploadStartedImage = (uploadUri, imageUri) => {
154
155
  const { imageFieldId } = this.state;
155
156
  const imagesUpdate = this.getImages(imageFieldId);
156
157
  imagesUpdate.splice(imagesUpdate.length - 1, 0, {
@@ -164,7 +165,7 @@ class MaintenanceRequest extends Component {
164
165
  this.setImages(imagesUpdate, imageFieldId);
165
166
  };
166
167
 
167
- onUploadProgress = progress => {
168
+ onUploadProgressImage = progress => {
168
169
  const { imageFieldId } = this.state;
169
170
  const imagesUpdate = this.getImages(imageFieldId);
170
171
  imagesUpdate.map(img => {
@@ -178,7 +179,7 @@ class MaintenanceRequest extends Component {
178
179
  this.setImages(imagesUpdate, imageFieldId);
179
180
  };
180
181
 
181
- onUploadSuccess = async (uri, uploadUri) => {
182
+ onUploadSuccessImage = async (uri, uploadUri) => {
182
183
  const { imageFieldId } = this.state;
183
184
  const imagesUpdate = this.getImages(imageFieldId);
184
185
  imagesUpdate.map(img => {
@@ -193,7 +194,7 @@ class MaintenanceRequest extends Component {
193
194
  this.setImages(imagesUpdate, imageFieldId, () => this.waitForThumbnails());
194
195
  };
195
196
 
196
- onUploadFailed = uploadUri => {
197
+ onUploadFailedImage = uploadUri => {
197
198
  const { imageFieldId } = this.state;
198
199
  const imagesUpdate = this.getImages(imageFieldId);
199
200
  imagesUpdate.map(img => {
@@ -221,6 +222,61 @@ class MaintenanceRequest extends Component {
221
222
  this.setImages(imagesUpdate, imageFieldId);
222
223
  };
223
224
 
225
+ onUploadStartedDocument = (uploadUri, documentUri, documentName, documentExt, documentFieldId) => {
226
+ const documentsUpdate = this.getDocuments(documentFieldId);
227
+ documentsUpdate.splice(documentsUpdate.length - 1, 0, {
228
+ uploading: true,
229
+ uploadProgress: '0%',
230
+ uploadUri,
231
+ documentUri,
232
+ documentName,
233
+ documentExt,
234
+ allowRetry: true,
235
+ });
236
+
237
+ this.setDocuments(documentsUpdate, documentFieldId);
238
+ };
239
+
240
+ onUploadProgressDocument = (progress, documentFieldId) => {
241
+ const documentsUpdate = this.getDocuments(documentFieldId);
242
+ documentsUpdate.map(doc => {
243
+ if (doc.uploadUri === progress.uri) {
244
+ doc.uploadProgress = progress.percentage;
245
+ doc.uploading = true;
246
+ doc.allowRetry = true;
247
+ }
248
+ });
249
+
250
+ this.setDocuments(documentsUpdate, documentFieldId);
251
+ };
252
+
253
+ onUploadSuccessDocument = async (uri, uploadUri, documentFieldId) => {
254
+ const documentsUpdate = this.getDocuments(documentFieldId);
255
+ documentsUpdate.map(doc => {
256
+ if (doc.uploadUri === uploadUri && doc.uploading) {
257
+ doc.uploading = false;
258
+ doc.uploadProgress = '100%';
259
+ doc.url = uri;
260
+ doc.allowRetry = true;
261
+ }
262
+ });
263
+
264
+ this.setDocuments(documentsUpdate, documentFieldId);
265
+ };
266
+
267
+ onUploadFailedDocument = (uploadUri, documentFieldId) => {
268
+ const documentsUpdate = this.getDocuments(documentFieldId);
269
+ documentsUpdate.map(doc => {
270
+ if (doc.uploadUri === uploadUri) {
271
+ doc.uploading = true; // Requried for retry
272
+ doc.uploadProgress = '';
273
+ doc.allowRetry = true;
274
+ }
275
+ });
276
+
277
+ this.setDocuments(documentsUpdate, documentFieldId);
278
+ };
279
+
224
280
  onPressBack() {
225
281
  Services.navigation.goBack();
226
282
  }
@@ -260,6 +316,7 @@ class MaintenanceRequest extends Component {
260
316
  fail: false,
261
317
  customFields: [],
262
318
  customFieldImages: {},
319
+ customFieldDocuments: {},
263
320
  isDateTimePickerVisible: false,
264
321
  popUpType: 'date',
265
322
  dateFieldId: null,
@@ -273,14 +330,17 @@ class MaintenanceRequest extends Component {
273
330
  const { mandatory, type, answer } = field;
274
331
  if (['staticTitle', 'staticText'].includes(type)) return true;
275
332
 
276
- const imagesList = type === 'image' ? this.getImageUrls(fieldId) : [];
277
333
  const checkMandatory = () => {
278
334
  if (!mandatory) return true;
279
335
  switch (type) {
280
336
  case 'yn':
281
337
  return _.isBoolean(answer);
282
338
  case 'image':
339
+ const imagesList = this.getImageUrls(fieldId);
283
340
  return imagesList.length > 0;
341
+ case 'document':
342
+ const documentsList = this.getDocumentAnswers(fieldId);
343
+ return documentsList.length > 0;
284
344
  case 'checkbox':
285
345
  return _.isArray(answer) && answer.length > 0;
286
346
  default:
@@ -312,7 +372,6 @@ class MaintenanceRequest extends Component {
312
372
  this.setState({
313
373
  types: res.data,
314
374
  });
315
- console.log(res.data);
316
375
  this.getDefaultJob();
317
376
  })
318
377
  .catch(() => { });
@@ -322,7 +381,6 @@ class MaintenanceRequest extends Component {
322
381
  const { types } = this.state;
323
382
  const selected = types.find(t => t.typeName === type) || {};
324
383
  if (values.forceCustomFields && !selected.hasCustomFields) {
325
- console.log(selected);
326
384
  this.setState({
327
385
  type,
328
386
  customFields: [],
@@ -379,6 +437,7 @@ class MaintenanceRequest extends Component {
379
437
  const customFields = _.cloneDeep(this.state.customFields);
380
438
  const updatedCustomFields = customFields.map((field, fieldId) => {
381
439
  if (field.type === 'image') field.answer = this.getImageUrls(fieldId);
440
+ if (field.type === 'document') field.answer = this.getDocumentAnswers(fieldId);
382
441
  return field;
383
442
  });
384
443
 
@@ -543,20 +602,54 @@ class MaintenanceRequest extends Component {
543
602
  this.setImages(imagesUpdate, fieldId);
544
603
  };
545
604
 
605
+ getDocuments = fieldId => {
606
+ const { customFieldDocuments } = this.state;
607
+ const documentsList = _.cloneDeep(customFieldDocuments[fieldId]) || [];
608
+ return documentsList;
609
+ };
610
+
611
+ setDocuments = (documentsList, fieldId) => {
612
+ let update = {};
613
+ const customFieldDocuments = _.cloneDeep(this.state.customFieldDocuments);
614
+ customFieldDocuments[fieldId] = documentsList;
615
+ update = { customFieldDocuments };
616
+ this.setState(update);
617
+ };
618
+
619
+ getDocumentAnswers = fieldId => {
620
+ const documentsList = this.getDocuments(fieldId);
621
+ return _.filter(documentsList, doc => {
622
+ return !doc.uploading && doc.url;
623
+ }).map(doc => {
624
+ return {
625
+ name: doc.documentName,
626
+ ext: doc.documentExt,
627
+ url: doc.url,
628
+ };
629
+ });
630
+ };
631
+
632
+ removeDocument = (index, fieldId) => {
633
+ const documentsUpdate = this.getDocuments(fieldId);
634
+ documentsUpdate.splice(index, 1);
635
+
636
+ this.setDocuments(documentsUpdate, fieldId);
637
+ };
638
+
546
639
  toggleFullscreenVideo = url => {
547
640
  if (typeof url !== 'string') url = '';
548
641
  this.setState({ showFullscreenVideo: url.length > 0, currentVideoUrl: url });
549
642
  };
550
643
 
551
- renderUploadMenu() {
644
+ renderImageUploader() {
552
645
  return (
553
646
  <Components.ImageUploader
554
647
  ref={ref => (this.imageUploader = ref)}
555
- onUploadStarted={this.onUploadStarted}
556
- onUploadSuccess={this.onUploadSuccess}
557
- onUploadFailed={this.onUploadFailed}
558
- onUploadProgress={this.onUploadProgress}
559
- onLibrarySelected={this.onLibrarySelected}
648
+ onUploadStarted={this.onUploadStartedImage}
649
+ onUploadSuccess={this.onUploadSuccessImage}
650
+ onUploadFailed={this.onUploadFailedImage}
651
+ onUploadProgress={this.onUploadProgressImage}
652
+ onLibrarySelected={this.onLibrarySelectedImage}
560
653
  size={{ width: 1400 }}
561
654
  quality={0.8}
562
655
  fileName={'serviceImage'}
@@ -623,6 +716,23 @@ class MaintenanceRequest extends Component {
623
716
  );
624
717
  }
625
718
 
719
+ renderDocument(item, index, fieldId) {
720
+ const { colourBrandingMain } = this.props;
721
+ return (
722
+ <View key={index} style={styles.documentContainer}>
723
+ <View style={{ ...styles.documentTypeContainer, backgroundColor: colourBrandingMain }}>
724
+ <Text style={styles.documentTypeText}>{item.documentExt}</Text>
725
+ </View>
726
+ <Text style={styles.documentText}>{`${item.documentName}${item.uploading ? ` - ${item.uploadProgress}` : ''}`}</Text>
727
+ {!item.uploading && (
728
+ <TouchableOpacity style={styles.removeDocumentButton} onPress={() => this.removeDocument(index, fieldId)}>
729
+ <Icon name="remove" type="font-awesome" iconStyle={{ ...styles.removeDocumentIcon, color: colourBrandingMain }} />
730
+ </TouchableOpacity>
731
+ )}
732
+ </View>
733
+ );
734
+ }
735
+
626
736
  renderSuccess() {
627
737
  return (
628
738
  <View style={{ padding: 16, flex: 1, backgroundColor: '#fff' }}>
@@ -634,21 +744,40 @@ class MaintenanceRequest extends Component {
634
744
  renderImageList(fieldId = null) {
635
745
  const imagesList = this.getImages(fieldId);
636
746
  return (
637
- <View style={styles.imageSection}>
638
- <View style={[styles.imageListContainer, imagesList.length < 2 && styles.imageListContainerEmpty]}>
639
- <FlatList
640
- keyboardShouldPersistTaps="always"
641
- enableEmptySections
642
- data={imagesList}
643
- renderItem={({ item, index }) => this.renderImage(item, index, fieldId)}
644
- keyExtractor={(item, index) => index}
645
- numColumns={3}
646
- />
647
- </View>
747
+ <View style={[styles.imageListContainer, imagesList.length < 2 && styles.imageListContainerEmpty]}>
748
+ <FlatList
749
+ keyboardShouldPersistTaps="always"
750
+ enableEmptySections
751
+ data={imagesList}
752
+ renderItem={({ item, index }) => this.renderImage(item, index, fieldId)}
753
+ keyExtractor={(item, index) => index}
754
+ numColumns={3}
755
+ />
648
756
  </View>
649
757
  );
650
758
  }
651
759
 
760
+ // renderDocumentList(fieldId) {
761
+ // const documentsList = this.getDocuments(fieldId);
762
+ // return (
763
+ // <View style={styles.documentListContainer}>
764
+ // {documentsList.length > 0 ? documentsList.map((document, index) => this.renderDocument(document, index, fieldId)) : null}
765
+ // <Components.DocumentUploader
766
+ // buttonTitle="Add Files"
767
+ // allowedTypes={['application/pdf']}
768
+ // onUploadStarted={(uploadUri, uri, name, ext) => this.onUploadStartedDocument(uploadUri, uri, name, ext, fieldId)}
769
+ // onUploadProgress={progress => this.onUploadProgressDocument(progress, fieldId)}
770
+ // onUploadSuccess={(uri, uploadUri) => this.onUploadSuccessDocument(uri, uploadUri, fieldId)}
771
+ // onUploadFailed={uploadUri => this.onUploadFailedDocument(uploadUri, fieldId)}
772
+ // fileName="serviceDocument"
773
+ // userId={this.props.uid}
774
+ // disabled={false}
775
+ // multiple
776
+ // />
777
+ // </View>
778
+ // );
779
+ // }
780
+
652
781
  renderDateField(field, fieldId, sectionStyle) {
653
782
  let displayText, placeHolder, icon, errorText;
654
783
  if (field.type === 'date') {
@@ -806,6 +935,19 @@ class MaintenanceRequest extends Component {
806
935
  {this.renderImageList(fieldId)}
807
936
  </Components.GenericInputSection>
808
937
  );
938
+ // case 'document':
939
+ // return (
940
+ // <Components.GenericInputSection
941
+ // key={fieldId}
942
+ // label={field.label}
943
+ // sectionStyle={sectionStyle}
944
+ // isValid={() => this.isFieldValid(field, fieldId)}
945
+ // required={field.mandatory}
946
+ // showError={this.state.showError}
947
+ // >
948
+ // {this.renderDocumentList(fieldId)}
949
+ // </Components.GenericInputSection>
950
+ // );
809
951
  default:
810
952
  return null;
811
953
  }
@@ -1021,7 +1163,7 @@ class MaintenanceRequest extends Component {
1021
1163
 
1022
1164
  return (
1023
1165
  <KeyboardAvoidingView behavior={Platform.OS === 'ios' && 'padding'} style={styles.viewContainer}>
1024
- {this.renderUploadMenu()}
1166
+ {this.renderImageUploader()}
1025
1167
  <View style={styles.container}>
1026
1168
  <Components.Header
1027
1169
  leftIcon="angle-left"
@@ -1086,6 +1228,11 @@ const styles = {
1086
1228
  alignItems: 'center',
1087
1229
  flexDirection: 'column',
1088
1230
  },
1231
+ documentListContainer: {
1232
+ marginTop: 8,
1233
+ flexDirection: 'column',
1234
+ alignItems: 'flex-start',
1235
+ },
1089
1236
  imageContainer: {
1090
1237
  width: PHOTO_SIZE,
1091
1238
  height: PHOTO_SIZE,
@@ -1211,6 +1358,42 @@ const styles = {
1211
1358
  fontSize: 26,
1212
1359
  color: Colours.TEXT_BLUEGREY,
1213
1360
  },
1361
+ documentContainer: {
1362
+ flexDirection: 'row',
1363
+ alignItems: 'center',
1364
+ justifyContent: 'space-between',
1365
+ paddingVertical: 4,
1366
+ },
1367
+ documentTypeContainer: {
1368
+ width: 50,
1369
+ height: 60,
1370
+ justifyContent: 'center',
1371
+ alignItems: 'center',
1372
+ borderRadius: 5,
1373
+ marginRight: 8,
1374
+ },
1375
+ documentTypeText: {
1376
+ color: '#fff',
1377
+ fontFamily: 'sf-semibold',
1378
+ textAlign: 'center',
1379
+ },
1380
+ documentText: {
1381
+ flex: 1,
1382
+ fontFamily: 'sf-semibold',
1383
+ fontSize: 16,
1384
+ color: '#65686D',
1385
+ },
1386
+ removeDocumentButton: {
1387
+ padding: 4,
1388
+ width: 40,
1389
+ height: 40,
1390
+ alignItems: 'center',
1391
+ justifyContent: 'center',
1392
+ marginLeft: 8,
1393
+ },
1394
+ removeDocumentIcon: {
1395
+ fontSize: 24,
1396
+ },
1214
1397
  };
1215
1398
 
1216
1399
  const mapStateToProps = state => {
@@ -0,0 +1,42 @@
1
+ const values = {
2
+ featureKey: 'maintenanceEnquiry',
3
+ aliases: ['maintenanceRequest'],
4
+ reducerKey: 'jobsEnquiry',
5
+ serviceKey: 'maintenanceEnquiry',
6
+ updateKey: 'jobsEnquiry',
7
+ commentKey: 'maintenancerequestEnquiry',
8
+ actionJobsLoaded: 'JOBS_LOADEDEnquiry',
9
+ actionJobAdded: 'JOB_ADDEDEnquiry',
10
+ actionJobsAdded: 'JOBS_ADDEDEnquiry',
11
+ actionJobsStatusesLoaded: 'JOBS_STATUSES_LOADEDEnquiry',
12
+ actionJobsHideSeen: 'JOBS_HIDE_SEENEnquiry',
13
+ actionJobFilterLoaded: 'JOBS_FILTER_LOADEDEnquiry',
14
+ screenMaintenance: 'maintenanceEnquiry',
15
+ screenRequestDetail: 'requestDetailEnquiry',
16
+ screenServiceRequest: 'serviceRequestEnquiry',
17
+ screenJobTypePicker: 'jobTypePickerEnquiry',
18
+ screenRequestNotes: 'requestNotesEnquiry',
19
+ permissionMaintenanceTracking: 'maintenanceTrackingEnquiry',
20
+ permissionMaintenanceAssignment: 'maintenanceAssignmentEnquiry',
21
+ iconGridMenu: 'form',
22
+ gridViewBox: '0 0 256 256',
23
+ iconAddMenu: 'form',
24
+ iconKioskAction: 'form',
25
+ hasMoreOption: false,
26
+ orderAddMenu: 5,
27
+ orderMoreMenu: 4,
28
+ orderKioskAction: 1,
29
+ textFeatureTitle: 'Enquiry',
30
+ textAddMenuTitle: 'New Enquiry',
31
+ textMoreMenuTitle: 'Enquiry',
32
+ textKioskActionTitle: 'Enquiry',
33
+ textEntityName: 'Enquiry',
34
+ textJobType: 'Enquiry Type',
35
+ emptyRequestsStaff: 'No active Enquiry',
36
+ emptyRequestsUser: 'Your Enquiry will show here',
37
+ forceCustomFields: true,
38
+ stringConfigJobStatus: 'maintenanceJobStatusEnquiry',
39
+ stringConfigHideSeen: 'maintenanceDisableSeenEnquiry',
40
+ };
41
+
42
+ export { values };
@@ -0,0 +1,42 @@
1
+ const values = {
2
+ featureKey: 'maintenanceFeedback',
3
+ aliases: ['maintenanceRequest'],
4
+ reducerKey: 'jobsFeedback',
5
+ serviceKey: 'maintenanceFeedback',
6
+ updateKey: 'jobsFeedback',
7
+ commentKey: 'maintenancerequestFeedback',
8
+ actionJobsLoaded: 'JOBS_LOADEDFeedback',
9
+ actionJobAdded: 'JOB_ADDEDFeedback',
10
+ actionJobsAdded: 'JOBS_ADDEDFeedback',
11
+ actionJobsStatusesLoaded: 'JOBS_STATUSES_LOADEDFeedback',
12
+ actionJobsHideSeen: 'JOBS_HIDE_SEENFeedback',
13
+ actionJobFilterLoaded: 'JOBS_FILTER_LOADEDFeedback',
14
+ screenMaintenance: 'maintenanceFeedback',
15
+ screenRequestDetail: 'requestDetailFeedback',
16
+ screenServiceRequest: 'serviceRequestFeedback',
17
+ screenJobTypePicker: 'jobTypePickerFeedback',
18
+ screenRequestNotes: 'requestNotesFeedback',
19
+ permissionMaintenanceTracking: 'maintenanceTrackingFeedback',
20
+ permissionMaintenanceAssignment: 'maintenanceAssignmentFeedback',
21
+ iconGridMenu: 'form',
22
+ gridViewBox: '0 0 256 256',
23
+ iconAddMenu: 'form',
24
+ iconKioskAction: 'form',
25
+ hasMoreOption: false,
26
+ orderAddMenu: 5,
27
+ orderMoreMenu: 4,
28
+ orderKioskAction: 1,
29
+ textFeatureTitle: 'Feedback',
30
+ textAddMenuTitle: 'New Feedback',
31
+ textMoreMenuTitle: 'Feedback',
32
+ textKioskActionTitle: 'Feedback',
33
+ textEntityName: 'Feedback',
34
+ textJobType: 'Feedback Type',
35
+ emptyRequestsStaff: 'No active Feedback',
36
+ emptyRequestsUser: 'Your Feedback will show here',
37
+ forceCustomFields: true,
38
+ stringConfigJobStatus: 'maintenanceJobStatusFeedback',
39
+ stringConfigHideSeen: 'maintenanceDisableSeenFeedback',
40
+ };
41
+
42
+ export { values };
@@ -0,0 +1,42 @@
1
+ const values = {
2
+ featureKey: 'maintenanceFood',
3
+ aliases: ['maintenanceRequest'],
4
+ reducerKey: 'jobsFood',
5
+ serviceKey: 'maintenanceFood',
6
+ updateKey: 'jobsFood',
7
+ commentKey: 'maintenancerequestFood',
8
+ actionJobsLoaded: 'JOBS_LOADEDFood',
9
+ actionJobAdded: 'JOB_ADDEDFood',
10
+ actionJobsAdded: 'JOBS_ADDEDFood',
11
+ actionJobsStatusesLoaded: 'JOBS_STATUSES_LOADEDFood',
12
+ actionJobsHideSeen: 'JOBS_HIDE_SEENFood',
13
+ actionJobFilterLoaded: 'JOBS_FILTER_LOADEDFood',
14
+ screenMaintenance: 'maintenanceFood',
15
+ screenRequestDetail: 'requestDetailFood',
16
+ screenServiceRequest: 'serviceRequestFood',
17
+ screenJobTypePicker: 'jobTypePickerFood',
18
+ screenRequestNotes: 'requestNotesFood',
19
+ permissionMaintenanceTracking: 'maintenanceTrackingFood',
20
+ permissionMaintenanceAssignment: 'maintenanceAssignmentFood',
21
+ iconGridMenu: 'form',
22
+ gridViewBox: '0 0 256 256',
23
+ iconAddMenu: 'form',
24
+ iconKioskAction: 'form',
25
+ hasMoreOption: false,
26
+ orderAddMenu: 5,
27
+ orderMoreMenu: 4,
28
+ orderKioskAction: 1,
29
+ textFeatureTitle: 'Food Ordering',
30
+ textAddMenuTitle: 'New Food Order',
31
+ textMoreMenuTitle: 'Food Ordering',
32
+ textKioskActionTitle: 'Food Ordering',
33
+ textEntityName: 'Food Order',
34
+ textJobType: 'Food Order Type',
35
+ emptyRequestsStaff: 'No active Food Orders',
36
+ emptyRequestsUser: 'Your Food Orders will show here',
37
+ forceCustomFields: true,
38
+ stringConfigJobStatus: 'maintenanceJobStatusFood',
39
+ stringConfigHideSeen: 'maintenanceDisableSeenFood',
40
+ };
41
+
42
+ export { values };