Skip to content

Commit

Permalink
feat(table): removing unnecessary method
Browse files Browse the repository at this point in the history
  • Loading branch information
conor-darcy committed Oct 17, 2024
1 parent 435a4c6 commit ae8a329
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,26 +438,11 @@ <h2>Data table with sortable columns</h2>
</gux-table>

<h2>Object table with rows selection</h2>
<ul>
<li>
Use the <strong>setChecked</strong> method on
<strong>gux-all-row-select</strong> to programatically manage the selected
state.
</li>
<li>
Use the <strong>setIndeterminate</strong> method to set the
indeterminate/unknown state on <strong>gux-all-row-select</strong>. Remember
to set it to false when the checkbox is checked or unchecked as it overrides
these states.
</li>
</ul>
<gux-button id="selectAll">Select all</gux-button>
<gux-button id="deselecAll">Deselect all</gux-button>
<gux-table object-table selectable-rows>
<table slot="data">
<thead>
<tr data-row-id="head">
<th><gux-all-row-select id="allRowSelect"></gux-all-row-select></th>
<th><gux-all-row-select></gux-all-row-select></th>
<th data-column-name="first-name">First name</th>
<th data-column-name="last-name">Last name</th>
<th data-column-name="age" data-cell-numeric>Age</th>
Expand Down Expand Up @@ -986,20 +971,6 @@ <h2>Data table with fixed columns</h2>
});
const selectAll = document.getElementById('selectAll');
const deselectAll = document.getElementById('deselecAll');
const allRowSelect = document.getElementById('allRowSelect');
selectAll.addEventListener('click', () => {
allRowSelect.setIndeterminate(false);
allRowSelect.setChecked(true);
});
deselectAll.addEventListener('click', () => {
allRowSelect.setIndeterminate(false);
allRowSelect.setChecked(false);
});
})()"
>
.not-used {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ export class GuxAllRowSelect {
this.inputElement.indeterminate = indeterminate;
}

@Method()
async setChecked(checked: boolean): Promise<void> {
this.selected = checked;
this.internalallrowselectchange.emit(this.selected);
}

async componentWillLoad(): Promise<void> {
this.i18n = await buildI18nForComponent(
this.root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,4 @@ describe('gux-all-row-select', () => {
await component.setIndeterminate(false);
expect(inputElement.indeterminate).toBe(false);
});

it('should handle the setChecked method', async () => {
const html = '<gux-all-row-select></gux-all-row-select>';
const page = await newSpecPage({ components, html, language });

const component = page.rootInstance;
const inputElement = page.root.shadowRoot.querySelector('input');

expect(inputElement.checked).toBe(false);

await component.setChecked(true);
await page.waitForChanges();
expect(inputElement.checked).toBe(true);

await component.setChecked(false);
await page.waitForChanges();
expect(inputElement.checked).toBe(false);
});
});

0 comments on commit ae8a329

Please sign in to comment.