Cmatch: Extract show/hide marking into own method
This is to give us a fairly easy means of testing this logic for a bugfix. This refactoring also obviates a pretty nasty bug; see docblock. * src/client/Cmatch.js (_handleClassMatch): Extract show/hide marking. (markShowHide): New method.master
parent
4b114d0137
commit
0a50b22496
|
@ -300,17 +300,7 @@ module.exports = Class( 'Cmatch',
|
||||||
( ( vis[ i ] ) ? show : hide ).push( i );
|
( ( vis[ i ] ) ? show : hide ).push( i );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( show.length )
|
this.markShowHide( field, visq, show, hide );
|
||||||
{
|
|
||||||
visq[ field ] = { event_id: 'show', name: field, indexes: show };
|
|
||||||
this._mergeCmatchHidden( field, show, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( hide.length )
|
|
||||||
{
|
|
||||||
visq[ field ] = { event_id: 'hide', name: field, indexes: hide };
|
|
||||||
this._mergeCmatchHidden( field, hide, true );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// it's important to do this before showing/hiding fields, since
|
// it's important to do this before showing/hiding fields, since
|
||||||
|
@ -339,6 +329,41 @@ module.exports = Class( 'Cmatch',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark fields to be shown/hidden
|
||||||
|
*
|
||||||
|
* This also updates the cached visibility of field FIELD.
|
||||||
|
*
|
||||||
|
* XXX: This method makes very obvious a nasty bug where hides override
|
||||||
|
* shows if both are set.
|
||||||
|
*
|
||||||
|
* @param {string} field field name
|
||||||
|
* @param {Array} show indexes to show
|
||||||
|
* @param {Array} hide indexes to hide
|
||||||
|
*
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
'protected markShowHide'( field, visq, show, hide )
|
||||||
|
{
|
||||||
|
if ( !( show.length || hide.length ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( show.length )
|
||||||
|
{
|
||||||
|
this._mergeCmatchHidden( field, show, false );
|
||||||
|
visq[ field ] = { event_id: 'show', name: field, indexes: show };
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( hide.length )
|
||||||
|
{
|
||||||
|
this._mergeCmatchHidden( field, hide, true );
|
||||||
|
visq[ field ] = { event_id: 'hide', name: field, indexes: hide };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger DataApi event for field FIELD
|
* Trigger DataApi event for field FIELD
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue