Use credential_type to fetch associated types in list view

This commit is contained in:
gconsidine
2017-10-10 10:54:05 -04:00
committed by Matthew Jones
parent 64c5e3994e
commit 766a088749
3 changed files with 37 additions and 14 deletions

View File

@@ -5,10 +5,13 @@
*************************************************/
export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', 'GetBasePath',
'Wait', '$state', '$filter', 'rbacUiControlService', 'Dataset', 'credentialType', 'i18n',
'Wait', '$state', '$filter', 'rbacUiControlService', 'Dataset', 'CredentialTypeModel',
'i18n',
function($scope, Rest, CredentialList, Prompt,
ProcessErrors, GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset,
credentialType, i18n) {
CredentialType, i18n) {
const credentialType = new CredentialType();
var list = CredentialList,
defaultUrl = GetBasePath('credentials');
@@ -45,9 +48,25 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
return;
}
$scope[list.name].forEach(credential => {
credential.kind = credentialType.match('id', credential.credential_type).name;
});
const params = $scope[list.name]
.reduce((accumulator, credential) => {
accumulator.push(credential.credential_type);
return accumulator;
}, [])
.filter((id, i, array) => array.indexOf(id) === i)
.map(id => `or__id=${id}`);
credentialType.search(params)
.then(found => {
if (!found) {
return;
}
$scope[list.name].forEach(credential => {
credential.kind = credentialType.match('id', credential.credential_type).name;
});
});
}
// iterate over the list and add fields like type label, after the