Skip to content

Commit

Permalink
Merge pull request Addepar#37 from Cuiyansong/row-loading-indicator-c…
Browse files Browse the repository at this point in the history
…omponent

Row loading indicator component
  • Loading branch information
Cuiyansong committed Jun 25, 2015
2 parents af4e077 + 57c81d6 commit 6b87e75
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 12 deletions.
8 changes: 8 additions & 0 deletions addon/styles/addon.less
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,14 @@
}
}

.row-loading-indicator {
display: inline-block;
position: relative;
width: 10px;
height: 10px;
margin-left: 5px;
}

//
// Financial theme is included by default.
//
Expand Down
17 changes: 17 additions & 0 deletions addon/views/row-loading-indicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Ember from 'ember';

export default Ember.View.extend({
templateName: 'row-loading-indicator',

classNameBindings: ['indicatorClass'],

isLoading: false,

indicatorClass: Ember.computed(function() {
var classNames = ['row-loading-indicator'];
if (this.get('isLoading')) {
classNames.push('loading');
}
return classNames.join(' ');
}).property('isLoading')
});
20 changes: 11 additions & 9 deletions app/templates/grouping-column-cell.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{{#if view.isLoading}}
<img class="loading-indicator" src="/ember-table/images/loading.gif" width="75px" height="15px">
{{view "row-loading-indicator"
isLoading=view.isLoading
}}
{{else}}
{{view view.indicatorView
hasChildren=view.hasChildren
isExpanded=view.isExpanded
expandLevel=view.expandLevel
}}
<span class="ember-table-content">
{{view.cellContent}}
</span>
{{view view.indicatorView
hasChildren=view.hasChildren
isExpanded=view.isExpanded
expandLevel=view.expandLevel
}}
<span class="ember-table-content">
{{view.cellContent}}
</span>
{{/if}}
1 change: 1 addition & 0 deletions app/templates/row-loading-indicator.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img class="loading-indicator" src="/ember-table/images/loading.gif" width="75px" height="15px">
3 changes: 3 additions & 0 deletions app/views/row-loading-indicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import RowLoadingIndicator from 'ember-table/views/row-loading-indicator';

export default RowLoadingIndicator;
2 changes: 2 additions & 0 deletions tests/helpers/module-for-ember-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default function moduleForEmberTable(description, subject) {
needs: [
'view:body-table-container',
'view:column-sortable-indicator',
'view:row-loading-indicator',
'view:footer-table-container',
'view:header-cell',
'view:header-row',
Expand All @@ -33,6 +34,7 @@ export default function moduleForEmberTable(description, subject) {
'template:table-cell',
'template:table-row',
'template:grouping-column-cell',
'template:row-loading-indicator',
'template:grouped-row-indicator'
],
subject: subject
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/components/loading-indicator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ test('render loading indicator', function(assert) {
var component = this.subject([{id: 1, isLoading: true}]);
this.render();
var helper = EmberTableHelper.create({ _assert: assert, _component: component});

var loadingRow = helper.bodyRows().eq(0);

assert.equal(loadingRow.find('.loading-indicator').length, 3, 'should render loading indicator');
});


test('expand grouped rows', function(assert) {
var component = this.subject([firstRowObject]);
this.render();
Expand All @@ -55,5 +54,5 @@ test('expand grouped rows', function(assert) {

secondRow = helper.bodyRows().eq(1);
var firstChildrenId = secondRow.find('.ember-table-content:eq(0)').text().trim();
assert.equal(firstChildrenId, '11', 'it should render chidlren');
assert.equal(firstChildrenId, '11', 'it should render children');
});

0 comments on commit 6b87e75

Please sign in to comment.