Skip to content

Commit d22391d

Browse files
Fix for list view actions button tooltips
Also adds ngDoc example for a start button which changes text upon click and disables upon click.
1 parent 543a6fe commit d22391d

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/views/listview/list-view-directive.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@
151151
};
152152
153153
$scope.enableButtonForItemFn = function(action, item) {
154-
return (action.name !=='Action 2') || (item.name !== "Frank Livingston");
154+
return !((action.name ==='Action 2') && (item.name === "Frank Livingston")) &&
155+
!(action.name === 'Start' && item.started);
155156
};
156157
157158
$scope.updateMenuActionForItemFn = function(action, item) {
@@ -258,18 +259,32 @@
258259
$scope.eventText = item.name + " : " + action.name + "\r\n" + $scope.eventText;
259260
};
260261
261-
var buttonInclude = '<span class="fa fa-plus"></span>{{actionButton.name}}';
262+
var startServer = function (action, item) {
263+
$scope.eventText = item.name + " : " + action.name + "\r\n" + $scope.eventText;
264+
item.started = true;
265+
};
262266
267+
var buttonInclude = '<span class="fa fa-plus"></span>{{actionButton.name}}';
263268
$templateCache.put('my-button-template', buttonInclude);
269+
270+
var startButtonInclude = '<span ng-disabled="item.started">{{item.started ? "Starting" : "Start"}}</span>';
271+
$templateCache.put('start-button-template', startButtonInclude);
272+
264273
$scope.actionButtons = [
274+
{
275+
name: 'Start',
276+
class: 'btn-primary',
277+
include: 'start-button-template',
278+
title: 'Start the server',
279+
actionFn: startServer
280+
},
265281
{
266282
name: 'Action 1',
267283
title: 'Perform an action',
268284
actionFn: performAction
269285
},
270286
{
271287
name: 'Action 2',
272-
class: 'btn-primary',
273288
title: 'Do something else',
274289
actionFn: performAction
275290
},

src/views/listview/list-view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="list-view-pf-actions"
1010
ng-if="(actionButtons && actionButtons.length > 0) || (menuActions && menuActions.length > 0)">
1111
<button class="btn btn-default {{actionButton.class}}" ng-repeat="actionButton in actionButtons"
12-
title="actionButton.title"
12+
title="{{actionButton.title}}"
1313
ng-class="{'disabled' : checkDisabled(item) || !enableButtonForItem(actionButton, item)}"
1414
ng-click="handleButtonAction(actionButton, item)">
1515
<div ng-if="actionButton.include" class="actionButton.includeClass" ng-include src="actionButton.include"></div>

0 commit comments

Comments
 (0)