@corpsmap/corpsmap 3.2.71 → 3.2.74

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.
@@ -1,85 +1,172 @@
1
1
  import React from "react";
2
2
  import { connect } from "redux-bundler-react";
3
3
  import { SearchInput, SearchResultsList } from "../../application-controls";
4
+ import SelectDistrict from "./select-district";
4
5
 
5
6
  class ChangeLogModal extends React.Component {
6
7
  constructor(props) {
7
8
  super(props);
8
9
 
9
- this.state = {
10
- searchBarStatus: "",
11
- };
12
10
  this.handleChange = this.handleChange.bind(this);
13
11
  this.close = this.close.bind(this);
14
12
  this.fomatDate = this.formatDate.bind(this);
15
13
  }
16
14
 
17
- handleChange(event){
18
- const {doSearchChangeLogData } = this.props;
19
- doSearchChangeLogData(event);
20
- this.setState({
21
- searchBarStatus: event.target.value
22
- })
15
+ handleChange(event) {
16
+ const { doSetSearchBarFilter } = this.props;
17
+ doSetSearchBarFilter(event.target.value);
23
18
  }
24
-
19
+
25
20
  close() {
26
21
  const { doModalClose } = this.props;
27
22
  doModalClose();
28
23
  }
29
24
 
30
- formatDate(oldDate){
25
+ formatDate(oldDate) {
31
26
  let newDate = new Date(oldDate);
32
- newDate = newDate.toLocaleDateString('default', { month: 'long', day: 'numeric', year: 'numeric'});
33
- return newDate
34
- }
35
-
27
+ newDate = newDate.toLocaleDateString("default", {
28
+ month: "long",
29
+ day: "numeric",
30
+ year: "numeric",
31
+ });
32
+ return newDate;
33
+ }
34
+
36
35
  render() {
37
- const { theme, doGetChangeLogData, changeLogItems } = this.props;
36
+ const {
37
+ theme,
38
+ doGetChangeLogData,
39
+ changeLogItems,
40
+ allChangeLogItems,
41
+ searchBarFilter,
42
+ } = this.props;
38
43
  const loginDataWk = changeLogItems;
39
- const arrayDataItems = loginDataWk.map( data =>
40
-
41
- <div key={data.id+data.id+9876} style={Object.keys(data).length > 0 ? {listStyleType: "disc"}: {listStyleType: "none"} }>
42
- {data.change_date ? <li key={data.change_date + data.id}><b>{this.formatDate(data.change_date)}</b></li> : null}
43
- {data.environment ? <li key={data.environment + data.id} style={{listStyleType: "none"}}><b>Environment:</b> {data.environment} </li> : null}
44
- {data.change_type ? <li key={data.change_type + data.id} style={{listStyleType: "none"}}><b>Change Type:</b> {data.change_type}</li> : null}
45
- {data.district_code ? <li key={data.district_code + data.id} style={{listStyleType: "none"}}><b>District:</b> {data.district_code}</li> : null}
46
- {data.description ? <li key={data.description + data.id} style={{listStyleType: "none"}}><b>Description:</b> {data.description}</li> : null}
44
+ let districtCodes = [
45
+ ...new Set(allChangeLogItems.map((feature) => feature.district_code)),
46
+ ];
47
+ let options = [];
48
+
49
+ districtCodes.sort().forEach((item, index) => {
50
+ if (item) {
51
+ options.push({
52
+ label: `${item}`,
53
+ value: `${item}`,
54
+ });
55
+ }
56
+ });
57
+
58
+ options.unshift({ label: "All Districts", value: "All" });
59
+
60
+ const arrayDataItems = loginDataWk.map((data) => (
61
+ <div
62
+ key={data.id + data.id + 9876}
63
+ style={
64
+ Object.keys(data).length > 0
65
+ ? { listStyleType: "disc" }
66
+ : { listStyleType: "none" }
67
+ }
68
+ >
69
+ {data.change_date ? (
70
+ <li key={data.change_date + data.id}>
71
+ <b>{this.formatDate(data.change_date)}</b>
72
+ </li>
73
+ ) : null}
74
+ {data.environment ? (
75
+ <li
76
+ key={data.environment + data.id}
77
+ style={{ listStyleType: "none" }}
78
+ >
79
+ <b>Environment:</b> {data.environment}{" "}
80
+ </li>
81
+ ) : null}
82
+ {data.change_type ? (
83
+ <li
84
+ key={data.change_type + data.id}
85
+ style={{ listStyleType: "none" }}
86
+ >
87
+ <b>Change Type:</b> {data.change_type}
88
+ </li>
89
+ ) : null}
90
+ {data.district_code ? (
91
+ <li
92
+ key={data.district_code + data.id}
93
+ style={{ listStyleType: "none" }}
94
+ >
95
+ <b>District:</b> {data.district_code}
96
+ </li>
97
+ ) : null}
98
+ {data.description ? (
99
+ <li
100
+ key={data.description + data.id}
101
+ style={{ listStyleType: "none" }}
102
+ >
103
+ <b>Description:</b> {data.description}
104
+ </li>
105
+ ) : null}
47
106
  <br></br>
48
107
  </div>
49
-
50
- )
51
-
108
+ ));
109
+
110
+ const filterStyle = {
111
+ // paddingLeft: "25px",
112
+ display: "flex",
113
+ justifyContent: "center",
114
+ alignItems: "center",
115
+ gap: "40px",
116
+ width: "700px",
117
+ alignItems: "flex-end",
118
+ // textAlign: "right",
119
+ // alignItems: "flex-end" /* Aligns content to the right */,
120
+ // width: 300px; /* Example width for the container */
121
+ // border: "1px solid lightgray" /* For visualization */,
122
+ padding: "5px",
123
+ };
124
+
52
125
  return (
53
126
  <div>
54
127
  <div className={"cm-modal-header " + theme}>Change Log</div>
55
- <div
56
- className="cm-modal-body"
57
- style={{ height: 290, top: 0, bottom: 0, left: 0, right: 0 }}
58
- >
59
- <div className="cm-form-group">
60
- <input
61
- placeholder="Change Log Search..."
62
- style={{border: "none", width: 600}}
63
- value={this.state.searchBarStatus}
64
- onChange={this.handleChange}
128
+
129
+ <div className="cm-modal-body">
130
+ <div style={filterStyle}>
131
+ <label style={{ fontSize: "18px", fontWeight: "bold" }}>
132
+ Change Log Filter
133
+ </label>
134
+ </div>
135
+
136
+ <div style={filterStyle}>
137
+ <label htmlFor="select-district">
138
+ <b>Filter by District:</b>
139
+ </label>
140
+ <SelectDistrict options={options} />
141
+ </div>
142
+
143
+ <div style={filterStyle}>
144
+ <label htmlFor="select-district">
145
+ <b>Change Log Search:</b>
146
+ </label>
147
+
148
+ <input
149
+ placeholder="Change Log Search..."
150
+ style={{ width: "200px" }}
151
+ value={searchBarFilter}
152
+ onChange={this.handleChange}
65
153
  ></input>
66
154
  </div>
67
- <div className="cm-form-group">
68
- <div style={{
69
- overflow: "auto scroll",
70
- width: "875px",
71
- height: "300px",
72
- whiteSpace: "pre-wrap",}}>
73
- <ul>{arrayDataItems}</ul>
74
-
75
- </div>
155
+ <div
156
+ style={{
157
+ overflow: "auto scroll",
158
+ width: "875px",
159
+ height: "400px",
160
+ whiteSpace: "pre-wrap",
161
+ }}
162
+ >
163
+ <ul>{arrayDataItems}</ul>
76
164
  </div>
77
165
  </div>
78
166
  <div className="cm-modal-footer">
79
167
  <br></br>
80
168
  <br></br>
81
169
  <br></br>
82
-
83
170
  <button
84
171
  style={{ textAlign: "left" }}
85
172
  type="Close"
@@ -90,7 +177,6 @@ class ChangeLogModal extends React.Component {
90
177
  </button>
91
178
  </div>
92
179
  </div>
93
-
94
180
  );
95
181
  }
96
182
  }
@@ -99,9 +185,11 @@ export default connect(
99
185
  "selectTheme",
100
186
  "selectChangeLogItems",
101
187
  "selectAllChangeLogItems",
188
+ "selectSearchBarFilter",
102
189
  "doModalClose",
103
190
  "doSubmitNotification",
104
191
  "doGetChangeLogData",
105
192
  "doSearchChangeLogData",
193
+ "doSetSearchBarFilter",
106
194
  ChangeLogModal
107
- );
195
+ );
@@ -0,0 +1,73 @@
1
+ import React from "react";
2
+ import { connect } from "redux-bundler-react";
3
+ import Select from "react-select";
4
+
5
+ class SelectDistrict extends React.Component {
6
+ constructor(props) {
7
+ super(props);
8
+ }
9
+
10
+ handleSelect(opts) {
11
+ const { doSetDistrictFilter } = this.props;
12
+ doSetDistrictFilter(opts);
13
+ }
14
+
15
+ render() {
16
+ const { options, districtFilter } = this.props;
17
+ const { label, value } = districtFilter;
18
+
19
+ const customStyles = {
20
+ control: (base) => ({
21
+ ...base,
22
+ minHeight: "25px", // Smaller height for the control
23
+ height: "25px",
24
+ fontSize: "14px", // Smaller font size for the selected value
25
+ width: "150px",
26
+ }),
27
+ dropdownIndicator: (base) => ({
28
+ ...base,
29
+ paddingTop: 0,
30
+ paddingBottom: 0,
31
+ }),
32
+ clearIndicator: (base) => ({
33
+ ...base,
34
+ paddingTop: 0,
35
+ paddingBottom: 0,
36
+ }),
37
+ valueContainer: (base) => ({
38
+ ...base,
39
+ padding: "0 8px", // Adjust padding within the value container
40
+ }),
41
+ input: (base) => ({
42
+ ...base,
43
+ margin: 0, // Remove default margin for the input
44
+ padding: 0,
45
+ }),
46
+ menu: (base) => ({
47
+ ...base,
48
+ fontSize: "14px", // Smaller font size for menu items
49
+ }),
50
+ option: (base) => ({
51
+ ...base,
52
+ padding: "5px 14px", // Adjust padding for individual options
53
+ }),
54
+ };
55
+ return (
56
+ <Select
57
+ id={"select-district"}
58
+ options={options}
59
+ onChange={(opts) => {
60
+ this.handleSelect(opts);
61
+ }}
62
+ styles={customStyles}
63
+ value={{ label: label, value: value }}
64
+ defaultValue={{ label: label, value: value }}
65
+ />
66
+ );
67
+ }
68
+ }
69
+ export default connect(
70
+ "doSetDistrictFilter",
71
+ "selectDistrictFilter",
72
+ SelectDistrict
73
+ );