-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
205 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { test } from 'qunit'; | ||
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; | ||
|
||
moduleForAcceptance('Acceptance | index'); | ||
|
||
test('visiting /custom-actions', function(assert) { | ||
server.create('user', {firstName: 'Joe'}); | ||
visit('/custom-actions'); | ||
|
||
andThen(function() { | ||
assert.equal($('td:contains(Joe)').length, 1); | ||
assert.equal(server.db.users.length, 1); | ||
click('.delete'); | ||
|
||
andThen(function() { | ||
assert.equal($('td:contains(Joe)').length, 0); | ||
assert.equal(server.db.users.length, 0); | ||
assert.equal(currentURL(), '/custom-actions'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Ember from 'ember'; | ||
import CheckboxColumn from 'ember-data-table-light/columns/checkbox'; | ||
import Table from 'ember-light-table'; | ||
|
||
const { | ||
Controller | ||
} = Ember; | ||
|
||
export default Controller.extend({ | ||
collapseCodeSnippet: true, | ||
activeTab: 0, | ||
|
||
init() { | ||
this._super(...arguments); | ||
this.set('table', new Table(this.get('columns'))); | ||
}, | ||
|
||
columns: [ | ||
CheckboxColumn, | ||
{ | ||
label: 'First Name', | ||
valuePath: 'firstName', | ||
width: '150px' | ||
}, | ||
{ | ||
label: 'Last Name', | ||
valuePath: 'lastName', | ||
width: '150px' | ||
}, | ||
{ | ||
label: 'Address', | ||
valuePath: 'address' | ||
}, | ||
{ | ||
label: 'State', | ||
valuePath: 'state' | ||
}, | ||
{ | ||
label: 'Country', | ||
valuePath: 'country' | ||
}, | ||
{ | ||
cellComponent: 'custom-actions', | ||
hideable: false | ||
} | ||
], | ||
|
||
actions: { | ||
deleteUser(row) { | ||
row.get('content').destroyRecord().then(()=> { | ||
this.get('table').removeRow(row); | ||
}); | ||
}, | ||
|
||
setActiveTab(tab) { | ||
this.set('activeTab', tab); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a class='delete' {{action tableActions.deleteUser row}}>Delete</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<div class="panel-group" role="tablist" aria-multiselectable="true"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading" role="tab" id="table-1"> | ||
<a role="button" {{action (toggle "collapseCodeSnippet" this)}} href="#code-snippet" aria-expanded="true" aria-controls="code-snippet"> | ||
<h4 class="panel-title">Custom Actions Example <span class="code-icon fa fa-code pull-right"></span></h4> | ||
</a> | ||
</div> | ||
{{#bs-collapse collapsed=collapseCodeSnippet id="code-snippet" class="panel-collapse" role="tabpanel" aria-labelledby="table-1"}} | ||
<div class="panel-body code-snippet"> | ||
<ul class="nav nav-tabs" role="tablist"> | ||
<li role="presentation" class="{{if (eq activeTab 0) 'active'}}"> | ||
<a {{action "setActiveTab" 0}} href="#component" aria-controls="component" role="tab">component.js</a> | ||
</li> | ||
<li role="presentation" class="{{if (eq activeTab 1) 'active'}}"> | ||
<a {{action "setActiveTab" 1}} href="#template" aria-controls="template" role="tab">template.hbs</a> | ||
</li> | ||
<li role="presentation" class="{{if (eq activeTab 2) 'active'}}"> | ||
<a {{action "setActiveTab" 2}} href="#template" aria-controls="component" role="tab">custom-actions.hbs</a> | ||
</li> | ||
</ul> | ||
<div class="tab-content"> | ||
<div role="tabpanel" class="tab-pane fade {{if (eq activeTab 0) 'active in'}}" id="component">{{code-snippet name="custom-actions-table.js"}}</div> | ||
<div role="tabpanel" class="tab-pane fade {{if (eq activeTab 1) 'active in'}}" id="template">{{code-snippet name="simple-table.hbs"}}</div> | ||
<div role="tabpanel" class="tab-pane fade {{if (eq activeTab 2) 'active in'}}" id="template">{{code-snippet name="custom-actions.hbs"}}</div> | ||
</div> | ||
</div> | ||
{{/bs-collapse}} | ||
<div class="panel-body table-container fixed-header"> | ||
{{!-- BEGIN-SNIPPET simple-table --}} | ||
{{data-table 'user' tableActions=(hash deleteUser=(action 'deleteUser')) columns=columns table=table height='50vh'}} | ||
{{!-- END-SNIPPET --}} | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Ember from 'ember'; | ||
import CheckboxColumn from 'ember-data-table-light/columns/checkbox'; | ||
import Table from 'ember-light-table'; | ||
|
||
const { | ||
Controller | ||
} = Ember; | ||
|
||
export default Controller.extend({ | ||
|
||
init() { | ||
this._super(...arguments); | ||
this.set('table', new Table(this.get('columns'))); | ||
}, | ||
|
||
columns: [ | ||
CheckboxColumn, | ||
{ | ||
label: 'First Name', | ||
valuePath: 'firstName', | ||
width: '150px' | ||
}, | ||
{ | ||
label: 'Last Name', | ||
valuePath: 'lastName', | ||
width: '150px' | ||
}, | ||
{ | ||
label: 'Address', | ||
valuePath: 'address' | ||
}, | ||
{ | ||
label: 'State', | ||
valuePath: 'state' | ||
}, | ||
{ | ||
label: 'Country', | ||
valuePath: 'country' | ||
}, | ||
{ | ||
cellComponent: 'custom-actions', | ||
hideable: false | ||
} | ||
], | ||
|
||
actions: { | ||
deleteUser(row) { | ||
row.get('content').destroyRecord().then(()=> { | ||
this.get('table').removeRow(row); | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a class='delete' {{action tableActions.deleteUser row}}>Delete</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters