Skip to content

Commit 9960e18

Browse files
authored
Merge pull request OptimalBPM#110 from albertjose/fix/onPopulationError
Add onPopulationError callback again
2 parents 506c13a + 9a0fc60 commit 9960e18

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/angular-schema-form-dynamic-select.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,13 @@ angular.module('schemaForm').controller('dynamicSelectController', ['$scope', '$
300300
console.log('asyncCallback items', form.titleMap);
301301
},
302302
function (data, status) {
303-
alert("Loading select items failed(Options: '" + String(form.options) +
304-
"\nError: " + status);
303+
if (form.options.onPopulationError) {
304+
$scope.getCallback(form.options.onPopulationError)(form, data, status);
305+
}
306+
else {
307+
alert("Loading select items failed(Options: '" + String(form.options) +
308+
"\nError: " + status);
309+
}
305310
});
306311
}
307312
else if (form.options.httpPost) {
@@ -314,8 +319,13 @@ angular.module('schemaForm').controller('dynamicSelectController', ['$scope', '$
314319
console.log('httpPost items', form.titleMap);
315320
},
316321
function (data, status) {
317-
alert("Loading select items failed (URL: '" + String(finalOptions.httpPost.url) +
318-
"' Parameter: " + String(finalOptions.httpPost.parameter) + "\nError: " + status);
322+
if (form.options.onPopulationError) {
323+
$scope.getCallback(form.options.onPopulationError)(form, data, status);
324+
}
325+
else {
326+
alert("Loading select items failed (URL: '" + String(finalOptions.httpPost.url) +
327+
"' Parameter: " + String(finalOptions.httpPost.parameter) + "\nError: " + status);
328+
}
319329
});
320330
}
321331
else if (form.options.httpGet) {
@@ -326,8 +336,13 @@ angular.module('schemaForm').controller('dynamicSelectController', ['$scope', '$
326336
console.log('httpGet items', form.titleMap);
327337
},
328338
function (data, status) {
329-
alert("Loading select items failed (URL: '" + String(finalOptions.httpGet.url) +
330-
"\nError: " + status);
339+
if (form.options.onPopulationError) {
340+
$scope.getCallback(form.options.onPopulationError)(form, data, status);
341+
}
342+
else {
343+
alert("Loading select items failed (URL: '" + String(finalOptions.httpGet.url) +
344+
"\nError: " + status);
345+
}
331346
});
332347
}
333348
else {

0 commit comments

Comments
 (0)