From 345e570e67c3d92b5228053fad89128f565daa4c Mon Sep 17 00:00:00 2001 From: Jeffrey Fisher Date: Tue, 12 Jun 2018 13:50:41 -0400 Subject: [PATCH] [DEV-3192] Fix hiding the header when all contents are hidden --- src/ui/group/GroupUi.js | 10 ++++++-- src/ui/group/StackedGroupUi.js | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/ui/group/GroupUi.js b/src/ui/group/GroupUi.js index 21824f8..de11c33 100644 --- a/src/ui/group/GroupUi.js +++ b/src/ui/group/GroupUi.js @@ -792,7 +792,7 @@ module.exports = Class( 'GroupUi' ) }, - 'public hideField': function( field, index ) + 'virtual public hideField': function( field, index ) { if ( this.isFieldVisible( field, index ) === false ) { @@ -814,7 +814,13 @@ module.exports = Class( 'GroupUi' ) }, - 'public showField': function( field, index ) + 'protected hasVisibleField'( index ) + { + return this._visCount[ index ] > 0 ? true : false; + }, + + + 'virtual public showField': function( field, index ) { if ( this.isFieldVisible( field, index ) === true ) { diff --git a/src/ui/group/StackedGroupUi.js b/src/ui/group/StackedGroupUi.js index 0da7145..f5c3edf 100644 --- a/src/ui/group/StackedGroupUi.js +++ b/src/ui/group/StackedGroupUi.js @@ -100,4 +100,49 @@ module.exports = Class( 'StackedGroupUi' ) return this.__super( index ); }, + + + /** + * Hide the header if there are no visible fields + * + * @param field + * @param index + */ + 'public override hideField'( field, index ) + { + this.__super( field, index ); + + if ( !this.hasVisibleField( index ) ) + { + const header = this._$container.find( 'dl' )[ index ]; + var attribute = header.getAttribute( 'class' ); + + attribute = attribute.includes( ' hidden ' ) ? attribute : attribute + ' hidden '; + + header.setAttribute( 'class', attribute ); + } + }, + + + /** + * Show the header if there are visible fields + * + * @param field + * @param index + */ + 'public override showField'( field, index ) + { + this.__super( field, index ); + + if ( this.hasVisibleField( index ) ) + { + const header = this._$container.find( 'dl' )[ index ]; + var attribute = header.getAttribute( 'class' ); + + attribute = attribute.includes( ' hidden ' ) ? attribute.replace(' hidden ', '') : attribute; + + header.setAttribute( 'class', attribute ); + } + + } } );