@plusscommunities/pluss-maintenance-app-a 6.0.11 → 6.0.13
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 +43 -20
- 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 +40 -25
- package/dist/module/helper.js.map +1 -1
- package/dist/module/reducers/JobsReducer.js +32 -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 +6 -1
- package/dist/module/values.config.js.map +1 -1
- package/package.json +1 -1
- 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 +55 -26
- 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 +52 -20
- package/src/reducers/JobsReducer.js +26 -1
- package/src/screens/RequestDetail.js +89 -26
- package/src/screens/RequestNotes.js +427 -28
- 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 +5 -0
|
@@ -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, getDefaultJobPriority } from '../helper';
|
|
8
|
+
import { values } from '../values.config';
|
|
7
9
|
|
|
8
10
|
const SCREEN_HEIGHT = Dimensions.get('window').height;
|
|
9
11
|
|
|
@@ -14,32 +16,11 @@ 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.statusOptions = [
|
|
22
|
-
{
|
|
23
|
-
label: 'All',
|
|
24
|
-
value: '',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
label: 'Incomplete',
|
|
28
|
-
value: 'Unassigned|In Progress',
|
|
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
|
-
},
|
|
42
|
-
];
|
|
43
24
|
}
|
|
44
25
|
|
|
45
26
|
componentDidMount() {
|
|
@@ -53,6 +34,45 @@ class FilterPopupMenu extends Component {
|
|
|
53
34
|
}
|
|
54
35
|
}
|
|
55
36
|
|
|
37
|
+
getStatusOptions = () => {
|
|
38
|
+
const statusOptions = getJobStatusOptions(this.props);
|
|
39
|
+
const options = [
|
|
40
|
+
{
|
|
41
|
+
label: 'All',
|
|
42
|
+
value: '',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: 'Incomplete',
|
|
46
|
+
value: `Unassigned|${getIncompleteJobStatuses(this.props)
|
|
47
|
+
.map(s => s.text)
|
|
48
|
+
.join('|')}`,
|
|
49
|
+
},
|
|
50
|
+
...statusOptions.map(s => ({
|
|
51
|
+
label: s.text,
|
|
52
|
+
value: s.text,
|
|
53
|
+
})),
|
|
54
|
+
];
|
|
55
|
+
// console.log('getStatusOptions', JSON.stringify(options, null, 2));
|
|
56
|
+
return options;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
getPriorityOptions = () => {
|
|
60
|
+
const priorityOptions = jobPriorityOptions;
|
|
61
|
+
const defaultPriority = getDefaultJobPriority();
|
|
62
|
+
const options = [
|
|
63
|
+
{
|
|
64
|
+
label: 'All',
|
|
65
|
+
value: '',
|
|
66
|
+
},
|
|
67
|
+
...priorityOptions.map(p => ({
|
|
68
|
+
label: p.label,
|
|
69
|
+
value: p.label === defaultPriority?.label ? `${p.label}|undefined` : p.label,
|
|
70
|
+
})),
|
|
71
|
+
];
|
|
72
|
+
// console.log('getPriorityOptions', JSON.stringify(options, null, 2));
|
|
73
|
+
return options;
|
|
74
|
+
};
|
|
75
|
+
|
|
56
76
|
getAssignees = async () => {
|
|
57
77
|
try {
|
|
58
78
|
const res = await maintenanceActions.getAssignees(this.props.site);
|
|
@@ -93,11 +113,13 @@ class FilterPopupMenu extends Component {
|
|
|
93
113
|
|
|
94
114
|
onDone = () => {
|
|
95
115
|
const { onClose } = this.props;
|
|
96
|
-
const { selectedStatus, selectedType, selectedAssignee } = this.state;
|
|
116
|
+
const { selectedStatus, selectedPriority, selectedType, selectedAssignee } = this.state;
|
|
97
117
|
if (onClose)
|
|
98
118
|
onClose({
|
|
99
119
|
status: selectedStatus,
|
|
100
|
-
statusText: this.
|
|
120
|
+
statusText: this.getStatusOptions().find(o => o.value === selectedStatus)?.label,
|
|
121
|
+
priority: selectedPriority,
|
|
122
|
+
priorityText: this.getPriorityOptions().find(o => o.value === selectedPriority)?.label,
|
|
101
123
|
type: selectedType,
|
|
102
124
|
assignee: selectedAssignee,
|
|
103
125
|
assigneeName: this.state.assignees.find(a => a.value === selectedAssignee)?.label,
|
|
@@ -148,15 +170,20 @@ class FilterPopupMenu extends Component {
|
|
|
148
170
|
}
|
|
149
171
|
|
|
150
172
|
render() {
|
|
173
|
+
// console.log('FilterPopupMenu', JSON.stringify({ category: this.props.user.category, permissions: this.props.user.permissions }, null, 2))
|
|
174
|
+
const isStaff = this.props.user.category === 'staff';
|
|
175
|
+
const canFilterAssignee = !_.includes(this.props.user.permissions, values.permissionMaintenanceAssignment);
|
|
176
|
+
|
|
151
177
|
return (
|
|
152
178
|
<Modal visible transparent animationType="slide" onRequestClose={this.onDone}>
|
|
153
179
|
<View style={styles.container}>
|
|
154
180
|
<View style={styles.menu}>
|
|
155
181
|
{this.renderTitle()}
|
|
156
182
|
<ScrollView style={styles.optionContent}>
|
|
157
|
-
{this.renderOptions('Status', this.
|
|
183
|
+
{this.renderOptions('Status', this.getStatusOptions(), 'selectedStatus')}
|
|
184
|
+
{isStaff ? this.renderOptions('Priority', this.getPriorityOptions(), 'selectedPriority') : null}
|
|
158
185
|
{this.renderOptions('Type', this.state.types, 'selectedType')}
|
|
159
|
-
{this.renderOptions('Assigned To', this.state.assignees, 'selectedAssignee')}
|
|
186
|
+
{canFilterAssignee ? this.renderOptions('Assigned To', this.state.assignees, 'selectedAssignee') : null}
|
|
160
187
|
</ScrollView>
|
|
161
188
|
{this.renderCancel()}
|
|
162
189
|
</View>
|
|
@@ -248,8 +275,10 @@ const mapStateToProps = state => {
|
|
|
248
275
|
const { user } = state;
|
|
249
276
|
|
|
250
277
|
return {
|
|
278
|
+
user,
|
|
251
279
|
site: user.site,
|
|
252
280
|
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
|
281
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
|
253
282
|
};
|
|
254
283
|
};
|
|
255
284
|
|
|
@@ -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.priorityText);
|
|
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, {
|
|
324
|
+
export default connect(mapStateToProps, { jobsLoaded, jobAdded, jobsAdded, jobStatusesUpdate, jobHideSeenUpdate, jobsFilterLoaded }, null, {
|
|
325
|
+
forwardRef: true,
|
|
326
|
+
})(MaintenanceList);
|
|
@@ -4,19 +4,7 @@ import _ from 'lodash';
|
|
|
4
4
|
import { Icon } from 'react-native-elements';
|
|
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 'react-native-elements';
|
|
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);
|