diff --git a/Gruntfile.js b/Gruntfile.js
index e2a380e4b..3779ed6a1 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -384,6 +384,11 @@ module.exports = function (grunt) {
src: ['form/**/*.html'],
dest: 'templates/form.js'
},
+ 'patternfly.bulkselection': {
+ cwd: 'src/',
+ src: ['bulkselection/**/*.html'],
+ dest: 'templates/bulkselection.js'
+ },
'patternfly.navigation': {
cwd: 'src/',
src: ['navigation/**/*.html'],
diff --git a/src/bulkselection/bulkselection.component.js b/src/bulkselection/bulkselection.component.js
new file mode 100644
index 000000000..7187a9930
--- /dev/null
+++ b/src/bulkselection/bulkselection.component.js
@@ -0,0 +1,59 @@
+angular.module('patternfly.bulkselection').component('pfBulkSelection', {
+
+ bindings: {
+ totalRecords: '=',
+ selectedRecordCount: '=',
+ updateSelectionFn: '<'
+ },
+ templateUrl: 'bulkselection/bulkselection.html',
+ controller: function () {
+ 'use strict';
+
+ var ctrl = this;
+ var BULKSELECTION_NONE = 'none';
+ var BULKSELECTION_ALL = 'all';
+ var BULKSELECTION_PARTIAL = 'partial';
+ ctrl.menuIsOpen = false;
+
+ ctrl.$onInit = function () {
+ ctrl.setBulkSelectionState(BULKSELECTION_NONE);
+ };
+ ctrl.updateBulkSelection = function (bulkSelectAction) {
+ ctrl.menuIsOpen = false;
+ ctrl.setBulkSelectionState (bulkSelectAction);
+ ctrl.updateSelectionFn(ctrl.bulkSelection);
+ };
+ ctrl.toggleBulkSelection = function () {
+ if (ctrl.selectedRecordCount > 0 || ctrl.bulkSelection === BULKSELECTION_ALL) {
+ ctrl.updateBulkSelection(BULKSELECTION_NONE);
+ } else {
+ ctrl.updateBulkSelection(BULKSELECTION_ALL);
+ }
+ };
+ ctrl.setBulkSelectionState = function(state) {
+ ctrl.bulkSelection = state;
+ switch (state) {
+ case BULKSELECTION_NONE:
+ ctrl.menuClass = 'fa-square-o';
+ break;
+ case BULKSELECTION_ALL:
+ ctrl.menuClass = 'fa-check-square all-selected';
+ break;
+ case BULKSELECTION_PARTIAL:
+ ctrl.menuClass = 'fa-minus-square-o partially-selected';
+ break;
+ }
+ };
+ ctrl.$doCheck = function () {
+ var recordsSelectedCount = ctrl.totalRecords - ctrl.selectedRecordCount;
+ if (ctrl.selectedRecordCount === 0) {
+ ctrl.setBulkSelectionState(BULKSELECTION_NONE);
+ }
+ if (recordsSelectedCount > 0 && ctrl.selectedRecordCount > 0 ) {
+ ctrl.setBulkSelectionState(BULKSELECTION_PARTIAL);
+ } else if (recordsSelectedCount === 0) {
+ ctrl.setBulkSelectionState(BULKSELECTION_ALL);
+ }
+ };
+ }
+});
diff --git a/src/bulkselection/bulkselection.html b/src/bulkselection/bulkselection.html
new file mode 100644
index 000000000..0c06d369d
--- /dev/null
+++ b/src/bulkselection/bulkselection.html
@@ -0,0 +1,15 @@
+
+
+
+
diff --git a/src/bulkselection/bulkselection.less b/src/bulkselection/bulkselection.less
new file mode 100644
index 000000000..a004773fd
--- /dev/null
+++ b/src/bulkselection/bulkselection.less
@@ -0,0 +1,12 @@
+.bulk-selection {
+ .dropdown-menu {
+ a{
+ &:hover {
+ cursor: pointer;
+ }
+ }
+ }
+ .all-selected,.partially-selected {
+ color: @color-pf-blue-400;
+ }
+}
diff --git a/src/bulkselection/bulkselection.module.js b/src/bulkselection/bulkselection.module.js
new file mode 100644
index 000000000..1abda243d
--- /dev/null
+++ b/src/bulkselection/bulkselection.module.js
@@ -0,0 +1,8 @@
+/**
+ * @name patternfly bulk selection
+ *
+ * @description
+ * Allows for handling bulk selection of lists
+ *
+ */
+angular.module('patternfly.bulkselection', []);
diff --git a/src/patternfly.module.js b/src/patternfly.module.js
index ebc20f54a..7d02d3415 100644
--- a/src/patternfly.module.js
+++ b/src/patternfly.module.js
@@ -6,6 +6,7 @@
*/
angular.module('patternfly', [
'patternfly.autofocus',
+ 'patternfly.bulkselection',
'patternfly.card',
'patternfly.datepicker',
'patternfly.filters',
diff --git a/src/toolbars/examples/toolbar.js b/src/toolbars/examples/toolbar.js
index 0260a3dcd..267d58121 100644
--- a/src/toolbars/examples/toolbar.js
+++ b/src/toolbars/examples/toolbar.js
@@ -13,6 +13,10 @@
* See pfSimpleFilter for filter config options.
* .sortConfig - (Object) Optional sort config. If undefined, no sort capabilities are shown.
* See pfSort for sort config options.
+ * .bulkSelectionConfig - (Object) Optional bulk selection config. If undefined, no bulk selection capabilities are shown.
+ *
+ * .bulkSelectionFn - (function(status)) This function should accept a parameter that is the state of bulk selection. This function should handle the (states, all, none, partially)
+ *
* .viewsConfig - (Object) Optional configuration settings for view type selection
*
* .views - (Array) List of available views for selection. See pfViewUtils for standard available views
@@ -73,10 +77,6 @@
-
-
- Add Action
-
@@ -422,11 +422,6 @@
name: 'Action 1',
title: 'Do the first thing',
actionFn: performAction
- },
- {
- name: 'Action 2',
- title: 'Do something else',
- actionFn: performAction
}
],
moreActions: [
@@ -467,12 +462,30 @@
],
actionsInclude: true
};
-
+ $scope.bulkSelectionChanges = function(action) {
+ var selectAll = false;
+ switch(action) {
+ case 'all':
+ selectAll = true;
+ break;
+ case 'none':
+ selectAll = false;
+ break;
+ }
+ $scope.items.map((item) => {
+ item.selected = selectAll;
+ });
+ $scope.updateItemsAvailable();
+ }
+ $scope.selectionConfig = {
+ bulkSelectionFn: $scope.bulkSelectionChanges
+ }
$scope.toolbarConfig = {
viewsConfig: $scope.viewsConfig,
filterConfig: $scope.filterConfig,
sortConfig: $scope.sortConfig,
- actionsConfig: $scope.actionsConfig
+ actionsConfig: $scope.actionsConfig,
+ bulkSelectionConfig: $scope.selectionConfig
};
$scope.listConfig = {
diff --git a/src/toolbars/toolbar.html b/src/toolbars/toolbar.html
index e9c5f1f6a..9b2544501 100644
--- a/src/toolbars/toolbar.html
+++ b/src/toolbars/toolbar.html
@@ -2,6 +2,13 @@