Skip to content

Commit

Permalink
Remove action from the data-table-content-body component
Browse files Browse the repository at this point in the history
  • Loading branch information
Windvis committed Nov 12, 2024
1 parent c1bc7be commit bbaa19e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
24 changes: 11 additions & 13 deletions addon/components/data-table-content-body.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { set } from '@ember/object';
import { computed } from '@ember/object';
import { action, computed } from '@ember/object';
import Component from '@ember/component';
import layout from '../templates/components/data-table-content-body';

Expand Down Expand Up @@ -32,16 +32,14 @@ export default Component.extend({
});
}
),
actions: {
updateSelection(selectedWrapper, event) {
set(selectedWrapper, 'isSelected', event.target.checked);
this.wrappedItems.forEach((wrapper) => {
if (wrapper.isSelected) {
this.get('data-table').addItemToSelection(wrapper.item);
} else {
this.get('data-table').removeItemFromSelection(wrapper.item);
}
});
},
},
updateSelection: action(function (selectedWrapper, event) {
set(selectedWrapper, 'isSelected', event.target.checked);
this.wrappedItems.forEach((wrapper) => {
if (wrapper.isSelected) {
this.get('data-table').addItemToSelection(wrapper.item);
} else {
this.get('data-table').removeItemFromSelection(wrapper.item);
}
});
}),
});
3 changes: 2 additions & 1 deletion addon/templates/components/data-table-content-body.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<tr role="button" class="{{if (includes wrapper.item this.data-table.selection) "selected"}} {{if this.onClickRow "clickable"}}" {{on "click" (fn (optional this.onClickRow) wrapper.item)}}>
{{#if this.enableSelection}}
<td class="center">
<Input @type="checkbox" @checked={{wrapper.isSelected}} {{on "click" (action "updateSelection" wrapper)}} />
hello
<Input @type="checkbox" @checked={{wrapper.isSelected}} {{on "click" (fn this.updateSelection wrapper)}} />
</td>
{{/if}}
{{#if this.enableLineNumbers}}
Expand Down

0 comments on commit bbaa19e

Please sign in to comment.