@@ -37,13 +37,14 @@ usageRightsEditor.controller(
37
37
const usageRights$ = observe$ ( $scope , ( ) => ctrl . usageRights ) ;
38
38
39
39
// @return Stream.<Array.<Category>>
40
- const categories $ = Rx . Observable . fromPromise ( editsApi . getUsageRightsCategories ( ) ) ;
40
+ const allCategories $ = Rx . Observable . fromPromise ( editsApi . getUsageRightsCategories ( ) ) ;
41
41
const filteredCategories$ = Rx . Observable . fromPromise ( editsApi . getFilteredUsageRightsCategories ( ) ) ;
42
-
43
- // @return Stream.<Array.<Category>>
44
- const displayCategories$ = usageRights$ . combineLatest ( filteredCategories$ , categories$ , ( urs , filCats , allCats ) => {
42
+ const categories$ = usageRights$ . combineLatest ( filteredCategories$ , allCategories$ , ( urs , filCats , allCats ) => {
45
43
const uniqueCats = getUniqueCats ( urs ) ;
46
44
if ( uniqueCats . length === 1 ) {
45
+ if ( allCats . length === filCats . length ) {
46
+ return allCats ;
47
+ }
47
48
const mtchCats = filCats . filter ( c => c . value === uniqueCats [ 0 ] ) ;
48
49
const extraCats = allCats . filter ( c => c . value === uniqueCats [ 0 ] ) ;
49
50
if ( mtchCats . length === 0 && extraCats . length === 1 ) {
@@ -52,7 +53,17 @@ usageRightsEditor.controller(
52
53
return filCats ;
53
54
}
54
55
} else {
55
- return [ multiCat ] . concat ( filCats ) ;
56
+ return filCats ;
57
+ }
58
+ } ) ;
59
+
60
+ // @return Stream.<Array.<Category>>
61
+ const displayCategories$ = usageRights$ . combineLatest ( categories$ , ( urs , cats ) => {
62
+ const uniqueCats = getUniqueCats ( urs ) ;
63
+ if ( uniqueCats . length === 1 ) {
64
+ return cats ;
65
+ } else {
66
+ return [ multiCat ] . concat ( cats ) ;
56
67
}
57
68
} ) ;
58
69
0 commit comments