@@ -6,27 +6,31 @@ export default Component.extend({
66 layout,
77 classNameBindings : [ 'model.isSelected:tree-highlight' , 'isChosen:tree-chosen' ] ,
88
9+ recursiveCheck : false ,
10+
911 isChosen : computed ( 'model.id' , 'chosenId' , function ( ) {
1012 return this . get ( 'model.id' ) === this . get ( 'chosenId' ) ;
1113 } ) ,
1214
13- recursiveCheck : false ,
14-
1515 click ( ) {
1616 let select = this . get ( 'onSelect' ) ;
1717 if ( select ) {
18- let wasChecked = this . get ( 'model.isChecked' ) ;
19- select ( this . get ( 'model' ) ) ;
20- let isChecked = this . get ( 'model.isChecked' ) ;
18+ let model = this . get ( 'model' ) ;
19+ let wasChecked = model . get ( 'isChecked' ) ;
20+
21+ select ( model ) ;
22+
23+ let isChecked = model . get ( 'isChecked' ) ;
2124 if ( isChecked !== wasChecked && this . get ( 'recursiveCheck' ) ) {
22- this . setChildCheckboxesRecursively ( this . get ( ' model' ) , isChecked ) ;
25+ this . setChildCheckboxesRecursively ( model , isChecked ) ;
2326 this . updateCheckbox ( ) ;
2427 }
2528 }
2629 } ,
2730
2831 mouseEnter ( ) {
2932 this . set ( 'model.isSelected' , true ) ;
33+
3034 let hover = this . get ( 'onHover' ) ;
3135 if ( hover ) {
3236 hover ( this . get ( 'model' ) ) ;
@@ -35,6 +39,7 @@ export default Component.extend({
3539
3640 mouseLeave ( ) {
3741 this . set ( 'model.isSelected' , false ) ;
42+
3843 let hoverOut = this . get ( 'onHoverOut' ) ;
3944 if ( hoverOut ) {
4045 hoverOut ( this . get ( 'model' ) ) ;
@@ -49,6 +54,7 @@ export default Component.extend({
4954 isChecked,
5055 isIndeterminate : false
5156 } ) ;
57+
5258 this . setChildCheckboxesRecursively ( child , isChecked ) ;
5359 } ) ;
5460 }
@@ -57,16 +63,18 @@ export default Component.extend({
5763 actions : {
5864 toggleCheck ( event ) {
5965 event . stopPropagation ( ) ;
60- this . toggleProperty ( 'model.isChecked' ) ;
66+
67+ let isChecked = this . toggleProperty ( 'model.isChecked' ) ;
68+ let model = this . get ( 'model' ) ;
69+
6170 if ( this . get ( 'recursiveCheck' ) ) {
62- let isChecked = this . get ( 'model.isChecked' ) ;
63- this . setChildCheckboxesRecursively ( this . model , isChecked ) ;
71+ this . setChildCheckboxesRecursively ( model , isChecked ) ;
6472 this . updateCheckbox ( ) ;
6573 }
6674
6775 let check = this . get ( 'onCheck' ) ;
6876 if ( check ) {
69- check ( this . get ( ' model' ) ) ;
77+ check ( model ) ;
7078 }
7179 } ,
7280
0 commit comments