1
1
/**
2
2
* @ngdoc directive
3
- * @name patternfly.notification.directive:pfNotificationDrawer
3
+ * @name patternfly.notification.component:pfNotificationDrawer
4
+ * @restrict E
4
5
*
5
6
* @description
6
- * Directive for rendering a notification drawer. This provides a common mechanism to handle how the notification
7
+ * Component for rendering a notification drawer. This provides a common mechanism to handle how the notification
7
8
* drawer should look and behave without mandating the look of the notification group heading or notification body.
8
9
* <br><br>
9
10
* An array of notification groups must be passed to create each group in the drawer. Each notification
47
48
</div>
48
49
<div class="layout-pf-fixed">
49
50
<div class="navbar-pf-vertical">
50
- <div pf-notification-drawer drawer-hidden="hideDrawer" drawer-title="Notifications Drawer" allow-expand="true"
51
+ <pf-notification-drawer drawer-hidden="hideDrawer" drawer-title="Notifications Drawer" allow-expand="true"
51
52
action-button-title="Mark All Read" action-button-callback="actionButtonCB" notification-groups="groups"
52
53
heading-include="heading.html" subheading-include="subheading.html" notification-body-include="notification-body.html"
53
54
notification-footer-include="notification-footer.html" custom-scope="customScope">
54
- </div >
55
+ </pf-notification-drawer >
55
56
</div>
56
57
</div>
57
58
<div class="col-md-12">
69
70
{{notificationGroup.subHeading}}
70
71
</file>
71
72
<file name="notification-footer.html">
72
- <a class="btn btn-link btn-block" role="button" ng-click="customScope.clearAll(notificationGroup)">
73
+ <a class="btn btn-link btn-block" role="button" ng-click="$ctrl. customScope.clearAll(notificationGroup)">
73
74
<span class="pficon pficon-close"></span>
74
75
<span> Clear All</span>
75
76
</a>
84
85
<li ng-repeat="action in notification.actions"
85
86
role="{{action.isSeparator === true ? 'separator' : 'menuitem'}}"
86
87
ng-class="{'divider': action.isSeparator === true, 'disabled': action.isDisabled === true}">
87
- <a ng-if="action.isSeparator !== true" class="secondary-action" title="{{action.title}}" ng-click="customScope.handleAction(notification, action)">
88
+ <a ng-if="action.isSeparator !== true" class="secondary-action" title="{{action.title}}" ng-click="$ctrl. customScope.handleAction(notification, action)">
88
89
{{action.name}}
89
90
</a>
90
91
</li>
91
92
</ul>
92
93
</div>
93
- <span ng-if="notification.status" class="{{'pull-left ' + customScope.getNotficationStatusIconClass(notification)}}" ng-click="customScope.markRead(notification)"></span>
94
- <span class="drawer-pf-notification-message" ng-click="customScope.markRead(notification)">{{notification.message}}</span>
95
- <div class="drawer-pf-notification-info" ng-click="customScope.markRead(notification)">
94
+ <span ng-if="notification.status" class="{{'pull-left ' + $ctrl. customScope.getNotficationStatusIconClass(notification)}}" ng-click="$ctrl. customScope.markRead(notification)"></span>
95
+ <span class="drawer-pf-notification-message" ng-click="$ctrl. customScope.markRead(notification)">{{notification.message}}</span>
96
+ <div class="drawer-pf-notification-info" ng-click="$ctrl. customScope.markRead(notification)">
96
97
<span class="date">{{notification.timeStamp | date:'MM/dd/yyyy'}}</span>
97
98
<span class="time">{{notification.timeStamp | date:'h:mm:ss a'}}</span>
98
99
</div>
99
100
</div>
100
101
<div ng-if="drawerExpanded" class="container-fluid">
101
102
<div class="row">
102
103
<div class="col-sm-6">
103
- <span class="pull-left {{customScope.getNotficationStatusIconClass(notification)}}"></span>
104
+ <span class="pull-left {{$ctrl. customScope.getNotficationStatusIconClass(notification)}}"></span>
104
105
<span class="drawer-pf-notification-message notification-message"
105
106
tooltip-append-to-body="true" tooltip-popup-delay="500" tooltip-placement="bottom" tooltip="{{notification.message}}">
106
107
{{notification.message}}
119
120
<li ng-repeat="action in notification.actions"
120
121
role="{{action.isSeparator === true ? 'separator' : 'menuitem'}}"
121
122
ng-class="{'divider': action.isSeparator === true, 'disabled': action.isDisabled === true}">
122
- <a ng-if="action.isSeparator !== true" class="secondary-action" title="{{action.title}}" ng-click="customScope.handleAction(notification, action)">
123
+ <a ng-if="action.isSeparator !== true" class="secondary-action" title="{{action.title}}" ng-click="$ctrl. customScope.handleAction(notification, action)">
123
124
{{action.name}}
124
125
</a>
125
126
</li>
471
472
</file>
472
473
</example>
473
474
*/
474
- angular . module ( 'patternfly.notification' ) . directive ( 'pfNotificationDrawer' , function ( $window , $timeout ) {
475
- 'use strict' ;
476
- return {
477
- restrict : 'A' ,
478
- scope : {
479
- drawerHidden : '=?' ,
480
- allowExpand : '=?' ,
481
- drawerExpanded : '=?' ,
482
- drawerTitle : '@' ,
483
- notificationGroups : '=' ,
484
- actionButtonTitle : '@' ,
485
- actionButtonCallback : '=?' ,
486
- titleInclude : '@' ,
487
- headingInclude : '@' ,
488
- subheadingInclude : '@' ,
489
- notificationBodyInclude : '@' ,
490
- notificationFooterInclude : '@' ,
491
- customScope : '=?'
492
- } ,
493
- templateUrl : 'notification/notification-drawer.html' ,
494
- controller : function ( $scope ) {
495
- if ( ! $scope . allowExpand || angular . isUndefined ( $scope . drawerExpanded ) ) {
496
- $scope . drawerExpanded = false ;
475
+ angular . module ( 'patternfly.notification' ) . component ( 'pfNotificationDrawer' , {
476
+ bindings : {
477
+ drawerHidden : '<?' ,
478
+ allowExpand : '=?' ,
479
+ drawerExpanded : '=?' ,
480
+ drawerTitle : '@' ,
481
+ notificationGroups : '<' ,
482
+ actionButtonTitle : '@' ,
483
+ actionButtonCallback : '=?' ,
484
+ titleInclude : '@' ,
485
+ headingInclude : '@' ,
486
+ subheadingInclude : '@' ,
487
+ notificationBodyInclude : '@' ,
488
+ notificationFooterInclude : '@' ,
489
+ customScope : '=?'
490
+ } ,
491
+ templateUrl : 'notification/notification-drawer.html' ,
492
+ controller : function ( $window , $timeout , $element ) {
493
+ 'use strict' ;
494
+ var ctrl = this ;
495
+
496
+ ctrl . toggleCollapse = function ( selectedGroup ) {
497
+ if ( selectedGroup . open ) {
498
+ selectedGroup . open = false ;
499
+ } else {
500
+ ctrl . notificationGroups . forEach ( function ( group ) {
501
+ group . open = false ;
502
+ } ) ;
503
+ selectedGroup . open = true ;
504
+ }
505
+ } ;
506
+
507
+ ctrl . toggleExpandDrawer = function ( ) {
508
+ ctrl . drawerExpanded = ! ctrl . drawerExpanded ;
509
+ } ;
510
+
511
+ ctrl . $onInit = function ( ) {
512
+ if ( ! ctrl . allowExpand || angular . isUndefined ( ctrl . drawerExpanded ) ) {
513
+ ctrl . drawerExpanded = false ;
497
514
}
498
- } ,
499
- link : function ( scope , element ) {
515
+ } ;
500
516
501
- scope . $watch ( 'notificationGroups' , function ( ) {
502
- var openFound = false ;
503
- scope . notificationGroups . forEach ( function ( group ) {
517
+ ctrl . $onChanges = function ( changesObj ) {
518
+ var openFound = false ;
519
+ if ( changesObj . notificationGroups ) {
520
+ changesObj . notificationGroups . currentValue . forEach ( function ( group ) {
504
521
if ( group . open ) {
505
522
if ( openFound ) {
506
523
group . open = false ;
@@ -509,35 +526,22 @@ angular.module('patternfly.notification').directive('pfNotificationDrawer', func
509
526
}
510
527
}
511
528
} ) ;
512
- } ) ;
529
+ }
513
530
514
- scope . $watch ( 'drawerHidden' , function ( ) {
531
+ if ( changesObj . drawerHidden ) {
515
532
$timeout ( function ( ) {
516
533
angular . element ( $window ) . triggerHandler ( 'resize' ) ;
517
534
} , 100 ) ;
518
- } ) ;
519
-
520
- scope . toggleCollapse = function ( selectedGroup ) {
521
- if ( selectedGroup . open ) {
522
- selectedGroup . open = false ;
523
- } else {
524
- scope . notificationGroups . forEach ( function ( group ) {
525
- group . open = false ;
526
- } ) ;
527
- selectedGroup . open = true ;
528
- }
529
- } ;
530
-
531
- scope . toggleExpandDrawer = function ( ) {
532
- scope . drawerExpanded = ! scope . drawerExpanded ;
533
- } ;
535
+ }
536
+ } ;
534
537
535
- if ( scope . groupHeight ) {
536
- element . find ( '.panel-group' ) . css ( "height" , scope . groupHeight ) ;
538
+ ctrl . $postLink = function ( ) {
539
+ if ( ctrl . groupHeight ) {
540
+ $element . find ( '.panel-group' ) . css ( "height" , ctrl . groupHeight ) ;
537
541
}
538
- if ( scope . groupClass ) {
539
- element . find ( '.panel-group' ) . addClass ( scope . groupClass ) ;
542
+ if ( ctrl . groupClass ) {
543
+ $ element. find ( '.panel-group' ) . addClass ( ctrl . groupClass ) ;
540
544
}
541
- }
542
- } ;
545
+ } ;
546
+ }
543
547
} ) ;
0 commit comments