@@ -11135,6 +11135,7 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1113511135 * <li>.selectionMatchProp - (string) Property of the items to use for determining matching, default is 'uuid'
1113611136 * <li>.onCheckBoxChange - ( function(item) ) Called to notify when a checkbox selection changes, default is none
1113711137 * <li>.itemsAvailable - (boolean) If 'false', displays the {@link patternfly.views.component:pfEmptyState Empty State} component.
11138+ * <li>.showCheckboxes - (boolean) Show checkboxes for row selection, default is true
1113811139 * </ul>
1113911140 * @param {object} dtOptions Optional angular-datatables DTOptionsBuilder configuration object. See {@link http://l-lin.github.io/angular-datatables/archives/#/api angular-datatables: DTOptionsBuilder}
1114011141 * @param {array} items Array of items to display in the table view.
@@ -11160,7 +11161,7 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1116011161 <example module="patternfly.tableview.demo">
1116111162 <file name="index.html">
1116211163 <div ng-controller="TableCtrl" class="row example-container">
11163- <div class="col-md-12">
11164+ <div class="col-md-12" ng-if="showComponent" >
1116411165 <pf-table-view id="exampleTableView"
1116511166 config="config"
1116611167 empty-state-config="emptyStateConfig"
@@ -11177,6 +11178,11 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1117711178 <input type="checkbox" ng-model="config.itemsAvailable">Items Available</input>
1117811179 </label>
1117911180 </div>
11181+ <div class="form-group">
11182+ <label class="checkbox-inline">
11183+ <input type="checkbox" ng-model="config.showCheckboxes" ng-change="addNewComponentToDOM()">Show Checkboxes</input>
11184+ </label>
11185+ </div>
1118011186 </div>
1118111187 <hr class="col-md-12">
1118211188 <div class="col-md-12">
@@ -11194,8 +11200,8 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1119411200 </file>
1119511201
1119611202 <file name="controller.js">
11197- angular.module('patternfly.tableview.demo').controller('TableCtrl', ['$scope', 'itemsService',
11198- function ($scope, itemsService) {
11203+ angular.module('patternfly.tableview.demo').controller('TableCtrl', ['$scope', '$timeout', ' itemsService',
11204+ function ($scope, $timeout, itemsService) {
1119911205 $scope.dtOptions = {
1120011206 order: [[2, "asc"]],
1120111207 };
@@ -11214,7 +11220,8 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1121411220 $scope.config = {
1121511221 onCheckBoxChange: handleCheckBoxChange,
1121611222 selectionMatchProp: "name",
11217- itemsAvailable: true
11223+ itemsAvailable: true,
11224+ showCheckboxes: true
1121811225 };
1121911226
1122011227 $scope.emptyStateConfig = {
@@ -11281,6 +11288,13 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1128111288 }
1128211289 ];
1128311290
11291+ $scope.showComponent = true;
11292+
11293+ $scope.addNewComponentToDOM = function () {
11294+ $scope.showComponent = false;
11295+ $timeout(() => $scope.showComponent = true);
11296+ };
11297+
1128411298 (function init() {
1128511299 itemsService.getItems()
1128611300 .then(items => $scope.items = items);
@@ -11368,7 +11382,8 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1136811382 * <li>.selectionMatchProp - (string) Property of the items to use for determining matching, default is 'uuid'
1136911383 * <li>.onCheckBoxChange - ( function(item) ) Called to notify when a checkbox selection changes, default is none
1137011384 * <li>.itemsAvailable - (boolean) If 'false', displays the {@link patternfly.views.component:pfEmptyState Empty State} component.
11371- * </ul>
11385+ * <li>.showCheckboxes - (boolean) Show checkboxes for row selection, default is true
11386+ * </ul>
1137211387 * @param {object} dtOptions Optional angular-datatables DTOptionsBuilder configuration object. See {@link http://l-lin.github.io/angular-datatables/archives/#/api angular-datatables: DTOptionsBuilder}
1137311388 * @param {array} items Array of items to display in the table view.
1137411389 * @param {array} columns Array of table column information to display in the table's header row
@@ -11396,7 +11411,7 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1139611411 <div class="col-md-12">
1139711412 <pf-toolbar id="exampleToolbar" config="toolbarConfig"></pf-toolbar>
1139811413 </div>
11399- <div class="col-md-12">
11414+ <div class="col-md-12" ng-if="showComponent" >
1140011415 <pf-table-view config="tableConfig"
1140111416 empty-state-config="emptyStateConfig"
1140211417 dt-options="dtOptions"
@@ -11419,6 +11434,11 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1141911434 <input ng-model="dtOptions.displayLength" ng-disabled="!usePagination" style="width: 24px; padding-left: 6px;"> # Rows Per Page</input>
1142011435 </label> --!>
1142111436 </div>
11437+ <div class="form-group">
11438+ <label class="checkbox-inline">
11439+ <input type="checkbox" ng-model="tableConfig.showCheckboxes" ng-change="addNewComponentToDOM()">Show Checkboxes</input>
11440+ </label>
11441+ </div>
1142211442 </div>
1142311443 <hr class="col-md-12">
1142411444 <div class="col-md-12">
@@ -11435,8 +11455,8 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1143511455 </file>
1143611456
1143711457 <file name="script.js">
11438- angular.module('patternfly.tableview.demo').controller('ViewCtrl', ['$scope', 'pfViewUtils', '$filter',
11439- function ($scope, pfViewUtils, $filter) {
11458+ angular.module('patternfly.tableview.demo').controller('ViewCtrl', ['$scope', '$timeout', ' pfViewUtils', '$filter',
11459+ function ($scope, $timeout, pfViewUtils, $filter) {
1144011460 $scope.actionsText = "";
1144111461
1144211462 $scope.columns = [
@@ -11745,7 +11765,8 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1174511765 $scope.tableConfig = {
1174611766 onCheckBoxChange: handleCheckBoxChange,
1174711767 selectionMatchProp: "name",
11748- itemsAvailable: true
11768+ itemsAvailable: true,
11769+ showCheckboxes: true
1174911770 };
1175011771
1175111772 $scope.emptyStateConfig = {
@@ -11815,6 +11836,13 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1181511836 handleCheckBoxChange();
1181611837 }
1181711838 };
11839+
11840+ $scope.showComponent = true;
11841+
11842+ $scope.addNewComponentToDOM = function () {
11843+ $scope.showComponent = false;
11844+ $timeout(() => $scope.showComponent = true);
11845+ };
1181811846 }
1181911847 ]);
1182011848 </file>
@@ -11855,7 +11883,8 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1185511883
1185611884 ctrl.defaultConfig = {
1185711885 selectionMatchProp: 'uuid',
11858- onCheckBoxChange: null
11886+ onCheckBoxChange: null,
11887+ showCheckboxes: true
1185911888 };
1186011889
1186111890 ctrl.$onInit = function () {
@@ -11982,18 +12011,22 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1198212011
1198312012 function setColumnDefs () {
1198412013 var i = 0, actnBtns = 1;
11985- var item, prop;
12014+ var item, prop, offset;
12015+ ctrl.dtColumnDefs = [];
1198612016
1198712017 // add checkbox col, not sortable
11988- ctrl.dtColumnDefs = [ DTColumnDefBuilder.newColumnDef(i++).notSortable() ];
12018+ if (ctrl.config.showCheckboxes) {
12019+ ctrl.dtColumnDefs.push(DTColumnDefBuilder.newColumnDef(i++).notSortable());
12020+ }
1198912021
1199012022 // add column definitions
1199112023 _.forEach(ctrl.columns, function (column) {
1199212024 ctrl.dtColumnDefs.push(DTColumnDefBuilder.newColumnDef(i++));
1199312025 });
1199412026
11995- // Determine selectionMatchProp column number (add 1 due to the checkbox column)
11996- ctrl.selectionMatchPropColNum = _.findIndex(ctrl.columns, ['itemField', ctrl.config.selectionMatchProp]) + 1;
12027+ // Determine selectionMatchProp column number (add offset due to the checkbox column)
12028+ offset = ctrl.config.showCheckboxes ? 1 : 0;
12029+ ctrl.selectionMatchPropColNum = _.findIndex(ctrl.columns, ['itemField', ctrl.config.selectionMatchProp]) + offset;
1199712030
1199812031 // add actions col.
1199912032 if (ctrl.actionButtons && ctrl.actionButtons.length > 0) {
@@ -12056,43 +12089,45 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1205612089 }
1205712090
1205812091 function selectRowsByChecked () {
12059- $timeout(function () {
12060- var oTable, rows, checked;
12092+ if (ctrl.config.showCheckboxes) {
12093+ $timeout(function () {
12094+ var oTable, rows, checked;
1206112095
12062- oTable = ctrl.dtInstance.DataTable;
12096+ oTable = ctrl.dtInstance.DataTable;
1206312097
12064- if (ctrl.debug) {
12065- $log.debug(" selectRowsByChecked");
12066- }
12098+ if (ctrl.debug) {
12099+ $log.debug(" selectRowsByChecked");
12100+ }
1206712101
12068- if (angular.isUndefined(oTable)) {
12069- return;
12070- }
12102+ if (angular.isUndefined(oTable)) {
12103+ return;
12104+ }
1207112105
12072- if (ctrl.debug) {
12073- $log.debug(" ...oTable defined");
12074- }
12106+ if (ctrl.debug) {
12107+ $log.debug(" ...oTable defined");
12108+ }
1207512109
12076- // deselect all
12077- rows = oTable.rows();
12078- rows.deselect();
12110+ // deselect all
12111+ rows = oTable.rows();
12112+ rows.deselect();
1207912113
12080- // select those with checked checkboxes
12081- rows = oTable.rows( function ( idx, data, node ) {
12082- // row td input type=checkbox
12083- checked = node.children[0].children[0].checked;
12084- return checked;
12085- });
12114+ // select those with checked checkboxes
12115+ rows = oTable.rows( function ( idx, data, node ) {
12116+ // row td input type=checkbox
12117+ checked = node.children[0].children[0].checked;
12118+ return checked;
12119+ });
1208612120
12087- if (ctrl.debug) {
12088- $log.debug(" ... #checkedRows = " + rows[0].length);
12089- }
12121+ if (ctrl.debug) {
12122+ $log.debug(" ... #checkedRows = " + rows[0].length);
12123+ }
1209012124
12091- if (rows[0].length > 0) {
12092- rows.select();
12093- }
12094- setSelectAllCheckbox();
12095- });
12125+ if (rows[0].length > 0) {
12126+ rows.select();
12127+ }
12128+ setSelectAllCheckbox();
12129+ });
12130+ }
1209612131 }
1209712132
1209812133 function setSelectAllCheckbox () {
@@ -16382,7 +16417,7 @@ angular.module('patternfly.wizard').component('pfWizard', {
1638216417 'use strict';
1638316418
1638416419 $templateCache.put('table/tableview/table-view.html',
16385- "<div class=container-fluid><table ng-if=\"$ctrl.config.itemsAvailable !== false\" datatable=ng dt-options=$ctrl.dtOptions dt-column-defs=$ctrl.dtColumnDefs dt-instance=$ctrl.dtInstanceCallback class=\"table-view-container table table-striped table-bordered table-hover dataTable\"><thead><tr role=row><th class=table-view-pf-select><input type=checkbox value=$ctrl.selectAll ng-model=$ctrl.selectAll ng-change=\"$ctrl.toggleAll()\"></th><th ng-repeat=\"col in $ctrl.columns\">{{col.header}}</th><th ng-if=$ctrl.areActions() colspan={{$ctrl.calcActionsColspan()}}>Actions</th></tr></thead><tbody><tr role=row ng-repeat=\"item in $ctrl.items track by $index\"><td class=table-view-pf-select><input type=checkbox value=item.selected ng-model=item.selected ng-change=\"$ctrl.toggleOne(item)\"></td><td ng-repeat=\"(key, value) in item\" ng-if=$ctrl.isColItemFld(key)>{{ value }}</td><td ng-if=\"$ctrl.actionButtons && $ctrl.actionButtons.length > 0\" class=table-view-pf-actions ng-repeat=\"actionButton in $ctrl.actionButtons\"><div class=table-view-pf-btn><button class=\"btn btn-default\" title={{actionButton.title}} ng-click=\"$ctrl.handleButtonAction(actionButton, item)\"><span ng-if=!actionButton.include>{{actionButton.name}}</span></button></div></td><td ng-if=\"$ctrl.menuActions && $ctrl.menuActions.length > 0\" class=\"table-view-pf-actions list-group-item-header\"><div uib-dropdown class=\"{{$ctrl.dropdownClass}} dropdown-kebab-pf\" id=kebab_{{$index}} ng-if=\"$ctrl.menuActions && $ctrl.menuActions.length > 0\"><button uib-dropdown-toggle class=\"btn btn-default dropdown-toggle\" type=button id=dropdownKebabRight_{{$index}} ng-click=\"$ctrl.setupActions(item, $event)\"><span class=\"fa fa-ellipsis-v\"></span></button><ul uib-dropdown-menu class=\"dropdown-menu dropdown-menu-right {{$index}}\" aria-labelledby=dropdownKebabRight_{{$index}}><li ng-repeat=\"menuAction in $ctrl.menuActions\" ng-if=\"menuAction.isVisible !== false\" role=\"{{menuAction.isSeparator === true ? 'separator' : 'menuitem'}}\" ng-class=\"{'divider': (menuAction.isSeparator === true), 'disabled': (menuAction.isDisabled === true)}\"><a ng-if=\"menuAction.isSeparator !== true\" title={{menuAction.title}} ng-click=\"$ctrl.handleMenuAction(menuAction, item)\">{{menuAction.name}}</a></li></ul></div></td></tr></tbody></table><pf-empty-state ng-if=\"$ctrl.config.itemsAvailable === false\" config=$ctrl.emptyStateConfig></pf-empty-state></div>"
16420+ "<div class=container-fluid><table ng-if=\"$ctrl.config.itemsAvailable !== false\" datatable=ng dt-options=$ctrl.dtOptions dt-column-defs=$ctrl.dtColumnDefs dt-instance=$ctrl.dtInstanceCallback class=\"table-view-container table table-striped table-bordered table-hover dataTable\"><thead><tr role=row><th class=table-view-pf-select ng-if=$ctrl.config.showCheckboxes><input type=checkbox value=$ctrl.selectAll ng-model=$ctrl.selectAll ng-change=\"$ctrl.toggleAll()\"></th><th ng-repeat=\"col in $ctrl.columns\">{{col.header}}</th><th ng-if=$ctrl.areActions() colspan={{$ctrl.calcActionsColspan()}}>Actions</th></tr></thead><tbody><tr role=row ng-repeat=\"item in $ctrl.items track by $index\"><td class=table-view-pf-select ng-if=$ctrl.config.showCheckboxes><input type=checkbox value=item.selected ng-model=item.selected ng-change=\"$ctrl.toggleOne(item)\"></td><td ng-repeat=\"(key, value) in item\" ng-if=$ctrl.isColItemFld(key)>{{ value }}</td><td ng-if=\"$ctrl.actionButtons && $ctrl.actionButtons.length > 0\" class=table-view-pf-actions ng-repeat=\"actionButton in $ctrl.actionButtons\"><div class=table-view-pf-btn><button class=\"btn btn-default\" title={{actionButton.title}} ng-click=\"$ctrl.handleButtonAction(actionButton, item)\"><span ng-if=!actionButton.include>{{actionButton.name}}</span></button></div></td><td ng-if=\"$ctrl.menuActions && $ctrl.menuActions.length > 0\" class=\"table-view-pf-actions list-group-item-header\"><div uib-dropdown class=\"{{$ctrl.dropdownClass}} dropdown-kebab-pf\" id=kebab_{{$index}} ng-if=\"$ctrl.menuActions && $ctrl.menuActions.length > 0\"><button uib-dropdown-toggle class=\"btn btn-default dropdown-toggle\" type=button id=dropdownKebabRight_{{$index}} ng-click=\"$ctrl.setupActions(item, $event)\"><span class=\"fa fa-ellipsis-v\"></span></button><ul uib-dropdown-menu class=\"dropdown-menu dropdown-menu-right {{$index}}\" aria-labelledby=dropdownKebabRight_{{$index}}><li ng-repeat=\"menuAction in $ctrl.menuActions\" ng-if=\"menuAction.isVisible !== false\" role=\"{{menuAction.isSeparator === true ? 'separator' : 'menuitem'}}\" ng-class=\"{'divider': (menuAction.isSeparator === true), 'disabled': (menuAction.isDisabled === true)}\"><a ng-if=\"menuAction.isSeparator !== true\" title={{menuAction.title}} ng-click=\"$ctrl.handleMenuAction(menuAction, item)\">{{menuAction.name}}</a></li></ul></div></td></tr></tbody></table><pf-empty-state ng-if=\"$ctrl.config.itemsAvailable === false\" config=$ctrl.emptyStateConfig></pf-empty-state></div>"
1638616421 );
1638716422
1638816423}]);
0 commit comments