1
- basis . require ( 'basis.ui' ) ;
2
- basis . require ( 'basis.data.dataset' ) ;
3
-
4
- var type = resource ( '../../type.js' ) . fetch ( ) ;
1
+ require ( 'basis.data.dataset' ) ;
2
+ require ( 'basis.data.index' ) ;
3
+ require ( 'basis.ui' ) ;
5
4
5
+ var type = require ( '../../type.js' ) ;
6
+ var countIndex = basis . data . index . count ;
6
7
var fileByType = new basis . data . dataset . Split ( {
7
8
source : type . files ,
8
9
rule : 'data.type'
9
10
} ) ;
10
11
11
- var view = new basis . ui . Node ( {
12
+ module . exports = new basis . ui . Node ( {
12
13
dataSource : fileByType ,
13
14
14
- template : resource ( 'template/fileStat.tmpl' ) ,
15
+ template : resource ( './ template/fileStat.tmpl' ) ,
15
16
binding : {
16
- totalCount : function ( ) {
17
- return type . files . itemCount ;
18
- } ,
19
- noSelected : 'selection.itemCount == 0'
17
+ totalCount : countIndex ( type . files ) ,
18
+ noSelected : function ( node ) {
19
+ return countIndex ( node . selection ) . as ( basis . bool . invert ) ;
20
+ }
20
21
} ,
21
22
action : {
22
23
resetSelection : function ( ) {
@@ -27,37 +28,23 @@ var view = new basis.ui.Node({
27
28
listen : {
28
29
selection : {
29
30
itemsChanged : function ( selection ) {
30
- this . updateBind ( 'noSelected' ) ;
31
- type . matched . setSources ( selection . getItems ( ) . map ( function ( node ) {
32
- return node . delegate ;
33
- } ) ) ;
31
+ var selected = selection . pick ( ) ;
32
+ type . matched . setDataset ( selected ? selected . delegate : null ) ;
34
33
}
35
34
}
36
35
} ,
37
36
38
37
selection : true ,
39
38
childClass : {
40
- template : resource ( 'template/type.tmpl' ) ,
39
+ template : resource ( './ template/type.tmpl' ) ,
41
40
binding : {
42
41
type : 'data:title' ,
43
- count : function ( node ) {
44
- return node . delegate && node . delegate . itemCount ;
45
- }
46
- } ,
47
- listen : {
48
- delegate : {
49
- itemsChanged : function ( ) {
50
- this . updateBind ( 'count' ) ;
42
+ count : {
43
+ events : 'delegateChanged' ,
44
+ getter : function ( node ) {
45
+ return node . delegate ? countIndex ( node . delegate ) : 0 ;
51
46
}
52
47
}
53
48
}
54
49
}
55
50
} ) ;
56
-
57
- type . files . addHandler ( {
58
- itemsChanged : function ( ) {
59
- view . updateBind ( 'totalCount' ) ;
60
- }
61
- } ) ;
62
-
63
- module . exports = view ;
0 commit comments