@@ -259,34 +259,51 @@ export class CubeEvaluator extends CubeSymbols {
259259
260260 private prepareFolders ( cube : any , errorReporter : ErrorReporter ) {
261261 const folders = cube . rawFolders ( ) ;
262- if ( folders . length ) {
263- cube . folders = folders . map ( it => {
264- const includedMembers = this . allMembersOrList ( cube , it . includes ) ;
265- const includes = includedMembers . map ( memberName => {
266- if ( memberName . includes ( '.' ) ) {
267- errorReporter . error (
268- `Paths aren't allowed in the 'folders' but '${ memberName } ' has been provided for ${ cube . name } `
269- ) ;
270- }
262+ if ( ! folders . length ) return ;
271263
272- const member = cube . includedMembers . find ( m => m . name === memberName ) ;
273- if ( ! member ) {
274- errorReporter . error (
275- `Member '${ memberName } ' included in folder '${ it . name } ' not found`
276- ) ;
277- return null ;
278- }
264+ const checkMember = ( memberName : string , folderName : string ) => {
265+ if ( memberName . includes ( '.' ) ) {
266+ errorReporter . error (
267+ `Paths aren't allowed in the 'folders' but '${ memberName } ' has been provided for ${ cube . name } `
268+ ) ;
269+ }
270+
271+ const member = cube . includedMembers . find ( m => m . name === memberName ) ;
272+ if ( ! member ) {
273+ errorReporter . error (
274+ `Member '${ memberName } ' included in folder '${ folderName } ' not found`
275+ ) ;
276+ return null ;
277+ }
279278
280- return member ;
281- } )
282- . filter ( Boolean ) ;
279+ return member ;
280+ } ;
281+
282+ const processFolder = ( folder : any ) : any => {
283+ let includedMembers : string [ ] ;
284+ let includes : any [ ] = [ ] ;
285+
286+ if ( folder . includes === '*' ) {
287+ includedMembers = this . allMembersOrList ( cube , folder . includes ) ;
288+ includes = includedMembers . map ( m => checkMember ( m , folder . name ) ) . filter ( Boolean ) ;
289+ } else if ( Array . isArray ( folder . includes ) ) {
290+ includes = folder . includes . map ( item => {
291+ if ( typeof item === 'object' && item !== null ) {
292+ return processFolder ( item ) ;
293+ }
283294
284- return ( {
285- ...it ,
286- includes
295+ return checkMember ( item , folder . name ) ;
287296 } ) ;
288- } ) ;
289- }
297+ }
298+
299+ return {
300+ ...folder ,
301+ type : 'folder' ,
302+ includes : includes . filter ( Boolean )
303+ } ;
304+ } ;
305+
306+ cube . folders = folders . map ( processFolder ) ;
290307 }
291308
292309 private prepareHierarchies ( cube : any , errorReporter : ErrorReporter ) : void {
0 commit comments