muba-posting 9.0.4 → 9.0.6
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/Publish2b.js +31 -26
- package/package.json +1 -1
package/Publish2b.js
CHANGED
|
@@ -44,12 +44,16 @@ export default class Publish2b extends React.Component {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
componentDidMount = async () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
47
|
+
let locationList = this.state.locationsList;
|
|
48
|
+
if (locationList.length === 0) {
|
|
49
|
+
locationList = await this.props.loadLocations();
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
|
|
52
|
+
this.setState({
|
|
53
|
+
locationsList: locationList
|
|
54
|
+
}, () => {
|
|
55
|
+
this.loadData();
|
|
56
|
+
});
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
loadData = async () => {
|
|
@@ -62,7 +66,7 @@ export default class Publish2b extends React.Component {
|
|
|
62
66
|
}
|
|
63
67
|
});
|
|
64
68
|
|
|
65
|
-
if (
|
|
69
|
+
if (region != null) {
|
|
66
70
|
this.setState({
|
|
67
71
|
cityOptions: {
|
|
68
72
|
elements: [this.state.cityOptions.elements[0], ...this.state.locationsList.filter(r => r.value === region)[0].subList.map(({ subList, ...rest }) => ({ ...rest }))],
|
|
@@ -71,7 +75,7 @@ export default class Publish2b extends React.Component {
|
|
|
71
75
|
});
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
if (
|
|
78
|
+
if (city != null) {
|
|
75
79
|
this.setState({
|
|
76
80
|
districtOptions: {
|
|
77
81
|
elements: [this.state.districtOptions.elements[0], ...this.state.locationsList.filter(r => r.value === region)[0].subList.filter(c => c.value === city)[0].subList.map(({ subList, ...rest }) => ({ ...rest }))],
|
|
@@ -80,7 +84,7 @@ export default class Publish2b extends React.Component {
|
|
|
80
84
|
});
|
|
81
85
|
}
|
|
82
86
|
|
|
83
|
-
if (
|
|
87
|
+
if (district != null) {
|
|
84
88
|
this.setState({
|
|
85
89
|
townOptions: {
|
|
86
90
|
elements: [this.state.townOptions.elements[0], ...this.state.locationsList.filter(r => r.value === region)[0].subList.filter(c => c.value === city)[0].subList.filter(d => d.value === district)[0].subList],
|
|
@@ -90,7 +94,7 @@ export default class Publish2b extends React.Component {
|
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
|
|
93
|
-
|
|
97
|
+
loadRegions() {
|
|
94
98
|
if (this.state.regionOptions.elements.length <= 1) {
|
|
95
99
|
const regionOptions = {
|
|
96
100
|
elements: [this.state.regionOptions.elements[0], ...this.state.locationsList.map(({ subList, ...rest }) => ({ ...rest }))],
|
|
@@ -101,7 +105,7 @@ export default class Publish2b extends React.Component {
|
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
loadCities(value) {
|
|
105
109
|
this.setState({ regionOptions: { ...this.state.regionOptions, selectedItem: value } });
|
|
106
110
|
this.props.postingAd.region = value;
|
|
107
111
|
|
|
@@ -124,7 +128,7 @@ export default class Publish2b extends React.Component {
|
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
loadDistricts(value) {
|
|
128
132
|
this.setState({ cityOptions: { ...this.state.cityOptions, selectedItem: value } });
|
|
129
133
|
this.props.postingAd.city = value;
|
|
130
134
|
|
|
@@ -139,20 +143,21 @@ export default class Publish2b extends React.Component {
|
|
|
139
143
|
districtOptions.selectedItem = city.subList[0].value;
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
this.setState({ districtOptions: districtOptions })
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
this.setState({ districtOptions: districtOptions }, async () => {
|
|
147
|
+
this.props.postingAd.district = null;
|
|
148
|
+
this.props.postingAd.town = null;
|
|
145
149
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
if (city.subList.length == 1) {
|
|
151
|
+
this.inputSelectDistrict?.onSubmitValidate();
|
|
152
|
+
this.loadTowns(districtOptions.selectedItem);
|
|
153
|
+
} else {
|
|
154
|
+
this.setState({ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null } });
|
|
155
|
+
}
|
|
156
|
+
});
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
159
|
|
|
155
|
-
|
|
160
|
+
loadTowns(value) {
|
|
156
161
|
this.setState({ districtOptions: { ...this.state.districtOptions, selectedItem: value } })
|
|
157
162
|
this.props.postingAd.district = value;
|
|
158
163
|
|
|
@@ -168,11 +173,11 @@ export default class Publish2b extends React.Component {
|
|
|
168
173
|
this.props.postingAd.town = townOptions.selectedItem;
|
|
169
174
|
}
|
|
170
175
|
|
|
171
|
-
this.setState({ townOptions: townOptions })
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
+
this.setState({ townOptions: townOptions }, () => {
|
|
177
|
+
if (district.subList.length == 1) {
|
|
178
|
+
this.inputSelectTown?.onSubmitValidate();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
176
181
|
}
|
|
177
182
|
}
|
|
178
183
|
|