@plusscommunities/pluss-maintenance-app 6.0.20 → 6.0.21-beta.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 +4 -4
- package/dist/module/actions/JobActions.js.map +1 -1
- package/dist/module/actions/index.js +1 -1
- package/dist/module/actions/index.js.map +1 -1
- package/dist/module/actions/types.js +1 -1
- package/dist/module/actions/types.js.map +1 -1
- package/dist/module/apis/index.js +3 -3
- package/dist/module/apis/index.js.map +1 -1
- package/dist/module/apis/maintenanceActions.js +36 -36
- package/dist/module/apis/maintenanceActions.js.map +1 -1
- package/dist/module/apis/userActions.js +5 -5
- package/dist/module/apis/userActions.js.map +1 -1
- package/dist/module/components/FilterPopupMenu.js +49 -49
- package/dist/module/components/FilterPopupMenu.js.map +1 -1
- package/dist/module/components/MaintenanceList.js +38 -38
- package/dist/module/components/MaintenanceList.js.map +1 -1
- package/dist/module/components/MaintenanceListItem.js +62 -62
- package/dist/module/components/MaintenanceListItem.js.map +1 -1
- package/dist/module/components/MaintenanceWidgetItem.js +27 -27
- package/dist/module/components/MaintenanceWidgetItem.js.map +1 -1
- package/dist/module/components/PrioritySelectorPopup.js +15 -15
- package/dist/module/components/PrioritySelectorPopup.js.map +1 -1
- package/dist/module/components/StatusSelectorPopup.js +16 -16
- package/dist/module/components/StatusSelectorPopup.js.map +1 -1
- package/dist/module/components/WidgetLarge.js +2 -2
- package/dist/module/components/WidgetLarge.js.map +1 -1
- package/dist/module/components/WidgetSmall.js +19 -19
- package/dist/module/components/WidgetSmall.js.map +1 -1
- package/dist/module/core.config.js +1 -1
- package/dist/module/core.config.js.map +1 -1
- package/dist/module/feature.config.js +17 -17
- package/dist/module/feature.config.js.map +1 -1
- package/dist/module/helper.js +10 -10
- package/dist/module/helper.js.map +1 -1
- package/dist/module/index.js +11 -11
- package/dist/module/index.js.map +1 -1
- package/dist/module/reducers/JobsReducer.js +13 -13
- package/dist/module/reducers/JobsReducer.js.map +1 -1
- package/dist/module/screens/JobTypePicker.js +17 -17
- package/dist/module/screens/JobTypePicker.js.map +1 -1
- package/dist/module/screens/MaintenancePage.js +10 -10
- package/dist/module/screens/MaintenancePage.js.map +1 -1
- package/dist/module/screens/MaintenanceUserPicker.js +129 -22
- package/dist/module/screens/MaintenanceUserPicker.js.map +1 -1
- package/dist/module/screens/RequestDetail.js +145 -145
- package/dist/module/screens/RequestDetail.js.map +1 -1
- package/dist/module/screens/RequestNotes.js +59 -59
- package/dist/module/screens/RequestNotes.js.map +1 -1
- package/dist/module/screens/ServiceRequest.js +187 -187
- package/dist/module/screens/ServiceRequest.js.map +1 -1
- package/dist/module/values.config.a.js +30 -30
- package/dist/module/values.config.a.js.map +1 -1
- package/dist/module/values.config.default.js +34 -34
- package/dist/module/values.config.default.js.map +1 -1
- package/dist/module/values.config.enquiry.js +34 -34
- package/dist/module/values.config.enquiry.js.map +1 -1
- package/dist/module/values.config.feedback.js +34 -34
- package/dist/module/values.config.feedback.js.map +1 -1
- package/dist/module/values.config.food.js +34 -34
- package/dist/module/values.config.food.js.map +1 -1
- package/dist/module/values.config.forms.js +34 -34
- package/dist/module/values.config.forms.js.map +1 -1
- package/dist/module/values.config.js +34 -34
- package/dist/module/values.config.js.map +1 -1
- package/package.json +51 -51
- package/src/actions/JobActions.js +67 -60
- package/src/actions/index.js +1 -1
- package/src/actions/types.js +1 -2
- package/src/apis/index.js +3 -3
- package/src/apis/maintenanceActions.js +189 -178
- package/src/apis/userActions.js +17 -17
- package/src/components/FilterPopupMenu.js +313 -256
- package/src/components/MaintenanceList.js +396 -317
- package/src/components/MaintenanceListItem.js +347 -288
- package/src/components/MaintenanceWidgetItem.js +145 -124
- package/src/components/PrioritySelectorPopup.js +81 -68
- package/src/components/StatusSelectorPopup.js +81 -70
- package/src/components/WidgetLarge.js +5 -5
- package/src/components/WidgetSmall.js +153 -133
- package/src/core.config.js +27 -3
- package/src/feature.config.js +62 -62
- package/src/helper.js +58 -53
- package/src/index.js +22 -22
- package/src/reducers/JobsReducer.js +85 -66
- package/src/screens/JobTypePicker.js +115 -92
- package/src/screens/MaintenancePage.js +89 -80
- package/src/screens/MaintenanceUserPicker.js +252 -100
- package/src/screens/RequestDetail.js +1348 -1125
- package/src/screens/RequestNotes.js +950 -806
- package/src/screens/ServiceRequest.js +1778 -1550
- package/src/values.config.a.js +33 -33
- package/src/values.config.default.js +39 -39
- package/src/values.config.enquiry.js +39 -39
- package/src/values.config.feedback.js +39 -39
- package/src/values.config.food.js +39 -39
- package/src/values.config.forms.js +39 -39
- package/src/values.config.js +39 -39
|
@@ -1,326 +1,405 @@
|
|
|
1
|
-
import React, { Component } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
FlatList,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
Text,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import _ from "lodash";
|
|
10
|
+
import { connect } from "react-redux";
|
|
11
|
+
import { maintenanceActions } from "../apis";
|
|
12
|
+
import {
|
|
13
|
+
jobsLoaded,
|
|
14
|
+
jobAdded,
|
|
15
|
+
jobsAdded,
|
|
16
|
+
jobStatusesUpdate,
|
|
17
|
+
jobHideSeenUpdate,
|
|
18
|
+
jobsFilterLoaded,
|
|
19
|
+
} from "../actions";
|
|
20
|
+
import MaintenanceListItem from "../components/MaintenanceListItem";
|
|
21
|
+
import FilterPopupMenu from "./FilterPopupMenu";
|
|
22
|
+
import { Components, Colours, Helper } from "../core.config";
|
|
23
|
+
import { values } from "../values.config";
|
|
11
24
|
|
|
12
25
|
class MaintenanceList extends Component {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
|
|
29
|
+
this.state = {
|
|
30
|
+
types: [],
|
|
31
|
+
filteredList: props.jobs,
|
|
32
|
+
loading: false,
|
|
33
|
+
searchText: "",
|
|
34
|
+
showFilterPopup: false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
componentDidMount() {
|
|
39
|
+
this.props.jobStatusesUpdate(this.props.site);
|
|
40
|
+
this.props.jobHideSeenUpdate(this.props.site);
|
|
41
|
+
this.refresh();
|
|
42
|
+
this.refreshTypes();
|
|
43
|
+
this.resetDataSource();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
componentDidUpdate(prevProps) {
|
|
47
|
+
if (!prevProps.dataUpdated && this.props.dataUpdated) this.refresh();
|
|
48
|
+
if (
|
|
49
|
+
!_.isEqual(prevProps.jobs, this.props.jobs) ||
|
|
50
|
+
!_.isEqual(prevProps.jobfilters, this.props.jobfilters)
|
|
51
|
+
)
|
|
52
|
+
this.resetDataSource();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
refresh = () => {
|
|
56
|
+
this.onLoadingChanged(true, async () => {
|
|
57
|
+
try {
|
|
58
|
+
const { jobfilters } = this.props;
|
|
59
|
+
const res = await maintenanceActions.getJobsRecursive(
|
|
60
|
+
this.props.site,
|
|
61
|
+
jobfilters.status,
|
|
62
|
+
jobfilters.priority,
|
|
63
|
+
jobfilters.type,
|
|
64
|
+
);
|
|
65
|
+
// console.log('refresh', res ? JSON.stringify(res[0], null, 2) : null);
|
|
66
|
+
if (
|
|
67
|
+
!_.isEmpty(jobfilters.status) ||
|
|
68
|
+
!_.isEmpty(jobfilters.priority) ||
|
|
69
|
+
!_.isEmpty(jobfilters.type)
|
|
70
|
+
) {
|
|
71
|
+
this.props.jobsAdded(res);
|
|
72
|
+
} else {
|
|
73
|
+
this.props.jobsLoaded(res);
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.log("refresh error", error);
|
|
77
|
+
} finally {
|
|
78
|
+
this.onLoadingChanged(false);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
refreshTypes = async () => {
|
|
84
|
+
const { data } = await maintenanceActions.getJobTypes(
|
|
85
|
+
Helper.getSite(this.props.site),
|
|
86
|
+
);
|
|
87
|
+
const types = data.map((t) => {
|
|
88
|
+
return { label: t.typeName, value: t.typeName };
|
|
89
|
+
});
|
|
90
|
+
types.splice(0, 0, { label: "All", value: "" });
|
|
91
|
+
// console.log('refreshTypes', types);
|
|
92
|
+
this.setState({ types });
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
fetchJob = (jobId) => {
|
|
96
|
+
if (this.state.loading) return;
|
|
97
|
+
|
|
98
|
+
this.onLoadingChanged(true, async () => {
|
|
99
|
+
try {
|
|
100
|
+
const job = await maintenanceActions.getJobByJobId(
|
|
101
|
+
this.props.site,
|
|
102
|
+
jobId,
|
|
103
|
+
);
|
|
104
|
+
// console.log('fetchJob', job?.data);
|
|
105
|
+
this.props.jobAdded(job.data);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.log("fetchJob error", error);
|
|
108
|
+
} finally {
|
|
109
|
+
this.onLoadingChanged(false);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
getEmptyStateText() {
|
|
115
|
+
if (this.props.options && !_.isEmpty(this.props.options.EmptyText)) {
|
|
116
|
+
return this.props.options.EmptyText;
|
|
117
|
+
}
|
|
118
|
+
return this.props.userCategory === "staff"
|
|
119
|
+
? values.emptyRequestsStaff
|
|
120
|
+
: values.emptyRequestsUser;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
resetDataSource = (source = "") => {
|
|
124
|
+
const { jobfilters } = this.props;
|
|
125
|
+
const { searchText } = this.state;
|
|
126
|
+
const { jobs } = this.props;
|
|
127
|
+
|
|
128
|
+
let filteredList = jobs;
|
|
129
|
+
let jobIdMatch = null;
|
|
130
|
+
if (searchText) {
|
|
131
|
+
jobIdMatch = _.find(jobs, (j) => j.jobId === searchText);
|
|
132
|
+
filteredList = jobs.filter((j) => {
|
|
133
|
+
if (
|
|
134
|
+
j.room &&
|
|
135
|
+
j.room.toLowerCase().indexOf(searchText.toLowerCase()) > -1
|
|
136
|
+
) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
});
|
|
141
|
+
if (!jobIdMatch) this.fetchJob(searchText);
|
|
142
|
+
}
|
|
143
|
+
if (jobfilters.status)
|
|
144
|
+
filteredList = filteredList.filter((j) =>
|
|
145
|
+
jobfilters.status.includes(j.status),
|
|
146
|
+
);
|
|
147
|
+
if (jobfilters.priority)
|
|
148
|
+
filteredList = filteredList.filter((j) =>
|
|
149
|
+
jobfilters.priority.includes(j.priority),
|
|
150
|
+
);
|
|
151
|
+
if (jobfilters.type)
|
|
152
|
+
filteredList = filteredList.filter((j) =>
|
|
153
|
+
jobfilters.type.includes(j.type),
|
|
154
|
+
);
|
|
155
|
+
if (jobfilters.assignee)
|
|
156
|
+
filteredList = filteredList.filter((j) =>
|
|
157
|
+
jobfilters.assignee.includes(j.AssigneeId),
|
|
158
|
+
);
|
|
159
|
+
if (jobIdMatch) {
|
|
160
|
+
const jobIndex = filteredList.indexOf(jobIdMatch);
|
|
161
|
+
if (jobIndex > -1) {
|
|
162
|
+
filteredList.splice(jobIndex, 1);
|
|
163
|
+
}
|
|
164
|
+
filteredList.unshift(jobIdMatch);
|
|
165
|
+
}
|
|
166
|
+
if (source !== "search") this.refresh();
|
|
167
|
+
|
|
168
|
+
this.setState({ filteredList });
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
onLoadingChanged = (loading, callback) => {
|
|
172
|
+
this.setState({ loading }, () => {
|
|
173
|
+
if (this.props.onLoadingChanged)
|
|
174
|
+
this.props.onLoadingChanged(this.state.loading);
|
|
175
|
+
if (callback) callback();
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
onSearchText = (value) => {
|
|
180
|
+
this.setState({ searchText: value }, () => {
|
|
181
|
+
if (_.isEmpty(this.state.searchText)) this.resetDataSource("search");
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
onSearchSubmit = () => {
|
|
186
|
+
this.resetDataSource("search");
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
onToggleFilter = () => {
|
|
190
|
+
this.setState({ showFilterPopup: !this.state.showFilterPopup });
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
onSelectFilter = (selected) => {
|
|
194
|
+
this.props.jobsFilterLoaded(selected);
|
|
195
|
+
this.onToggleFilter();
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
getFilterButtonText = () => {
|
|
199
|
+
const { jobfilters } = this.props;
|
|
200
|
+
const filterTexts = [];
|
|
201
|
+
if (!_.isEmpty(jobfilters.status)) {
|
|
202
|
+
filterTexts.push(jobfilters.statusText);
|
|
203
|
+
}
|
|
204
|
+
if (!_.isEmpty(jobfilters.priority)) {
|
|
205
|
+
filterTexts.push(jobfilters.priorityText);
|
|
206
|
+
}
|
|
207
|
+
if (!_.isEmpty(jobfilters.type)) {
|
|
208
|
+
filterTexts.push(jobfilters.type);
|
|
209
|
+
}
|
|
210
|
+
if (!_.isEmpty(jobfilters.assignee)) {
|
|
211
|
+
filterTexts.push(jobfilters.assigneeName);
|
|
212
|
+
}
|
|
213
|
+
if (_.isEmpty(filterTexts)) {
|
|
214
|
+
return "Filter";
|
|
215
|
+
}
|
|
216
|
+
return `Filtering by ${filterTexts.join(", ")}`;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
renderEmptyList() {
|
|
220
|
+
return this.state.loading ? null : (
|
|
221
|
+
<Components.EmptyStateMain
|
|
222
|
+
title={this.getEmptyStateText()}
|
|
223
|
+
style={{ marginHorizontal: 16 }}
|
|
224
|
+
/>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
renderFilterButton() {
|
|
229
|
+
return (
|
|
230
|
+
<TouchableOpacity onPress={this.onToggleFilter}>
|
|
231
|
+
<View style={styles.filterButton}>
|
|
232
|
+
<Text
|
|
233
|
+
style={[
|
|
234
|
+
styles.filterButtonText,
|
|
235
|
+
{ color: this.props.colourBrandingMain },
|
|
236
|
+
]}
|
|
237
|
+
>
|
|
238
|
+
{this.getFilterButtonText()}
|
|
239
|
+
</Text>
|
|
240
|
+
</View>
|
|
241
|
+
</TouchableOpacity>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
renderSearch() {
|
|
246
|
+
if (!this.props.hasPermission) return null;
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<View style={styles.searchContainer}>
|
|
250
|
+
<Components.GenericInput
|
|
251
|
+
placeholder={`Search by ${values.textEntityName} ID or Address`}
|
|
252
|
+
value={this.state.searchText}
|
|
253
|
+
onChangeText={this.onSearchText}
|
|
254
|
+
onSubmitEditing={this.onSearchSubmit}
|
|
255
|
+
squaredCorners
|
|
256
|
+
hasClear
|
|
257
|
+
// keyboardType={'numeric'}
|
|
258
|
+
returnKeyType={"done"}
|
|
259
|
+
/>
|
|
260
|
+
</View>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
renderListHeader() {
|
|
265
|
+
const { ListHeaderComponent } = this.props;
|
|
266
|
+
return (
|
|
267
|
+
<View>
|
|
268
|
+
{ListHeaderComponent ? (
|
|
269
|
+
ListHeaderComponent
|
|
270
|
+
) : (
|
|
271
|
+
<View style={{ height: 8 }} />
|
|
272
|
+
)}
|
|
273
|
+
{this.renderFilterButton()}
|
|
274
|
+
{this.renderSearch()}
|
|
275
|
+
</View>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
renderList() {
|
|
280
|
+
const { filteredList } = this.state;
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<FlatList
|
|
284
|
+
keyboardShouldPersistTaps="always"
|
|
285
|
+
style={{ flex: 1 }}
|
|
286
|
+
contentContainerStyle={{ paddingBottom: 16 }}
|
|
287
|
+
data={filteredList}
|
|
288
|
+
keyExtractor={(item) => item.id}
|
|
289
|
+
renderItem={({ item }) => (
|
|
290
|
+
<MaintenanceListItem style={this.props.itemStyle} job={item} />
|
|
291
|
+
)}
|
|
292
|
+
ListEmptyComponent={this.renderEmptyList()}
|
|
293
|
+
ListHeaderComponent={this.renderListHeader()}
|
|
294
|
+
/>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
renderFilterPopup() {
|
|
299
|
+
const { jobfilters } = this.props;
|
|
300
|
+
const { showFilterPopup, types } = this.state;
|
|
301
|
+
if (!showFilterPopup) return null;
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<FilterPopupMenu
|
|
305
|
+
site={this.props.site}
|
|
306
|
+
types={types}
|
|
307
|
+
status={jobfilters.status}
|
|
308
|
+
priority={jobfilters.priority}
|
|
309
|
+
assignee={jobfilters.assignee}
|
|
310
|
+
type={jobfilters.type}
|
|
311
|
+
onClose={this.onSelectFilter}
|
|
312
|
+
/>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
render() {
|
|
317
|
+
return (
|
|
318
|
+
<View style={[styles.container, this.props.style]}>
|
|
319
|
+
{this.renderList()}
|
|
320
|
+
{this.renderFilterPopup()}
|
|
321
|
+
</View>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
257
324
|
}
|
|
258
325
|
|
|
259
326
|
const styles = StyleSheet.create({
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
327
|
+
container: {
|
|
328
|
+
flex: 1,
|
|
329
|
+
backgroundColor: "#fff",
|
|
330
|
+
},
|
|
331
|
+
filterContainerOuter: {
|
|
332
|
+
flexDirection: "row",
|
|
333
|
+
justifyContent: "space-between",
|
|
334
|
+
alignItems: "center",
|
|
335
|
+
paddingHorizontal: 16,
|
|
336
|
+
paddingVertical: 16,
|
|
337
|
+
},
|
|
338
|
+
filterTitle: {
|
|
339
|
+
fontFamily: "sf-bold",
|
|
340
|
+
fontSize: 11,
|
|
341
|
+
letterSpacing: 0.8,
|
|
342
|
+
color: "#4d4d4d",
|
|
343
|
+
},
|
|
344
|
+
filterContainer: {
|
|
345
|
+
flexDirection: "row",
|
|
346
|
+
alignItems: "center",
|
|
347
|
+
},
|
|
348
|
+
filterText: {
|
|
349
|
+
fontFamily: "sf-semibold",
|
|
350
|
+
fontSize: 16,
|
|
351
|
+
marginRight: 6,
|
|
352
|
+
},
|
|
353
|
+
filterIcon: {
|
|
354
|
+
fontSize: 20,
|
|
355
|
+
},
|
|
356
|
+
searchContainer: {
|
|
357
|
+
flexDirection: "row",
|
|
358
|
+
alignItems: "center",
|
|
359
|
+
paddingBottom: 8,
|
|
360
|
+
paddingHorizontal: 16,
|
|
361
|
+
},
|
|
362
|
+
filterButton: {
|
|
363
|
+
paddingBottom: 8,
|
|
364
|
+
paddingHorizontal: 16,
|
|
365
|
+
flexDirection: "row-reverse",
|
|
366
|
+
},
|
|
367
|
+
filterButtonText: {
|
|
368
|
+
fontFamily: "sf-semibold",
|
|
369
|
+
fontSize: 16,
|
|
370
|
+
},
|
|
304
371
|
});
|
|
305
372
|
|
|
306
|
-
const mapStateToProps = state => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
373
|
+
const mapStateToProps = (state) => {
|
|
374
|
+
const { user, notifications } = state;
|
|
375
|
+
const jobs = state[values.reducerKey];
|
|
376
|
+
const jobsOrdered = _.orderBy(jobs.jobs, ["createdUnix"], ["desc"]);
|
|
377
|
+
const hasPermission = _.includes(user.permissions, "maintenanceTracking");
|
|
378
|
+
|
|
379
|
+
return {
|
|
380
|
+
hasPermission,
|
|
381
|
+
jobs: jobsOrdered,
|
|
382
|
+
site: user.site,
|
|
383
|
+
userCategory: user.category,
|
|
384
|
+
colourBrandingMain: Colours.getMainBrandingColourFromState(state),
|
|
385
|
+
dataUpdated: notifications.dataUpdated[values.updateKey],
|
|
386
|
+
statusTypes: state[values.reducerKey].jobstatuses,
|
|
387
|
+
jobfilters: state[values.reducerKey].jobfilters || {},
|
|
388
|
+
};
|
|
322
389
|
};
|
|
323
390
|
|
|
324
|
-
export default connect(
|
|
325
|
-
|
|
326
|
-
|
|
391
|
+
export default connect(
|
|
392
|
+
mapStateToProps,
|
|
393
|
+
{
|
|
394
|
+
jobsLoaded,
|
|
395
|
+
jobAdded,
|
|
396
|
+
jobsAdded,
|
|
397
|
+
jobStatusesUpdate,
|
|
398
|
+
jobHideSeenUpdate,
|
|
399
|
+
jobsFilterLoaded,
|
|
400
|
+
},
|
|
401
|
+
null,
|
|
402
|
+
{
|
|
403
|
+
forwardRef: true,
|
|
404
|
+
},
|
|
405
|
+
)(MaintenanceList);
|