@@ -609,6 +609,9 @@ var ClientFormView = Backbone.View.extend({
609
609
this . defaultAcrValuesCollection = new Backbone . Collection ( ) ;
610
610
this . requestUrisCollection = new Backbone . Collection ( ) ;
611
611
// TODO: add Spring authorities collection and resource IDs collection?
612
+
613
+ // collection of sub-views that need to be sync'd on save
614
+ this . listWidgetViews = [ ] ;
612
615
} ,
613
616
614
617
events :{
@@ -800,12 +803,15 @@ var ClientFormView = Backbone.View.extend({
800
803
801
804
$ ( '.control-group' ) . removeClass ( 'error' ) ;
802
805
806
+
807
+ // sync any leftover collection items
808
+ _ . each ( this . listWidgetViews , function ( v ) {
809
+ v . addItem ( $ . Event ( 'click' ) ) ;
810
+ } ) ;
811
+
812
+
803
813
// build the scope object
804
814
var scopes = this . scopeCollection . pluck ( "item" ) ;
805
- var extraScope = $ ( '#scope input' ) . val ( ) ;
806
- if ( extraScope ) {
807
- scopes . push ( extraScope ) ;
808
- }
809
815
810
816
// build the grant type object
811
817
var grantTypes = [ ] ;
@@ -992,55 +998,69 @@ var ClientFormView = Backbone.View.extend({
992
998
993
999
var _self = this ;
994
1000
1001
+ // clear the sub-view collection
1002
+ this . listWidgetViews = [ ] ;
1003
+
995
1004
// build and bind registered redirect URI collection and view
996
1005
_ . each ( this . model . get ( "redirectUris" ) , function ( redirectUri ) {
997
1006
_self . redirectUrisCollection . add ( new URIModel ( { item :redirectUri } ) ) ;
998
1007
} ) ;
999
1008
1000
- $ ( "#redirectUris .controls" , this . el ) . html ( new ListWidgetView ( {
1009
+
1010
+ var redirUriView = new ListWidgetView ( {
1001
1011
type :'uri' ,
1002
1012
placeholder : 'https://' ,
1003
- collection : this . redirectUrisCollection } ) . render ( ) . el ) ;
1013
+ collection : this . redirectUrisCollection } ) ;
1014
+ $ ( "#redirectUris .controls" , this . el ) . html ( redirUriView . render ( ) . el ) ;
1015
+ this . listWidgetViews . push ( redirUriView ) ;
1004
1016
1005
1017
// build and bind scopes
1006
1018
_ . each ( this . model . get ( "scope" ) , function ( scope ) {
1007
1019
_self . scopeCollection . add ( new Backbone . Model ( { item :scope } ) ) ;
1008
1020
} ) ;
1009
1021
1010
- $ ( "#scope .controls" , this . el ) . html ( new ListWidgetView ( {
1022
+ var scopeView = new ListWidgetView ( {
1011
1023
placeholder : 'new scope' ,
1012
1024
autocomplete : _ . uniq ( _ . flatten ( this . options . systemScopeList . pluck ( "value" ) ) ) ,
1013
- collection : this . scopeCollection } ) . render ( ) . el ) ;
1025
+ collection : this . scopeCollection } ) ;
1026
+ $ ( "#scope .controls" , this . el ) . html ( scopeView . render ( ) . el ) ;
1027
+ this . listWidgetViews . push ( scopeView ) ;
1014
1028
1015
1029
// build and bind contacts
1016
1030
_ . each ( this . model . get ( 'contacts' ) , function ( contact ) {
1017
1031
_self . contactsCollection . add ( new Backbone . Model ( { item :contact } ) ) ;
1018
1032
} ) ;
1019
1033
1020
- $ ( "#contacts .controls" , this . el ) . html ( new ListWidgetView ( {
1034
+ var contactsView = new ListWidgetView ( {
1021
1035
placeholder : 'new contact' ,
1022
- collection : this . contactsCollection } ) . render ( ) . el ) ;
1036
+ collection : this . contactsCollection } ) ;
1037
+ $ ( "#contacts .controls" , this . el ) . html ( contactsView . render ( ) . el ) ;
1038
+ this . listWidgetViews . push ( contactsView ) ;
1023
1039
1024
1040
1025
1041
// build and bind request URIs
1026
1042
_ . each ( this . model . get ( 'requestUris' ) , function ( requestUri ) {
1027
1043
_self . requestUrisCollection . add ( new URIModel ( { item :requestUri } ) ) ;
1028
1044
} ) ;
1029
1045
1030
- $ ( '#requestUris .controls' , this . el ) . html ( new ListWidgetView ( {
1046
+ var requestUriView = new ListWidgetView ( {
1031
1047
type : 'uri' ,
1032
1048
placeholder : 'https://' ,
1033
- collection : this . requestUrisCollection } ) . render ( ) . el ) ;
1049
+ collection : this . requestUrisCollection } ) ;
1050
+ $ ( '#requestUris .controls' , this . el ) . html ( requestUriView . render ( ) . el ) ;
1051
+ this . listWidgetViews . push ( requestUriView ) ;
1034
1052
1035
1053
// build and bind default ACR values
1036
1054
_ . each ( this . model . get ( 'defaultAcrValues' ) , function ( defaultAcrValue ) {
1037
1055
_self . defaultAcrValuesCollection . add ( new Backbone . Model ( { item :defaultAcrValue } ) ) ;
1038
1056
} ) ;
1039
1057
1040
- $ ( '#defaultAcrValues .controls' , this . el ) . html ( new ListWidgetView ( {
1058
+ var defaultAcrView = new ListWidgetView ( {
1041
1059
placeholder : 'new ACR value' ,
1042
1060
// TODO: autocomplete from spec
1043
- collection : this . defaultAcrValuesCollection } ) . render ( ) . el ) ;
1061
+ collection : this . defaultAcrValuesCollection } ) ;
1062
+ $ ( '#defaultAcrValues .controls' , this . el ) . html ( defaultAcrView . render ( ) . el ) ;
1063
+ this . listWidgetViews . push ( defaultAcrView ) ;
1044
1064
1045
1065
// build and bind
1046
1066
0 commit comments