@plusscommunities/pluss-maintenance-app 7.0.0 → 7.0.1
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/module/components/FilterPopupMenu.js +18 -11
- package/dist/module/components/FilterPopupMenu.js.map +1 -1
- package/dist/module/components/MaintenanceList.js +2 -2
- package/dist/module/components/MaintenanceList.js.map +1 -1
- package/dist/module/helper.js +3 -2
- package/dist/module/helper.js.map +1 -1
- package/dist/module/reducers/JobsReducer.js +2 -1
- package/dist/module/reducers/JobsReducer.js.map +1 -1
- package/dist/module/screens/RequestDetail.js +77 -5
- package/dist/module/screens/RequestDetail.js.map +1 -1
- package/dist/module/screens/ServiceRequest.js +194 -17
- package/dist/module/screens/ServiceRequest.js.map +1 -1
- package/dist/module/values.config.enquiry.js +42 -0
- package/dist/module/values.config.enquiry.js.map +1 -0
- package/dist/module/values.config.feedback.js +42 -0
- package/dist/module/values.config.feedback.js.map +1 -0
- package/dist/module/values.config.food.js +42 -0
- package/dist/module/values.config.food.js.map +1 -0
- package/package.json +3 -2
- package/src/components/FilterPopupMenu.js +26 -16
- package/src/components/MaintenanceList.js +5 -5
- package/src/helper.js +6 -3
- package/src/reducers/JobsReducer.js +2 -1
- package/src/screens/RequestDetail.js +70 -4
- package/src/screens/ServiceRequest.js +208 -25
- package/src/values.config.enquiry.js +42 -0
- package/src/values.config.feedback.js +42 -0
- package/src/values.config.food.js +42 -0
@@ -92,7 +92,7 @@ class MaintenanceRequest extends Component {
|
|
92
92
|
}
|
93
93
|
this.setState(update);
|
94
94
|
});
|
95
|
-
_defineProperty(this, "
|
95
|
+
_defineProperty(this, "onUploadStartedImage", (uploadUri, imageUri) => {
|
96
96
|
const {
|
97
97
|
imageFieldId
|
98
98
|
} = this.state;
|
@@ -106,7 +106,7 @@ class MaintenanceRequest extends Component {
|
|
106
106
|
});
|
107
107
|
this.setImages(imagesUpdate, imageFieldId);
|
108
108
|
});
|
109
|
-
_defineProperty(this, "
|
109
|
+
_defineProperty(this, "onUploadProgressImage", progress => {
|
110
110
|
const {
|
111
111
|
imageFieldId
|
112
112
|
} = this.state;
|
@@ -120,7 +120,7 @@ class MaintenanceRequest extends Component {
|
|
120
120
|
});
|
121
121
|
this.setImages(imagesUpdate, imageFieldId);
|
122
122
|
});
|
123
|
-
_defineProperty(this, "
|
123
|
+
_defineProperty(this, "onUploadSuccessImage", async (uri, uploadUri) => {
|
124
124
|
const {
|
125
125
|
imageFieldId
|
126
126
|
} = this.state;
|
@@ -135,7 +135,7 @@ class MaintenanceRequest extends Component {
|
|
135
135
|
});
|
136
136
|
this.setImages(imagesUpdate, imageFieldId, () => this.waitForThumbnails());
|
137
137
|
});
|
138
|
-
_defineProperty(this, "
|
138
|
+
_defineProperty(this, "onUploadFailedImage", uploadUri => {
|
139
139
|
const {
|
140
140
|
imageFieldId
|
141
141
|
} = this.state;
|
@@ -163,6 +163,53 @@ class MaintenanceRequest extends Component {
|
|
163
163
|
});
|
164
164
|
this.setImages(imagesUpdate, imageFieldId);
|
165
165
|
});
|
166
|
+
_defineProperty(this, "onUploadStartedDocument", (uploadUri, documentUri, documentName, documentExt, documentFieldId) => {
|
167
|
+
const documentsUpdate = this.getDocuments(documentFieldId);
|
168
|
+
documentsUpdate.splice(documentsUpdate.length - 1, 0, {
|
169
|
+
uploading: true,
|
170
|
+
uploadProgress: '0%',
|
171
|
+
uploadUri,
|
172
|
+
documentUri,
|
173
|
+
documentName,
|
174
|
+
documentExt,
|
175
|
+
allowRetry: true
|
176
|
+
});
|
177
|
+
this.setDocuments(documentsUpdate, documentFieldId);
|
178
|
+
});
|
179
|
+
_defineProperty(this, "onUploadProgressDocument", (progress, documentFieldId) => {
|
180
|
+
const documentsUpdate = this.getDocuments(documentFieldId);
|
181
|
+
documentsUpdate.map(doc => {
|
182
|
+
if (doc.uploadUri === progress.uri) {
|
183
|
+
doc.uploadProgress = progress.percentage;
|
184
|
+
doc.uploading = true;
|
185
|
+
doc.allowRetry = true;
|
186
|
+
}
|
187
|
+
});
|
188
|
+
this.setDocuments(documentsUpdate, documentFieldId);
|
189
|
+
});
|
190
|
+
_defineProperty(this, "onUploadSuccessDocument", async (uri, uploadUri, documentFieldId) => {
|
191
|
+
const documentsUpdate = this.getDocuments(documentFieldId);
|
192
|
+
documentsUpdate.map(doc => {
|
193
|
+
if (doc.uploadUri === uploadUri && doc.uploading) {
|
194
|
+
doc.uploading = false;
|
195
|
+
doc.uploadProgress = '100%';
|
196
|
+
doc.url = uri;
|
197
|
+
doc.allowRetry = true;
|
198
|
+
}
|
199
|
+
});
|
200
|
+
this.setDocuments(documentsUpdate, documentFieldId);
|
201
|
+
});
|
202
|
+
_defineProperty(this, "onUploadFailedDocument", (uploadUri, documentFieldId) => {
|
203
|
+
const documentsUpdate = this.getDocuments(documentFieldId);
|
204
|
+
documentsUpdate.map(doc => {
|
205
|
+
if (doc.uploadUri === uploadUri) {
|
206
|
+
doc.uploading = true; // Requried for retry
|
207
|
+
doc.uploadProgress = '';
|
208
|
+
doc.allowRetry = true;
|
209
|
+
}
|
210
|
+
});
|
211
|
+
this.setDocuments(documentsUpdate, documentFieldId);
|
212
|
+
});
|
166
213
|
_defineProperty(this, "isFieldValid", (field, fieldId) => {
|
167
214
|
const {
|
168
215
|
mandatory,
|
@@ -170,14 +217,17 @@ class MaintenanceRequest extends Component {
|
|
170
217
|
answer
|
171
218
|
} = field;
|
172
219
|
if (['staticTitle', 'staticText'].includes(type)) return true;
|
173
|
-
const imagesList = type === 'image' ? this.getImageUrls(fieldId) : [];
|
174
220
|
const checkMandatory = () => {
|
175
221
|
if (!mandatory) return true;
|
176
222
|
switch (type) {
|
177
223
|
case 'yn':
|
178
224
|
return _.isBoolean(answer);
|
179
225
|
case 'image':
|
226
|
+
const imagesList = this.getImageUrls(fieldId);
|
180
227
|
return imagesList.length > 0;
|
228
|
+
case 'document':
|
229
|
+
const documentsList = this.getDocumentAnswers(fieldId);
|
230
|
+
return documentsList.length > 0;
|
181
231
|
case 'checkbox':
|
182
232
|
return _.isArray(answer) && answer.length > 0;
|
183
233
|
default:
|
@@ -229,6 +279,7 @@ class MaintenanceRequest extends Component {
|
|
229
279
|
const customFields = _.cloneDeep(this.state.customFields);
|
230
280
|
const updatedCustomFields = customFields.map((field, fieldId) => {
|
231
281
|
if (field.type === 'image') field.answer = this.getImageUrls(fieldId);
|
282
|
+
if (field.type === 'document') field.answer = this.getDocumentAnswers(fieldId);
|
232
283
|
return field;
|
233
284
|
});
|
234
285
|
maintenanceActions.sendMaintenanceRequest(this.props.uid, this.state.userName, this.state.phone, this.state.roomNumber, this.state.title, description, null, this.state.type, images, Helper.getSite(this.props.site), this.state.isHome, this.state.times, updatedCustomFields).then(res => {
|
@@ -343,6 +394,39 @@ class MaintenanceRequest extends Component {
|
|
343
394
|
imagesUpdate.splice(index, 1);
|
344
395
|
this.setImages(imagesUpdate, fieldId);
|
345
396
|
});
|
397
|
+
_defineProperty(this, "getDocuments", fieldId => {
|
398
|
+
const {
|
399
|
+
customFieldDocuments
|
400
|
+
} = this.state;
|
401
|
+
const documentsList = _.cloneDeep(customFieldDocuments[fieldId]) || [];
|
402
|
+
return documentsList;
|
403
|
+
});
|
404
|
+
_defineProperty(this, "setDocuments", (documentsList, fieldId) => {
|
405
|
+
let update = {};
|
406
|
+
const customFieldDocuments = _.cloneDeep(this.state.customFieldDocuments);
|
407
|
+
customFieldDocuments[fieldId] = documentsList;
|
408
|
+
update = {
|
409
|
+
customFieldDocuments
|
410
|
+
};
|
411
|
+
this.setState(update);
|
412
|
+
});
|
413
|
+
_defineProperty(this, "getDocumentAnswers", fieldId => {
|
414
|
+
const documentsList = this.getDocuments(fieldId);
|
415
|
+
return _.filter(documentsList, doc => {
|
416
|
+
return !doc.uploading && doc.url;
|
417
|
+
}).map(doc => {
|
418
|
+
return {
|
419
|
+
name: doc.documentName,
|
420
|
+
ext: doc.documentExt,
|
421
|
+
url: doc.url
|
422
|
+
};
|
423
|
+
});
|
424
|
+
});
|
425
|
+
_defineProperty(this, "removeDocument", (index, fieldId) => {
|
426
|
+
const documentsUpdate = this.getDocuments(fieldId);
|
427
|
+
documentsUpdate.splice(index, 1);
|
428
|
+
this.setDocuments(documentsUpdate, fieldId);
|
429
|
+
});
|
346
430
|
_defineProperty(this, "toggleFullscreenVideo", url => {
|
347
431
|
if (typeof url !== 'string') url = '';
|
348
432
|
this.setState({
|
@@ -375,6 +459,7 @@ class MaintenanceRequest extends Component {
|
|
375
459
|
confirmationToShow: false,
|
376
460
|
customFields: [],
|
377
461
|
customFieldImages: {},
|
462
|
+
customFieldDocuments: {},
|
378
463
|
isDateTimePickerVisible: false,
|
379
464
|
popUpType: 'date',
|
380
465
|
dateFieldId: null,
|
@@ -433,6 +518,7 @@ class MaintenanceRequest extends Component {
|
|
433
518
|
fail: false,
|
434
519
|
customFields: [],
|
435
520
|
customFieldImages: {},
|
521
|
+
customFieldDocuments: {},
|
436
522
|
isDateTimePickerVisible: false,
|
437
523
|
popUpType: 'date',
|
438
524
|
dateFieldId: null,
|
@@ -444,7 +530,6 @@ class MaintenanceRequest extends Component {
|
|
444
530
|
this.setState({
|
445
531
|
types: res.data
|
446
532
|
});
|
447
|
-
console.log(res.data);
|
448
533
|
this.getDefaultJob();
|
449
534
|
}).catch(() => {});
|
450
535
|
}
|
@@ -454,7 +539,6 @@ class MaintenanceRequest extends Component {
|
|
454
539
|
} = this.state;
|
455
540
|
const selected = types.find(t => t.typeName === type) || {};
|
456
541
|
if (values.forceCustomFields && !selected.hasCustomFields) {
|
457
|
-
console.log(selected);
|
458
542
|
this.setState({
|
459
543
|
type,
|
460
544
|
customFields: [],
|
@@ -540,14 +624,14 @@ class MaintenanceRequest extends Component {
|
|
540
624
|
}
|
541
625
|
this.submit();
|
542
626
|
}
|
543
|
-
|
627
|
+
renderImageUploader() {
|
544
628
|
return /*#__PURE__*/React.createElement(Components.ImageUploader, {
|
545
629
|
ref: ref => this.imageUploader = ref,
|
546
|
-
onUploadStarted: this.
|
547
|
-
onUploadSuccess: this.
|
548
|
-
onUploadFailed: this.
|
549
|
-
onUploadProgress: this.
|
550
|
-
onLibrarySelected: this.
|
630
|
+
onUploadStarted: this.onUploadStartedImage,
|
631
|
+
onUploadSuccess: this.onUploadSuccessImage,
|
632
|
+
onUploadFailed: this.onUploadFailedImage,
|
633
|
+
onUploadProgress: this.onUploadProgressImage,
|
634
|
+
onLibrarySelected: this.onLibrarySelectedImage,
|
551
635
|
size: {
|
552
636
|
width: 1400
|
553
637
|
},
|
@@ -612,6 +696,34 @@ class MaintenanceRequest extends Component {
|
|
612
696
|
style: styles.removeImage
|
613
697
|
}))));
|
614
698
|
}
|
699
|
+
renderDocument(item, index, fieldId) {
|
700
|
+
const {
|
701
|
+
colourBrandingMain
|
702
|
+
} = this.props;
|
703
|
+
return /*#__PURE__*/React.createElement(View, {
|
704
|
+
key: index,
|
705
|
+
style: styles.documentContainer
|
706
|
+
}, /*#__PURE__*/React.createElement(View, {
|
707
|
+
style: {
|
708
|
+
...styles.documentTypeContainer,
|
709
|
+
backgroundColor: colourBrandingMain
|
710
|
+
}
|
711
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
712
|
+
style: styles.documentTypeText
|
713
|
+
}, item.documentExt)), /*#__PURE__*/React.createElement(Text, {
|
714
|
+
style: styles.documentText
|
715
|
+
}, `${item.documentName}${item.uploading ? ` - ${item.uploadProgress}` : ''}`), !item.uploading && /*#__PURE__*/React.createElement(TouchableOpacity, {
|
716
|
+
style: styles.removeDocumentButton,
|
717
|
+
onPress: () => this.removeDocument(index, fieldId)
|
718
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
719
|
+
name: "remove",
|
720
|
+
type: "font-awesome",
|
721
|
+
iconStyle: {
|
722
|
+
...styles.removeDocumentIcon,
|
723
|
+
color: colourBrandingMain
|
724
|
+
}
|
725
|
+
})));
|
726
|
+
}
|
615
727
|
renderSuccess() {
|
616
728
|
return /*#__PURE__*/React.createElement(View, {
|
617
729
|
style: {
|
@@ -626,8 +738,6 @@ class MaintenanceRequest extends Component {
|
|
626
738
|
renderImageList(fieldId = null) {
|
627
739
|
const imagesList = this.getImages(fieldId);
|
628
740
|
return /*#__PURE__*/React.createElement(View, {
|
629
|
-
style: styles.imageSection
|
630
|
-
}, /*#__PURE__*/React.createElement(View, {
|
631
741
|
style: [styles.imageListContainer, imagesList.length < 2 && styles.imageListContainerEmpty]
|
632
742
|
}, /*#__PURE__*/React.createElement(FlatList, {
|
633
743
|
keyboardShouldPersistTaps: "always",
|
@@ -639,7 +749,24 @@ class MaintenanceRequest extends Component {
|
|
639
749
|
}) => this.renderImage(item, index, fieldId),
|
640
750
|
keyExtractor: (item, index) => index,
|
641
751
|
numColumns: 3
|
642
|
-
}))
|
752
|
+
}));
|
753
|
+
}
|
754
|
+
renderDocumentList(fieldId) {
|
755
|
+
const documentsList = this.getDocuments(fieldId);
|
756
|
+
return /*#__PURE__*/React.createElement(View, {
|
757
|
+
style: styles.documentListContainer
|
758
|
+
}, documentsList.length > 0 ? documentsList.map((document, index) => this.renderDocument(document, index, fieldId)) : null, /*#__PURE__*/React.createElement(Components.DocumentUploader, {
|
759
|
+
buttonTitle: "Add Files",
|
760
|
+
allowedTypes: ['application/pdf'],
|
761
|
+
onUploadStarted: (uploadUri, uri, name, ext) => this.onUploadStartedDocument(uploadUri, uri, name, ext, fieldId),
|
762
|
+
onUploadProgress: progress => this.onUploadProgressDocument(progress, fieldId),
|
763
|
+
onUploadSuccess: (uri, uploadUri) => this.onUploadSuccessDocument(uri, uploadUri, fieldId),
|
764
|
+
onUploadFailed: uploadUri => this.onUploadFailedDocument(uploadUri, fieldId),
|
765
|
+
fileName: "serviceDocument",
|
766
|
+
userId: this.props.uid,
|
767
|
+
disabled: false,
|
768
|
+
multiple: true
|
769
|
+
}));
|
643
770
|
}
|
644
771
|
renderDateField(field, fieldId, sectionStyle) {
|
645
772
|
let displayText, placeHolder, icon, errorText;
|
@@ -793,6 +920,15 @@ class MaintenanceRequest extends Component {
|
|
793
920
|
required: field.mandatory,
|
794
921
|
showError: this.state.showError
|
795
922
|
}, this.renderImageList(fieldId));
|
923
|
+
case 'document':
|
924
|
+
return /*#__PURE__*/React.createElement(Components.GenericInputSection, {
|
925
|
+
key: fieldId,
|
926
|
+
label: field.label,
|
927
|
+
sectionStyle: sectionStyle,
|
928
|
+
isValid: () => this.isFieldValid(field, fieldId),
|
929
|
+
required: field.mandatory,
|
930
|
+
showError: this.state.showError
|
931
|
+
}, this.renderDocumentList(fieldId));
|
796
932
|
default:
|
797
933
|
return null;
|
798
934
|
}
|
@@ -1034,7 +1170,7 @@ class MaintenanceRequest extends Component {
|
|
1034
1170
|
return /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
|
1035
1171
|
behavior: Platform.OS === 'ios' && 'padding',
|
1036
1172
|
style: styles.viewContainer
|
1037
|
-
}, this.
|
1173
|
+
}, this.renderImageUploader(), /*#__PURE__*/React.createElement(View, {
|
1038
1174
|
style: styles.container
|
1039
1175
|
}, /*#__PURE__*/React.createElement(Components.Header, {
|
1040
1176
|
leftIcon: "angle-left",
|
@@ -1092,6 +1228,11 @@ const styles = {
|
|
1092
1228
|
alignItems: 'center',
|
1093
1229
|
flexDirection: 'column'
|
1094
1230
|
},
|
1231
|
+
documentListContainer: {
|
1232
|
+
marginTop: 8,
|
1233
|
+
flexDirection: 'column',
|
1234
|
+
alignItems: 'flex-start'
|
1235
|
+
},
|
1095
1236
|
imageContainer: {
|
1096
1237
|
width: PHOTO_SIZE,
|
1097
1238
|
height: PHOTO_SIZE,
|
@@ -1219,6 +1360,42 @@ const styles = {
|
|
1219
1360
|
removeIcon: {
|
1220
1361
|
fontSize: 26,
|
1221
1362
|
color: Colours.TEXT_BLUEGREY
|
1363
|
+
},
|
1364
|
+
documentContainer: {
|
1365
|
+
flexDirection: 'row',
|
1366
|
+
alignItems: 'center',
|
1367
|
+
justifyContent: 'space-between',
|
1368
|
+
paddingVertical: 4
|
1369
|
+
},
|
1370
|
+
documentTypeContainer: {
|
1371
|
+
width: 50,
|
1372
|
+
height: 60,
|
1373
|
+
justifyContent: 'center',
|
1374
|
+
alignItems: 'center',
|
1375
|
+
borderRadius: 5,
|
1376
|
+
marginRight: 8
|
1377
|
+
},
|
1378
|
+
documentTypeText: {
|
1379
|
+
color: '#fff',
|
1380
|
+
fontFamily: 'sf-semibold',
|
1381
|
+
textAlign: 'center'
|
1382
|
+
},
|
1383
|
+
documentText: {
|
1384
|
+
flex: 1,
|
1385
|
+
fontFamily: 'sf-semibold',
|
1386
|
+
fontSize: 16,
|
1387
|
+
color: '#65686D'
|
1388
|
+
},
|
1389
|
+
removeDocumentButton: {
|
1390
|
+
padding: 4,
|
1391
|
+
width: 40,
|
1392
|
+
height: 40,
|
1393
|
+
alignItems: 'center',
|
1394
|
+
justifyContent: 'center',
|
1395
|
+
marginLeft: 8
|
1396
|
+
},
|
1397
|
+
removeDocumentIcon: {
|
1398
|
+
fontSize: 24
|
1222
1399
|
}
|
1223
1400
|
};
|
1224
1401
|
const mapStateToProps = state => {
|