Skip to content

Commit

Permalink
Merge branch 'ember-fix-800-issue' of https://github.com/lifeart/js-f…
Browse files Browse the repository at this point in the history
…ramework-benchmark into lifeart-ember-fix-800-issue
  • Loading branch information
krausest committed Nov 7, 2020
2 parents 886a1db + 6d56b27 commit 9949c5f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
9 changes: 0 additions & 9 deletions frameworks/keyed/ember/app/components/my-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,11 @@ export default class MyTable extends Component {
}

@action remove(id) {
const selected = this.data.find(({selected}) => selected === true);
if (selected) {
selected.selected = false;
}
this.data = deleteRow(this.data, id);
this.selected = undefined;
}

@action select(id) {
this.selected = id;
const selected = this.data.find(({selected}) => selected === true);
if (selected) {
selected.selected = false;
}
this.data.find((item)=>item.id === id).selected = true;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- template-lint-disable --}}
<tr class={{if @item.selected "danger"}}>
<tr ...attributes>
<td class="col-md-1">{{@item.id}}</td>
<td class="col-md-4"><a {{on 'click' @onSelect}}>{{@item.label}}</a></td>
<td class="col-md-1"><a {{on 'click' @onRemove}}><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

{{#if this.data.length}}
<FastEach class="table table-hover table-striped test-data" @items={{this.data}} as |item|>
<TableRow @item={{item}} @onSelect={{fn this.select item.id}} @onRemove={{fn this.remove item.id}} />
<TableRow class={{if (eq this.selected item.id) 'danger'}} @item={{item}} @onSelect={{fn this.select item.id}} @onRemove={{fn this.remove item.id}} />
</FastEach>
{{/if}}

Expand Down
5 changes: 1 addition & 4 deletions frameworks/keyed/ember/app/utils/benchmark-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { tracked } from '@glimmer/tracking';

class TodoItem {
@tracked label;
@tracked selected;
@tracked id
constructor({label,selected, id}) {
constructor({label, id}) {
this.label = label;
this.selected = selected;
this.id = id;
}
}
Expand Down Expand Up @@ -43,7 +41,6 @@ export const buildData = (id, count = 1000) => {
for (var i = 0; i < count; i++)
data.push(new TodoItem({
id: id++,
selected: false,
label: adjectives[_random(adjectives.length)]
+ " "
+ colours[_random(colours.length)]
Expand Down

0 comments on commit 9949c5f

Please sign in to comment.