@@ -48,7 +48,7 @@ angular.module( 'patternfly.utils', [] );
48
48
* Views module for patternfly.
49
49
*
50
50
*/
51
- angular . module ( 'patternfly.views' , [ ] ) ;
51
+ angular . module ( 'patternfly.views' , [ 'patternfly.utils' ] ) ;
52
52
; /**
53
53
* @ngdoc directive
54
54
* @name patternfly.autofocus:pfFocused
@@ -1987,6 +1987,130 @@ angular.module('patternfly.select', []).directive('pfSelect', function ($timeout
1987
1987
} ;
1988
1988
} ) ;
1989
1989
;
1990
+ /**
1991
+ * @ngdoc directive
1992
+ * @name patternfly.utils.directive:pfTransclude
1993
+ * @restrict A
1994
+ * @element ANY
1995
+ * @param {string } pfTransclude specifies the type of transclusion to use.<br/>
1996
+ * <strong>Values:</strong>
1997
+ * <ul style='list-style-type: none'>
1998
+ * <li> 'sibling' - The transcluded contents scope is a sibling one to the element where transclusion happens (default)
1999
+ * <li> 'parent' - The transcluded contents scope is that of the element where transclusion happens.
2000
+ * <li> 'child' - The transcluded contents scope is child scope to the scope of the element where transclusion happens.
2001
+ * </ul>
2002
+ *
2003
+ * @description
2004
+ * Directive for transcluding in directives and setting up scope of children of parent directives. This is a workaround
2005
+ * for https://github.com/angular/angular.js/issues/5489
2006
+ *
2007
+ * @example
2008
+ <example module="patternfly.utils">
2009
+ <file name="index.html">
2010
+ <style>
2011
+
2012
+ .pf-transclude-example div {
2013
+ border: 1px solid #337ab7;
2014
+ margin-bottom: 20px;
2015
+ margin-left: 20px;
2016
+ }
2017
+
2018
+ .pf-transclude-example p {
2019
+ background-color: #337ab7;
2020
+ margin: 0;
2021
+ padding: 5px 10px;
2022
+ }
2023
+
2024
+ .pf-transclude-example id {
2025
+ display: inline-block;
2026
+ background-color: #def3ff;
2027
+ color: #000000;
2028
+ border-radius: 10px;
2029
+ width: 20px;
2030
+ height: 20px;
2031
+ text-align: center;
2032
+ line-height: 20px;
2033
+ margin-left: 5px;
2034
+ }
2035
+
2036
+ .pf-transclude-example pre {
2037
+ padding: 5px;
2038
+ border-width: 0px;
2039
+ }
2040
+ </style>
2041
+ <div ng-controller="UtilCtrl" class="row pf-transclude-example" style="display:inline-block; width: 100%;">
2042
+ <span>Here the scope id is: <id>{{$id}}</id></span>
2043
+
2044
+ <transclude-sibling class="pf-transclude-example">
2045
+ <pre>This content was transcluded using <b>pf-transclude</b> or <b>pf-transclude="sibling"</b>.</pre><pre>Its scope is: <id>{{$id}}</id> the parent of which is <id>{{$parent.$id}}</id></pre>
2046
+ </transclude-sibling>
2047
+
2048
+ <transclude-parent>
2049
+ <pre>This content was transcluded using <b>pf-transclude="parent"</b>.</pre><pre>Its scope is: <id>{{$id}}</id> the parent of which is <id>{{$parent.$id}}</id></pre>
2050
+ </transclude-parent>
2051
+
2052
+ <transclude-child>
2053
+ <pre>This content was transcluded using <b>pf-transclude="child"</b>.</pre><pre>Its scope is: <id>{{$id}}</id> the parent of which is <id>{{$parent.$id}}</id></pre>
2054
+ </transclude-child>
2055
+ </div>
2056
+ </file>
2057
+
2058
+ <file name="script.js">
2059
+ angular.module('patternfly.utils')
2060
+ .controller( 'UtilCtrl', function($scope) {
2061
+
2062
+ })
2063
+
2064
+ .config(function($provide){
2065
+ $provide.decorator('ngTranscludeDirective', ['$delegate', function($delegate) {
2066
+ // Remove the original directive
2067
+ $delegate.shift();
2068
+ return $delegate;
2069
+ }]);
2070
+ })
2071
+
2072
+ .directive( 'transcludeSibling', function() {
2073
+ return {
2074
+ restrict: 'E',
2075
+ transclude: true,
2076
+ scope: {},
2077
+ template:
2078
+ '<div>' +
2079
+ '<p>I am a directive with scope <id>{{$id}}</id></p>' +
2080
+ '<span pf-transclude></span>' +
2081
+ '</div>'
2082
+ }
2083
+ })
2084
+
2085
+ .directive( 'transcludeParent', function() {
2086
+ return {
2087
+ restrict: 'E',
2088
+ transclude: true,
2089
+ scope: {},
2090
+ template:
2091
+ '<div>' +
2092
+ '<p>I am a directive with scope <id>{{$id}}</id></p>' +
2093
+ '<span pf-transclude="parent"></span>' +
2094
+ '</div>'
2095
+ }
2096
+ })
2097
+
2098
+ .directive( 'transcludeChild', function() {
2099
+ return {
2100
+ restrict: 'E',
2101
+ transclude: true,
2102
+ scope: {},
2103
+ template:
2104
+ '<div>' +
2105
+ '<p>I am a directive with scope <id>{{$id}}</id></p>' +
2106
+ '<span pf-transclude="child"></span>' +
2107
+ '</div>'
2108
+ }
2109
+ })
2110
+ ;
2111
+ </file>
2112
+ </example>
2113
+ */
1990
2114
angular
1991
2115
. module ( 'patternfly.utils' ) . directive ( 'pfTransclude' , function ( ) {
1992
2116
'use strict' ;
@@ -2208,7 +2332,7 @@ angular.module('patternfly.validation', []).directive('pfValidation', function (
2208
2332
* Directive for rendering a data list.
2209
2333
* <br><br>
2210
2334
*
2211
- * @param {object } config configuration settings for the sparkline chart :<br/>
2335
+ * @param {object } config configuration settings for the data list :<br/>
2212
2336
* <ul style='list-style-type: none'>
2213
2337
* <li>.showSelectBox - (boolean) Show item selection boxes for each item, default is true
2214
2338
* <li>.selectItems - (boolean) Allow row selection, default is false
@@ -2307,7 +2431,7 @@ angular.module('patternfly.validation', []).directive('pfValidation', function (
2307
2431
</file>
2308
2432
2309
2433
<file name="script.js">
2310
- angular.module('patternfly.views').controller('ViewCtrl', ['$scope',
2434
+ angular.module('patternfly.views').controller('ViewCtrl', ['$scope',
2311
2435
function ($scope) {
2312
2436
$scope.eventText = '';
2313
2437
var handleSelect = function (item, e) {
@@ -2379,8 +2503,8 @@ angular.module('patternfly.validation', []).directive('pfValidation', function (
2379
2503
city: "New York",
2380
2504
state: "New York"
2381
2505
},
2382
- ];
2383
- };
2506
+ ]
2507
+ }
2384
2508
]);
2385
2509
</file>
2386
2510
</example>
@@ -2391,11 +2515,10 @@ angular.module('patternfly.views').directive('pfDataList', [
2391
2515
return {
2392
2516
restrict : 'A' ,
2393
2517
scope : {
2394
- config : '=' ,
2518
+ config : '=? ' ,
2395
2519
items : '=' ,
2396
2520
eventId : '@id'
2397
2521
} ,
2398
- replace : true ,
2399
2522
transclude : true ,
2400
2523
templateUrl : 'views/datalist/data-list.html' ,
2401
2524
controller : [ '$scope' ,
@@ -2450,7 +2573,7 @@ angular.module('patternfly.views').directive('pfDataList', [
2450
2573
2451
2574
if ( alreadySelected ) {
2452
2575
// already selected so deselect
2453
- scope . config . selectedItems = _ . without ( scope . config . selectedItems , selectMatch ) ;
2576
+ scope . config . selectedItems = _ . without ( scope . config . selectedItems , item ) ;
2454
2577
} else {
2455
2578
// add the item to the selected items
2456
2579
scope . config . selectedItems . push ( item ) ;
@@ -2573,7 +2696,7 @@ angular.module('patternfly.views').directive('pfDataList', [
2573
2696
'use strict' ;
2574
2697
2575
2698
$templateCache . put ( 'views/datalist/data-list.html' ,
2576
- "<div class=data-list-pf><div class=list-group-item ng-repeat=\"item in items track by $index\" ng-class=\"{'pf-selectable': selectItems, 'active': isSelected(item), 'disabled': checkDisabled(item)}\"><div class=\"row list-row\"><div pf-transclude=parent class=list-content ng-class=\"{'with-check-box': config.showSelectBox, 'with-menu':config.showActionMenus}\" ng-click=\"itemClick($event, item)\" ng-dblclick=\"dblClick($event, item)\" ng-transclude=\"\" ></div><div class=list-check-box ng-if=config.showSelectBox style=\"padding-top: {{(config.rowHeight - 32) / 2}}px\"><input type=checkbox value=item.selected ng-model=item.selected ng-disabled=checkDisabled(item) ng-change=\"checkBoxChange(item)\"></div></div></div></div>"
2699
+ "<div class=data-list-pf><div class=list-group-item ng-repeat=\"item in items track by $index\" ng-class=\"{'pf-selectable': selectItems, 'active': isSelected(item), 'disabled': checkDisabled(item)}\"><div class=\"row list-row\"><div pf-transclude=parent class=list-content ng-class=\"{'with-check-box': config.showSelectBox, 'with-menu':config.showActionMenus}\" ng-click=\"itemClick($event, item)\" ng-dblclick=\"dblClick($event, item)\"></div><div class=list-check-box ng-if=config.showSelectBox style=\"padding-top: {{(config.rowHeight - 32) / 2}}px\"><input type=checkbox value=item.selected ng-model=item.selected ng-disabled=checkDisabled(item) ng-change=\"checkBoxChange(item)\"></div></div></div></div>"
2577
2700
) ;
2578
2701
2579
2702
} ] ) ;
0 commit comments