11/**
22 * @ngdoc directive
3- * @name patternfly.notification.directive:pfNotificationDrawer
3+ * @name patternfly.notification.component:pfNotificationDrawer
4+ * @restrict E
45 *
56 * @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
78 * drawer should look and behave without mandating the look of the notification group heading or notification body.
89 * <br><br>
910 * An array of notification groups must be passed to create each group in the drawer. Each notification
4748 </div>
4849 <div class="layout-pf-fixed">
4950 <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"
5152 action-button-title="Mark All Read" action-button-callback="actionButtonCB" notification-groups="groups"
5253 heading-include="heading.html" subheading-include="subheading.html" notification-body-include="notification-body.html"
5354 notification-footer-include="notification-footer.html" custom-scope="customScope">
54- </div >
55+ </pf-notification-drawer >
5556 </div>
5657 </div>
5758 <div class="col-md-12">
6970 {{notificationGroup.subHeading}}
7071 </file>
7172 <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)">
7374 <span class="pficon pficon-close"></span>
7475 <span> Clear All</span>
7576 </a>
8485 <li ng-repeat="action in notification.actions"
8586 role="{{action.isSeparator === true ? 'separator' : 'menuitem'}}"
8687 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)">
8889 {{action.name}}
8990 </a>
9091 </li>
9192 </ul>
9293 </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)">
9697 <span class="date">{{notification.timeStamp | date:'MM/dd/yyyy'}}</span>
9798 <span class="time">{{notification.timeStamp | date:'h:mm:ss a'}}</span>
9899 </div>
99100 </div>
100101 <div ng-if="drawerExpanded" class="container-fluid">
101102 <div class="row">
102103 <div class="col-sm-6">
103- <span class="pull-left {{customScope.getNotficationStatusIconClass(notification)}}"></span>
104+ <span class="pull-left {{$ctrl. customScope.getNotficationStatusIconClass(notification)}}"></span>
104105 <span class="drawer-pf-notification-message notification-message"
105106 tooltip-append-to-body="true" tooltip-popup-delay="500" tooltip-placement="bottom" tooltip="{{notification.message}}">
106107 {{notification.message}}
119120 <li ng-repeat="action in notification.actions"
120121 role="{{action.isSeparator === true ? 'separator' : 'menuitem'}}"
121122 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)">
123124 {{action.name}}
124125 </a>
125126 </li>
471472 </file>
472473</example>
473474*/
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 ;
497514 }
498- } ,
499- link : function ( scope , element ) {
515+ } ;
500516
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 ) {
504521 if ( group . open ) {
505522 if ( openFound ) {
506523 group . open = false ;
@@ -509,35 +526,22 @@ angular.module('patternfly.notification').directive('pfNotificationDrawer', func
509526 }
510527 }
511528 } ) ;
512- } ) ;
529+ }
513530
514- scope . $watch ( 'drawerHidden' , function ( ) {
531+ if ( changesObj . drawerHidden ) {
515532 $timeout ( function ( ) {
516533 angular . element ( $window ) . triggerHandler ( 'resize' ) ;
517534 } , 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+ } ;
534537
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 ) ;
537541 }
538- if ( scope . groupClass ) {
539- element . find ( '.panel-group' ) . addClass ( scope . groupClass ) ;
542+ if ( ctrl . groupClass ) {
543+ $ element. find ( '.panel-group' ) . addClass ( ctrl . groupClass ) ;
540544 }
541- }
542- } ;
545+ } ;
546+ }
543547} ) ;
0 commit comments