GUI -- Table scrolling fixed header directive no longer depends on a timeout function.

- Added a general directive that emits when ng-repeat is completed.

Change-Id: I23131adecded9f0393334d003812845ac6b4f031
This commit is contained in:
Bri Prebilic Cole 2015-02-10 10:53:15 -08:00
parent 1eab7d5f25
commit b0e66be049
3 changed files with 21 additions and 5 deletions

View File

@ -70,5 +70,14 @@
} }
}; };
}])
// create a general ng-repeat complete notifier directive
.directive('ngRepeatDone', [function () {
return function (scope, element, attrs) {
if(scope.$last) {
scope.$emit('LastElement');
}
}
}]); }]);
}()); }());

View File

@ -113,7 +113,6 @@
}; };
}]) }])
// TODO: find another solution other than timeout for waiting for ng-repeat to end
.directive('onosFixedHeader', ['$window', '$timeout', .directive('onosFixedHeader', ['$window', '$timeout',
'MastService', 'FnService', 'MastService', 'FnService',
function (_$window_, $timeout, mast, _fs_) { function (_$window_, $timeout, mast, _fs_) {
@ -121,7 +120,8 @@
$window = _$window_; $window = _$window_;
fs = _fs_; fs = _fs_;
var w = angular.element($window), var w = angular.element($window),
table = d3.select(element[0]); table = d3.select(element[0]),
shouldResize = false;
scope.$watch(function () { scope.$watch(function () {
return { return {
@ -136,10 +136,16 @@
scope.windowWidth = newVal.w; scope.windowWidth = newVal.w;
scope.setTableHW = function () { scope.setTableHW = function () {
$timeout(function () { scope.$on('LastElement', function (event) {
fixTable(table, thead, tbody); fixTable(table, thead, tbody);
}, 250); shouldResize = true;
});
}; };
if (shouldResize) {
fixTable(table, thead, tbody);
}
}, true); }, true);
w.bind('onos-fixed-header', function () { w.bind('onos-fixed-header', function () {

View File

@ -18,7 +18,8 @@
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="dev in ctrl.deviceData"> <tr ng-repeat="dev in ctrl.deviceData"
ng-repeat-done>
<td><div icon icon-id="{{dev._iconid_available}}"></div></td> <td><div icon icon-id="{{dev._iconid_available}}"></div></td>
<td>{{dev.id}}</td> <td>{{dev.id}}</td>
<td>{{dev.mfr}}</td> <td>{{dev.mfr}}</td>