1
-
2
1
angular . module ( 'schemaForm' ) . config ( [ 'schemaFormDecoratorsProvider' , 'sfBuilderProvider' , 'sfPathProvider' ,
3
2
function ( decoratorsProvider , sfBuilderProvider , sfPathProvider ) {
4
3
var base = 'decorators/bootstrap/' ;
@@ -9,9 +8,7 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
9
8
var sfField = sfBuilderProvider . builders . sfField ;
10
9
11
10
var array = function ( args ) {
12
- console . log ( 'array' , args ) ;
13
-
14
- var items = args . fieldFrag . querySelector ( 'li.schema-form-array-items' ) ;
11
+ var items = args . fieldFrag . querySelector ( '[schema-form-array-items]' ) ;
15
12
if ( items ) {
16
13
state = angular . copy ( args . state ) ;
17
14
state . keyRedaction = state . keyRedaction || 0 ;
@@ -40,7 +37,7 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
40
37
textarea : { template : base + 'textarea.html' , builder : defaults } ,
41
38
fieldset : { template : base + 'fieldset.html' , builder : [ sfField , simpleTransclusion ] } ,
42
39
array : { template : base + 'array.html' , builder : [ sfField , ngModelOptions , ngModel , array ] } ,
43
- tabarray : { template : base + 'tabarray.html' , replace : false } ,
40
+ tabarray : { template : base + 'tabarray.html' , builder : [ sfField , ngModelOptions , ngModel , array ] } ,
44
41
tabs : { template : base + 'tabs.html' , replace : false } ,
45
42
section : { template : base + 'section.html' , builder : [ sfField , simpleTransclusion ] } ,
46
43
conditional : { template : base + 'section.html' , builder : [ sfField , simpleTransclusion ] } ,
@@ -77,10 +74,8 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
77
74
var watchFn = function ( ) {
78
75
//scope.modelArray = modelArray;
79
76
scope . modelArray = scope . $eval ( attrs . sfNewArray ) ;
80
- console . warn ( 'array watch!' )
81
77
// validateField method is exported by schema-validate
82
78
if ( scope . validateField ) {
83
- console . warn ( 'calling validate field' ) ;
84
79
scope . validateField ( ) ;
85
80
}
86
81
} ;
@@ -110,7 +105,7 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
110
105
} else {
111
106
// Otherwise we like to check if the instance of the array has changed, or if something
112
107
// has been added/removed.
113
- scope . $watch ( [ attrs . sfNewArray , attrs . sfNewArray + '.length' ] , function ( ) {
108
+ scope . $watchGroup ( [ attrs . sfNewArray , attrs . sfNewArray + '.length' ] , function ( ) {
114
109
watchFn ( ) ;
115
110
onChangeFn ( ) ;
116
111
} ) ;
@@ -120,6 +115,7 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
120
115
} ) ;
121
116
122
117
scope . appendToArray = function ( ) {
118
+
123
119
var empty ;
124
120
125
121
// Same old add empty things to the array hack :(
@@ -139,18 +135,19 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
139
135
var selection = sfPath . parse ( attrs . sfNewArray ) ;
140
136
model = [ ] ;
141
137
sel ( selection , scope , model ) ;
142
- if ( scope . ngModel ) {
143
- scope . ngModel . $setViewValue ( model ) ;
144
- }
138
+ scope . modelArray = model ;
145
139
}
146
140
model . push ( empty ) ;
141
+
142
+ return model ;
147
143
} ;
148
144
149
145
scope . deleteFromArray = function ( index ) {
150
146
var model = scope . modelArray ;
151
147
if ( model ) {
152
148
model . splice ( index , 1 ) ;
153
149
}
150
+ return model ;
154
151
} ;
155
152
}
156
153
} ;
0 commit comments