muba-posting 6.0.15 → 6.0.17

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/Publish2.js CHANGED
@@ -18,6 +18,7 @@ export default class Publish2 extends React.Component {
18
18
  super(props);
19
19
 
20
20
  this.state = {
21
+ movedMapPointer: false,
21
22
  latitude: props.postingAd.latitude,
22
23
  longitude: props.postingAd.longitude,
23
24
  zoom: props.postingAd.latitude != null && props.postingAd.longitude != null ? 15 : 9,
@@ -25,8 +26,14 @@ export default class Publish2 extends React.Component {
25
26
  }
26
27
  }
27
28
 
29
+ componentDidMount() {
30
+ if (this.props.postingAd.id == null) {
31
+ this.props.postingAd.exactlyLocated = false;
32
+ }
33
+ }
34
+
28
35
  async nextStep() {
29
- if (await this.validateLocation()) {
36
+ if ((this.props.postingAd.exactlyLocated && !this.state.movedMapPointer) || await this.validateLocation()) {
30
37
  const responseCheckZone = await this.props.request(this.props.context, GET_CHECK_ZONE, {
31
38
  businessId: this.props.businessId,
32
39
  cityId: this.props.postingAd.city
@@ -57,11 +64,12 @@ export default class Publish2 extends React.Component {
57
64
  });
58
65
 
59
66
  if (responseJson.httpStatus === 200) {
60
- if (responseJson.exactlyLocated) {
61
- this.props.postingAd.exactlyLocated = true;
62
- validateLocation = true;
63
- } else {
67
+ validateLocation = responseJson.exactlyLocated;
68
+
69
+ if (responseJson.country == null || responseJson.country !== this.props.postingAd.country) {
64
70
  this.props.postingAd.exactlyLocated = false;
71
+ this.props.postingAd.latitude = null;
72
+ this.props.postingAd.longitude = null;
65
73
  }
66
74
 
67
75
  if (responseJson.region !== undefined) {
@@ -94,6 +102,7 @@ export default class Publish2 extends React.Component {
94
102
  }
95
103
 
96
104
  _changeMapLocation(region) {
105
+ this.props.postingAd.exactlyLocated = this.props.postingAd.exactlyLocated || this.state.movedMapPointer;
97
106
  this.props.postingAd.latitude = region.latitude;
98
107
  this.props.postingAd.longitude = region.longitude;
99
108
  this.props.postingAd.zoom = region.zoom;
@@ -115,6 +124,7 @@ export default class Publish2 extends React.Component {
115
124
  request={this.props.request}
116
125
  context={this.props.context}
117
126
  baseUrl={this.props.baseUrl}
127
+ locationChange={() => this.setState({ movedMapPointer: true })}
118
128
  onMapReady={() => this.props.hideLoading()} />
119
129
  <View style={commonStyles.buttomButton} onLayout={this.onLayout}>
120
130
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
package/Publish2b.js CHANGED
@@ -34,7 +34,11 @@ export default class Publish2b extends React.Component {
34
34
  elements: [{ section: true, value: null, label: strings('setup.town') }],
35
35
  selectedItem: this.props.postingAd.town
36
36
  },
37
- address: this.props.postingAd.address
37
+ address: this.props.postingAd.address,
38
+ originalRegion: this.props.postingAd.region,
39
+ originalCity: this.props.postingAd.city,
40
+ originalDistrict: this.props.postingAd.district,
41
+ originalTown: this.props.postingAd.town
38
42
  };
39
43
  }
40
44
 
@@ -162,7 +166,7 @@ export default class Publish2b extends React.Component {
162
166
  }
163
167
  }
164
168
 
165
- validateForm() {
169
+ async validateForm() {
166
170
  var validate = true;
167
171
 
168
172
  validate = this.inputSelectTown.onSubmitValidate() && validate;
@@ -170,6 +174,18 @@ export default class Publish2b extends React.Component {
170
174
  validate = this.inputSelecCity.onSubmitValidate() && validate;
171
175
  validate = this.inputSelectRegion.onSubmitValidate() && validate;
172
176
 
177
+ if (this.props.postingAd.exactlyLocated) {
178
+ let keepsExactlyLocated = (this.state.originalRegion == null || this.state.originalRegion === this.props.postingAd.region)
179
+ && (this.state.originalCity == null || this.state.originalCity === this.props.postingAd.city)
180
+ && (this.state.originalDistrict == null || this.state.originalDistrict === this.props.postingAd.district)
181
+ && (this.state.originalTown == null || this.state.originalTown === this.props.postingAd.town);
182
+ this.props.postingAd.exactlyLocated = keepsExactlyLocated;
183
+ if (!keepsExactlyLocated) {
184
+ this.props.postingAd.latitude = null;
185
+ this.props.postingAd.longitude = null;
186
+ }
187
+ }
188
+
173
189
  return validate;
174
190
  }
175
191
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "6.0.15",
3
+ "version": "6.0.17",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {