Skip to content

Commit ea21366

Browse files
authored
Fixes for data sample
* fixed for create data - add contentType * QBWEBSDK-618 * QBWEBSDK-586 * QBWEBSDK-594
1 parent 7d03d3c commit ea21366

File tree

6 files changed

+39
-11
lines changed

6 files changed

+39
-11
lines changed

quickblox.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/data/index.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@ <h2 class="panel__title">Create a new place</h2>
101101
<input id="latlng" type="hidden" value={{latLng}}>
102102

103103
<div class="form_item">
104-
<input id="title" class="inp" type="text" required placeholder="Place name" maxlength="40">
104+
<input id="title" class="inp" type="text" required pattern="[A-Za-z\s]{4,40}" title="Only latin from 4 to 40 symbols" placeholder="Place name">
105105
</div>
106106

107107
<div class="form_item">
108-
<input id="description" class="inp" type="text" required placeholder="Description" maxlength="80">
108+
<input id="description" class="inp" type="text" required pattern="[A-Za-z\s]{4,80}" title="Only latin from 4 to 80 symbols" placeholder="Description" >
109109
</div>
110110

111111
<div class="form_item">
112112
<label for="rate">Rate</label>
113-
<input id="rate" class="inp" type="number" min="0" max="5" step="0.1" value="0" required>
113+
<input id="rate" class="inp" type="number" min="0" max="5" step="0.1" value="5" required>
114114
</div>
115115

116116
<div class="form_item" class="form_item form_item-media">
@@ -227,7 +227,12 @@ <h4 class="form__title">Check in</h4>
227227
<input id="checkin_id" type="hidden" value={{id}}>
228228

229229
<div class="form_item">
230-
<input id="checkin_comment" class="inp" type="text" required placeholder="Enter your comment" maxlength="40" required>
230+
<input id="checkin_comment" class="inp"
231+
type="text"
232+
placeholder="Enter your comment"
233+
pattern="[A-Za-z\s]{4,40}"
234+
title="Only latin from 4 to 40 symbols"
235+
required>
231236
</div>
232237

233238
<div class="form_item">

samples/data/js/app.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function App() {
3535

3636
/* A list of possible name of pages */
3737
this._PAGES = ['dashboard', 'new_place', 'place_detailed', 'checkin'];
38+
39+
this._activePageName = '';
3840

3941
/**
4042
* Write to root element a class name of a page
@@ -55,10 +57,15 @@ function App() {
5557

5658
// render the page
5759
self.renderPage(params.pageName, params.detailed);
60+
61+
this._activePageName = params.pageName;
62+
},
63+
get: function() {
64+
return this._activePageName;
5865
}
5966
});
6067

61-
this._init();
68+
this._init();
6269
}
6370

6471
App.prototype._init = function() {
@@ -486,7 +493,9 @@ App.prototype.renderPlaceDetailed = function(placeId) {
486493
}).then(function(res) {
487494
self.places.updateLocal(res);
488495

489-
self.renderPlaceDetailed(placeId);
496+
if(self.activePage === 'place_detailed') {
497+
self.renderPlaceDetailed(placeId);
498+
}
490499
});
491500
});
492501
});
@@ -505,7 +514,7 @@ App.prototype.renderCheckin = function(placeId) {
505514
var place = self.places.getPlace(placeId),
506515
checkinForm = document.getElementById('checkin-submit');
507516

508-
// this fix deletes empty symbols from start and end of form's values (https://quickblox.atlassian.net/browse/QBWEBSDK-559)
517+
// this fix deletes empty symbols from start and end of form's values
509518
checkinForm.addEventListener('change', function() {
510519
var comment = document.getElementById('checkin_comment').value.trim();
511520

@@ -548,7 +557,6 @@ App.prototype.renderCheckin = function(placeId) {
548557
// clear form
549558
target.parentNode.removeChild(target);
550559

551-
552560
return false;
553561
});
554562

samples/data/js/places.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,12 @@ Places.prototype.update = function(params) {
8080
Places.prototype.updateLocal = function(newPlace) {
8181
var place = this.getPlace(newPlace._id);
8282

83+
function sortByUpdate(a, b) {
84+
if (a.updated_at < b.updated_at) return 1;
85+
if (a.updated_at > b.updated_at) return -1;
86+
}
87+
8388
Object.assign(place, newPlace);
89+
90+
this.items.sort(sortByUpdate);
8491
};

src/modules/qbData.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,15 @@ DataProxy.prototype = {
5252
* @param {object} error - The error object
5353
* @param {object} response - An object
5454
*/
55-
this.service.ajax({url: Utils.getUrl(config.urls.data, className), data: data, type: 'POST'}, function(err,res) {
55+
var ajaxParams = {
56+
'type': 'POST',
57+
'data': data,
58+
'isNeedStringify': true,
59+
'contentType': 'application/json; charset=utf-8',
60+
'url': Utils.getUrl(config.urls.data, className)
61+
};
62+
63+
this.service.ajax(ajaxParams, function(err,res) {
5664
if (err) {
5765
callback(err, null);
5866
} else {

src/qbConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
var config = {
1515
version: '2.8.0',
16-
buildNumber: '1054',
16+
buildNumber: '1055',
1717
creds: {
1818
appId: '',
1919
authKey: '',

0 commit comments

Comments
 (0)