muba-posting 4.1.15 → 4.1.18
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/Posting.js +5 -1
- package/Publish4.js +71 -25
- package/Publish5.js +0 -1
- package/assets/images/animals-hover.png +0 -0
- package/assets/images/animals.png +0 -0
- package/assets/images/exteriorFacade-hover.png +0 -0
- package/assets/images/exteriorFacade.png +0 -0
- package/assets/images/orientation-hover.png +0 -0
- package/assets/images/orientation.png +0 -0
- package/package.json +1 -1
package/Posting.js
CHANGED
|
@@ -363,7 +363,11 @@ export default class Posting extends React.Component {
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
async _saveEditAd() {
|
|
366
|
-
const
|
|
366
|
+
const ad = { ...this.state.postingAd, id: { adId: this.state.postingAd.id } };
|
|
367
|
+
if (this.state.originView === Views.EDIT_SELECTOR && Views.PUBLISH_4 !== this.state.view) {
|
|
368
|
+
delete ad.images;
|
|
369
|
+
}
|
|
370
|
+
const response = await this.props.request(this, UPDATE_AD, ad);
|
|
367
371
|
if (this.props.adId) {
|
|
368
372
|
if (this.state.originView === Views.EDIT_SELECTOR) {
|
|
369
373
|
this.setState({ isLoading: true });
|
package/Publish4.js
CHANGED
|
@@ -14,6 +14,7 @@ export default class Publish4 extends React.Component {
|
|
|
14
14
|
super(props);
|
|
15
15
|
|
|
16
16
|
this.state = {
|
|
17
|
+
images: this.props.postingAd.images,
|
|
17
18
|
popupSelectPhotoVisible: false,
|
|
18
19
|
showErrorNoSelectedImages: false,
|
|
19
20
|
allPhotosSelected: false,
|
|
@@ -31,12 +32,16 @@ export default class Publish4 extends React.Component {
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
if (prevProps.maxPictures !== this.props.maxPictures ||
|
|
35
|
+
if (prevProps.maxPictures !== this.props.maxPictures || this.state.images.length !== this.props.postingAd.images.length) {
|
|
35
36
|
if (this.props.postingAd.images.length == this.props.maxPictures) {
|
|
36
37
|
this.setState({ allPhotosSelected: true });
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
if (!prevProps.showView && this.props.showView && !this.isSameList(this.props.postingAd.images, this.state.images)) {
|
|
42
|
+
this.setState({ images: this.props.postingAd.images })
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
const componentsHeight = this.props.headerHeight + this.props.progressBarHeight;
|
|
41
46
|
const minHeight = window.height - componentsHeight;
|
|
42
47
|
if (this.state.minHeight != minHeight) {
|
|
@@ -44,53 +49,75 @@ export default class Publish4 extends React.Component {
|
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
|
|
52
|
+
/*shouldComponentUpdate(nextProps, nextState) {
|
|
53
|
+
return !this.isSameList(this.state.images, nextState.images) || (!this.props.showView && nextProps.showView && !this.state.viewLoaded);
|
|
54
|
+
} */
|
|
55
|
+
|
|
56
|
+
isSameList = (firstList, secondList) => {
|
|
57
|
+
if (firstList.length != secondList.length) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
for (let index = 0; index < firstList.length; ++index) {
|
|
61
|
+
if (firstList[index].id != secondList[index].id || firstList[index].uri != secondList[index].uri) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
47
68
|
async loadImage(imgUri) {
|
|
48
69
|
if (imgUri) {
|
|
49
70
|
let fileType = imgUri.substring(imgUri.lastIndexOf('.') + 1).toLowerCase();
|
|
50
71
|
|
|
51
72
|
const image = {
|
|
52
73
|
uri: imgUri,
|
|
53
|
-
name: 'photo_' + this.
|
|
74
|
+
name: 'photo_' + this.state.images.length + '.' + fileType,
|
|
54
75
|
type: 'image/' + fileType,
|
|
55
|
-
mainPicture: this.
|
|
76
|
+
mainPicture: this.state.images.length === 0,
|
|
56
77
|
referenceType: 'AD',
|
|
57
78
|
referenceId: this.props.postingAd.id,
|
|
58
|
-
extraInfo: this.
|
|
79
|
+
extraInfo: this.state.images.length
|
|
59
80
|
}
|
|
60
81
|
|
|
61
|
-
let imagesArray = this.
|
|
82
|
+
let imagesArray = this.state.images;
|
|
62
83
|
imagesArray.push(image);
|
|
63
|
-
this.props.postingAd.images = imagesArray;
|
|
64
84
|
|
|
65
|
-
this.setState({
|
|
85
|
+
await this.setState({
|
|
86
|
+
showErrorNoSelectedImages: false,
|
|
87
|
+
images: imagesArray
|
|
88
|
+
});
|
|
66
89
|
|
|
67
|
-
if (this.
|
|
90
|
+
if (this.state.images.length == this.props.maxPictures) {
|
|
68
91
|
this.setState({ allPhotosSelected: true });
|
|
69
|
-
} else if (this.
|
|
70
|
-
this.selectMainPhoto(this.
|
|
92
|
+
} else if (this.state.images.length == 1) {
|
|
93
|
+
this.selectMainPhoto(this.state.images[0]);
|
|
71
94
|
}
|
|
72
95
|
}
|
|
73
96
|
}
|
|
74
97
|
|
|
75
|
-
async deleteImage(
|
|
76
|
-
if (
|
|
98
|
+
async deleteImage(itemId, index) {
|
|
99
|
+
if (itemId) {
|
|
77
100
|
if (!this.props.postingAd.deletedFiles) {
|
|
78
101
|
this.props.postingAd.deletedFiles = [];
|
|
79
102
|
}
|
|
80
|
-
this.props.postingAd.deletedFiles.push(
|
|
103
|
+
this.props.postingAd.deletedFiles.push(itemId);
|
|
81
104
|
}
|
|
82
105
|
|
|
83
|
-
let
|
|
106
|
+
let imagesArray = [...this.state.images];
|
|
107
|
+
imagesArray.splice(index, 1)
|
|
108
|
+
|
|
109
|
+
await this.setState({
|
|
110
|
+
allPhotosSelected: false,
|
|
111
|
+
images: imagesArray
|
|
112
|
+
});
|
|
84
113
|
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
if (this.props.postingAd.images.length >= 1) {
|
|
88
|
-
this.selectMainPhoto(this.props.postingAd.images[0]);
|
|
114
|
+
if (this.state.images.length >= 1) {
|
|
115
|
+
this.selectMainPhoto(this.state.images[0]);
|
|
89
116
|
}
|
|
90
117
|
}
|
|
91
118
|
|
|
92
119
|
selectMainPhoto(itemSelected) {
|
|
93
|
-
let imagesArray = this.
|
|
120
|
+
let imagesArray = this.state.images.slice();
|
|
94
121
|
|
|
95
122
|
for (let imageObject of imagesArray) {
|
|
96
123
|
imageObject.mainPicture = false;
|
|
@@ -108,14 +135,17 @@ export default class Publish4 extends React.Component {
|
|
|
108
135
|
++index;
|
|
109
136
|
}
|
|
110
137
|
|
|
111
|
-
this.
|
|
112
|
-
|
|
138
|
+
this.setState({
|
|
139
|
+
updateMainPhoto: true,
|
|
140
|
+
images: imagesArray
|
|
141
|
+
});
|
|
113
142
|
}
|
|
114
143
|
|
|
115
144
|
nextStep() {
|
|
116
|
-
if (this.
|
|
145
|
+
if (this.state.images.length == 0) {
|
|
117
146
|
this.setState({ showErrorNoSelectedImages: true });
|
|
118
147
|
} else {
|
|
148
|
+
this.props.postingAd.images = this.state.images;
|
|
119
149
|
this.setState({ showErrorNoSelectedImages: false });
|
|
120
150
|
if (this.props.postingAd.id == null || this.props.fullPosting) {
|
|
121
151
|
if (this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) {
|
|
@@ -129,6 +159,21 @@ export default class Publish4 extends React.Component {
|
|
|
129
159
|
}
|
|
130
160
|
}
|
|
131
161
|
|
|
162
|
+
rerenderImage(index) {
|
|
163
|
+
const images = this.state.images;
|
|
164
|
+
if (images[index].uri.indexOf('?t=') < 0) {
|
|
165
|
+
images[index].uri = images[index].uri + '?t=' + Date.now();
|
|
166
|
+
} else {
|
|
167
|
+
images[index].uri = images[index].uri.substring(0, images[index].uri.indexOf('?t=')) + '?t=' + Date.now();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
setTimeout(() => {
|
|
171
|
+
this.setState({
|
|
172
|
+
images: images
|
|
173
|
+
});
|
|
174
|
+
}, 500);
|
|
175
|
+
}
|
|
176
|
+
|
|
132
177
|
render() {
|
|
133
178
|
return (
|
|
134
179
|
<View style={this.props.showView ? '' : commonStyles.displayNone}>
|
|
@@ -167,12 +212,13 @@ export default class Publish4 extends React.Component {
|
|
|
167
212
|
</TouchableOpacity>
|
|
168
213
|
</TouchableOpacity>
|
|
169
214
|
}
|
|
170
|
-
{this.
|
|
215
|
+
{this.state.images.map((item, index) => {
|
|
171
216
|
return (
|
|
172
|
-
<ImageBackground style={[commonStyles.photoBox, commonStyles.photoBoxImage]} source={{ uri: item.uri }} borderRadius={10} key={index}
|
|
217
|
+
<ImageBackground style={[commonStyles.photoBox, commonStyles.photoBoxImage]} source={{ uri: item.uri }} borderRadius={10} key={index}
|
|
218
|
+
onError={() => this.rerenderImage(index)}>
|
|
173
219
|
<ImageBackground style={[commonStyles.photoControls, commonStyles.row]} source={require('./assets/images/bg-shadow.png')} resizeMode='stretch' borderRadius={1.5}>
|
|
174
220
|
|
|
175
|
-
<TouchableHighlight style={commonStyles.leftIcon} onPress={() => this.deleteImage(item)}>
|
|
221
|
+
<TouchableHighlight style={commonStyles.leftIcon} onPress={() => this.deleteImage(item.id, index)}>
|
|
176
222
|
<FontAwesomeIcon style={commonStyles.whiteIcon} name="cancel-circled" />
|
|
177
223
|
</TouchableHighlight>
|
|
178
224
|
<TouchableHighlight style={commonStyles.rightIcon} onPress={() => this.selectMainPhoto(item)}>
|
package/Publish5.js
CHANGED
|
@@ -4,7 +4,6 @@ import { strings } from 'muba-i18n';
|
|
|
4
4
|
import commonStyles from './commonStyles';
|
|
5
5
|
import InputSelect from 'muba-input-select';
|
|
6
6
|
import { Views } from './utils/Views';
|
|
7
|
-
import { Orientation } from 'expo-screen-orientation';
|
|
8
7
|
const window = Dimensions.get('window');
|
|
9
8
|
|
|
10
9
|
export default class Publish5 extends React.Component {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|