@plusscommunities/pluss-maintenance-app 7.0.0-beta.0 → 7.0.0-beta.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/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 +2 -0
- package/dist/module/apis/index.js.map +1 -1
- package/dist/module/apis/maintenanceActions.js +21 -6
- package/dist/module/apis/maintenanceActions.js.map +1 -1
- package/dist/module/components/FilterPopupMenu.js +34 -18
- package/dist/module/components/FilterPopupMenu.js.map +1 -1
- package/dist/module/components/MaintenanceList.js +47 -56
- package/dist/module/components/MaintenanceList.js.map +1 -1
- package/dist/module/components/MaintenanceListItem.js +39 -26
- package/dist/module/components/MaintenanceListItem.js.map +1 -1
- package/dist/module/components/MaintenanceWidgetItem.js +12 -12
- 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 -14
- package/dist/module/components/StatusSelectorPopup.js.map +1 -1
- package/dist/module/components/WidgetSmall.js +7 -3
- package/dist/module/components/WidgetSmall.js.map +1 -1
- package/dist/module/helper.js +39 -25
- package/dist/module/helper.js.map +1 -1
- package/dist/module/reducers/JobsReducer.js +31 -2
- package/dist/module/reducers/JobsReducer.js.map +1 -1
- package/dist/module/screens/RequestDetail.js +90 -18
- package/dist/module/screens/RequestDetail.js.map +1 -1
- package/dist/module/screens/RequestNotes.js +430 -21
- package/dist/module/screens/RequestNotes.js.map +1 -1
- package/dist/module/values.config.a.js +6 -1
- package/dist/module/values.config.a.js.map +1 -1
- package/dist/module/values.config.default.js +6 -1
- package/dist/module/values.config.default.js.map +1 -1
- package/dist/module/values.config.forms.js +6 -1
- package/dist/module/values.config.forms.js.map +1 -1
- package/dist/module/values.config.js +34 -29
- package/dist/module/values.config.js.map +1 -1
- package/package.json +2 -2
- package/src/actions/JobActions.js +53 -1
- package/src/actions/types.js +4 -0
- package/src/apis/index.js +4 -0
- package/src/apis/maintenanceActions.js +18 -6
- package/src/components/FilterPopupMenu.js +40 -21
- package/src/components/MaintenanceList.js +38 -47
- package/src/components/MaintenanceListItem.js +35 -21
- package/src/components/MaintenanceWidgetItem.js +16 -12
- package/src/components/PrioritySelectorPopup.js +79 -0
- package/src/components/StatusSelectorPopup.js +8 -14
- package/src/components/WidgetSmall.js +5 -3
- package/src/helper.js +50 -21
- package/src/reducers/JobsReducer.js +25 -1
- package/src/screens/RequestDetail.js +87 -24
- package/src/screens/RequestNotes.js +429 -30
- package/src/values.config.a.js +5 -0
- package/src/values.config.default.js +5 -0
- package/src/values.config.forms.js +5 -0
- package/src/values.config.js +34 -29
@@ -4,6 +4,8 @@ import { connect } from 'react-redux';
|
|
4
4
|
import _ from 'lodash';
|
5
5
|
import { maintenanceActions } from '../apis';
|
6
6
|
import { Colours, Helper } from '../core.config';
|
7
|
+
import { getJobStatusOptions, getIncompleteJobStatuses, jobPriorityOptions } from '../helper';
|
8
|
+
import { values } from '../values.config';
|
7
9
|
|
8
10
|
const SCREEN_HEIGHT = Dimensions.get('window').height;
|
9
11
|
|
@@ -14,31 +16,20 @@ class FilterPopupMenu extends Component {
|
|
14
16
|
this.state = {
|
15
17
|
types: props.types || [],
|
16
18
|
selectedStatus: props.status || '',
|
19
|
+
selectedPriority: props.priority || '',
|
17
20
|
selectedType: props.type || '',
|
18
21
|
selectedAssignee: props.assignee || '',
|
19
22
|
assignees: [],
|
20
23
|
};
|
21
|
-
this.
|
24
|
+
this.priorityOptions = [
|
22
25
|
{
|
23
26
|
label: 'All',
|
24
27
|
value: '',
|
25
28
|
},
|
26
|
-
{
|
27
|
-
label:
|
28
|
-
value:
|
29
|
-
}
|
30
|
-
{
|
31
|
-
label: 'Open',
|
32
|
-
value: 'Unassigned',
|
33
|
-
},
|
34
|
-
{
|
35
|
-
label: 'In Progress',
|
36
|
-
value: 'In Progress',
|
37
|
-
},
|
38
|
-
{
|
39
|
-
label: 'Completed',
|
40
|
-
value: 'Completed',
|
41
|
-
},
|
29
|
+
...jobPriorityOptions.map(p => ({
|
30
|
+
label: p.label,
|
31
|
+
value: p.label,
|
32
|
+
}))
|
42
33
|
];
|
43
34
|
}
|
44
35
|
|
@@ -53,6 +44,26 @@ class FilterPopupMenu extends Component {
|
|
53
44
|
}
|
54
45
|
}
|
55
46
|
|
47
|
+
getStatusOptions = () => {
|
48
|
+
const statusOptions = getJobStatusOptions(this.props);
|
49
|
+
const options = [
|
50
|
+
{
|
51
|
+
label: 'All',
|
52
|
+
value: '',
|
53
|
+
},
|
54
|
+
{
|
55
|
+
label: 'Incomplete',
|
56
|
+
value: `Unassigned|${getIncompleteJobStatuses(this.props).map(s => s.text).join('|')}`,
|
57
|
+
},
|
58
|
+
...statusOptions.map(s => ({
|
59
|
+
label: s.text,
|
60
|
+
value: s.text,
|
61
|
+
})),
|
62
|
+
];
|
63
|
+
// console.log('getStatusOptions', options);
|
64
|
+
return options;
|
65
|
+
}
|
66
|
+
|
56
67
|
getAssignees = async () => {
|
57
68
|
try {
|
58
69
|
const res = await maintenanceActions.getAssignees(this.props.site);
|
@@ -93,11 +104,12 @@ class FilterPopupMenu extends Component {
|
|
93
104
|
|
94
105
|
onDone = () => {
|
95
106
|
const { onClose } = this.props;
|
96
|
-
const { selectedStatus, selectedType, selectedAssignee } = this.state;
|
107
|
+
const { selectedStatus, selectedPriority, selectedType, selectedAssignee } = this.state;
|
97
108
|
if (onClose)
|
98
109
|
onClose({
|
99
110
|
status: selectedStatus,
|
100
|
-
statusText: this.
|
111
|
+
statusText: this.getStatusOptions().find(o => o.value === selectedStatus)?.label,
|
112
|
+
priority: selectedPriority,
|
101
113
|
type: selectedType,
|
102
114
|
assignee: selectedAssignee,
|
103
115
|
assigneeName: this.state.assignees.find(a => a.value === selectedAssignee)?.label,
|
@@ -148,15 +160,20 @@ class FilterPopupMenu extends Component {
|
|
148
160
|
}
|
149
161
|
|
150
162
|
render() {
|
163
|
+
// console.log('FilterPopupMenu', JSON.stringify({ category: this.props.user.category, permissions: this.props.user.permissions }, null, 2))
|
164
|
+
const isStaff = this.props.user.category === 'staff'
|
165
|
+
const canFilterAssignee = !_.includes(this.props.user.permissions, values.permissionMaintenanceAssignment);
|
166
|
+
|
151
167
|
return (
|
152
168
|
<Modal visible transparent animationType="slide" onRequestClose={this.onDone}>
|
153
169
|
<View style={styles.container}>
|
154
170
|
<View style={styles.menu}>
|
155
171
|
{this.renderTitle()}
|
156
172
|
<ScrollView style={styles.optionContent}>
|
157
|
-
{this.renderOptions('Status', this.
|
173
|
+
{this.renderOptions('Status', this.getStatusOptions(), 'selectedStatus')}
|
174
|
+
{isStaff ? this.renderOptions('Priority', this.priorityOptions, 'selectedPriority') : null}
|
158
175
|
{this.renderOptions('Type', this.state.types, 'selectedType')}
|
159
|
-
{this.renderOptions('Assigned To', this.state.assignees, 'selectedAssignee')}
|
176
|
+
{canFilterAssignee ? this.renderOptions('Assigned To', this.state.assignees, 'selectedAssignee') : null}
|
160
177
|
</ScrollView>
|
161
178
|
{this.renderCancel()}
|
162
179
|
</View>
|
@@ -248,8 +265,10 @@ const mapStateToProps = state => {
|
|
248
265
|
const { user } = state;
|
249
266
|
|
250
267
|
return {
|
268
|
+
user,
|
251
269
|
site: user.site,
|
252
270
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
271
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
253
272
|
};
|
254
273
|
};
|
255
274
|
|
@@ -3,53 +3,45 @@ import { View, StyleSheet, FlatList, TouchableOpacity, Text } from 'react-native
|
|
3
3
|
import _ from 'lodash';
|
4
4
|
import { connect } from 'react-redux';
|
5
5
|
import { maintenanceActions } from '../apis';
|
6
|
-
import { jobsLoaded, jobAdded, jobsAdded } from '../actions';
|
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
|
-
this.initialStatusText = props.hasPermission ? 'Incomplete' : '';
|
18
|
-
|
19
16
|
this.state = {
|
20
17
|
types: [],
|
21
18
|
filteredList: props.jobs,
|
22
19
|
loading: false,
|
23
20
|
searchText: '',
|
24
21
|
showFilterPopup: false,
|
25
|
-
selectedStatus: this.initialStatus,
|
26
|
-
selectedStatusText: this.initialStatusText,
|
27
|
-
selectedType: '',
|
28
|
-
selectedAssignee: '',
|
29
|
-
selectedAssigneeName: '',
|
30
22
|
};
|
31
23
|
}
|
32
24
|
|
33
25
|
componentDidMount() {
|
26
|
+
this.props.jobStatusesUpdate(this.props.site);
|
27
|
+
this.props.jobHideSeenUpdate(this.props.site);
|
34
28
|
this.refresh();
|
35
29
|
this.refreshTypes();
|
36
|
-
|
37
30
|
this.resetDataSource();
|
38
31
|
}
|
39
32
|
|
40
33
|
componentDidUpdate(prevProps) {
|
41
34
|
if (!prevProps.dataUpdated && this.props.dataUpdated) this.refresh();
|
42
|
-
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();
|
43
36
|
}
|
44
37
|
|
45
38
|
refresh = () => {
|
46
39
|
this.onLoadingChanged(true, async () => {
|
47
40
|
try {
|
48
|
-
const {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
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)) {
|
53
45
|
this.props.jobsAdded(res);
|
54
46
|
} else {
|
55
47
|
this.props.jobsLoaded(res);
|
@@ -96,7 +88,8 @@ class MaintenanceList extends Component {
|
|
96
88
|
}
|
97
89
|
|
98
90
|
resetDataSource = (source = '') => {
|
99
|
-
const {
|
91
|
+
const { jobfilters } = this.props;
|
92
|
+
const { searchText } = this.state;
|
100
93
|
const { jobs } = this.props;
|
101
94
|
|
102
95
|
let filteredList = jobs;
|
@@ -111,9 +104,10 @@ class MaintenanceList extends Component {
|
|
111
104
|
});
|
112
105
|
if (!jobIdMatch) this.fetchJob(searchText);
|
113
106
|
}
|
114
|
-
if (
|
115
|
-
if (
|
116
|
-
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));
|
117
111
|
if (jobIdMatch) {
|
118
112
|
const jobIndex = filteredList.indexOf(jobIdMatch);
|
119
113
|
if (jobIndex > -1) {
|
@@ -148,33 +142,24 @@ class MaintenanceList extends Component {
|
|
148
142
|
};
|
149
143
|
|
150
144
|
onSelectFilter = selected => {
|
151
|
-
this.
|
152
|
-
|
153
|
-
selectedStatus: selected.status,
|
154
|
-
selectedStatusText: selected.statusText,
|
155
|
-
selectedType: selected.type,
|
156
|
-
selectedAssignee: selected.assignee,
|
157
|
-
selectedAssigneeName: selected.assigneeName,
|
158
|
-
},
|
159
|
-
() => {
|
160
|
-
this.resetDataSource();
|
161
|
-
this.onToggleFilter();
|
162
|
-
},
|
163
|
-
);
|
145
|
+
this.props.jobsFilterLoaded(selected);
|
146
|
+
this.onToggleFilter();
|
164
147
|
};
|
165
148
|
|
166
149
|
getFilterButtonText = () => {
|
167
|
-
const {
|
150
|
+
const { jobfilters } = this.props;
|
168
151
|
const filterTexts = [];
|
169
|
-
if (!_.isEmpty(
|
170
|
-
filterTexts.push(
|
152
|
+
if (!_.isEmpty(jobfilters.status)) {
|
153
|
+
filterTexts.push(jobfilters.statusText);
|
171
154
|
}
|
172
|
-
|
173
|
-
|
174
|
-
|
155
|
+
if (!_.isEmpty(jobfilters.priority)) {
|
156
|
+
filterTexts.push(jobfilters.priority);
|
157
|
+
}
|
158
|
+
if (!_.isEmpty(jobfilters.type)) {
|
159
|
+
filterTexts.push(jobfilters.type);
|
175
160
|
}
|
176
|
-
if (!_.isEmpty(
|
177
|
-
filterTexts.push(
|
161
|
+
if (!_.isEmpty(jobfilters.assignee)) {
|
162
|
+
filterTexts.push(jobfilters.assigneeName);
|
178
163
|
}
|
179
164
|
if (_.isEmpty(filterTexts)) {
|
180
165
|
return 'Filter';
|
@@ -244,16 +229,18 @@ class MaintenanceList extends Component {
|
|
244
229
|
}
|
245
230
|
|
246
231
|
renderFilterPopup() {
|
247
|
-
const {
|
232
|
+
const { jobfilters } = this.props;
|
233
|
+
const { showFilterPopup, types } = this.state;
|
248
234
|
if (!showFilterPopup) return null;
|
249
235
|
|
250
236
|
return (
|
251
237
|
<FilterPopupMenu
|
252
238
|
site={this.props.site}
|
253
239
|
types={types}
|
254
|
-
status={
|
255
|
-
|
256
|
-
|
240
|
+
status={jobfilters.status}
|
241
|
+
priority={jobfilters.priority}
|
242
|
+
assignee={jobfilters.assignee}
|
243
|
+
type={jobfilters.type}
|
257
244
|
onClose={this.onSelectFilter}
|
258
245
|
/>
|
259
246
|
);
|
@@ -329,7 +316,11 @@ const mapStateToProps = state => {
|
|
329
316
|
userCategory: user.category,
|
330
317
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
331
318
|
dataUpdated: notifications.dataUpdated[values.updateKey],
|
319
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
320
|
+
jobfilters: state[values.reducerKey].jobfilters,
|
332
321
|
};
|
333
322
|
};
|
334
323
|
|
335
|
-
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
|
+
);
|
@@ -4,19 +4,7 @@ import _ from 'lodash';
|
|
4
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 (
|
@@ -65,7 +53,9 @@ class MaintenanceListItem extends Component {
|
|
65
53
|
const createdTime = moment(job.createdUnix);
|
66
54
|
const createdTimeText = `${createdTime.format('ddd, D MMMM')} • ${createdTime.format('h:mma')}`;
|
67
55
|
const assigneeText = job.Assignee ? `Assigned to\n${job.Assignee.displayName}` : '';
|
68
|
-
const
|
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}>
|
@@ -98,16 +88,21 @@ class MaintenanceListItem extends Component {
|
|
98
88
|
{/* {this.renderDescription()} */}
|
99
89
|
<Text style={styles.jobCreatedText}>{createdTimeText}</Text>
|
100
90
|
<View style={styles.jobActivityContainer}>
|
101
|
-
<View style={[styles.jobStatusContainer, { backgroundColor:
|
91
|
+
<View style={[styles.jobStatusContainer, { backgroundColor: status?.color }]}>
|
102
92
|
{/* <Icon name="wrench" type="font-awesome" iconStyle={styles.jobStatusIcon} /> */}
|
103
|
-
<Text style={styles.jobStatusText}>{
|
93
|
+
<Text style={styles.jobStatusText}>{status?.text}</Text>
|
104
94
|
</View>
|
105
|
-
<View style={[styles.jobStatusLine, { borderColor:
|
95
|
+
<View style={[styles.jobStatusLine, { borderColor: status?.color }]}>
|
106
96
|
<View style={styles.jobStatusLineMask} />
|
107
97
|
</View>
|
108
|
-
<View style={[styles.jobStatusCircle, { backgroundColor:
|
98
|
+
<View style={[styles.jobStatusCircle, { backgroundColor: status?.color }]} />
|
109
99
|
<Text style={styles.jobStatusDateText}>{assigneeText}</Text>
|
110
100
|
</View>
|
101
|
+
{isStaff && (
|
102
|
+
<View style={[styles.jobPriorityContainer, { backgroundColor: priority.color }]}>
|
103
|
+
<Text style={styles.jobPriorityText}>{priority.label}</Text>
|
104
|
+
</View>
|
105
|
+
)}
|
111
106
|
</View>
|
112
107
|
</View>
|
113
108
|
</View>
|
@@ -278,11 +273,30 @@ const styles = StyleSheet.create({
|
|
278
273
|
fontSize: 14,
|
279
274
|
color: Colours.TEXT_DARK,
|
280
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
|
+
},
|
281
292
|
});
|
282
293
|
|
283
294
|
const mapStateToProps = state => {
|
284
295
|
return {
|
296
|
+
user: state.user,
|
285
297
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
298
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
299
|
+
hideSeen: state[values.reducerKey].hideSeen,
|
286
300
|
};
|
287
301
|
};
|
288
302
|
|
@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
|
|
4
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:
|
48
|
+
<View style={[styles.jobStatusContainer, { backgroundColor: status?.color }]}>
|
47
49
|
{/* <Icon name="wrench" type="font-awesome" iconStyle={styles.jobStatusIcon} /> */}
|
48
|
-
<Text style={styles.jobStatusText}>{
|
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,25 +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
|
-
label: getJobStatusLabel(status),
|
15
|
-
color: getJobStatusColour(status),
|
16
|
-
};
|
17
|
-
})
|
18
|
-
: jobStatusOptions;
|
10
|
+
const { title, includeAll, allText, onClose, onSelect } = this.props;
|
11
|
+
let statuses = getJobStatusOptions(this.props);
|
19
12
|
if (includeAll)
|
20
13
|
statuses = [
|
21
14
|
{
|
22
|
-
|
15
|
+
text: allText || 'Show All',
|
23
16
|
color: this.props.colourBrandingMain,
|
24
17
|
},
|
25
18
|
...statuses,
|
@@ -31,9 +24,9 @@ class StatusSelectorPopup extends PureComponent {
|
|
31
24
|
<View style={styles.statusPopupOptionsContainer}>
|
32
25
|
{statuses.map(status => {
|
33
26
|
return (
|
34
|
-
<TouchableOpacity key={status.
|
27
|
+
<TouchableOpacity key={status.text} onPress={() => onSelect(status.text)}>
|
35
28
|
<View style={[styles.jobStatusContainer, { backgroundColor: status.color }]}>
|
36
|
-
<Text style={styles.jobStatusText}>{status.
|
29
|
+
<Text style={styles.jobStatusText}>{status.text}</Text>
|
37
30
|
</View>
|
38
31
|
</TouchableOpacity>
|
39
32
|
);
|
@@ -81,6 +74,7 @@ const styles = StyleSheet.create({
|
|
81
74
|
const mapStateToProps = state => {
|
82
75
|
return {
|
83
76
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
77
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
84
78
|
};
|
85
79
|
};
|
86
80
|
|
@@ -3,10 +3,10 @@ import { Text, View, ScrollView, StyleSheet } from 'react-native';
|
|
3
3
|
import { connect } from 'react-redux';
|
4
4
|
import _ from 'lodash';
|
5
5
|
import { maintenanceActions } from '../apis';
|
6
|
-
import { jobsLoaded } from '../actions';
|
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
|
|
@@ -149,4 +151,4 @@ const mapStateToProps = state => {
|
|
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);
|