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

feat: add option to customize row selection and row collapse #1

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
![npm version](https://img.shields.io/npm/v/ember-table)

# Changes by Lighthouse

This fork of ember-table is used by Lighthouse where the following changes have been made:

| PR | Short Description |
| --- | --- |
| https://github.com/OTA-Insight/ember-table/pull/1/ | Add ability to customise the row selection and row collapsing/expanding |

# Ember Table

An addon to support large data set and a number of features around table. Ember Table can
Expand Down
50 changes: 29 additions & 21 deletions addon/components/ember-td/template.hbs
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
{{#if this.isFirstColumn}}
<div class="et-cell-container">
{{#if this.canSelect}}
<span
class="et-toggle-select {{unless this.shouldShowCheckbox 'et-speech-only'}}"
data-test-select-row-container
>
<EmberTableSimpleCheckbox
@checked={{this.rowMeta.isGroupSelected}}
@onClick={{action "onSelectionToggled"}}
@ariaLabel="Select row"
@dataTestSelectRow={{this.isTesting}}
/>
<span></span>
</span>
{{#if (has-block "select")}}
{{yield this.rowMeta (action "onSelectionToggled") to="select"}}
{{else}}
<span
class="et-toggle-select {{unless this.shouldShowCheckbox 'et-speech-only'}}"
data-test-select-row-container
>
<EmberTableSimpleCheckbox
@checked={{this.rowMeta.isGroupSelected}}
@onClick={{action "onSelectionToggled"}}
@ariaLabel="Select row"
@dataTestSelectRow={{this.isTesting}}
/>
<span></span>
</span>
{{/if}}
{{/if}}

{{#if this.canCollapse}}
<span class="et-toggle-collapse et-depth-indent {{this.depthClass}}">
<EmberTableSimpleCheckbox
@checked={{this.rowMeta.isCollapsed}}
@onChange={{action "onCollapseToggled"}}
@ariaLabel="Collapse row"
@dataTestCollapseRow={{this.isTesting}}
/>
<span></span>
</span>
{{#if (has-block "collapse")}}
{{yield this.rowMeta (action "onCollapseToggled") to="collapse"}}
{{else}}
<span class="et-toggle-collapse et-depth-indent {{this.depthClass}}">
<EmberTableSimpleCheckbox
@checked={{this.rowMeta.isCollapsed}}
@onChange={{action "onCollapseToggled"}}
@ariaLabel="Collapse row"
@dataTestCollapseRow={{this.isTesting}}
/>
<span></span>
</span>
{{/if}}
{{else}}
<div class="et-depth-indent et-depth-placeholder {{this.depthClass}}"></div>
{{/if}}
Expand Down
8 changes: 8 additions & 0 deletions types/components/ember-td/component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ export interface EmberTdSignature<RowType, ColumnType> {
columnMeta: unknown,
rowMeta: TableRowMeta,
];
select?: [
rowMeta: TableRowMeta,
onSelectionToggled: () => void,
];
collapse?: [
rowMeta: TableRowMeta,
onCollapseToggled: () => void,
];
};
}

Expand Down