Property suggestion for data extension should try CORS first. 'suggest' key is optional in service manifest (#3710)
Co-authored-by: Douglas Mennella <douglas.mennella@gmail.com> Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
This commit is contained in:
parent
b455dc577a
commit
50a905e9da
@ -100,34 +100,43 @@ ExtendReconciledDataPreviewDialog.getAllProperties = function(url, typeID, onDon
|
|||||||
onDone([]);
|
onDone([]);
|
||||||
} else {
|
} else {
|
||||||
var done = false;
|
var done = false;
|
||||||
$.getJSON(
|
var onSuccess = function (data) {
|
||||||
url +"?type=" + typeID + "&callback=?",
|
|
||||||
null,
|
|
||||||
function(data) {
|
|
||||||
if (done) return;
|
if (done) return;
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
var allProperties = [];
|
var allProperties = [];
|
||||||
for (var i = 0; i < data.properties.length; i++) {
|
for (var i = 0; i < data.properties.length; i++) {
|
||||||
var property = data.properties[i];
|
var property = data.properties[i];
|
||||||
var property2 = {
|
var property2 = {
|
||||||
id: property.id,
|
id: property.id,
|
||||||
name: property.name
|
name: property.name,
|
||||||
};
|
};
|
||||||
allProperties.push(property2);
|
allProperties.push(property2);
|
||||||
}
|
}
|
||||||
allProperties.sort(function(a, b) { return a.name.localeCompare(b.name); });
|
allProperties.sort(function (a, b) {
|
||||||
|
return a.name.localeCompare(b.name);
|
||||||
|
});
|
||||||
|
|
||||||
onDone(allProperties);
|
onDone(allProperties);
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
|
||||||
window.setTimeout(function() {
|
$.ajax(url + "?type=" + typeID, {
|
||||||
|
dataType: "json",
|
||||||
|
success: onSuccess,
|
||||||
|
timeout: 7000,
|
||||||
|
error: function () {
|
||||||
|
$.ajax(url + "?type=" + typeID, {
|
||||||
|
dataType: "jsonp",
|
||||||
|
success: onSuccess,
|
||||||
|
timeout: 7000,
|
||||||
|
error: function () {
|
||||||
if (done) return;
|
if (done) return;
|
||||||
|
|
||||||
done = true;
|
done = true;
|
||||||
onDone([]);
|
onDone([]);
|
||||||
}, 7000); // time to give up?
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -158,7 +167,7 @@ ExtendReconciledDataPreviewDialog.prototype._show = function(properties) {
|
|||||||
renderSuggestedProperty(properties[i]);
|
renderSuggestedProperty(properties[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var suggestConfig = $.extend({}, this._serviceMetadata.suggest.property);
|
var suggestConfig = $.extend({}, this._serviceMetadata.suggest && this._serviceMetadata.suggest.property);
|
||||||
suggestConfig.key = null;
|
suggestConfig.key = null;
|
||||||
suggestConfig.query_param_name = "prefix";
|
suggestConfig.query_param_name = "prefix";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user