Don't let the same doctype be selectable twice in the Nested Content configuration
This commit is contained in:
@@ -37,6 +37,18 @@
|
||||
});
|
||||
});
|
||||
|
||||
$scope.selectableDocTypesFor = function (config) {
|
||||
// return all doctypes that are:
|
||||
// 1. either already selected for this config, or
|
||||
// 2. not selected in any other config
|
||||
return _.filter($scope.model.docTypes, function (docType) {
|
||||
return docType.alias === config.ncAlias || !_.find($scope.model.value, function(c) {
|
||||
return docType.alias === c.ncAlias;
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (!$scope.model.value) {
|
||||
$scope.model.value = [];
|
||||
$scope.add();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<select id="{{model.alias}}_doctype_select"
|
||||
ng-options="dt.alias as dt.name for dt in model.docTypes | orderBy: 'name'"
|
||||
ng-options="dt.alias as dt.name for dt in selectableDocTypesFor(config) | orderBy: 'name'"
|
||||
ng-model="config.ncAlias" required></select>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user