Skip to content

Table fillup mode#424

Merged
billy-addepar merged 10 commits into2.0from
billy/fillup-columns
Oct 2, 2017
Merged

Table fillup mode#424
billy-addepar merged 10 commits into2.0from
billy/fillup-columns

Conversation

@billy-addepar
Copy link
Copy Markdown
Contributor

Add table fill up mode for table when total columns width does not match table width. The extra space can go to either the first column or be distributed equally among all columns.

@billy-addepar
Copy link
Copy Markdown
Contributor Author

@pzuraq

@billy-addepar
Copy link
Copy Markdown
Contributor Author

Ready for review

@cyril-sf
Copy link
Copy Markdown
Contributor

Are there tests for the first_column and last_column modes?

Comment thread addon/components/ember-table.js Outdated
}
} else if (tableFillupMode === TABLE_FILLUP_MODE_LAST_COLUMN) {
// Add all delta to last column
columns[columns.length - 1].set('width', columns[columns.length - 1].get('width') + delta);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would store columns[columns.length - 1] in a variable to make this line easier to read (you're doing it right above)

Comment thread tests/dummy/app/templates/simple.hbs Outdated
}}
{{#ember-table-row
row=t

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

empty lines are weird

@billy-addepar
Copy link
Copy Markdown
Contributor Author

Tests added. Comments addressed

});

test(`Test ${headerTest}column fill up - none mode`, async function(assert) {
await setupFullTable(this, {}, { headerComponent: customHeader });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would enforce the mode here instead of making assumptions about the default value of the template.


assert.ok(
Math.abs(tableWidth - firstColumnWidth - 180 * (headerCount - 1)) <= 1,
'First column takes extra sapce in first column fill up mode.');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo space


const headerCount = findAll('.et-thead tr th').length;
for (let i = 1; i <= headerCount; i++) {
assert.equal(tableHelpers.getHeaderElement(i).offsetWidth, 180,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would create a constant in the test file otherwise it's not easy to understand where this value comes from

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also the sample data doesn't seem to allow to fully test that option, no? (why would they all be the same unless the test data forces that behavior?)

const headerCount = findAll('.et-thead tr th').length;
for (let i = 1; i <= headerCount; i++) {
assert.equal(tableHelpers.getHeaderElement(i).offsetWidth, 180,
'Table header have same width in proportional fill up mode.');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is the none mode.

@billy-addepar
Copy link
Copy Markdown
Contributor Author

Comments addressed

}
} else if (tableFillupMode === TABLE_FILLUP_MODE_EQUAL_COLUMN) {
// Split delta by their proportion.
const columnDelta = delta / columns.length;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need to do something for the remainder?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is real number division. You do not have to worry about remainder.

@billy-addepar
Copy link
Copy Markdown
Contributor Author

Bump

Comment thread addon/components/ember-table.js Outdated
* 3) "first_column": extra space is added into the first column.
* 4) "last_column": extra space is added into the last column.
*/
@property tableFillupMode = TABLE_FILLUP_MODE_NONE;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's call this tableResizeMode, without context I don't think people will understand what "fillup" means here, whereas "resize" gives them a bit more of a hint

@billy-addepar
Copy link
Copy Markdown
Contributor Author

Name changed.

Copy link
Copy Markdown
Contributor

@pzuraq pzuraq left a comment

Choose a reason for hiding this comment

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

Awesome, looks good to merge!

@billy-addepar billy-addepar dismissed cyril-sf’s stale review October 2, 2017 17:45

All comments addressed

@billy-addepar billy-addepar merged commit 7a20d17 into 2.0 Oct 2, 2017
@bantic bantic deleted the billy/fillup-columns branch July 11, 2019 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants