applied list widget catch to all objects

pull/730/head
Justin Richer 2014-11-13 14:16:00 -10:00
parent 51b10dbe96
commit b4f3039c5a
4 changed files with 73 additions and 27 deletions

View File

@ -803,13 +803,11 @@ var ClientFormView = Backbone.View.extend({
$('.control-group').removeClass('error'); $('.control-group').removeClass('error');
// sync any leftover collection items // sync any leftover collection items
_.each(this.listWidgetViews, function(v) { _.each(this.listWidgetViews, function(v) {
v.addItem($.Event('click')); v.addItem($.Event('click'));
}); });
// build the scope object // build the scope object
var scopes = this.scopeCollection.pluck("item"); var scopes = this.scopeCollection.pluck("item");

View File

@ -176,6 +176,8 @@ var DynRegEditView = Backbone.View.extend({
this.contactsCollection = new Backbone.Collection(); this.contactsCollection = new Backbone.Collection();
this.defaultAcrValuesCollection = new Backbone.Collection(); this.defaultAcrValuesCollection = new Backbone.Collection();
this.requestUrisCollection = new Backbone.Collection(); this.requestUrisCollection = new Backbone.Collection();
this.listWidgetViews = [];
}, },
load:function(callback) { load:function(callback) {
@ -318,6 +320,11 @@ var DynRegEditView = Backbone.View.extend({
$('.control-group').removeClass('error'); $('.control-group').removeClass('error');
// sync any leftover collection items
_.each(this.listWidgetViews, function(v) {
v.addItem($.Event('click'));
});
// build the scope object // build the scope object
var scopes = this.scopeCollection.pluck("item").join(" "); var scopes = this.scopeCollection.pluck("item").join(" ");
@ -434,6 +441,8 @@ var DynRegEditView = Backbone.View.extend({
render:function() { render:function() {
$(this.el).html(this.template({client: this.model.toJSON(), userInfo: getUserInfo()})); $(this.el).html(this.template({client: this.model.toJSON(), userInfo: getUserInfo()}));
this.listWidgetViews = [];
var _self = this; var _self = this;
// build and bind registered redirect URI collection and view // build and bind registered redirect URI collection and view
@ -441,10 +450,12 @@ var DynRegEditView = Backbone.View.extend({
_self.redirectUrisCollection.add(new URIModel({item:redirectUri})); _self.redirectUrisCollection.add(new URIModel({item:redirectUri}));
}); });
$("#redirectUris .controls",this.el).html(new ListWidgetView({ var redirectUriView = new ListWidgetView({
type:'uri', type:'uri',
placeholder: 'https://', placeholder: 'https://',
collection: this.redirectUrisCollection}).render().el); collection: this.redirectUrisCollection});
$("#redirectUris .controls",this.el).html(redirectUriView.render().el);
this.listWidgetViews.push(redirectUriView);
// build and bind scopes // build and bind scopes
var scopes = this.model.get("scope"); var scopes = this.model.get("scope");
@ -453,40 +464,47 @@ var DynRegEditView = Backbone.View.extend({
_self.scopeCollection.add(new Backbone.Model({item:scope})); _self.scopeCollection.add(new Backbone.Model({item:scope}));
}); });
$("#scope .controls",this.el).html(new ListWidgetView({ var scopeView = new ListWidgetView({
placeholder: 'new scope', placeholder: 'new scope',
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.pluck("value"))), autocomplete: _.uniq(_.flatten(this.options.systemScopeList.pluck("value"))),
collection: this.scopeCollection}).render().el); collection: this.scopeCollection});
$("#scope .controls",this.el).html(scopeView.render().el);
this.listWidgetViews.push(scopeView);
// build and bind contacts // build and bind contacts
_.each(this.model.get('contacts'), function (contact) { _.each(this.model.get('contacts'), function (contact) {
_self.contactsCollection.add(new Backbone.Model({item:contact})); _self.contactsCollection.add(new Backbone.Model({item:contact}));
}); });
$("#contacts .controls div", this.el).html(new ListWidgetView({ var contactView = new ListWidgetView({
placeholder: 'new contact', placeholder: 'new contact',
collection: this.contactsCollection}).render().el); collection: this.contactsCollection});
$("#contacts .controls div", this.el).html(contactView.render().el);
this.listWidgetViews.push(contactView);
// build and bind request URIs // build and bind request URIs
_.each(this.model.get('request_uris'), function (requestUri) { _.each(this.model.get('request_uris'), function (requestUri) {
_self.requestUrisCollection.add(new URIModel({item:requestUri})); _self.requestUrisCollection.add(new URIModel({item:requestUri}));
}); });
$('#requestUris .controls', this.el).html(new ListWidgetView({ var requestUriView = new ListWidgetView({
type: 'uri', type: 'uri',
placeholder: 'https://', placeholder: 'https://',
collection: this.requestUrisCollection}).render().el); collection: this.requestUrisCollection});
$('#requestUris .controls', this.el).html(requestUriView.render().el);
this.listWidgetViews.push(requestUriView);
// build and bind default ACR values // build and bind default ACR values
_.each(this.model.get('default_acr_values'), function (defaultAcrValue) { _.each(this.model.get('default_acr_values'), function (defaultAcrValue) {
_self.defaultAcrValuesCollection.add(new Backbone.Model({item:defaultAcrValue})); _self.defaultAcrValuesCollection.add(new Backbone.Model({item:defaultAcrValue}));
}); });
$('#defaultAcrValues .controls', this.el).html(new ListWidgetView({ var defaultAcrView = new ListWidgetView({
placeholder: 'new ACR value', placeholder: 'new ACR value',
// TODO: autocomplete from spec // TODO: autocomplete from spec
collection: this.defaultAcrValuesCollection}).render().el); collection: this.defaultAcrValuesCollection});
$('#defaultAcrValues .controls', this.el).html(defaultAcrView.render().el);
this.listWidgetViews.push(defaultAcrView);
this.toggleClientCredentials(); this.toggleClientCredentials();
this.previewLogo(); this.previewLogo();

View File

@ -142,6 +142,8 @@ var ResRegEditView = Backbone.View.extend({
this.contactsCollection = new Backbone.Collection(); this.contactsCollection = new Backbone.Collection();
this.defaultAcrValuesCollection = new Backbone.Collection(); this.defaultAcrValuesCollection = new Backbone.Collection();
this.requestUrisCollection = new Backbone.Collection(); this.requestUrisCollection = new Backbone.Collection();
this.listWidgetViews = [];
}, },
load:function(callback) { load:function(callback) {
@ -263,6 +265,11 @@ var ResRegEditView = Backbone.View.extend({
$('.control-group').removeClass('error'); $('.control-group').removeClass('error');
// sync any leftover collection items
_.each(this.listWidgetViews, function(v) {
v.addItem($.Event('click'));
});
// build the scope object // build the scope object
var scopes = this.scopeCollection.pluck("item").join(" "); var scopes = this.scopeCollection.pluck("item").join(" ");
@ -334,6 +341,8 @@ var ResRegEditView = Backbone.View.extend({
render:function() { render:function() {
$(this.el).html(this.template({client: this.model.toJSON(), userInfo: getUserInfo()})); $(this.el).html(this.template({client: this.model.toJSON(), userInfo: getUserInfo()}));
this.listWidgetViews = [];
var _self = this; var _self = this;
// build and bind registered redirect URI collection and view // build and bind registered redirect URI collection and view
@ -341,10 +350,12 @@ var ResRegEditView = Backbone.View.extend({
_self.redirectUrisCollection.add(new URIModel({item:redirectUri})); _self.redirectUrisCollection.add(new URIModel({item:redirectUri}));
}); });
$("#redirectUris .controls",this.el).html(new ListWidgetView({ var redirectUriView = new ListWidgetView({
type:'uri', type:'uri',
placeholder: 'https://', placeholder: 'https://',
collection: this.redirectUrisCollection}).render().el); collection: this.redirectUrisCollection});
$("#redirectUris .controls",this.el).html(redirectUriView.render().el);
this.listWidgetViews.push(redirectUriView);
// build and bind scopes // build and bind scopes
var scopes = this.model.get("scope"); var scopes = this.model.get("scope");
@ -353,19 +364,23 @@ var ResRegEditView = Backbone.View.extend({
_self.scopeCollection.add(new Backbone.Model({item:scope})); _self.scopeCollection.add(new Backbone.Model({item:scope}));
}); });
$("#scope .controls",this.el).html(new ListWidgetView({ var scopeView = new ListWidgetView({
placeholder: 'new scope', placeholder: 'new scope',
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.pluck("value"))), autocomplete: _.uniq(_.flatten(this.options.systemScopeList.pluck("value"))),
collection: this.scopeCollection}).render().el); collection: this.scopeCollection});
$("#scope .controls",this.el).html(scopeView.render().el);
this.listWidgetViews.push(scopeView);
// build and bind contacts // build and bind contacts
_.each(this.model.get('contacts'), function (contact) { _.each(this.model.get('contacts'), function (contact) {
_self.contactsCollection.add(new Backbone.Model({item:contact})); _self.contactsCollection.add(new Backbone.Model({item:contact}));
}); });
$("#contacts .controls div", this.el).html(new ListWidgetView({ var contactView = new ListWidgetView({
placeholder: 'new contact', placeholder: 'new contact',
collection: this.contactsCollection}).render().el); collection: this.contactsCollection});
$("#contacts .controls div", this.el).html(contactView.render().el);
this.listWidgetViews.push(contactView);
// build and bind request URIs // build and bind request URIs
@ -373,20 +388,24 @@ var ResRegEditView = Backbone.View.extend({
_self.requestUrisCollection.add(new URIModel({item:requestUri})); _self.requestUrisCollection.add(new URIModel({item:requestUri}));
}); });
$('#requestUris .controls', this.el).html(new ListWidgetView({ var requestUriView = new ListWidgetView({
type: 'uri', type: 'uri',
placeholder: 'https://', placeholder: 'https://',
collection: this.requestUrisCollection}).render().el); collection: this.requestUrisCollection});
$('#requestUris .controls', this.el).html(requestUriView.render().el);
this.listWidgetViews.push(requestUriView);
// build and bind default ACR values // build and bind default ACR values
_.each(this.model.get('defaultAcrValues'), function (defaultAcrValue) { _.each(this.model.get('defaultAcrValues'), function (defaultAcrValue) {
_self.defaultAcrValuesCollection.add(new Backbone.Model({item:defaultAcrValue})); _self.defaultAcrValuesCollection.add(new Backbone.Model({item:defaultAcrValue}));
}); });
$('#defaultAcrValues .controls', this.el).html(new ListWidgetView({ var defaultAcrView = new ListWidgetView({
placeholder: 'new ACR value', placeholder: 'new ACR value',
// TODO: autocomplete from spec // TODO: autocomplete from spec
collection: this.defaultAcrValuesCollection}).render().el); collection: this.defaultAcrValuesCollection});
$('#defaultAcrValues .controls', this.el).html(defaultAcrView.render().el);
this.listWidgetViews.push(defaultAcrView);
this.toggleClientCredentials(); this.toggleClientCredentials();
this.previewLogo(); this.previewLogo();

View File

@ -248,6 +248,9 @@ var WhiteListFormView = Backbone.View.extend({
} }
this.scopeCollection = new Backbone.Collection(); this.scopeCollection = new Backbone.Collection();
this.listWidgetViews = [];
}, },
events:{ events:{
@ -260,6 +263,11 @@ var WhiteListFormView = Backbone.View.extend({
e.preventDefault(); e.preventDefault();
$('.control-group').removeClass('error'); $('.control-group').removeClass('error');
// sync any leftover collection items
_.each(this.listWidgetViews, function(v) {
v.addItem($.Event('click'));
});
// process allowed scopes // process allowed scopes
var allowedScopes = this.scopeCollection.pluck("item"); var allowedScopes = this.scopeCollection.pluck("item");
@ -319,6 +327,7 @@ var WhiteListFormView = Backbone.View.extend({
this.$el.html(this.template(json)); this.$el.html(this.template(json));
this.listWidgetViews = [];
var _self = this; var _self = this;
// build and bind scopes // build and bind scopes
@ -326,10 +335,12 @@ var WhiteListFormView = Backbone.View.extend({
_self.scopeCollection.add(new Backbone.Model({item:scope})); _self.scopeCollection.add(new Backbone.Model({item:scope}));
}); });
$("#scope .controls",this.el).html(new ListWidgetView({ var scopeView = new ListWidgetView({
placeholder: 'new scope here', placeholder: 'new scope here',
autocomplete: this.options.client.scope, autocomplete: this.options.client.scope,
collection: this.scopeCollection}).render().el); collection: this.scopeCollection});
$("#scope .controls",this.el).html(scopeView.render().el);
this.listWidgetViews.push(scopeView);
return this; return this;