Introduce getScaffoldByKeys that makes use of GetEmptyByKeys
This commit is contained in:
@@ -688,6 +688,24 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
});
|
||||
},
|
||||
|
||||
getScaffoldByKeys: function (parentId, scaffoldKeys) {
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"contentApiBaseUrl",
|
||||
"GetEmptyByKeys",
|
||||
{ contentTypeKeys: scaffoldKeys, parentId: parentId })),
|
||||
'Failed to retrieve data for empty content items ids' + scaffoldKeys.join(", "))
|
||||
.then(function (result) {
|
||||
Object.keys(result).map(function(key) {
|
||||
result[key] = umbDataFormatter.formatContentGetData(result[key]);
|
||||
});
|
||||
|
||||
return $q.when(result);
|
||||
});
|
||||
},
|
||||
|
||||
getBlueprintScaffold: function (parentId, blueprintId) {
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
|
||||
@@ -419,18 +419,18 @@
|
||||
// removing duplicates.
|
||||
scaffoldKeys = scaffoldKeys.filter((value, index, self) => self.indexOf(value) === index);
|
||||
|
||||
scaffoldKeys.forEach(contentTypeKey => {
|
||||
tasks.push(contentResource.getScaffoldByKey(-20, contentTypeKey).then(scaffold => {
|
||||
tasks.push(contentResource.getScaffoldByKeys(-20, scaffoldKeys).then(scaffolds => {
|
||||
Object.values(scaffolds).forEach(scaffold => {
|
||||
// self.scaffolds might not exists anymore, this happens if this instance has been destroyed before the load is complete.
|
||||
if (self.scaffolds) {
|
||||
self.scaffolds.push(formatScaffoldData(scaffold));
|
||||
}
|
||||
}).catch(
|
||||
() => {
|
||||
// Do nothing if we get an error.
|
||||
}
|
||||
));
|
||||
});
|
||||
});
|
||||
}).catch(
|
||||
() => {
|
||||
// Do nothing if we get an error.
|
||||
}
|
||||
));
|
||||
|
||||
return $q.all(tasks);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user