Auto calculate the height of the tables depending on the space left

Additionally make the footer lookup more unique seeing as we are in js
here
This commit is contained in:
John Cowen 2018-05-24 15:41:11 +01:00
parent 8f76a54c6a
commit 6489f1c401
2 changed files with 11 additions and 8 deletions

View File

@ -62,7 +62,7 @@ export default Component.extend(SlotsMixin, {
this._super(...arguments); this._super(...arguments);
this.change = change.bind(this); this.change = change.bind(this);
this.confirming = []; this.confirming = [];
// TODO: This should auto calculate properly from the CSS // TODO: The row height should auto calculate properly from the CSS
this['cell-layout'] = new ZIndexedGrid(get(this, 'width'), 50); this['cell-layout'] = new ZIndexedGrid(get(this, 'width'), 50);
this.handler = () => { this.handler = () => {
this.resize(createSizeEvent()); this.resize(createSizeEvent());
@ -86,12 +86,15 @@ export default Component.extend(SlotsMixin, {
window.removeEventListener('resize', this.handler); window.removeEventListener('resize', this.handler);
}, },
resize: function(e) { resize: function(e) {
const $footer = [...$$('#wrapper > footer')][0]; const $tbody = this.$('tbody').get(0);
const $thead = [...$$('main > div')][0]; if ($tbody) {
if ($thead) { const rect = $tbody.getBoundingClientRect();
// TODO: This should auto calculate properly from the CSS const $footer = [...$$('footer[role="contentinfo"]')][0];
this.set('height', Math.max(0, new Number(e.detail.height - ($footer.clientHeight + 218)))); const space = rect.top + $footer.clientHeight;
this['cell-layout'] = new ZIndexedGrid($thead.clientWidth, 50); const height = new Number(e.detail.height - space);
this.set('height', Math.max(0, height));
// TODO: The row height should auto calculate properly from the CSS
this['cell-layout'] = new ZIndexedGrid($tbody.clientWidth, 50);
this.updateItems(); this.updateItems();
this.updateScrollPosition(); this.updateScrollPosition();
} }

View File

@ -51,7 +51,7 @@
<main> <main>
{{yield}} {{yield}}
</main> </main>
<footer data-test-footer> <footer role="contentinfo" data-test-footer>
<a data-test-footer-copyright href="{{env 'CONSUL_COPYRIGHT_URL'}}/" rel="noopener noreferrer" target="_blank">&copy; {{env 'CONSUL_COPYRIGHT_YEAR'}} HashiCorp</a> <a data-test-footer-copyright href="{{env 'CONSUL_COPYRIGHT_URL'}}/" rel="noopener noreferrer" target="_blank">&copy; {{env 'CONSUL_COPYRIGHT_YEAR'}} HashiCorp</a>
<p data-test-footer-version>Consul {{env 'CONSUL_VERSION'}}</p> <p data-test-footer-version>Consul {{env 'CONSUL_VERSION'}}</p>
<a data-test-footer-docs href="{{env 'CONSUL_DOCUMENTATION_URL'}}/index.html" rel="help noopener noreferrer" target="_blank">Documentation</a> <a data-test-footer-docs href="{{env 'CONSUL_DOCUMENTATION_URL'}}/index.html" rel="help noopener noreferrer" target="_blank">Documentation</a>