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