Bri Prebilic Cole

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
...@@ -70,5 +70,14 @@ ...@@ -70,5 +70,14 @@
70 } 70 }
71 }; 71 };
72 72
73 + }])
74 +
75 + // create a general ng-repeat complete notifier directive
76 + .directive('ngRepeatDone', [function () {
77 + return function (scope, element, attrs) {
78 + if(scope.$last) {
79 + scope.$emit('LastElement');
80 + }
81 + }
73 }]); 82 }]);
74 }()); 83 }());
......
...@@ -113,7 +113,6 @@ ...@@ -113,7 +113,6 @@
113 }; 113 };
114 }]) 114 }])
115 115
116 - // TODO: find another solution other than timeout for waiting for ng-repeat to end
117 .directive('onosFixedHeader', ['$window', '$timeout', 116 .directive('onosFixedHeader', ['$window', '$timeout',
118 'MastService', 'FnService', 117 'MastService', 'FnService',
119 function (_$window_, $timeout, mast, _fs_) { 118 function (_$window_, $timeout, mast, _fs_) {
...@@ -121,7 +120,8 @@ ...@@ -121,7 +120,8 @@
121 $window = _$window_; 120 $window = _$window_;
122 fs = _fs_; 121 fs = _fs_;
123 var w = angular.element($window), 122 var w = angular.element($window),
124 - table = d3.select(element[0]); 123 + table = d3.select(element[0]),
124 + shouldResize = false;
125 125
126 scope.$watch(function () { 126 scope.$watch(function () {
127 return { 127 return {
...@@ -136,10 +136,16 @@ ...@@ -136,10 +136,16 @@
136 scope.windowWidth = newVal.w; 136 scope.windowWidth = newVal.w;
137 137
138 scope.setTableHW = function () { 138 scope.setTableHW = function () {
139 - $timeout(function () { 139 + scope.$on('LastElement', function (event) {
140 fixTable(table, thead, tbody); 140 fixTable(table, thead, tbody);
141 - }, 250); 141 + shouldResize = true;
142 + });
142 }; 143 };
144 +
145 + if (shouldResize) {
146 + fixTable(table, thead, tbody);
147 + }
148 +
143 }, true); 149 }, true);
144 150
145 w.bind('onos-fixed-header', function () { 151 w.bind('onos-fixed-header', function () {
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
18 </thead> 18 </thead>
19 19
20 <tbody> 20 <tbody>
21 - <tr ng-repeat="dev in ctrl.deviceData"> 21 + <tr ng-repeat="dev in ctrl.deviceData"
22 + ng-repeat-done>
22 <td><div icon icon-id="{{dev._iconid_available}}"></div></td> 23 <td><div icon icon-id="{{dev._iconid_available}}"></div></td>
23 <td>{{dev.id}}</td> 24 <td>{{dev.id}}</td>
24 <td>{{dev.mfr}}</td> 25 <td>{{dev.mfr}}</td>
......