Skip to content

Commit 13a13d6

Browse files
authored
Merge pull request #387 from dtaylor113/branch-4.0-dev
pfTableView: v1.0
2 parents 01cd5db + a159b08 commit 13a13d6

16 files changed

+1254
-21
lines changed

Gruntfile.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,16 @@ module.exports = function (grunt) {
125125
dest: 'docs',
126126
image: 'misc/logo-alt.svg',
127127
scripts: [
128+
'node_modules/jquery/dist/jquery.js',
129+
'node_modules/datatables.net/js/jquery.dataTables.js',
130+
'node_modules/datatables.net-select/js/dataTables.select.js',
128131
'node_modules/moment/moment.js',
129132
'node_modules/c3/c3.js',
130133
'node_modules/d3/d3.js',
131134
'node_modules/patternfly/dist/js/patternfly-settings.js',
132135
'node_modules/angular/angular.js',
136+
'node_modules/angular-datatables/dist/angular-datatables.min.js',
137+
'node_modules/angular-datatables/dist/plugins/select/angular-datatables.select.min.js',
133138
'node_modules/angular-sanitize/angular-sanitize.js',
134139
'node_modules/angular-animate/angular-animate.js',
135140
'node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
@@ -139,8 +144,12 @@ module.exports = function (grunt) {
139144
'node_modules/angular-ui-router/release/angular-ui-router.min.js'],
140145
html5Mode: false,
141146
template: 'grunt-ngdocs-index.tmpl',
142-
styles: ['node_modules/patternfly/dist/css/patternfly.css', 'node_modules/patternfly/dist/css/patternfly-additions.css',
143-
'dist/styles/angular-patternfly.css', 'misc/ng-docs.css', 'misc/examples.css']
147+
styles: ['node_modules/datatables.net-dt/css/jquery.dataTables.css',
148+
'node_modules/patternfly/dist/css/patternfly.css',
149+
'node_modules/patternfly/dist/css/patternfly-additions.css',
150+
'dist/styles/angular-patternfly.css',
151+
'misc/ng-docs.css',
152+
'misc/examples.css']
144153
},
145154

146155
all: ['src/**/*.js']
@@ -203,6 +212,11 @@ module.exports = function (grunt) {
203212
src: ['sort/**/*.html'],
204213
dest: 'templates/sort.js'
205214
},
215+
'patternfly.table': {
216+
cwd: 'src/',
217+
src: ['table/**/*.html'],
218+
dest: 'templates/table.js'
219+
},
206220
'patternfly.toolbars': {
207221
cwd: 'src/',
208222
src: ['toolbars/**/*.html'],

bower.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
"angular-sanitize": "1.5.*",
4343
"angular-bootstrap": "2.2.x",
4444
"lodash": "4.x",
45-
"patternfly": "~3.15.0"
45+
"patternfly": "~3.15.0",
46+
"angular-datatables": "^0.5.6",
47+
"datatables.net": "^1.10.12",
48+
"datatables.net-select": "~1.2.0"
4649
},
4750
"devDependencies": {
4851
"angular-mocks": "1.5.*",

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@
5252
"c3": "~0.4.11",
5353
"d3": "~3.5.17",
5454
"jquery": "~2.1.4",
55-
"moment": "~2.14.1"
55+
"moment": "~2.14.1",
56+
"angular-datatables": "^0.5.6",
57+
"datatables.net": "^1.10.11",
58+
"datatables.net-select": "~1.2.0"
5659
},
5760
"scripts": {
5861
"test": "grunt test"

src/filters/filter-results-component.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* </ul>
2020
* <li>.appliedFilters - (Array) List of the currently applied filters
2121
* <li>.resultsCount - (int) The number of results returned after the current applied filters have been applied
22+
* <li>.selectedCount - (int) The number selected items, The 'n' in the label: 'n' of 'm' selected
23+
* <li>.totalCount - (int) The total number of items before any filters have been applied. The 'm' in the label: 'n' of 'm' selected
2224
* <li>.onFilterChange - ( function(array of filters) ) Function to call when the applied filters list changes
2325
* </ul>
2426
*
@@ -61,6 +63,12 @@ angular.module('patternfly.filters').component('pfFilterResults', {
6163
if (ctrl.config.resultsCount === undefined) {
6264
ctrl.config.resultsCount = 0;
6365
}
66+
if (ctrl.config.selectedCount === undefined) {
67+
ctrl.config.selectedCount = 0;
68+
}
69+
if (ctrl.config.totalCount === undefined) {
70+
ctrl.config.totalCount = 0;
71+
}
6472
}
6573

6674
function clearFilter (item) {

src/filters/filter-results.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ <h5>{{$ctrl.config.resultsCount}} Results</h5>
1212
</li>
1313
</ul>
1414
<p><a class="clear-filters" ng-click="$ctrl.clearAllFilters()" ng-if="$ctrl.config.appliedFilters.length > 0">Clear All Filters</a></p>
15+
<div ng-if="$ctrl.config.totalCount !== 0" class="pf-table-view-selected-label">
16+
<strong>{{$ctrl.config.selectedCount}}</strong> of <strong>{{$ctrl.config.totalCount}}</strong> selected
17+
</div>
1518
</div><!-- /col -->
1619
</div><!-- /row -->
1720
</div>

src/sort/sort-component.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ angular.module('patternfly.sort').component('pfSort', {
1010
var prevConfig;
1111

1212
ctrl.$onInit = function () {
13+
if (angular.isDefined(ctrl.config) && angular.isUndefined(ctrl.config.show)) {
14+
// default to true
15+
ctrl.config.show = true;
16+
}
17+
1318
angular.extend(ctrl, {
1419
selectField: selectField,
1520
changeDirection: changeDirection,

src/table/table.module.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @name patternfly
3+
*
4+
* @description
5+
* Table module for patternfly.
6+
*
7+
*/
8+
angular.module('patternfly.table', ['datatables', 'patternfly.utils', 'patternfly.filters', 'patternfly.sort']);
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/**
2+
* @ngdoc directive
3+
* @name patternfly.table.component:pfTableView - Basic
4+
*
5+
* @description
6+
* Component for rendering a simple table view.<br><br>
7+
* See {@link patternfly.table.component:pfTableView%20-%20with%20Toolbar pfTableView - with Toolbar} for use with a Toolbar<br>
8+
* See {@link patternfly.toolbars.componenet:pfToolbar pfToolbar} for use in Toolbar View Switcher
9+
*
10+
* @param {object} config Optional configuration object
11+
* <ul style='list-style-type: none'>
12+
* <li>.selectionMatchProp - (string) Property of the items to use for determining matching, default is 'uuid'
13+
* <li>.onCheckBoxChange - ( function(item) ) Called to notify when a checkbox selection changes, default is none
14+
* </ul>
15+
* @param {object} dtOptions Optional angular-datatables DTOptionsBuilder configuration object. See {@link http://l-lin.github.io/angular-datatables/archives/#/api angular-datatables: DTOptionsBuilder}
16+
* @param {array} items Array of items to display in the table view.
17+
* @param {array} columns Array of table column information to display in the table's header row
18+
* <ul style='list-style-type: none'>
19+
* <li>.header - (string) Text label for a column header
20+
* <li>.itemField - (string) Item field to associate with a particular column.
21+
* </ul>
22+
* @param {array} actionButtons List of action buttons in each row
23+
* <ul style='list-style-type: none'>
24+
* <li>.name - (String) The name of the action, displayed on the button
25+
* <li>.title - (String) Optional title, used for the tooltip
26+
* <li>.actionFn - (function(action)) Function to invoke when the action selected
27+
* </ul>
28+
* @param {array} menuActions List of actions for dropdown menu in each row
29+
* <ul style='list-style-type: none'>
30+
* <li>.name - (String) The name of the action, displayed on the button
31+
* <li>.title - (String) Optional title, used for the tooltip
32+
* <li>.actionFn - (function(action)) Function to invoke when the action selected
33+
* </ul>
34+
* @example
35+
<example module="patternfly.table">
36+
<file name="index.html">
37+
<div ng-controller="TableCtrl" class="row example-container">
38+
<div class="col-md-12">
39+
<pf-table-view id="exampleTableView"
40+
config="config"
41+
dt-options="dtOptions"
42+
colummns="colummns"
43+
items="items"
44+
action-buttons="actionButtons"
45+
menu-actions="menuActions">
46+
</pf-table-view>
47+
<div class="col-md-12" style="padding-top: 12px;">
48+
<label style="font-weight:normal;vertical-align:center;">Events: </label>
49+
</div>
50+
<div class="col-md-12">
51+
<textarea rows="10" class="col-md-12">{{eventText}}</textarea>
52+
</div>
53+
</div>
54+
</div>
55+
</file>
56+
57+
<file name="script.js">
58+
angular.module('patternfly.table').controller('TableCtrl', ['$scope',
59+
function ($scope) {
60+
$scope.dtOptions = {
61+
order: [[2, "asc"]],
62+
};
63+
64+
$scope.colummns = [
65+
{ header: "Name", itemField: "name" },
66+
{ header: "Address", itemField: "address"},
67+
{ header: "City", itemField: "city" },
68+
{ header: "State", itemField: "state"}
69+
];
70+
71+
$scope.items = [
72+
{
73+
name: "Fred Flintstone",
74+
address: "20 Dinosaur Way",
75+
city: "Bedrock",
76+
state: "Washingstone"
77+
},
78+
{
79+
name: "John Smith",
80+
address: "415 East Main Street",
81+
city: "Norfolk",
82+
state: "Virginia",
83+
},
84+
{
85+
name: "Frank Livingston",
86+
address: "234 Elm Street",
87+
city: "Pittsburgh",
88+
state: "Pennsylvania"
89+
},
90+
{
91+
name: "Linda McGovern",
92+
address: "22 Oak Street",
93+
city: "Denver",
94+
state: "Colorado"
95+
},
96+
{
97+
name: "Jim Brown",
98+
address: "72 Bourbon Way",
99+
city: "Nashville",
100+
state: "Tennessee"
101+
},
102+
{
103+
name: "Holly Nichols",
104+
address: "21 Jump Street",
105+
city: "Hollywood",
106+
state: "California"
107+
},
108+
{
109+
name: "Marie Edwards",
110+
address: "17 Cross Street",
111+
city: "Boston",
112+
state: "Massachusetts"
113+
},
114+
{
115+
name: "Pat Thomas",
116+
address: "50 Second Street",
117+
city: "New York",
118+
state: "New York"
119+
},
120+
];
121+
122+
$scope.eventText = "";
123+
124+
$scope.config = {
125+
onCheckBoxChange: handleCheckBoxChange,
126+
selectionMatchProp: "name"
127+
};
128+
129+
function handleCheckBoxChange (item) {
130+
$scope.eventText = item.name + ' checked: ' + item.selected + '\r\n' + $scope.eventText;
131+
};
132+
133+
var performAction = function (action, item) {
134+
$scope.eventText = item.name + " : " + action.name + "\r\n" + $scope.eventText;
135+
};
136+
137+
$scope.actionButtons = [
138+
{
139+
name: 'Action',
140+
title: 'Perform an action',
141+
actionFn: performAction
142+
}
143+
];
144+
145+
$scope.menuActions = [
146+
{
147+
name: 'Action',
148+
title: 'Perform an action',
149+
actionFn: performAction
150+
},
151+
{
152+
name: 'Another Action',
153+
title: 'Do something else',
154+
actionFn: performAction
155+
},
156+
{
157+
name: 'Disabled Action',
158+
title: 'Unavailable action',
159+
actionFn: performAction,
160+
isDisabled: true
161+
},
162+
{
163+
name: 'Something Else',
164+
title: '',
165+
actionFn: performAction
166+
},
167+
{
168+
isSeparator: true
169+
},
170+
{
171+
name: 'Grouped Action 1',
172+
title: 'Do something',
173+
actionFn: performAction
174+
},
175+
{
176+
name: 'Grouped Action 2',
177+
title: 'Do something similar',
178+
actionFn: performAction
179+
}
180+
];
181+
}
182+
]);
183+
</file>
184+
</example>
185+
*/

0 commit comments

Comments
 (0)