Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-select action #1319

Merged
merged 1 commit into from
Dec 13, 2023
Merged

Add multi-select action #1319

merged 1 commit into from
Dec 13, 2023

Conversation

Fosol
Copy link
Collaborator

@Fosol Fosol commented Dec 13, 2023

Cleaned up component and page implementation to support a toolbar action to select all content.

@jdtoombs You can figure out how to make it look better. The select all highlights each row which is ugly.

Summary

  • Published tno-core:0.0.384
  • Fixed Flexboxtable compoent

List View

image

@Fosol Fosol added bug Something isn't working enhancement New feature or request subscriber PR contains changes towards the subscriber application, tno-core update Indicates that there have been changes to our tno-core package, which can pose concurrency issues. editor labels Dec 13, 2023
Published tno-core:0.0.384
/** whether or not this is being used on a list view */
onList?: boolean;
/** Whether the back button is displayed */
showBackButton?: boolean;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make components that are not tightly coupled to implementation if possible.

@@ -0,0 +1,5 @@
import { ContentActionBar, IContentActionBarProps } from './ContentActionBar';

export const ContentListActionBar: React.FC<IContentActionBarProps> = ({ className, ...rest }) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since a common implementation is to add the className, we can create a simple wrapper.

@@ -185,7 +185,7 @@ export const ViewContent: React.FC<IViewContentProps> = ({ setActiveContent }) =
<div className="source-section">{`${content?.section} ${
content?.page && `:${content.page}`
}`}</div>
{content?.tonePools && (
{content?.tonePools && content?.tonePools.length && (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed bug unrelated to this PR. Developers please don't assume an array has items in it.

@@ -33,28 +33,32 @@ export const Home: React.FC = () => {
},
{ findContentWithElasticsearch, storeHomeFilter: storeFilter },
] = useContent();
const [homeItems, setHomeItems] = React.useState<IContentModel[]>([]);
const navigate = useNavigate();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the organization convention alive. It's easier for all of us to read the code.

Place dependency hooks first.
Then React.useState
Then local variables
Then React.useEffect and functions

@@ -70,8 +70,7 @@ export class TableInternal<T extends object> implements ITableInternal<T> {
const rows = this.filterData(this.search).map((original, index) => {
const selected = this.selectedRowIds.some((id) => this._rowId(original) === id)
? true
: selectedRows.find((row) => this._rowId(row.original) === this._rowId(original))
?.isSelected ?? false;
: false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug, but I don't know whether this will break something else.

/** Event fires when back button is pressed */
onBack?: () => void;
/** Event fires when select all checkbox is changed */
onSelectAll?: React.ChangeEventHandler<HTMLInputElement>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an event to let the parent decide on implementation.

Copy link
Collaborator

@jdtoombs jdtoombs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, thanks for doing that. I needed fresh eyes

@Fosol Fosol merged commit 4446edb into bcgov:dev Dec 13, 2023
2 checks passed
@Fosol Fosol deleted the all branch December 13, 2023 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editor enhancement New feature or request subscriber PR contains changes towards the subscriber application, tno-core update Indicates that there have been changes to our tno-core package, which can pose concurrency issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants