@@ -14,7 +14,7 @@ angular.module('patternfly.table').component('pfTableView', {
1414 templateUrl : 'table/tableview/table-view.html' ,
1515 controller : function ( DTOptionsBuilder , DTColumnDefBuilder , $element , pfUtils , $log , $filter , $timeout , $sce ) {
1616 'use strict' ;
17- var ctrl = this , prevDtOptions , prevItems ;
17+ var ctrl = this , prevDtOptions , prevItems , prevPageConfig ;
1818
1919 // Once datatables is out of active development I'll remove log statements
2020 ctrl . debug = false ;
@@ -40,16 +40,7 @@ angular.module('patternfly.table').component('pfTableView', {
4040 showCheckboxes : true
4141 } ;
4242
43- ctrl . $onInit = function ( ) {
44-
45- if ( ctrl . debug ) {
46- $log . debug ( "$onInit" ) ;
47- }
48-
49- if ( angular . isDefined ( ctrl . colummns ) && angular . isUndefined ( ctrl . columns ) ) {
50- ctrl . columns = ctrl . colummns ;
51- }
52-
43+ function setPagination ( ) {
5344 if ( angular . isUndefined ( ctrl . dtOptions ) ) {
5445 ctrl . dtOptions = { } ;
5546 } else {
@@ -59,16 +50,16 @@ angular.module('patternfly.table').component('pfTableView', {
5950 if ( angular . isUndefined ( ctrl . pageConfig ) ) {
6051 ctrl . pageConfig = { } ;
6152 }
62- if ( angular . isUndefined ( ctrl . pageConfig . pageNumber ) ) {
53+ if ( ! angular . isNumber ( ctrl . pageConfig . pageNumber ) ) {
6354 ctrl . pageConfig . pageNumber = 1 ;
6455 }
6556 }
66- if ( angular . isDefined ( ctrl . dtOptions . displayLength ) ) {
57+ if ( angular . isNumber ( ctrl . dtOptions . displayLength ) ) {
6758 ctrl . dtOptions . paging = true ;
6859 if ( angular . isUndefined ( ctrl . pageConfig ) ) {
6960 ctrl . pageConfig = { } ;
7061 }
71- if ( angular . isUndefined ( ctrl . pageConfig . pageSize ) ) {
62+ if ( ! angular . isNumber ( ctrl . pageConfig . pageSize ) ) {
7263 ctrl . pageConfig . pageSize = ctrl . dtOptions . displayLength ;
7364 }
7465 }
@@ -92,6 +83,17 @@ angular.module('patternfly.table').component('pfTableView', {
9283 ctrl . pageConfig . pageNumber = 1 ;
9384 }
9485 }
86+ }
87+
88+ ctrl . $onInit = function ( ) {
89+
90+ if ( ctrl . debug ) {
91+ $log . debug ( "$onInit" ) ;
92+ }
93+
94+ if ( angular . isDefined ( ctrl . colummns ) && angular . isUndefined ( ctrl . columns ) ) {
95+ ctrl . columns = ctrl . colummns ;
96+ }
9597
9698 if ( angular . isUndefined ( ctrl . config ) ) {
9799 ctrl . config = { } ;
@@ -103,19 +105,22 @@ angular.module('patternfly.table').component('pfTableView', {
103105 } ;
104106
105107 ctrl . updateConfigOptions = function ( ) {
106- var col , props = "" ;
108+ var props = "" ;
107109
108110 if ( ctrl . debug ) {
109111 $log . debug ( " updateConfigOptions" ) ;
110112 }
111113
114+ setPagination ( ) ;
115+
112116 if ( angular . isDefined ( ctrl . dtOptions ) && angular . isDefined ( ctrl . dtOptions . displayLength ) ) {
113117 ctrl . dtOptions . displayLength = Number ( ctrl . dtOptions . displayLength ) ;
114118 }
115119
116120 // Need to deep watch changes in dtOptions and items
117121 prevDtOptions = angular . copy ( ctrl . dtOptions ) ;
118122 prevItems = angular . copy ( ctrl . items ) ;
123+ prevPageConfig = angular . copy ( ctrl . pageConfig ) ;
119124
120125 // Setting bound variables to new variables loses it's one way binding
121126 // ctrl.dtOptions = pfUtils.merge(ctrl.defaultDtOptions, ctrl.dtOptions);
@@ -143,7 +148,6 @@ angular.module('patternfly.table').component('pfTableView', {
143148 } ;
144149
145150 ctrl . dtInstanceCallback = function ( _dtInstance ) {
146- var oTable , rows ;
147151 if ( ctrl . debug ) {
148152 $log . debug ( "--> dtInstanceCallback" ) ;
149153 }
@@ -188,7 +192,8 @@ angular.module('patternfly.table').component('pfTableView', {
188192 $log . debug ( "$doCheck" ) ;
189193 }
190194 // do a deep compare on dtOptions and items
191- if ( ! angular . equals ( ctrl . dtOptions , prevDtOptions ) ) {
195+ if ( ! angular . equals ( ctrl . dtOptions , prevDtOptions ) ||
196+ ! angular . equals ( ctrl . pageConfig , prevPageConfig ) ) {
192197 if ( ctrl . debug ) {
193198 $log . debug ( " dtOptions !== prevDtOptions" ) ;
194199 }
@@ -223,7 +228,7 @@ angular.module('patternfly.table').component('pfTableView', {
223228
224229 function setColumnDefs ( ) {
225230 var i = 0 , actnBtns = 1 ;
226- var item , prop , offset ;
231+ var offset ;
227232 ctrl . dtColumnDefs = [ ] ;
228233
229234 // add checkbox col, not sortable
@@ -368,7 +373,6 @@ angular.module('patternfly.table').component('pfTableView', {
368373 // returns ['Mary Jane', 'Fred Flinstone', 'Frank Livingston']
369374 //
370375 var i , rowData , visibleRows = new Array ( ) ;
371- var oTable = ctrl . dtInstance . dataTable ;
372376
373377 var anNodes = document . querySelectorAll ( "#" + ctrl . tableId + " tbody tr" ) ;
374378
@@ -455,7 +459,8 @@ angular.module('patternfly.table').component('pfTableView', {
455459 } ) ;
456460 } ;
457461
458- ctrl . checkDisabled = function ( item ) {
462+ ctrl . checkDisabled = function ( ) {
463+ //TODO: implement checkDisabled
459464 return false ;
460465 } ;
461466
0 commit comments