@@ -24,6 +24,8 @@ export default class FinderComponent extends Component {
2424 this . loadBranchLeaves = this . loadBranchLeaves . bind ( this ) ;
2525 this . onLoadMore = this . onLoadMore . bind ( this ) ;
2626 this . renderBranch = this . renderBranch . bind ( this ) ;
27+ this . renderActiveLocations = this . renderActiveLocations . bind ( this ) ;
28+ this . renderBranches = this . renderBranches . bind ( this ) ;
2729 this . setBranchContainerRef = this . setBranchContainerRef . bind ( this ) ;
2830 this . setPreselectedState = this . getPreselectedState . bind ( this ) ;
2931
@@ -450,6 +452,53 @@ export default class FinderComponent extends Component {
450452 ) ;
451453 }
452454
455+ renderActiveLocations ( ) {
456+ const { activeLocations, locationsMap } = this . state ;
457+
458+ return activeLocations . map ( ( location , index ) => {
459+ const locationId = location ? location . id : this . props . startingLocationId ;
460+ const branchActiveLocation = activeLocations [ index + 1 ] ;
461+ const branchActiveLocationId = branchActiveLocation ? branchActiveLocation . id : null ;
462+ const isBranchActiveLocationLoading = branchActiveLocationId && ! locationsMap [ branchActiveLocationId ] ;
463+ const locationData = locationsMap [ locationId ] ;
464+
465+ return this . renderBranch ( locationData , branchActiveLocationId , isBranchActiveLocationLoading ) ;
466+ } ) ;
467+ }
468+
469+ renderEmptyContent ( ) {
470+ const noContentMessage = Translator . trans (
471+ /*@Desc ("No content items.")*/ 'finder.no_content.message' ,
472+ { } ,
473+ 'universal_discovery_widget'
474+ ) ;
475+
476+ return < div className = "c-finder__no-content-info" > { noContentMessage } </ div > ;
477+ }
478+
479+ renderBranches ( ) {
480+ const { activeLocations } = this . state ;
481+ const branches = [
482+ this . renderStartingLocationBranch ( ) ,
483+ ...this . renderActiveLocations ( ) ,
484+ ] ;
485+ const hasActiveLocations = activeLocations . some ( ( location ) => location ) ;
486+ const hasNonEmptyBranches = branches . every ( ( branch ) => ! branch ) ;
487+
488+ if ( hasActiveLocations && hasNonEmptyBranches ) {
489+ const noContentMessage = Translator . trans (
490+ /*@Desc ("No content items.")*/ 'finder.no_content.message' ,
491+ { } ,
492+ 'universal_discovery_widget'
493+ ) ;
494+
495+ return < div className = "c-finder__no-content-info" > { noContentMessage } </ div > ;
496+ }
497+
498+ return branches ;
499+
500+ }
501+
453502 setBranchContainerRef ( ref ) {
454503 this . _refBranchesContainer = ref ;
455504 }
@@ -461,21 +510,10 @@ export default class FinderComponent extends Component {
461510 return null ;
462511 }
463512
464- const { locationsMap } = this . state ;
465-
466513 return (
467514 < div className = "c-finder" >
468515 < div className = "c-finder__branches" style = { { height : `${ this . props . maxHeight } px` } } ref = { this . setBranchContainerRef } >
469- { this . renderStartingLocationBranch ( ) }
470- { activeLocations . map ( ( location , index ) => {
471- const locationId = location ? location . id : this . props . startingLocationId ;
472- const branchActiveLocation = activeLocations [ index + 1 ] ;
473- const branchActiveLocationId = branchActiveLocation ? branchActiveLocation . id : null ;
474- const isBranchActiveLocationLoading = branchActiveLocationId && ! locationsMap [ branchActiveLocationId ] ;
475- const locationData = locationsMap [ locationId ] ;
476-
477- return this . renderBranch ( locationData , branchActiveLocationId , isBranchActiveLocationLoading ) ;
478- } ) }
516+ { this . renderBranches ( ) }
479517 </ div >
480518 </ div >
481519 ) ;
0 commit comments