[Tables] #733 Made code style changes for conformance with style guide

This commit is contained in:
Henry
2016-03-14 11:25:26 -07:00
parent c5de90a951
commit fc08df4f6f
7 changed files with 122 additions and 92 deletions

View File

@@ -57,10 +57,12 @@ define(
metadata.forEach(function (metadatum) { metadata.forEach(function (metadatum) {
//Push domains first //Push domains first
(metadatum.domains || []).forEach(function (domainMetadata) { (metadatum.domains || []).forEach(function (domainMetadata) {
self.addColumn(new DomainColumn(domainMetadata, self.telemetryFormatter)); self.addColumn(new DomainColumn(domainMetadata,
self.telemetryFormatter));
}); });
(metadatum.ranges || []).forEach(function (rangeMetadata) { (metadatum.ranges || []).forEach(function (rangeMetadata) {
self.addColumn(new RangeColumn(rangeMetadata, self.telemetryFormatter)); self.addColumn(new RangeColumn(rangeMetadata,
self.telemetryFormatter));
}); });
}); });
@@ -125,7 +127,9 @@ define(
// Don't replace something with nothing. // Don't replace something with nothing.
// This occurs when there are multiple columns with the // This occurs when there are multiple columns with the
// column title // column title
if (rowObject[columnTitle] === undefined || rowObject[columnTitle].text === undefined || rowObject[columnTitle].text.length === 0) { if (rowObject[columnTitle] === undefined ||
rowObject[columnTitle].text === undefined ||
rowObject[columnTitle].text.length === 0) {
rowObject[columnTitle] = columnValue; rowObject[columnTitle] = columnValue;
} }
return rowObject; return rowObject;
@@ -136,7 +140,8 @@ define(
* @private * @private
*/ */
TableConfiguration.prototype.defaultColumnConfiguration = function () { TableConfiguration.prototype.defaultColumnConfiguration = function () {
return ((this.domainObject.getModel().configuration || {}).table || {}).columns || {}; return ((this.domainObject.getModel().configuration || {}).table ||
{}).columns || {};
}; };
/** /**
@@ -169,7 +174,9 @@ define(
* existing (persisted) configuration if available * existing (persisted) configuration if available
*/ */
this.getHeaders().forEach(function (columnTitle) { this.getHeaders().forEach(function (columnTitle) {
configuration[columnTitle] = typeof defaultConfig[columnTitle] === 'undefined' ? true : defaultConfig[columnTitle]; configuration[columnTitle] =
typeof defaultConfig[columnTitle] === 'undefined' ? true :
defaultConfig[columnTitle];
}); });
return configuration; return configuration;

View File

@@ -115,7 +115,8 @@ define(
MCTTableController.prototype.onScroll = function (event) { MCTTableController.prototype.onScroll = function (event) {
//If user scrolls away from bottom, disable auto-scroll. //If user scrolls away from bottom, disable auto-scroll.
// Auto-scroll will be re-enabled if user scrolls to bottom again. // Auto-scroll will be re-enabled if user scrolls to bottom again.
if (this.scrollable[0].scrollTop < (this.scrollable[0].scrollHeight - this.scrollable[0].offsetHeight)) { if (this.scrollable[0].scrollTop <
(this.scrollable[0].scrollHeight - this.scrollable[0].offsetHeight)) {
this.$scope.autoScroll = false; this.$scope.autoScroll = false;
} else { } else {
this.$scope.autoScroll = true; this.$scope.autoScroll = true;
@@ -144,7 +145,8 @@ define(
if (this.$scope.displayRows.length < this.maxDisplayRows) { if (this.$scope.displayRows.length < this.maxDisplayRows) {
//Check whether need to resynchronize visible with display //Check whether need to resynchronize visible with display
// rows (if data added) // rows (if data added)
if (this.$scope.visibleRows.length != this.$scope.displayRows.length){ if (this.$scope.visibleRows.length !=
this.$scope.displayRows.length){
start = 0; start = 0;
end = this.$scope.displayRows.length; end = this.$scope.displayRows.length;
} else { } else {
@@ -159,11 +161,13 @@ define(
firstVisible = 0; firstVisible = 0;
} else { } else {
firstVisible = Math.floor( firstVisible = Math.floor(
(topScroll - this.$scope.headerHeight) / this.$scope.rowHeight (topScroll - this.$scope.headerHeight) /
this.$scope.rowHeight
); );
} }
lastVisible = Math.ceil( lastVisible = Math.ceil(
(bottomScroll - this.$scope.headerHeight) / this.$scope.rowHeight (bottomScroll - this.$scope.headerHeight) /
this.$scope.rowHeight
); );
totalVisible = lastVisible - firstVisible; totalVisible = lastVisible - firstVisible;
@@ -173,12 +177,14 @@ define(
if (start < 0) { if (start < 0) {
start = 0; start = 0;
end = Math.min(this.maxDisplayRows, this.$scope.displayRows.length); end = Math.min(this.maxDisplayRows,
this.$scope.displayRows.length);
} else if (end >= this.$scope.displayRows.length) { } else if (end >= this.$scope.displayRows.length) {
end = this.$scope.displayRows.length; end = this.$scope.displayRows.length;
start = end - this.maxDisplayRows + 1; start = end - this.maxDisplayRows + 1;
} }
if (this.$scope.visibleRows[0] && this.$scope.visibleRows[0].rowIndex === start && if (this.$scope.visibleRows[0] &&
this.$scope.visibleRows[0].rowIndex === start &&
this.$scope.visibleRows[this.$scope.visibleRows.length - 1] this.$scope.visibleRows[this.$scope.visibleRows.length - 1]
.rowIndex === end) { .rowIndex === end) {
@@ -213,7 +219,8 @@ define(
} }
// Reset column sort information unless the new headers // Reset column sort information unless the new headers
// contain the column currently sorted on. // contain the column currently sorted on.
if (this.$scope.enableSort && newHeaders.indexOf(this.$scope.sortColumn) === -1) { if (this.$scope.enableSort &&
newHeaders.indexOf(this.$scope.sortColumn) === -1) {
this.$scope.sortColumn = undefined; this.$scope.sortColumn = undefined;
this.$scope.sortDirection = undefined; this.$scope.sortDirection = undefined;
} }
@@ -234,7 +241,8 @@ define(
rowHeight = 20, rowHeight = 20,
columnWidth, columnWidth,
tableWidth = 0, tableWidth = 0,
overallHeight = headerHeight + (rowHeight * (this.$scope.displayRows ? this.$scope.displayRows.length - 1 : 0)); overallHeight = headerHeight + (rowHeight *
(this.$scope.displayRows ? this.$scope.displayRows.length - 1 : 0));
this.$scope.columnWidths = []; this.$scope.columnWidths = [];
@@ -248,12 +256,14 @@ define(
this.$scope.rowHeight = rowHeight; this.$scope.rowHeight = rowHeight;
this.$scope.totalHeight = overallHeight; this.$scope.totalHeight = overallHeight;
this.setVisibleRows(); this.setVisibleRows();
this.$scope.overrideRowPositioning = true;
if (tableWidth > 0) { if (tableWidth > 0) {
this.$scope.totalWidth = tableWidth + 'px'; this.$scope.totalWidth = tableWidth + 'px';
} else { } else {
this.$scope.totalWidth = 'none'; this.$scope.totalWidth = 'none';
} }
this.$scope.overrideRowPositioning = true;
}; };
/** /**
@@ -272,16 +282,22 @@ define(
return min; // Element is not in array, min gives direction return min; // Element is not in array, min gives direction
} }
valA = isNaN(searchElement[sortKey].text) ? searchElement[sortKey].text : parseFloat(searchElement[sortKey].text); valA = isNaN(searchElement[sortKey].text) ?
valB = isNaN(searchArray[sampleAt][sortKey].text) ? searchArray[sampleAt][sortKey].text : searchArray[sampleAt][sortKey].text; searchElement[sortKey].text :
parseFloat(searchElement[sortKey].text);
valB = isNaN(searchArray[sampleAt][sortKey].text) ?
searchArray[sampleAt][sortKey].text :
searchArray[sampleAt][sortKey].text;
switch(self.sortComparator(valA, valB)) { switch(self.sortComparator(valA, valB)) {
case -1: case -1:
return binarySearch(searchArray, searchElement, min, sampleAt - 1); return binarySearch(searchArray, searchElement, min,
sampleAt - 1);
case 0 : case 0 :
return sampleAt; return sampleAt;
case 1 : case 1 :
return binarySearch(searchArray, searchElement, sampleAt + 1, max); return binarySearch(searchArray, searchElement,
sampleAt + 1, max);
} }
} }
@@ -352,8 +368,10 @@ define(
//If the values to compare can be compared as //If the values to compare can be compared as
// numbers, do so. String comparison of number // numbers, do so. String comparison of number
// values can cause inconsistencies // values can cause inconsistencies
var valA = isNaN(a[sortKey].text) ? a[sortKey].text : parseFloat(a[sortKey].text), var valA = isNaN(a[sortKey].text) ? a[sortKey].text :
valB = isNaN(b[sortKey].text) ? b[sortKey].text : parseFloat(b[sortKey].text); parseFloat(a[sortKey].text),
valB = isNaN(b[sortKey].text) ? b[sortKey].text :
parseFloat(b[sortKey].text);
return self.sortComparator(valA, valB); return self.sortComparator(valA, valB);
}); });

View File

@@ -94,7 +94,8 @@ define(
self.$scope.rows = [row]; self.$scope.rows = [row];
} else { } else {
self.$scope.rows.push(row); self.$scope.rows.push(row);
self.$scope.$broadcast('add:row', self.$scope.rows.length - 1); self.$scope.$broadcast('add:row',
self.$scope.rows.length - 1);
} }
} }
}); });

View File

@@ -54,7 +54,8 @@ define(
this.handle = undefined; this.handle = undefined;
//this.pending = false; //this.pending = false;
this.telemetryHandler = telemetryHandler; this.telemetryHandler = telemetryHandler;
this.table = new TableConfiguration($scope.domainObject, telemetryFormatter); this.table = new TableConfiguration($scope.domainObject,
telemetryFormatter);
this.changeListeners = []; this.changeListeners = [];
$scope.rows = undefined; $scope.rows = undefined;
@@ -84,10 +85,12 @@ define(
this.changeListeners = []; this.changeListeners = [];
// When composition changes, re-subscribe to the various // When composition changes, re-subscribe to the various
// telemetry subscriptions // telemetry subscriptions
this.changeListeners.push(this.$scope.$watchCollection('domainObject.getModel().composition', this.subscribe.bind(this))); this.changeListeners.push(this.$scope.$watchCollection(
'domainObject.getModel().composition', this.subscribe.bind(this)));
//Change of bounds in time conductor //Change of bounds in time conductor
this.changeListeners.push(this.$scope.$on('telemetry:display:bounds', this.subscribe.bind(this))); this.changeListeners.push(this.$scope.$on('telemetry:display:bounds',
this.subscribe.bind(this)));
}; };
/** /**
@@ -141,7 +144,8 @@ define(
i = 0; i = 0;
for (; i < pointCount; i++) { for (; i < pointCount; i++) {
rowData.push(self.table.getRowValues(telemetryObject, self.handle.makeDatum(telemetryObject, series, i))); rowData.push(self.table.getRowValues(telemetryObject,
self.handle.makeDatum(telemetryObject, series, i)));
} }
}); });
@@ -157,7 +161,7 @@ define(
self = this; self = this;
if (handle) { if (handle) {
handle.promiseTelemetryObjects().then(function (objects) { handle.promiseTelemetryObjects().then(function () {
table.buildColumns(handle.getMetadata()); table.buildColumns(handle.getMetadata());
self.filterColumns(); self.filterColumns();