Skip to content

Commit 25acc87

Browse files
committed
fixed #449: pfTableView with toolbar - inconsistent with design
1 parent 54eb08c commit 25acc87

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

src/table/table.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ table.dataTable.no-footer {
1414
padding: 0px;
1515
}
1616
table.dataTable {
17+
margin: 0;
1718
thead {
1819
.sorting_asc {
1920
background-image: none !important;

src/table/tableview/examples/table-view-with-toolbar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@
381381
$scope.toolbarConfig = {
382382
filterConfig: $scope.filterConfig,
383383
sortConfig: $scope.sortConfig,
384-
actionsConfig: $scope.toolbarActionsConfig
384+
actionsConfig: $scope.toolbarActionsConfig,
385+
isTableView: true
385386
};
386387
387388
$scope.tableConfig = {

src/table/tableview/table-view.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<span>
1+
<div class="container-fluid">
22
<table ng-if="$ctrl.config.itemsAvailable !== false"
33
datatable="ng" dt-options="$ctrl.dtOptions" dt-column-defs="$ctrl.dtColumnDefs" dt-instance="$ctrl.dtInstanceCallback"
44
class="table-view-container table table-striped table-bordered table-hover dataTable">
@@ -48,4 +48,4 @@
4848
</tbody>
4949
</table>
5050
<pf-empty-state ng-if="$ctrl.config.itemsAvailable === false" config="$ctrl.emptyStateConfig"></pf-empty-state>
51-
</span>
51+
</div>

src/toolbars/examples/toolbar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* </ul>
4444
* <li>.actionsInclude - (Boolean) set to true if using the actions transclude to add custom action buttons (only available if using Angular 1.5 or later)
4545
* </ul>
46+
* <li>.isTableView - (Boolean) set to true if toolbar is only being used with a table view and viewsConfig is not defined.
4647
* </ul>
4748
*
4849
* @example

src/toolbars/toolbar-component.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ angular.module('patternfly.toolbars').component('pfToolbar', {
2121
angular.extend(ctrl, {
2222
viewSelected: viewSelected,
2323
isViewSelected: isViewSelected,
24+
isTableViewSelected: isTableViewSelected,
2425
checkViewDisabled: checkViewDisabled,
2526
addFilter: addFilter,
2627
handleAction: handleAction
@@ -45,7 +46,7 @@ angular.module('patternfly.toolbars').component('pfToolbar', {
4546
ctrl.config.viewsConfig.viewsList = angular.copy(ctrl.config.viewsConfig.views);
4647

4748
if (!ctrl.config.viewsConfig.currentView) {
48-
ctrl.config.viewsConfig.currentView = ctrl.config.viewsConfig.viewsList[0];
49+
ctrl.config.viewsConfig.currentView = ctrl.config.viewsConfig.viewsList[0].id;
4950
}
5051
}
5152
}
@@ -61,6 +62,10 @@ angular.module('patternfly.toolbars').component('pfToolbar', {
6162
return ctrl.config.viewsConfig && (ctrl.config.viewsConfig.currentView === viewId);
6263
}
6364

65+
function isTableViewSelected () {
66+
return ctrl.config.viewsConfig ? (ctrl.config.viewsConfig.currentView === 'tableView') : ctrl.config.isTableView;
67+
}
68+
6469
function checkViewDisabled (view) {
6570
return ctrl.config.viewsConfig.checkViewDisabled && ctrl.config.viewsConfig.checkViewDisabled(view);
6671
}

src/toolbars/toolbar.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="container-fluid">
2-
<div class="row toolbar-pf">
2+
<div class="row toolbar-pf" ng-class="{'table-view-pf-toolbar': $ctrl.isTableViewSelected()}">
33
<div class="col-sm-12">
4-
<form class="toolbar-pf-actions" ng-class="{'no-filter-results': !$ctrl.config.filterConfig}">
4+
<form class="toolbar-pf-actions" ng-class="{'no-filter': !$ctrl.config.filterConfig}">
55
<div class="form-group toolbar-apf-filter">
66
<pf-filter-fields config="$ctrl.config.filterConfig" ng-if="$ctrl.config.filterConfig" add-filter-fn="$ctrl.addFilter"></pf-filter-fields>
77
</div>

src/toolbars/toolbars.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
opacity: 0;
2727
pointer-events: none;
2828
}
29-
.toolbar-pf-actions.no-filter-results {
29+
.toolbar-pf-actions.no-filter {
30+
margin-left: -30px;
3031
margin-bottom: 10px;
3132
}

test/toolbars/toolbar.spec.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,6 @@ describe('Directive: pfToolbar', function () {
282282
var active = element.find('.active');
283283

284284
expect(viewSelector.length).toBe(1);
285-
expect(active.length).toBe(0);
286-
287-
$scope.config.viewsConfig.currentView = $scope.config.viewsConfig.views[0].id;
288-
$scope.$apply();
289-
290-
active = element.find('.active');
291285
expect(active.length).toBe(1);
292286
});
293287

@@ -297,7 +291,7 @@ describe('Directive: pfToolbar', function () {
297291
var listSelector = element.find('.toolbar-pf-view-selector .btn-link');
298292

299293
expect(viewSelector.length).toBe(1);
300-
expect(active.length).toBe(0);
294+
expect(active.length).toBe(1);
301295
expect(listSelector.length).toBe(5);
302296

303297
eventFire(listSelector[0], 'click');

0 commit comments

Comments
 (0)