Skip to content

Commit ccdaddd

Browse files
committed
fix ut
1 parent 562f645 commit ccdaddd

12 files changed

+70
-57
lines changed

dist/iclient-classic.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,9 +1809,12 @@ var CommonServiceBase = function () {
18091809
timeout: options.async ? 0 : null,
18101810
proxy: options.proxy
18111811
}).then(function (response) {
1812-
return response.json();
1813-
}).then(function (result) {
1814-
1812+
return response.text();
1813+
}).then(function (text) {
1814+
var result = new _SuperMap2.default.Format.JSON().read(text);
1815+
if (!result) {
1816+
result = { error: text };
1817+
}
18151818
if (result.error) {
18161819
var failure = options.scope ? _SuperMap2.default.Function.bind(options.failure, options.scope) : options.failure;
18171820
failure(result.error);

dist/iclient-classic.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.

dist/iclient9-leaflet.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,9 +1616,12 @@ var CommonServiceBase = function () {
16161616
timeout: options.async ? 0 : null,
16171617
proxy: options.proxy
16181618
}).then(function (response) {
1619-
return response.json();
1620-
}).then(function (result) {
1621-
1619+
return response.text();
1620+
}).then(function (text) {
1621+
var result = new _SuperMap2["default"].Format.JSON().read(text);
1622+
if (!result) {
1623+
result = { error: text };
1624+
}
16221625
if (result.error) {
16231626
var failure = options.scope ? _SuperMap2["default"].Function.bind(options.failure, options.scope) : options.failure;
16241627
failure(result.error);
@@ -29847,17 +29850,16 @@ var EditFeaturesParameters = function () {
2984729850

2984829851
features = { ids: params.IDs };
2984929852
} else {
29850-
if (params.features === null) return;
29851-
29852-
len = params.features.length;
2985329853
features = [];
29854-
for (var i = 0; i < len; i++) {
29855-
feature = params.features[i];
29856-
feature.geometry = _SuperMap2["default"].REST.ServerGeometry.fromGeometry(feature.geometry);
29857-
features.push(feature);
29854+
if (params.features) {
29855+
len = params.features.length;
29856+
for (var i = 0; i < len; i++) {
29857+
feature = params.features[i];
29858+
feature.geometry = _SuperMap2["default"].REST.ServerGeometry.fromGeometry(feature.geometry);
29859+
features.push(feature);
29860+
}
2985829861
}
2985929862
}
29860-
2986129863
return _SuperMap2["default"].Util.toJSON(features);
2986229864
}
2986329865
}]);

dist/iclient9-leaflet.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.

dist/iclient9-mapboxgl.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,9 +1610,12 @@ var CommonServiceBase = function () {
16101610
timeout: options.async ? 0 : null,
16111611
proxy: options.proxy
16121612
}).then(function (response) {
1613-
return response.json();
1614-
}).then(function (result) {
1615-
1613+
return response.text();
1614+
}).then(function (text) {
1615+
var result = new _SuperMap2.default.Format.JSON().read(text);
1616+
if (!result) {
1617+
result = { error: text };
1618+
}
16161619
if (result.error) {
16171620
var failure = options.scope ? _SuperMap2.default.Function.bind(options.failure, options.scope) : options.failure;
16181621
failure(result.error);
@@ -23860,17 +23863,16 @@ var EditFeaturesParameters = function () {
2386023863

2386123864
features = { ids: params.IDs };
2386223865
} else {
23863-
if (params.features === null) return;
23864-
23865-
len = params.features.length;
2386623866
features = [];
23867-
for (var i = 0; i < len; i++) {
23868-
feature = params.features[i];
23869-
feature.geometry = _SuperMap2.default.REST.ServerGeometry.fromGeometry(feature.geometry);
23870-
features.push(feature);
23867+
if (params.features) {
23868+
len = params.features.length;
23869+
for (var i = 0; i < len; i++) {
23870+
feature = params.features[i];
23871+
feature.geometry = _SuperMap2.default.REST.ServerGeometry.fromGeometry(feature.geometry);
23872+
features.push(feature);
23873+
}
2387123874
}
2387223875
}
23873-
2387423876
return _SuperMap2.default.Util.toJSON(features);
2387523877
}
2387623878
}]);

dist/iclient9-mapboxgl.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.

dist/iclient9-openlayers.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,9 +1616,12 @@ var CommonServiceBase = function () {
16161616
timeout: options.async ? 0 : null,
16171617
proxy: options.proxy
16181618
}).then(function (response) {
1619-
return response.json();
1620-
}).then(function (result) {
1621-
1619+
return response.text();
1620+
}).then(function (text) {
1621+
var result = new _SuperMap2.default.Format.JSON().read(text);
1622+
if (!result) {
1623+
result = { error: text };
1624+
}
16221625
if (result.error) {
16231626
var failure = options.scope ? _SuperMap2.default.Function.bind(options.failure, options.scope) : options.failure;
16241627
failure(result.error);
@@ -25152,17 +25155,16 @@ var EditFeaturesParameters = function () {
2515225155

2515325156
features = { ids: params.IDs };
2515425157
} else {
25155-
if (params.features === null) return;
25156-
25157-
len = params.features.length;
2515825158
features = [];
25159-
for (var i = 0; i < len; i++) {
25160-
feature = params.features[i];
25161-
feature.geometry = _SuperMap2.default.REST.ServerGeometry.fromGeometry(feature.geometry);
25162-
features.push(feature);
25159+
if (params.features) {
25160+
len = params.features.length;
25161+
for (var i = 0; i < len; i++) {
25162+
feature = params.features[i];
25163+
feature.geometry = _SuperMap2.default.REST.ServerGeometry.fromGeometry(feature.geometry);
25164+
features.push(feature);
25165+
}
2516325166
}
2516425167
}
25165-
2516625168
return _SuperMap2.default.Util.toJSON(features);
2516725169
}
2516825170
}]);

dist/iclient9-openlayers.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.

src/common/iServer/CommonServiceBase.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ export default class CommonServiceBase {
351351
let error = result.error || result;
352352
this.events.triggerEvent("processFailed", {error: error});
353353
}
354+
354355
_commit(options) {
355356
if (options.method === "POST" || options.method === "PUT") {
356357
if (options.params) {
@@ -364,21 +365,25 @@ export default class CommonServiceBase {
364365
withCredentials: options.withCredentials,
365366
timeout: options.async ? 0 : null,
366367
proxy: options.proxy
367-
}).then(function (response){
368-
return response.json()
369-
}).then(function (result) {
370-
371-
if(result.error){
368+
}).then(function (response) {
369+
return response.text()
370+
}).then(function (text) {
371+
var result = new SuperMap.Format.JSON().read(text);
372+
if (!result) {
373+
result = {error: text};
374+
}
375+
if (result.error) {
372376
var failure = (options.scope) ? SuperMap.Function.bind(options.failure, options.scope) : options.failure;
373377
failure(result.error);
374-
}else{
378+
} else {
375379
result.succeed = result.succeed == undefined ? true : result.succeed;
376380
var success = (options.scope) ? SuperMap.Function.bind(options.success, options.scope) : options.success;
377381
success(result);
378382
}
379383

380384
});
381385
}
386+
382387
CLASS_NAME = "SuperMap.CommonServiceBase";
383388
}
384389

src/common/iServer/EditFeaturesParameters.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,16 @@ export default class EditFeaturesParameters {
9797

9898
features = {ids: params.IDs};
9999
} else {
100-
if (params.features === null) return;
101-
102-
len = params.features.length;
103100
features = [];
104-
for (var i = 0; i < len; i++) {
105-
feature = params.features[i];
106-
feature.geometry = SuperMap.REST.ServerGeometry.fromGeometry(feature.geometry);
107-
features.push(feature);
101+
if (params.features){
102+
len = params.features.length;
103+
for (var i = 0; i < len; i++) {
104+
feature = params.features[i];
105+
feature.geometry = SuperMap.REST.ServerGeometry.fromGeometry(feature.geometry);
106+
features.push(feature);
107+
}
108108
}
109109
}
110-
111110
return SuperMap.Util.toJSON(features);
112111
}
113112

0 commit comments

Comments
 (0)