Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #226 from dalogsdon/report-height-computation
Browse files Browse the repository at this point in the history
Report fix: proper empty cell computation
  • Loading branch information
parente committed Apr 19, 2016
2 parents cd5a64c + 160a526 commit ef348d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ define([
];
}

// Must wait for CSS to be evaluated before we generate the grid. Otherwise, positioning
// is calculated incorrectly.
// Must wait for CSS to be evaluated before we generate the grid.
// Otherwise, positioning is calculated incorrectly.
$.when.apply(null, cssLoaded).then(function() {
var nolayout = this._addMetadataToDom(); // returns cells that don't have metadata

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,34 @@ define([
this.$container = opts.$container;

if (!cssLoaded) {
cssLoaded = [
linkCSS('./dashboard-view/layout/report/layout.css')
];
cssLoaded = linkCSS('./dashboard-view/layout/report/layout.css');
}

Metadata.dashboardLayout = Metadata.DASHBOARD_LAYOUT.REPORT;

// setup cells for report layout
var self = this;
this.$container.find('.cell').each(function() {
var $cell = $(this);

// hide cell if empty
if ($cell.height() === 0 && !Metadata.getCellLayout($cell)) {
Metadata.hideCell($cell);
}

// set hidden state
$cell.toggleClass('dashboard-hidden dashboard-collapsed', !Metadata.isCellVisible($cell));

// add controle for hide, add, edit
self._addCellControls($cell);

self._updateCollapseBtns();
});
$.when(cssLoaded).then(function() {
// setup cells for report layout
var self = this;
this.$container.find('.cell')
.css('min-height', '0px') // we detect empty cells by height
.each(function() {
var $cell = $(this);

// hide cell if empty
if ($cell.height() === 0 && !Metadata.getCellLayout($cell)) {
Metadata.hideCell($cell);
}

// set hidden state
$cell.toggleClass('dashboard-hidden dashboard-collapsed', !Metadata.isCellVisible($cell));

// add controle for hide, add, edit
self._addCellControls($cell);

self._updateCollapseBtns();
})
.css('min-height','');
}.bind(this));
}

ReportLayout.prototype._addCellControls = function($cell) {
Expand Down

0 comments on commit ef348d8

Please sign in to comment.