From f91071c350dc1935a4ab7ee90ea76c15accfe4dc Mon Sep 17 00:00:00 2001 From: Michael Jett Date: Mon, 14 May 2012 15:33:27 -0400 Subject: [PATCH] New clients now attempt to POST to client API --- .../src/main/webapp/resources/js/app.js | 36 +++++++++++++++++-- .../webapp/resources/template/client.html | 10 +++--- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/openid-connect-server/src/main/webapp/resources/js/app.js b/openid-connect-server/src/main/webapp/resources/js/app.js index 0f652d5ce..cd6cf1f85 100644 --- a/openid-connect-server/src/main/webapp/resources/js/app.js +++ b/openid-connect-server/src/main/webapp/resources/js/app.js @@ -102,6 +102,34 @@ } }, + events:{ + "click .btn-primary":"saveClient" + }, + + saveClient:function () { + this.model.set({ + name:$('#name').val(), + redirectURL:$('#redirectURL').val(), + description:$('#description').val() + }); + if (this.model.isNew()) { + var self = this; + app.clientList.create(this.model, { + success:function () { + alert('bravo!'); + }, + error: function () { + alert('boo!'); + } + }); + + } else { + this.model.save(); + } + + return false; + }, + render:function (eventName) { var action = "Edit"; @@ -137,12 +165,16 @@ }, newClient:function() { - this.clientFormView = new ClientFormView(); + this.clientFormView = new ClientFormView({model:new ClientModel()}); $('#content').html(this.clientFormView.render().el); } }); + // holds the global app. + // this gets init after the templates load + var app = null; + // main $(function () { @@ -150,7 +182,7 @@ $.get('resources/template/client.html', function (templates) { $('body').append(templates); - var app = new AppRouter(); + app = new AppRouter(); Backbone.history.start(); }); diff --git a/openid-connect-server/src/main/webapp/resources/template/client.html b/openid-connect-server/src/main/webapp/resources/template/client.html index ca3bf7efe..73b261d23 100644 --- a/openid-connect-server/src/main/webapp/resources/template/client.html +++ b/openid-connect-server/src/main/webapp/resources/template/client.html @@ -87,14 +87,14 @@
- Associated help text! + Associated help text! - - Associated help text! + + Associated help text!
- Associated help text!
@@ -108,7 +108,7 @@ - +