Fix bug with checking user preferences for report column visibility.
This commit is contained in:
parent
90edd4e5a6
commit
974566ea0c
|
@ -108,14 +108,19 @@ class ReportTable extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
filterShownHeaders( headers, hiddenKeys ) {
|
filterShownHeaders( headers, hiddenKeys ) {
|
||||||
if ( ! hiddenKeys || ! hiddenKeys.length ) {
|
// If no user preferences, set visibilty based on column default.
|
||||||
return headers;
|
if ( ! hiddenKeys ) {
|
||||||
|
return headers.map( header => ( {
|
||||||
|
...header,
|
||||||
|
visible: header.required || ! header.hiddenByDefault,
|
||||||
|
} ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return headers.map( header => {
|
// Set visibilty based on user preferences.
|
||||||
const hidden = hiddenKeys.includes( header.key ) && ! header.required;
|
return headers.map( header => ( {
|
||||||
return { ...header, hiddenByDefault: hidden };
|
...header,
|
||||||
} );
|
visible: header.required || ! hiddenKeys.includes( header.key ),
|
||||||
|
} ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -93,7 +93,15 @@ class TableCard extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
getShowCols( headers ) {
|
getShowCols( headers ) {
|
||||||
return headers.map( ( { key, hiddenByDefault } ) => ! hiddenByDefault && key ).filter( Boolean );
|
return headers.map( ( { key, visible } ) => {
|
||||||
|
if (
|
||||||
|
'undefined' === typeof visible ||
|
||||||
|
visible
|
||||||
|
) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} ).filter( Boolean );
|
||||||
}
|
}
|
||||||
|
|
||||||
getVisibleHeaders() {
|
getVisibleHeaders() {
|
||||||
|
|
Loading…
Reference in New Issue