File tree Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ var PageModel = DefineMap.extend({
7676 localStorage . setItem ( storageKey , true ) ;
7777 }
7878 } ,
79+ collection : 'string' ,
7980 description : 'string' ,
8081 descriptionWithoutHTML : {
8182 get : function ( ) {
@@ -129,9 +130,25 @@ var PageModel = DefineMap.extend({
129130 return [ 'group' , 'prototype' , 'static' ] . indexOf ( this . type ) !== - 1 ;
130131 }
131132 } ,
133+ isInCoreCollection : {
134+ type : 'boolean' ,
135+ default : false ,
136+ get : function ( ) {
137+ var collection = this . collection ;
138+ if ( ! collection ) {
139+ // Walk up the parents to find the collection
140+ var parent = this . parentPage ;
141+ while ( parent ) {
142+ collection = parent . collection ;
143+ parent = ( collection ) ? null : parent . parentPage ;
144+ }
145+ }
146+ return collection === 'can-core' ;
147+ }
148+ } ,
132149 name : {
133150 type : 'string' ,
134- value : ''
151+ default : ''
135152 } ,
136153 order : 'number' ,
137154 parent : 'string' ,
@@ -232,7 +249,7 @@ var PageModel = DefineMap.extend({
232249 title : 'string' ,
233250 type : 'string' ,
234251 unsortedChildren : {
235- value : function ( ) {
252+ default : function ( ) {
236253 return [ ] ;
237254 }
238255 } ,
Original file line number Diff line number Diff line change @@ -30,13 +30,13 @@ module.exports = DefineMap.extend({
3030 } ,
3131 pageMap : {
3232 type : 'any' ,
33- value : function ( ) {
33+ default : function ( ) {
3434 return { } ;
3535 }
3636 } ,
3737 pathPrefix : {
3838 type : 'string' ,
39- value : '' ,
39+ default : '' ,
4040 set : function ( pathPrefix ) {
4141 if ( pathPrefix ) {
4242 if ( pathPrefix . substr ( - 1 ) !== '/' ) {
@@ -99,7 +99,7 @@ module.exports = DefineMap.extend({
9999 if ( selectedPage . isCollapsed && selectedPage . visibleChildren . length === 0 ) {
100100 selectedPage . isCollapsed = false ;
101101
102- } else if ( selectedPage . collection !== 'can-core' ) {
102+ } else if ( ! selectedPage . isInCoreCollection ) {
103103 // If the page is not in the core collection, walk up the parents to
104104 // make sure they are not collapsed.
105105 var parent = ( selectedPage ) ? selectedPage . parentPage : null ;
Original file line number Diff line number Diff line change @@ -184,6 +184,15 @@ QUnit.test('When a Core package is selected, its parent should not automatically
184184 assert . ok ( vm . shouldShowExpandCollapseButton ( canObservablesPage ) , 'expand/collapse button is shown' ) ;
185185} ) ;
186186
187+ QUnit . test ( 'When a child page of a Core package is selected, the package’s group should not automatically be expanded' , function ( assert ) {
188+ var vm = new ViewModel ( { searchMap : searchMap } ) ;
189+ var canDefineTypesPage = vm . pageMap [ 'can-define.types' ] ;
190+ var canObservablesPage = canDefineTypesPage . parentPage . parentPage . parentPage ;
191+ vm . selectedPage = canDefineTypesPage ;
192+ assert . ok ( canObservablesPage . isCollapsed , 'parent page is collapsed' ) ;
193+ assert . ok ( vm . shouldShowExpandCollapseButton ( canObservablesPage ) , 'expand/collapse button is shown' ) ;
194+ } ) ;
195+
187196QUnit . test ( 'When a collapsed purpose group page with no visible children is selected, it should be expanded' , function ( assert ) {
188197 var vm = new ViewModel ( { searchMap : searchMap } ) ;
189198 var domUtilitiesPage = vm . pageMap [ 'can-dom-utilities' ] ;
You can’t perform that action at this time.
0 commit comments