@plusscommunities/pluss-maintenance-app 6.1.1-beta.0 → 7.0.0-auth.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/module/actions/JobActions.js +44 -1
- package/dist/module/actions/JobActions.js.map +1 -1
- package/dist/module/actions/types.js +3 -0
- package/dist/module/actions/types.js.map +1 -1
- package/dist/module/apis/index.js +3 -1
- package/dist/module/apis/index.js.map +1 -1
- package/dist/module/apis/{generalActions.js → maintenanceActions.js} +44 -45
- package/dist/module/apis/maintenanceActions.js.map +1 -0
- package/dist/module/components/FilterPopupMenu.js +78 -26
- package/dist/module/components/FilterPopupMenu.js.map +1 -1
- package/dist/module/components/MaintenanceList.js +70 -45
- package/dist/module/components/MaintenanceList.js.map +1 -1
- package/dist/module/components/MaintenanceListItem.js +54 -42
- package/dist/module/components/MaintenanceListItem.js.map +1 -1
- package/dist/module/components/MaintenanceWidgetItem.js +16 -20
- package/dist/module/components/MaintenanceWidgetItem.js.map +1 -1
- package/dist/module/components/PrioritySelectorPopup.js +82 -0
- package/dist/module/components/PrioritySelectorPopup.js.map +1 -0
- package/dist/module/components/StatusSelectorPopup.js +9 -13
- package/dist/module/components/StatusSelectorPopup.js.map +1 -1
- package/dist/module/components/WidgetSmall.js +14 -10
- package/dist/module/components/WidgetSmall.js.map +1 -1
- package/dist/module/feature.config.js +3 -3
- package/dist/module/feature.config.js.map +1 -1
- package/dist/module/helper.js +39 -17
- package/dist/module/helper.js.map +1 -1
- package/dist/module/reducers/JobsReducer.js +33 -3
- package/dist/module/reducers/JobsReducer.js.map +1 -1
- package/dist/module/screens/JobTypePicker.js +3 -3
- package/dist/module/screens/JobTypePicker.js.map +1 -1
- package/dist/module/screens/MaintenancePage.js +2 -2
- package/dist/module/screens/RequestDetail.js +340 -88
- package/dist/module/screens/RequestDetail.js.map +1 -1
- package/dist/module/screens/RequestNotes.js +437 -26
- package/dist/module/screens/RequestNotes.js.map +1 -1
- package/dist/module/screens/ServiceRequest.js +596 -93
- package/dist/module/screens/ServiceRequest.js.map +1 -1
- package/dist/module/values.config.a.js +9 -1
- package/dist/module/values.config.a.js.map +1 -1
- package/dist/module/values.config.default.js +15 -1
- package/dist/module/values.config.default.js.map +1 -1
- package/dist/module/values.config.forms.js +42 -0
- package/dist/module/values.config.forms.js.map +1 -0
- package/dist/module/values.config.js +15 -1
- package/dist/module/values.config.js.map +1 -1
- package/package.json +16 -12
- package/src/actions/JobActions.js +53 -1
- package/src/actions/types.js +4 -0
- package/src/apis/index.js +5 -1
- package/src/apis/{generalActions.js → maintenanceActions.js} +51 -43
- package/src/components/FilterPopupMenu.js +75 -24
- package/src/components/MaintenanceList.js +64 -33
- package/src/components/MaintenanceListItem.js +53 -31
- package/src/components/MaintenanceWidgetItem.js +18 -14
- package/src/components/PrioritySelectorPopup.js +79 -0
- package/src/components/StatusSelectorPopup.js +8 -13
- package/src/components/WidgetSmall.js +10 -8
- package/src/feature.config.js +15 -13
- package/src/helper.js +51 -13
- package/src/reducers/JobsReducer.js +27 -2
- package/src/screens/JobTypePicker.js +1 -1
- package/src/screens/RequestDetail.js +324 -75
- package/src/screens/RequestNotes.js +434 -33
- package/src/screens/ServiceRequest.js +642 -157
- package/src/values.config.a.js +8 -0
- package/src/values.config.default.js +14 -0
- package/src/values.config.forms.js +42 -0
- package/src/values.config.js +14 -0
- package/dist/module/apis/generalActions.js.map +0 -1
- package/dist/module/values.config.b.js +0 -28
- package/dist/module/values.config.b.js.map +0 -1
- package/dist/module/values.config.c.js +0 -28
- package/dist/module/values.config.c.js.map +0 -1
- package/dist/module/values.config.d.js +0 -28
- package/dist/module/values.config.d.js.map +0 -1
- package/src/values.config.b.js +0 -28
- package/src/values.config.c.js +0 -28
- package/src/values.config.d.js +0 -28
@@ -2,50 +2,46 @@ import React, { Component } from 'react';
|
|
2
2
|
import { View, StyleSheet, FlatList, TouchableOpacity, Text } from 'react-native';
|
3
3
|
import _ from 'lodash';
|
4
4
|
import { connect } from 'react-redux';
|
5
|
-
import {
|
6
|
-
import { jobsLoaded, jobAdded, jobsAdded } from '../actions';
|
5
|
+
import { maintenanceActions } from '../apis';
|
6
|
+
import { jobsLoaded, jobAdded, jobsAdded, jobStatusesUpdate, jobHideSeenUpdate, jobsFilterLoaded } from '../actions';
|
7
7
|
import MaintenanceListItem from '../components/MaintenanceListItem';
|
8
8
|
import FilterPopupMenu from './FilterPopupMenu';
|
9
|
-
import { Components, Colours,
|
9
|
+
import { Components, Colours, Helper } from '../core.config';
|
10
10
|
import { values } from '../values.config';
|
11
11
|
|
12
12
|
class MaintenanceList extends Component {
|
13
13
|
constructor(props) {
|
14
14
|
super(props);
|
15
15
|
|
16
|
-
this.initialStatus = props.hasPermission ? 'Unassigned|In Progress' : '';
|
17
|
-
|
18
16
|
this.state = {
|
19
17
|
types: [],
|
20
18
|
filteredList: props.jobs,
|
21
19
|
loading: false,
|
22
20
|
searchText: '',
|
23
21
|
showFilterPopup: false,
|
24
|
-
selectedStatus: this.initialStatus,
|
25
|
-
selectedType: '',
|
26
22
|
};
|
27
23
|
}
|
28
24
|
|
29
25
|
componentDidMount() {
|
26
|
+
this.props.jobStatusesUpdate(this.props.site);
|
27
|
+
this.props.jobHideSeenUpdate(this.props.site);
|
30
28
|
this.refresh();
|
31
29
|
this.refreshTypes();
|
32
|
-
|
33
30
|
this.resetDataSource();
|
34
31
|
}
|
35
32
|
|
36
33
|
componentDidUpdate(prevProps) {
|
37
34
|
if (!prevProps.dataUpdated && this.props.dataUpdated) this.refresh();
|
38
|
-
if (!_.isEqual(prevProps.jobs, this.props.jobs)) this.resetDataSource();
|
35
|
+
if (!_.isEqual(prevProps.jobs, this.props.jobs) || !_.isEqual(prevProps.jobfilters, this.props.jobfilters)) this.resetDataSource();
|
39
36
|
}
|
40
37
|
|
41
38
|
refresh = () => {
|
42
39
|
this.onLoadingChanged(true, async () => {
|
43
40
|
try {
|
44
|
-
const {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
if (selectedStatus !== this.initialStatus || !_.isEmpty(selectedType)) {
|
41
|
+
const { jobfilters } = this.props;
|
42
|
+
const res = await maintenanceActions.getJobsRecursive(this.props.site, jobfilters.status, jobfilters.priority, jobfilters.type);
|
43
|
+
// console.log('refresh', res ? JSON.stringify(res[0], null, 2) : null);
|
44
|
+
if (!_.isEmpty(jobfilters.status) || !_.isEmpty(jobfilters.priority) || !_.isEmpty(jobfilters.type)) {
|
49
45
|
this.props.jobsAdded(res);
|
50
46
|
} else {
|
51
47
|
this.props.jobsLoaded(res);
|
@@ -59,7 +55,7 @@ class MaintenanceList extends Component {
|
|
59
55
|
};
|
60
56
|
|
61
57
|
refreshTypes = async () => {
|
62
|
-
const { data } = await
|
58
|
+
const { data } = await maintenanceActions.getJobTypes(Helper.getSite(this.props.site));
|
63
59
|
const types = data.map(t => {
|
64
60
|
return { label: t.typeName, value: t.typeName };
|
65
61
|
});
|
@@ -73,7 +69,7 @@ class MaintenanceList extends Component {
|
|
73
69
|
|
74
70
|
this.onLoadingChanged(true, async () => {
|
75
71
|
try {
|
76
|
-
const job = await
|
72
|
+
const job = await maintenanceActions.getJobByJobId(this.props.site, jobId);
|
77
73
|
// console.log('fetchJob', job?.data);
|
78
74
|
this.props.jobAdded(job.data);
|
79
75
|
} catch (error) {
|
@@ -88,11 +84,12 @@ class MaintenanceList extends Component {
|
|
88
84
|
if (this.props.options && !_.isEmpty(this.props.options.EmptyText)) {
|
89
85
|
return this.props.options.EmptyText;
|
90
86
|
}
|
91
|
-
return this.props.userCategory === 'staff' ?
|
87
|
+
return this.props.userCategory === 'staff' ? values.emptyRequestsStaff : values.emptyRequestsUser;
|
92
88
|
}
|
93
89
|
|
94
90
|
resetDataSource = (source = '') => {
|
95
|
-
const {
|
91
|
+
const { jobfilters } = this.props;
|
92
|
+
const { searchText } = this.state;
|
96
93
|
const { jobs } = this.props;
|
97
94
|
|
98
95
|
let filteredList = jobs;
|
@@ -107,8 +104,10 @@ class MaintenanceList extends Component {
|
|
107
104
|
});
|
108
105
|
if (!jobIdMatch) this.fetchJob(searchText);
|
109
106
|
}
|
110
|
-
if (
|
111
|
-
if (
|
107
|
+
if (jobfilters.status) filteredList = filteredList.filter(j => jobfilters.status.includes(j.status));
|
108
|
+
if (jobfilters.priority) filteredList = filteredList.filter(j => jobfilters.priority.includes(j.priority));
|
109
|
+
if (jobfilters.type) filteredList = filteredList.filter(j => jobfilters.type.includes(j.type));
|
110
|
+
if (jobfilters.assignee) filteredList = filteredList.filter(j => jobfilters.assignee.includes(j.AssigneeId));
|
112
111
|
if (jobIdMatch) {
|
113
112
|
const jobIndex = filteredList.indexOf(jobIdMatch);
|
114
113
|
if (jobIndex > -1) {
|
@@ -143,10 +142,29 @@ class MaintenanceList extends Component {
|
|
143
142
|
};
|
144
143
|
|
145
144
|
onSelectFilter = selected => {
|
146
|
-
this.
|
147
|
-
|
148
|
-
|
149
|
-
|
145
|
+
this.props.jobsFilterLoaded(selected);
|
146
|
+
this.onToggleFilter();
|
147
|
+
};
|
148
|
+
|
149
|
+
getFilterButtonText = () => {
|
150
|
+
const { jobfilters } = this.props;
|
151
|
+
const filterTexts = [];
|
152
|
+
if (!_.isEmpty(jobfilters.status)) {
|
153
|
+
filterTexts.push(jobfilters.statusText);
|
154
|
+
}
|
155
|
+
if (!_.isEmpty(jobfilters.priority)) {
|
156
|
+
filterTexts.push(jobfilters.priority);
|
157
|
+
}
|
158
|
+
if (!_.isEmpty(jobfilters.type)) {
|
159
|
+
filterTexts.push(jobfilters.type);
|
160
|
+
}
|
161
|
+
if (!_.isEmpty(jobfilters.assignee)) {
|
162
|
+
filterTexts.push(jobfilters.assigneeName);
|
163
|
+
}
|
164
|
+
if (_.isEmpty(filterTexts)) {
|
165
|
+
return 'Filter';
|
166
|
+
}
|
167
|
+
return `Filtering by ${filterTexts.join(', ')}`;
|
150
168
|
};
|
151
169
|
|
152
170
|
renderEmptyList() {
|
@@ -157,7 +175,7 @@ class MaintenanceList extends Component {
|
|
157
175
|
return (
|
158
176
|
<TouchableOpacity onPress={this.onToggleFilter}>
|
159
177
|
<View style={styles.filterButton}>
|
160
|
-
<Text style={[styles.filterButtonText, { color: this.props.colourBrandingMain }]}>
|
178
|
+
<Text style={[styles.filterButtonText, { color: this.props.colourBrandingMain }]}>{this.getFilterButtonText()}</Text>
|
161
179
|
</View>
|
162
180
|
</TouchableOpacity>
|
163
181
|
);
|
@@ -169,7 +187,7 @@ class MaintenanceList extends Component {
|
|
169
187
|
return (
|
170
188
|
<View style={styles.searchContainer}>
|
171
189
|
<Components.GenericInput
|
172
|
-
placeholder=
|
190
|
+
placeholder={`Search by ${values.textEntityName} ID or Address`}
|
173
191
|
value={this.state.searchText}
|
174
192
|
onChangeText={this.onSearchText}
|
175
193
|
onSubmitEditing={this.onSearchSubmit}
|
@@ -186,7 +204,7 @@ class MaintenanceList extends Component {
|
|
186
204
|
const { ListHeaderComponent } = this.props;
|
187
205
|
return (
|
188
206
|
<View>
|
189
|
-
{ListHeaderComponent ? ListHeaderComponent : <View style={{ height:
|
207
|
+
{ListHeaderComponent ? ListHeaderComponent : <View style={{ height: 8 }} />}
|
190
208
|
{this.renderFilterButton()}
|
191
209
|
{this.renderSearch()}
|
192
210
|
</View>
|
@@ -211,11 +229,20 @@ class MaintenanceList extends Component {
|
|
211
229
|
}
|
212
230
|
|
213
231
|
renderFilterPopup() {
|
214
|
-
const {
|
232
|
+
const { jobfilters } = this.props;
|
233
|
+
const { showFilterPopup, types } = this.state;
|
215
234
|
if (!showFilterPopup) return null;
|
216
235
|
|
217
236
|
return (
|
218
|
-
<FilterPopupMenu
|
237
|
+
<FilterPopupMenu
|
238
|
+
site={this.props.site}
|
239
|
+
types={types}
|
240
|
+
status={jobfilters.status}
|
241
|
+
priority={jobfilters.priority}
|
242
|
+
assignee={jobfilters.assignee}
|
243
|
+
type={jobfilters.type}
|
244
|
+
onClose={this.onSelectFilter}
|
245
|
+
/>
|
219
246
|
);
|
220
247
|
}
|
221
248
|
|
@@ -266,9 +293,9 @@ const styles = StyleSheet.create({
|
|
266
293
|
paddingHorizontal: 16,
|
267
294
|
},
|
268
295
|
filterButton: {
|
269
|
-
|
270
|
-
|
271
|
-
|
296
|
+
paddingBottom: 8,
|
297
|
+
paddingHorizontal: 16,
|
298
|
+
flexDirection: 'row-reverse',
|
272
299
|
},
|
273
300
|
filterButtonText: {
|
274
301
|
fontFamily: 'sf-semibold',
|
@@ -289,7 +316,11 @@ const mapStateToProps = state => {
|
|
289
316
|
userCategory: user.category,
|
290
317
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
291
318
|
dataUpdated: notifications.dataUpdated[values.updateKey],
|
319
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
320
|
+
jobfilters: state[values.reducerKey].jobfilters,
|
292
321
|
};
|
293
322
|
};
|
294
323
|
|
295
|
-
export default connect(mapStateToProps, { jobsLoaded, jobAdded, jobsAdded }, null, { forwardRef: true })(
|
324
|
+
export default connect(mapStateToProps, { jobsLoaded, jobAdded, jobsAdded, jobStatusesUpdate, jobHideSeenUpdate, jobsFilterLoaded }, null, { forwardRef: true })(
|
325
|
+
MaintenanceList,
|
326
|
+
);
|
@@ -1,22 +1,10 @@
|
|
1
1
|
import React, { Component } from 'react';
|
2
2
|
import { Image, Text, TouchableOpacity, View, StyleSheet } from 'react-native';
|
3
3
|
import _ from 'lodash';
|
4
|
-
import { Icon } from '
|
4
|
+
import { Icon } from '@rneui/themed';
|
5
5
|
import { connect } from 'react-redux';
|
6
6
|
import moment from 'moment';
|
7
|
-
|
8
|
-
// getShadowStyle,
|
9
|
-
// LINEGREY,
|
10
|
-
// TEXT_DARK,
|
11
|
-
// TEXT_LIGHT,
|
12
|
-
// COLOUR_GREEN,
|
13
|
-
// getMainBrandingColourFromState,
|
14
|
-
// hexToRGBAstring,
|
15
|
-
// getJobStatusProps,
|
16
|
-
// jobStatusOptions,
|
17
|
-
// } from '../../js';
|
18
|
-
// import NavigationService from '../../js/NavigationService';
|
19
|
-
import { getJobStatusProps, jobStatusOptions } from '../helper';
|
7
|
+
import { getJobStatus, getJobPriority } from '../helper';
|
20
8
|
import { Services } from '../feature.config';
|
21
9
|
import { Helper, Colours } from '../core.config';
|
22
10
|
import { values } from '../values.config';
|
@@ -47,9 +35,9 @@ class MaintenanceListItem extends Component {
|
|
47
35
|
}
|
48
36
|
|
49
37
|
renderSeen() {
|
50
|
-
const { job } = this.props;
|
51
|
-
const showSeen = !job.status || job.status ===
|
52
|
-
if (!showSeen || !job.seen) {
|
38
|
+
const { job, hideSeen } = this.props;
|
39
|
+
const showSeen = !job.status || job.status === getJobStatus(null, this.props).text;
|
40
|
+
if (hideSeen || !showSeen || !job.seen) {
|
53
41
|
return null;
|
54
42
|
}
|
55
43
|
return (
|
@@ -64,8 +52,10 @@ class MaintenanceListItem extends Component {
|
|
64
52
|
const { job } = this.props;
|
65
53
|
const createdTime = moment(job.createdUnix);
|
66
54
|
const createdTimeText = `${createdTime.format('ddd, D MMMM')} • ${createdTime.format('h:mma')}`;
|
67
|
-
const
|
68
|
-
const
|
55
|
+
const assigneeText = job.Assignee ? `Assigned to\n${job.Assignee.displayName}` : '';
|
56
|
+
const status = getJobStatus(job.status, this.props);
|
57
|
+
const priority = getJobPriority(job.priority);
|
58
|
+
const isStaff = this.props.user.category === 'staff'
|
69
59
|
|
70
60
|
return (
|
71
61
|
<TouchableOpacity onPress={this.onPressJob}>
|
@@ -73,12 +63,18 @@ class MaintenanceListItem extends Component {
|
|
73
63
|
<View style={styles.jobInnerContainer}>
|
74
64
|
<View style={styles.jobTopSection}>
|
75
65
|
<View style={styles.jobTopLeft}>
|
76
|
-
{job.jobId ?
|
66
|
+
{job.jobId ? (
|
67
|
+
<Text
|
68
|
+
style={[styles.jobIdText, { color: this.props.colourBrandingMain }]}
|
69
|
+
>{`${values.textEntityName} #${job.jobId}`}</Text>
|
70
|
+
) : null}
|
77
71
|
<Text style={styles.jobTitleText}>{job.title}</Text>
|
78
72
|
{job.room ? <Text style={styles.jobLocationText}>{job.room}</Text> : null}
|
79
73
|
<View style={styles.jobTypeSeenContainer}>
|
80
74
|
<View style={[styles.jobTypeContainer, { backgroundColor: Colours.hexToRGBAstring(this.props.colourBrandingMain, 0.2) }]}>
|
81
|
-
<Text style={[styles.jobTypeText, { color: this.props.colourBrandingMain }]}
|
75
|
+
<Text style={[styles.jobTypeText, { color: this.props.colourBrandingMain }]} numberOfLines={2}>
|
76
|
+
{job.type}
|
77
|
+
</Text>
|
82
78
|
</View>
|
83
79
|
{this.renderSeen()}
|
84
80
|
</View>
|
@@ -92,16 +88,21 @@ class MaintenanceListItem extends Component {
|
|
92
88
|
{/* {this.renderDescription()} */}
|
93
89
|
<Text style={styles.jobCreatedText}>{createdTimeText}</Text>
|
94
90
|
<View style={styles.jobActivityContainer}>
|
95
|
-
<View style={[styles.jobStatusContainer, { backgroundColor:
|
96
|
-
<Icon name="wrench" type="font-awesome" iconStyle={styles.jobStatusIcon} />
|
97
|
-
<Text style={styles.jobStatusText}>{
|
91
|
+
<View style={[styles.jobStatusContainer, { backgroundColor: status?.color }]}>
|
92
|
+
{/* <Icon name="wrench" type="font-awesome" iconStyle={styles.jobStatusIcon} /> */}
|
93
|
+
<Text style={styles.jobStatusText}>{status?.text}</Text>
|
98
94
|
</View>
|
99
|
-
<View style={[styles.jobStatusLine, { borderColor:
|
95
|
+
<View style={[styles.jobStatusLine, { borderColor: status?.color }]}>
|
100
96
|
<View style={styles.jobStatusLineMask} />
|
101
97
|
</View>
|
102
|
-
<View style={[styles.jobStatusCircle, { backgroundColor:
|
103
|
-
<Text style={styles.jobStatusDateText}>{
|
98
|
+
<View style={[styles.jobStatusCircle, { backgroundColor: status?.color }]} />
|
99
|
+
<Text style={styles.jobStatusDateText}>{assigneeText}</Text>
|
104
100
|
</View>
|
101
|
+
{isStaff && (
|
102
|
+
<View style={[styles.jobPriorityContainer, { backgroundColor: priority.color }]}>
|
103
|
+
<Text style={styles.jobPriorityText}>{priority.label}</Text>
|
104
|
+
</View>
|
105
|
+
)}
|
105
106
|
</View>
|
106
107
|
</View>
|
107
108
|
</View>
|
@@ -152,8 +153,9 @@ const styles = StyleSheet.create({
|
|
152
153
|
alignItems: 'center',
|
153
154
|
},
|
154
155
|
jobTypeContainer: {
|
155
|
-
|
156
|
-
|
156
|
+
padding: 4,
|
157
|
+
minWidth: 80,
|
158
|
+
maxWidth: 140,
|
157
159
|
borderRadius: 4,
|
158
160
|
justifyContent: 'center',
|
159
161
|
},
|
@@ -161,6 +163,7 @@ const styles = StyleSheet.create({
|
|
161
163
|
fontFamily: 'sf-semibold',
|
162
164
|
fontSize: 12,
|
163
165
|
textAlign: 'center',
|
166
|
+
maxWidth: '100%',
|
164
167
|
},
|
165
168
|
jobSeenContainer: {
|
166
169
|
flexDirection: 'row',
|
@@ -228,7 +231,7 @@ const styles = StyleSheet.create({
|
|
228
231
|
jobStatusContainer: {
|
229
232
|
flexDirection: 'row',
|
230
233
|
alignItems: 'center',
|
231
|
-
justifyContent: '
|
234
|
+
justifyContent: 'center',
|
232
235
|
width: 105,
|
233
236
|
height: 30,
|
234
237
|
paddingHorizontal: 8,
|
@@ -266,15 +269,34 @@ const styles = StyleSheet.create({
|
|
266
269
|
jobStatusDateText: {
|
267
270
|
flex: 1,
|
268
271
|
textAlign: 'right',
|
269
|
-
fontFamily: 'sf-
|
272
|
+
fontFamily: 'sf-medium',
|
270
273
|
fontSize: 14,
|
271
274
|
color: Colours.TEXT_DARK,
|
272
275
|
},
|
276
|
+
jobPriorityContainer: {
|
277
|
+
flexDirection: 'row',
|
278
|
+
alignItems: 'center',
|
279
|
+
justifyContent: 'center',
|
280
|
+
width: 105,
|
281
|
+
height: 24,
|
282
|
+
paddingHorizontal: 8,
|
283
|
+
borderRadius: 4,
|
284
|
+
marginTop: 8,
|
285
|
+
},
|
286
|
+
jobPriorityText: {
|
287
|
+
color: '#fff',
|
288
|
+
textAlign: 'center',
|
289
|
+
fontFamily: 'sf-semibold',
|
290
|
+
fontSize: 13,
|
291
|
+
},
|
273
292
|
});
|
274
293
|
|
275
294
|
const mapStateToProps = state => {
|
276
295
|
return {
|
296
|
+
user: state.user,
|
277
297
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
298
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
299
|
+
hideSeen: state[values.reducerKey].hideSeen,
|
278
300
|
};
|
279
301
|
};
|
280
302
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React, { Component } from 'react';
|
2
2
|
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';
|
3
3
|
import { connect } from 'react-redux';
|
4
|
-
import { Icon } from '
|
4
|
+
import { Icon } from '@rneui/themed';
|
5
5
|
import moment from 'moment';
|
6
6
|
import _ from 'lodash';
|
7
|
-
import {
|
7
|
+
import { getJobStatus } from '../helper';
|
8
8
|
import { Services } from '../feature.config';
|
9
9
|
import { Colours, Helper } from '../core.config';
|
10
10
|
import { values } from '../values.config';
|
@@ -15,12 +15,12 @@ class MaintenanceWidgetItem extends Component {
|
|
15
15
|
};
|
16
16
|
|
17
17
|
render() {
|
18
|
-
const { job } = this.props;
|
18
|
+
const { job, hideSeen } = this.props;
|
19
19
|
const createdTime = moment(job.createdUnix);
|
20
20
|
const createdTimeText = `${createdTime.format('ddd, D MMMM')} • ${createdTime.format('h:mma')}`;
|
21
|
-
const
|
21
|
+
const status = getJobStatus(job.status, this.props);
|
22
22
|
const seenText = (() => {
|
23
|
-
if (!job.status || job.status ===
|
23
|
+
if (!job.status || job.status === getJobStatus(null, this.props).text) {
|
24
24
|
return job.seen ? 'Seen' : 'Unseen';
|
25
25
|
}
|
26
26
|
return '';
|
@@ -35,17 +35,19 @@ class MaintenanceWidgetItem extends Component {
|
|
35
35
|
{job.title}
|
36
36
|
</Text>
|
37
37
|
<Text style={styles.jobCreatedTimeText}>{createdTimeText}</Text>
|
38
|
-
|
39
|
-
{
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
{!hideSeen ? (
|
39
|
+
<View style={styles.jobSeenContainer}>
|
40
|
+
{job.seen && !_.isEmpty(seenText) && (
|
41
|
+
<Icon name="check" type="font-awesome" iconStyle={[styles.jobSeenIcon, { color: this.props.colourBrandingMain }]} />
|
42
|
+
)}
|
43
|
+
<Text style={[styles.jobSeenText, job.seen && { color: this.props.colourBrandingMain }]}>{seenText}</Text>
|
44
|
+
</View>
|
45
|
+
) : null}
|
44
46
|
</View>
|
45
47
|
<View style={styles.jobBottomSection}>
|
46
|
-
<View style={[styles.jobStatusContainer, { backgroundColor:
|
47
|
-
<Icon name="wrench" type="font-awesome" iconStyle={styles.jobStatusIcon} />
|
48
|
-
<Text style={styles.jobStatusText}>{
|
48
|
+
<View style={[styles.jobStatusContainer, { backgroundColor: status?.color }]}>
|
49
|
+
{/* <Icon name="wrench" type="font-awesome" iconStyle={styles.jobStatusIcon} /> */}
|
50
|
+
<Text style={styles.jobStatusText}>{status?.text}</Text>
|
49
51
|
</View>
|
50
52
|
</View>
|
51
53
|
</View>
|
@@ -126,6 +128,8 @@ const styles = StyleSheet.create({
|
|
126
128
|
const mapStateToProps = state => {
|
127
129
|
return {
|
128
130
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
131
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
132
|
+
hideSeen: state[values.reducerKey].hideSeen,
|
129
133
|
};
|
130
134
|
};
|
131
135
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import React, { PureComponent } from 'react';
|
2
|
+
import { View, StyleSheet, TouchableOpacity, Text } from 'react-native';
|
3
|
+
import { connect } from 'react-redux';
|
4
|
+
import { jobPriorityOptions } from '../helper';
|
5
|
+
import { Components, Colours } from '../core.config';
|
6
|
+
|
7
|
+
class PrioritySelectorPopup extends PureComponent {
|
8
|
+
render() {
|
9
|
+
const { title, includeAll, allText, onClose, onSelect } = this.props;
|
10
|
+
let priorities = jobPriorityOptions;
|
11
|
+
if (includeAll)
|
12
|
+
priorities = [
|
13
|
+
{
|
14
|
+
label: allText || 'Show All',
|
15
|
+
color: this.props.colourBrandingMain,
|
16
|
+
},
|
17
|
+
...priorities,
|
18
|
+
];
|
19
|
+
|
20
|
+
return (
|
21
|
+
<Components.MiddlePopup style={[styles.statusPopup, { height: priorities.length * 50 + 40 }]} onClose={onClose}>
|
22
|
+
<Text style={styles.statusPopupTitle}>{title || 'Select Priority'}</Text>
|
23
|
+
<View style={styles.statusPopupOptionsContainer}>
|
24
|
+
{priorities.map(priority => {
|
25
|
+
return (
|
26
|
+
<TouchableOpacity key={priority.label} onPress={() => onSelect(priority.label)}>
|
27
|
+
<View style={[styles.jobStatusContainer, { backgroundColor: priority.color }]}>
|
28
|
+
<Text style={styles.jobStatusText}>{priority.label}</Text>
|
29
|
+
</View>
|
30
|
+
</TouchableOpacity>
|
31
|
+
);
|
32
|
+
})}
|
33
|
+
</View>
|
34
|
+
</Components.MiddlePopup>
|
35
|
+
);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
const styles = StyleSheet.create({
|
40
|
+
statusPopup: {
|
41
|
+
width: 160,
|
42
|
+
padding: 16,
|
43
|
+
borderRadius: 12,
|
44
|
+
},
|
45
|
+
statusPopupTitle: {
|
46
|
+
fontFamily: 'sf-bold',
|
47
|
+
color: Colours.TEXT_DARK,
|
48
|
+
fontSize: 18,
|
49
|
+
marginBottom: 16,
|
50
|
+
},
|
51
|
+
statusPopupOptionsContainer: {
|
52
|
+
flex: 1,
|
53
|
+
justifyContent: 'space-between',
|
54
|
+
},
|
55
|
+
jobStatusContainer: {
|
56
|
+
flexDirection: 'row',
|
57
|
+
alignItems: 'center',
|
58
|
+
justifyContent: 'space-between',
|
59
|
+
width: 105,
|
60
|
+
height: 30,
|
61
|
+
paddingHorizontal: 8,
|
62
|
+
borderRadius: 4,
|
63
|
+
},
|
64
|
+
jobStatusText: {
|
65
|
+
color: '#fff',
|
66
|
+
textAlign: 'center',
|
67
|
+
fontFamily: 'sf-semibold',
|
68
|
+
fontSize: 13,
|
69
|
+
flex: 1,
|
70
|
+
},
|
71
|
+
});
|
72
|
+
|
73
|
+
const mapStateToProps = state => {
|
74
|
+
return {
|
75
|
+
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
76
|
+
};
|
77
|
+
};
|
78
|
+
|
79
|
+
export default connect(mapStateToProps, {})(PrioritySelectorPopup);
|
@@ -1,24 +1,18 @@
|
|
1
1
|
import React, { PureComponent } from 'react';
|
2
2
|
import { View, StyleSheet, TouchableOpacity, Text } from 'react-native';
|
3
3
|
import { connect } from 'react-redux';
|
4
|
-
import {
|
4
|
+
import { getJobStatusOptions } from '../helper';
|
5
5
|
import { Components, Colours } from '../core.config';
|
6
|
+
import { values } from '../values.config';
|
6
7
|
|
7
8
|
class StatusSelectorPopup extends PureComponent {
|
8
9
|
render() {
|
9
|
-
const { title,
|
10
|
-
let statuses =
|
11
|
-
? filter.map(status => {
|
12
|
-
return {
|
13
|
-
name: status,
|
14
|
-
color: getJobStatusColour(status),
|
15
|
-
};
|
16
|
-
})
|
17
|
-
: jobStatusOptions;
|
10
|
+
const { title, includeAll, allText, onClose, onSelect } = this.props;
|
11
|
+
let statuses = getJobStatusOptions(this.props);
|
18
12
|
if (includeAll)
|
19
13
|
statuses = [
|
20
14
|
{
|
21
|
-
|
15
|
+
text: allText || 'Show All',
|
22
16
|
color: this.props.colourBrandingMain,
|
23
17
|
},
|
24
18
|
...statuses,
|
@@ -30,9 +24,9 @@ class StatusSelectorPopup extends PureComponent {
|
|
30
24
|
<View style={styles.statusPopupOptionsContainer}>
|
31
25
|
{statuses.map(status => {
|
32
26
|
return (
|
33
|
-
<TouchableOpacity key={status.
|
27
|
+
<TouchableOpacity key={status.text} onPress={() => onSelect(status.text)}>
|
34
28
|
<View style={[styles.jobStatusContainer, { backgroundColor: status.color }]}>
|
35
|
-
<Text style={styles.jobStatusText}>{status.
|
29
|
+
<Text style={styles.jobStatusText}>{status.text}</Text>
|
36
30
|
</View>
|
37
31
|
</TouchableOpacity>
|
38
32
|
);
|
@@ -80,6 +74,7 @@ const styles = StyleSheet.create({
|
|
80
74
|
const mapStateToProps = state => {
|
81
75
|
return {
|
82
76
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
77
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
83
78
|
};
|
84
79
|
};
|
85
80
|
|
@@ -2,11 +2,11 @@ import React, { Component } from 'react';
|
|
2
2
|
import { Text, View, ScrollView, StyleSheet } from 'react-native';
|
3
3
|
import { connect } from 'react-redux';
|
4
4
|
import _ from 'lodash';
|
5
|
-
import {
|
6
|
-
import { jobsLoaded } from '../actions';
|
5
|
+
import { maintenanceActions } from '../apis';
|
6
|
+
import { jobsLoaded, jobStatusesUpdate, jobHideSeenUpdate } from '../actions';
|
7
7
|
import MaintenanceWidgetItem from './MaintenanceWidgetItem';
|
8
8
|
import { Services } from '../feature.config';
|
9
|
-
import { Colours, Components
|
9
|
+
import { Colours, Components } from '../core.config';
|
10
10
|
import { values } from '../values.config';
|
11
11
|
|
12
12
|
const MAX_ITEMS = 10;
|
@@ -18,6 +18,8 @@ class WidgetSmall extends Component {
|
|
18
18
|
}
|
19
19
|
|
20
20
|
componentDidMount() {
|
21
|
+
this.props.jobStatusesUpdate(this.props.site);
|
22
|
+
this.props.jobHideSeenUpdate(this.props.site);
|
21
23
|
this.refresh();
|
22
24
|
}
|
23
25
|
|
@@ -34,13 +36,13 @@ class WidgetSmall extends Component {
|
|
34
36
|
getEmptyStateText = () => {
|
35
37
|
const { options, userCategory } = this.props;
|
36
38
|
if (options && !_.isEmpty(options.EmptyText)) return options.EmptyText;
|
37
|
-
return userCategory === 'staff' ?
|
39
|
+
return userCategory === 'staff' ? values.emptyRequestsStaff : values.emptyRequestsUser;
|
38
40
|
};
|
39
41
|
|
40
42
|
refresh = () => {
|
41
43
|
this.onLoadingChanged(true, async () => {
|
42
44
|
try {
|
43
|
-
const res = await
|
45
|
+
const res = await maintenanceActions.getJobsRecursive(this.props.site);
|
44
46
|
// console.log('WidgetSmall - refresh', res.data);
|
45
47
|
this.props.jobsLoaded(res);
|
46
48
|
} catch (error) {
|
@@ -59,7 +61,7 @@ class WidgetSmall extends Component {
|
|
59
61
|
};
|
60
62
|
|
61
63
|
onPressAll = () => {
|
62
|
-
Services.navigation.navigate(
|
64
|
+
Services.navigation.navigate(values.screenMaintenance, { options: this.props.options });
|
63
65
|
};
|
64
66
|
|
65
67
|
renderContent() {
|
@@ -144,9 +146,9 @@ const mapStateToProps = state => {
|
|
144
146
|
jobs: _.orderBy(jobs.jobs, ['createdUnix'], ['desc']),
|
145
147
|
site: user.site,
|
146
148
|
userCategory: user.category,
|
147
|
-
dataUpdated: notifications.dataUpdated.
|
149
|
+
dataUpdated: notifications.dataUpdated[values.updateKey],
|
148
150
|
strings: state.strings?.config || {},
|
149
151
|
};
|
150
152
|
};
|
151
153
|
|
152
|
-
export default connect(mapStateToProps, { jobsLoaded }, null, { forwardRef: true })(WidgetSmall);
|
154
|
+
export default connect(mapStateToProps, { jobsLoaded, jobStatusesUpdate, jobHideSeenUpdate }, null, { forwardRef: true })(WidgetSmall);
|