Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable components #177

Merged
merged 7 commits into from
Sep 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions addon/components/lt-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,48 @@ export default Component.extend({
*/
useVirtualScrollbar: false,

/**
* Allows to customize the component used to render rows
*
* ```hbs
* {{#light-table table as |t|}}
* {{t.body rowComponent=(component 'my-row')}}
* {{/light-table}}
* ```
* @property rowComponent
* @type {Ember.Component}
* @default null
*/
rowComponent: null,

/**
* Allows to customize the component used to render spanned rows
*
* ```hbs
* {{#light-table table as |t|}}
* {{t.body spannedRowComponent=(component 'my-spanned-row')}}
* {{/light-table}}
* ```
* @property rowComponent
* @type {Ember.Component}
* @default null
*/
spannedRowComponent: null,

/**
* Allows to customize the component used to render infinite loader
*
* ```hbs
* {{#light-table table as |t|}}
* {{t.body infinityComponent=(component 'my-infinity')}}
* {{/light-table}}
* ```
* @property rowComponent
* @type {Ember.Component}
* @default null
*/
infinityComponent: null,

rows: computed.readOnly('table.visibleRows'),
columns: computed.readOnly('table.visibleColumns'),
colspan: computed.readOnly('columns.length'),
Expand Down
24 changes: 21 additions & 3 deletions addon/templates/components/light-table.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{{yield (hash
head=(component 'lt-head' tableId=elementId table=table tableActions=tableActions tableClassNames=tableClassNames sharedOptions=sharedOptions)
body=(component 'lt-body' tableId=elementId table=table tableActions=tableActions tableClassNames=tableClassNames sharedOptions=sharedOptions)
foot=(component 'lt-foot' tableId=elementId table=table tableActions=tableActions tableClassNames=tableClassNames sharedOptions=sharedOptions)
head=(component 'lt-head'
tableId=elementId
table=table
tableActions=tableActions
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
body=(component 'lt-body'
tableId=elementId
table=table
tableActions=tableActions
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
foot=(component 'lt-foot'
tableId=elementId
table=table
tableActions=tableActions
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
)}}
79 changes: 43 additions & 36 deletions addon/templates/components/lt-body.hbs
Original file line number Diff line number Diff line change
@@ -1,43 +1,50 @@
{{#lt-scrollable
tagName=''
virtualScrollbar=useVirtualScrollbar
autoHide=autoHideScrollbar
{{#with (hash
row=(or rowComponent (component 'lt-row'))
spanned-row=(or spannedRowComponent (component 'lt-spanned-row'))
infinity=(or infinityComponent (component 'lt-infinity'))
) as |lt|
}}
<div id={{concat tableId '_inline_head'}} class="lt-inline lt-head"></div>
{{#lt-scrollable
tagName=''
virtualScrollbar=useVirtualScrollbar
autoHide=autoHideScrollbar
}}
<div id={{concat tableId '_inline_head'}} class="lt-inline lt-head"></div>

<table class={{tableClassNames}}>
<tbody class="lt-body">
{{#if overwrite}}
{{yield columns rows}}
{{else}}
{{#each rows as |row|}}
{{lt-row row columns
table=table
tableActions=tableActions
canExpand=canExpand
canSelect=canSelect
click=(action 'onRowClick' row)
doubleClick=(action 'onRowDoubleClick' row)}}
<table class={{tableClassNames}}>
<tbody class="lt-body">
{{#if overwrite}}
{{yield columns rows}}
{{else}}
{{#each rows as |row|}}
{{lt.row row columns
table=table
tableActions=tableActions
canExpand=canExpand
canSelect=canSelect
click=(action 'onRowClick' row)
doubleClick=(action 'onRowDoubleClick' row)}}

{{yield (hash
expanded-row=(component lt.spanned-row classes='lt-expanded-row' colspan=colspan yield=row visible=row.expanded)
loader=(component lt.spanned-row visible=false)
no-data=(component lt.spanned-row visible=false)
) rows}}
{{/each}}

{{yield (hash
expanded-row=(component 'lt-spanned-row' classes='lt-expanded-row' colspan=colspan yield=row visible=row.expanded)
loader=(component 'lt-spanned-row' visible=false)
no-data=(component 'lt-spanned-row' visible=false)
loader=(component lt.spanned-row classes='lt-is-loading' colspan=colspan)
no-data=(component lt.spanned-row classes='lt-no-data' colspan=colspan)
expanded-row=(component lt.spanned-row visible=false)
) rows}}
{{/each}}

{{yield (hash
loader=(component 'lt-spanned-row' classes='lt-is-loading' colspan=colspan)
no-data=(component 'lt-spanned-row' classes='lt-no-data' colspan=colspan)
expanded-row=(component 'lt-spanned-row' visible=false)
) rows}}
{{/if}}
</tbody>
</table>
{{/if}}
</tbody>
</table>

{{#if onScrolledToBottom}}
{{lt-infinity rows=rows onScrolledToBottom=onScrolledToBottom scrollBuffer=scrollBuffer}}
{{/if}}
{{#if onScrolledToBottom}}
{{lt.infinity rows=rows onScrolledToBottom=onScrolledToBottom scrollBuffer=scrollBuffer}}
{{/if}}

<div id={{concat tableId '_inline_foot'}} class="lt-inline lt-foot"></div>
{{/lt-scrollable}}
<div id={{concat tableId '_inline_foot'}} class="lt-inline lt-foot"></div>
{{/lt-scrollable}}
{{/with}}
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"jquery": "2.2.4"
},
"resolutions": {
"ember": "2.3.1"
"ember": "2.3.1",
"jquery": "2.2.4"
},
"devDependencies": {
"blanket": "5e94fc30f2e694bb5c3718ddcbf60d467f4b4d26",
"ember-qunit-notifications": "0.1.0"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"ember-cli": "^2.8.0",
"ember-cli-app-version": "^2.0.0",
"ember-cli-autoprefixer": "0.6.0",
"ember-cli-blanket": "0.9.9",
"ember-cli-changelog": "0.3.4",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-es5-shim": "0.3.0",
Expand All @@ -50,6 +49,7 @@
"ember-font-awesome": "2.2.0",
"ember-load-initializers": "^0.5.1",
"ember-lodash": "0.0.10",
"ember-owner-test-utils": "0.1.1",
"ember-resolver": "^2.0.3",
"ember-truth-helpers": "1.2.0",
"loader.js": "^4.0.1",
Expand Down
18 changes: 0 additions & 18 deletions tests/blanket-options.js

This file was deleted.

4 changes: 0 additions & 4 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">
<style>#blanket-main { position: relative; z-index: 99999; }</style>

{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
Expand All @@ -26,10 +25,7 @@
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="{{rootURL}}assets/blanket-options.js"></script>
<script src="{{rootURL}}assets/blanket-loader.js"></script>
<script src="{{rootURL}}assets/tests.js"></script>
<script src="{{rootURL}}assets/test-loader.js"></script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
Expand Down
Loading