Introduce getScaffoldByKeys that makes use of GetEmptyByKeys

This commit is contained in:
Elitsa Marinovska
2021-05-06 10:58:13 +02:00
parent 051be40eb0
commit 7bcfd8dad9
2 changed files with 26 additions and 8 deletions

View File

@@ -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(

View File

@@ -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);
},