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

head & foot: make table.height optional, warn in table-header mixin #449

Merged
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
12 changes: 3 additions & 9 deletions addon/components/lt-foot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import layout from 'ember-light-table/templates/components/lt-foot';
import TableHeaderMixin from 'ember-light-table/mixins/table-header';

const {
assert,
Component,
isEmpty,
set
get,
trySet
} = Ember;

/**
Expand Down Expand Up @@ -46,11 +45,6 @@ export default Component.extend(TableHeaderMixin, {
init() {
this._super(...arguments);

let sharedOptions = this.get('sharedOptions') || {};
let fixed = this.get('fixed');

assert('[ember-light-table] The height property is required for fixed footer', !fixed || fixed && !isEmpty(sharedOptions.height));

set(sharedOptions, 'fixedFooter', fixed);
trySet(this, 'sharedOptions.fixedFooter', get(this, 'fixed'));
}
});
12 changes: 3 additions & 9 deletions addon/components/lt-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import layout from 'ember-light-table/templates/components/lt-head';
import TableHeaderMixin from 'ember-light-table/mixins/table-header';

const {
assert,
Component,
isEmpty,
set
get,
trySet
} = Ember;

/**
Expand Down Expand Up @@ -48,11 +47,6 @@ export default Component.extend(TableHeaderMixin, {
init() {
this._super(...arguments);

let sharedOptions = this.get('sharedOptions') || {};
let fixed = this.get('fixed');

assert('[ember-light-table] The height property is required for fixed header', !fixed || fixed && !isEmpty(sharedOptions.height));

set(sharedOptions, 'fixedHeader', fixed);
trySet(this, 'sharedOptions.fixedHeader', get(this, 'fixed'));
}
});
17 changes: 16 additions & 1 deletion addon/mixins/table-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import Ember from 'ember';

const {
computed,
Mixin
isEmpty,
Mixin,
warn
} = Ember;

/**
Expand Down Expand Up @@ -105,6 +107,19 @@ export default Mixin.create({
return this.getProperties(['iconAscending', 'iconDescending']);
}).readOnly(),

init() {
this._super(...arguments);

let fixed = this.get('fixed');
let height = this.get('sharedOptions.height');

warn(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shouldn't be necessary as warn is supposed to be an empty function in a production build. I have not actually verified this though.

https://www.emberjs.com/api/#method_warn

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just checked Ember.warn in our production deployment. It's indeed an empty function. 😄

'You did not set a `height` attribute for your table, but marked a header or footer to be fixed. This means that you have to set the table height via CSS. For more information please refer to: https://github.com/offirgolan/ember-light-table/issues/446',
!fixed || fixed && !isEmpty(height),
{ id: 'ember-light-table.height-attribute' }
);
},

actions: {
/**
* onColumnClick action. Handles column sorting.
Expand Down