Don't assume that the query always succeeds. Error reporting is rudimentary (alert), but better than nothing.
This commit is contained in:
parent
6c9ad3f31d
commit
4359f894b8
@ -52,24 +52,28 @@ ReconStandardServicePanel.prototype._guessTypes = function(f) {
|
|||||||
}),
|
}),
|
||||||
null,
|
null,
|
||||||
function(data) {
|
function(data) {
|
||||||
self._types = data.types;
|
if (data.code && data.code === 'ok') {
|
||||||
|
self._types = data.types;
|
||||||
|
|
||||||
if (self._types.length === 0 && "defaultTypes" in self._service) {
|
if (self._types.length === 0 && "defaultTypes" in self._service) {
|
||||||
var defaultTypes = {};
|
var defaultTypes = {};
|
||||||
$.each(self._service.defaultTypes, function() {
|
$.each(self._service.defaultTypes, function() {
|
||||||
defaultTypes[this.id] = this.name;
|
defaultTypes[this.id] = this.name;
|
||||||
});
|
});
|
||||||
$.each(self._types, function() {
|
$.each(self._types, function() {
|
||||||
delete defaultTypes[typeof this == "string" ? this : this.id];
|
delete defaultTypes[typeof this == "string" ? this : this.id];
|
||||||
});
|
});
|
||||||
for (var id in defaultTypes) {
|
for (var id in defaultTypes) {
|
||||||
if (defaultTypes.hasOwnProperty(id)) {
|
if (defaultTypes.hasOwnProperty(id)) {
|
||||||
self._types.push({
|
self._types.push({
|
||||||
id: id,
|
id: id,
|
||||||
name: defaultTypes[id].name
|
name: defaultTypes[id].name
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
alert('Guess Types query failed ' + data.code + ' : ' + data.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
dismissBusy();
|
dismissBusy();
|
||||||
|
Loading…
Reference in New Issue
Block a user