Skip to content

Commit 2cbef9d

Browse files
committed
Remove ember-composable-helpers
We don't really need it, and the few couple of helpers we use can be easily implemented as a private helper where needed.
1 parent b705e5d commit 2cbef9d

8 files changed

+26
-354
lines changed

addon/components/au-data-table.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
noDataMessage=this.noDataMessage
2323
enableSelection=this.enableSelection
2424
enableLineNumbers=this.enableLineNumbers
25-
onClickRow=(optional this.onClickRow)
25+
onClickRow=this.onClickRow
2626
data-table=this
2727
)
2828
)
@@ -42,7 +42,7 @@
4242
@noDataMessage={{this.noDataMessage}}
4343
@enableSelection={{this.enableSelection}}
4444
@enableLineNumbers={{this.enableLineNumbers}}
45-
@onClickRow={{optional this.onClickRow}}
45+
@onClickRow={{this.onClickRow}}
4646
@data-table={{this}}
4747
/>
4848
{{/if}}

addon/components/au-data-table/content-body.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
{{#each this.wrappedItems as |wrapper index|}}
66
<tr
77
class={{if
8-
(includes wrapper.item this.data-table.selection)
8+
(this.includes this.data-table.selection wrapper.item)
99
"selected"
1010
}}
11-
{{on "click" (fn (optional this.onClickRow) wrapper.item)}}
11+
{{on "click" (fn (this.optional this.onClickRow) wrapper.item)}}
1212
{{!template-lint-disable no-invalid-interactive}}
1313
>
1414
{{#if this.enableSelection}}

addon/components/au-data-table/content-body.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { action, computed } from '@ember/object';
44
import Component from '@ember/component';
55

66
// Source: https://github.com/mu-semtech/ember-data-table/blob/c690a3948b2d9d5f91d69f0a935c6b5cdb4862ca/addon/components/data-table-content-body.js
7-
export default Component.extend({
7+
const ContentBody = Component.extend({
88
tagName: 'tbody',
99
init() {
1010
this._super(...arguments);
@@ -42,7 +42,16 @@ export default Component.extend({
4242
}
4343
});
4444
}),
45+
});
46+
47+
export default ContentBody.extend({
4548
add(a, b) {
4649
return a + b;
47-
}
50+
},
51+
includes(array, item) {
52+
return array.includes(item);
53+
},
54+
optional(maybeFunction) {
55+
return typeof maybeFunction === 'function' ? maybeFunction : () => {};
56+
},
4857
});

addon/components/au-data-table/content.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
enableSelection=this.enableSelection
1717
enableLineNumbers=this.enableLineNumbers
1818
noDataMessage=this.noDataMessage
19-
onClickRow=(optional this.onClickRow)
19+
onClickRow=this.onClickRow
2020
data-table=this.data-table
2121
)
2222
)
@@ -32,7 +32,7 @@
3232
@enableSelection={{this.enableSelection}}
3333
@enableLineNumbers={{this.enableLineNumbers}}
3434
@noDataMessage={{this.noDataMessage}}
35-
@onClickRow={{optional this.onClickRow}}
35+
@onClickRow={{this.onClickRow}}
3636
@data-table={{this.data-table}}
3737
/>
3838
{{/if}}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{{#unless this.data-table.selectionIsEmpty}}
2-
{{yield
3-
(slice 0 this.selectionCount this.data-table.selection)
4-
this.data-table
5-
}}
2+
{{yield this.selection this.data-table}}
63
{{/unless}}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable ember/no-classic-classes, ember/no-classic-components, ember/no-get, ember/require-tagless-components */
2-
import { action } from '@ember/object';
2+
import { action, computed } from '@ember/object';
33
import { reads } from '@ember/object/computed';
44
import Component from '@ember/component';
55

66
// Source: https://github.com/mu-semtech/ember-data-table/blob/c690a3948b2d9d5f91d69f0a935c6b5cdb4862ca/addon/components/data-table-menu-selected.js
7-
export default Component.extend({
7+
const MenuSelected = Component.extend({
88
init: function () {
99
this._super(...arguments);
1010
this.set('data-table.enableSelection', true);
@@ -14,3 +14,9 @@ export default Component.extend({
1414
this.get('data-table').clearSelection();
1515
}),
1616
});
17+
18+
export default MenuSelected.extend({
19+
selection: computed('data-table.selection.[]', function () {
20+
return this.get('data-table.selection').slice();
21+
}),
22+
});

0 commit comments

Comments
 (0)