1-
21angular . module ( 'schemaForm' ) . config ( [ 'schemaFormDecoratorsProvider' , 'sfBuilderProvider' , 'sfPathProvider' ,
32function ( decoratorsProvider , sfBuilderProvider , sfPathProvider ) {
43 var base = 'decorators/bootstrap/' ;
@@ -9,9 +8,7 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
98 var sfField = sfBuilderProvider . builders . sfField ;
109
1110 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]' ) ;
1512 if ( items ) {
1613 state = angular . copy ( args . state ) ;
1714 state . keyRedaction = state . keyRedaction || 0 ;
@@ -40,7 +37,7 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
4037 textarea : { template : base + 'textarea.html' , builder : defaults } ,
4138 fieldset : { template : base + 'fieldset.html' , builder : [ sfField , simpleTransclusion ] } ,
4239 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 ] } ,
4441 tabs : { template : base + 'tabs.html' , replace : false } ,
4542 section : { template : base + 'section.html' , builder : [ sfField , simpleTransclusion ] } ,
4643 conditional : { template : base + 'section.html' , builder : [ sfField , simpleTransclusion ] } ,
@@ -77,10 +74,8 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
7774 var watchFn = function ( ) {
7875 //scope.modelArray = modelArray;
7976 scope . modelArray = scope . $eval ( attrs . sfNewArray ) ;
80- console . warn ( 'array watch!' )
8177 // validateField method is exported by schema-validate
8278 if ( scope . validateField ) {
83- console . warn ( 'calling validate field' ) ;
8479 scope . validateField ( ) ;
8580 }
8681 } ;
@@ -110,7 +105,7 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
110105 } else {
111106 // Otherwise we like to check if the instance of the array has changed, or if something
112107 // has been added/removed.
113- scope . $watch ( [ attrs . sfNewArray , attrs . sfNewArray + '.length' ] , function ( ) {
108+ scope . $watchGroup ( [ attrs . sfNewArray , attrs . sfNewArray + '.length' ] , function ( ) {
114109 watchFn ( ) ;
115110 onChangeFn ( ) ;
116111 } ) ;
@@ -120,6 +115,7 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
120115 } ) ;
121116
122117 scope . appendToArray = function ( ) {
118+
123119 var empty ;
124120
125121 // Same old add empty things to the array hack :(
@@ -139,18 +135,19 @@ function(decoratorsProvider, sfBuilderProvider, sfPathProvider) {
139135 var selection = sfPath . parse ( attrs . sfNewArray ) ;
140136 model = [ ] ;
141137 sel ( selection , scope , model ) ;
142- if ( scope . ngModel ) {
143- scope . ngModel . $setViewValue ( model ) ;
144- }
138+ scope . modelArray = model ;
145139 }
146140 model . push ( empty ) ;
141+
142+ return model ;
147143 } ;
148144
149145 scope . deleteFromArray = function ( index ) {
150146 var model = scope . modelArray ;
151147 if ( model ) {
152148 model . splice ( index , 1 ) ;
153149 }
150+ return model ;
154151 } ;
155152 }
156153 } ;
0 commit comments