Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Nov 28, 2023
1 parent 28c8acd commit 652a32e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 56 deletions.
104 changes: 48 additions & 56 deletions packages/edit-site/src/components/dataviews/view-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function ViewList( {
} ) {
const areAllSelected = selection && selection.length === data.length;
const columns = useMemo( () => {
const fieldsColumns = fields.map( ( field ) => {
const _columns = fields.map( ( field ) => {
const { render, getValue, ...column } = field;
column.cell = ( props ) =>
render( { item: props.row.original, view } );
Expand All @@ -253,61 +253,53 @@ function ViewList( {
}
return column;
} );
const _columns =
selection !== undefined
? [
{
header: (
<CheckboxControl
__nextHasNoMarginBottom
checked={ areAllSelected }
onChange={ () => {
if ( areAllSelected ) {
setSelection( [] );
} else {
setSelection(
data.map( ( { id } ) => id )
);
}
} }
/>
),
id: 'selection',
cell: ( props ) => {
//console.log({ props });
const item = props.row.original;
const isSelected = selection.includes(
item.id
);
//console.log({ item, isSelected });
return (
<CheckboxControl
__nextHasNoMarginBottom
checked={ isSelected }
onChange={ () => {
if ( ! isSelected ) {
const newSelection = [
...selection,
item.id,
];
setSelection( newSelection );
} else {
setSelection(
selection.filter(
( id ) => id !== item.id
)
);
}
} }
/>
);
},
enableHiding: false,
width: 40,
},
...fieldsColumns,
]
: fieldsColumns;
if ( selection !== undefined ) {
_columns.unshift( {
header: (
<CheckboxControl
__nextHasNoMarginBottom
checked={ areAllSelected }
onChange={ () => {
if ( areAllSelected ) {
setSelection( [] );
} else {
setSelection( data.map( ( { id } ) => id ) );
}
} }
/>
),
id: 'selection',
cell: ( props ) => {
//console.log({ props });
const item = props.row.original;
const isSelected = selection.includes( item.id );
//console.log({ item, isSelected });
return (
<CheckboxControl
__nextHasNoMarginBottom
checked={ isSelected }
onChange={ () => {
if ( ! isSelected ) {
const newSelection = [
...selection,
item.id,
];
setSelection( newSelection );
} else {
setSelection(
selection.filter(
( id ) => id !== item.id
)
);
}
} }
/>
);
},
enableHiding: false,
width: 40,
} );
}
if ( actions?.length ) {
_columns.push( {
header: __( 'Actions' ),
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export default function PagePages() {
totalPages,
} = useEntityRecords( 'postType', postType, queryArgs );

// Remove any selected pages that are no longer in the list of visible pages.
useEffect( () => {
if (
selection.some(
Expand Down

0 comments on commit 652a32e

Please sign in to comment.