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

Fix demo and css for selection #21

Merged
merged 1 commit into from
Jun 9, 2017
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
27 changes: 17 additions & 10 deletions addon/components/frost-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,31 @@ export default Component.extend({
this.set('_isShiftDown', event.shiftKey)
}
},
setCellWidths (position) {
const curBodyColumn = this.$().find('.frost-table-row .frost-table-body-cell:nth-child(' + (position) + ')')
const curHeaderCell = this.$().find('.frost-table-header-cell:nth-child(' + (position) + ')')

const bodyCellWidth = curBodyColumn.outerWidth(true)
const headerCellWidth = curHeaderCell.outerWidth(true)

const width = bodyCellWidth > headerCellWidth ? bodyCellWidth : headerCellWidth

curHeaderCell.css('width', width + 'px')
curBodyColumn.css('width', width + 'px')
},
// == DOM Events ============================================================

// == Lifecycle Hooks =======================================================

didInsertElement () {
run.schedule('afterRender', this, function () {
const selectable = this.get('_isSelectable')
if (selectable) {
this.setCellWidths(1)
}
this.columns.forEach((column, index) => {
const curBodyColumn = this.$().find('.frost-table-row .frost-table-body-cell:nth-child(' + (index + 1) + ')')
const curHeaderCell = this.$().find('.frost-table-header-cell:nth-child(' + (index + 1) + ')')

const bodyCellWidth = curBodyColumn.outerWidth(true)
const headerCellWidth = curHeaderCell.outerWidth(true)

const width = bodyCellWidth > headerCellWidth ? bodyCellWidth : headerCellWidth

curHeaderCell.css('width', width + 'px')
curBodyColumn.css('width', width + 'px')
let position = index + (selectable ? 2 : 1)
this.setCellWidths(position)
})
})
},
Expand Down
4 changes: 2 additions & 2 deletions addon/templates/components/frost-table-header.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{! Template for the frost-table-header component }}
{{#if isSelectable}}
<td class='frost-table-cell'>
<th class='frost-table-header-cell frost-table-cell'>
{{frost-table-header-selection
hook=(concat hookPrefix '-selectionCell')
hookQualifiers=(extend hookQualifiers column=column.index)

onSelectionChange=onSelectionChange
}}
</td>
</th>
{{/if}}
{{#each columns as |column|}}
{{frost-table-cell
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/frost-table-row.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{! Template for the frost-table-row component }}
{{#if isSelectable}}
<td class='frost-table-cell'>
<td class='frost-table-cell frost-table-body-cell'>
{{frost-table-row-selection
hook=(concat hookPrefix '-selectionCell')
hookQualifiers=(extend hookQualifiers column=column.index)
Expand Down
4 changes: 4 additions & 0 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ module.exports = function (environment) {
if (environment === 'production') {
ENV.locationType = 'hash'
ENV.rootURL = '/ember-frost-table'
ENV.mirageNamespace = 'https://ciena-frost.github.io'
ENV['ember-cli-mirage'] = {
enabled: true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this, I wasn't thinking about the gh-pages when I turned on mirage in my other PR

}

return ENV
Expand Down
5 changes: 5 additions & 0 deletions tests/dummy/mirage/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import config from '../config/environment'

export default function () {
if (config && config.mirageNamespace) {
this.namespace = config.mirageNamespace
}
this.get('/characters')
}