diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js b/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js
index cf710eead..0aa15e796 100644
--- a/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js
+++ b/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js
@@ -33,6 +33,7 @@ Backbone.Model.prototype.fetchIfNeeded = function(options) {
return options.success(this, null);
}
};
+
Backbone.Collection.prototype.fetchIfNeeded = function(options) {
var _self = this;
if (!options) {
@@ -639,58 +640,26 @@ var AppRouter = Backbone.Router.extend({
this.updateSidebar('admin/clients');
var client = this.clientList.get(id);
-
- if (client == null) {
- // it wasn't in the list, try loading the client directly
- client = new ClientModel({id: id});
+ if (!client) {
+ client = new ClientModel({id:id});
}
-
- $('#loadingbox').sheet('show');
- $('#loading').html(
- '' + $.t('common.scopes') + ' '
- + '' + $.t('common.client') + ' ');
-
- // re-sync the client every time
- client.fetch({
- success: function(client, response, options) {
- $('#loading-client').addClass('label-success');
-
- if ($.inArray("refresh_token", client.get("grantTypes")) != -1) {
- client.set({
- allowRefresh: true
- }, { silent: true });
- }
-
- client.set({
- generateClientSecret:false,
- displayClientSecret:false
- }, { silent: true });
-
- var view = new ClientFormView({model:client, systemScopeList: app.systemScopeList});
- view.load(function() {
- $('#content').html(view.render().el);
- setPageTitle($.t('client.client-form.edit'));
- });
-
-
- },
- error: function(model, response, options) {
-
- //Pull out the response text.
- var responseJson = JSON.parse(response.responseText);
-
- //Display an alert with an error message
- $('#modalAlert div.modal-header').html(responseJson.error);
- $('#modalAlert div.modal-body').html(responseJson.error_description);
-
- $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog
- "backdrop" : "static",
- "keyboard" : true,
- "show" : true // ensure the modal is shown immediately
- });
-
- }
- });
+
+ var view = new ClientFormView({model:client, systemScopeList: app.systemScopeList});
+ view.load(function() {
+ if ($.inArray("refresh_token", client.get("grantTypes")) != -1) {
+ client.set({
+ allowRefresh: true
+ }, { silent: true });
+ }
+
+ client.set({
+ generateClientSecret:false,
+ displayClientSecret:false
+ }, { silent: true });
+
+ $('#content').html(view.render().el);
+ setPageTitle($.t('client.client-form.edit'));
+ });
},
diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/client.js b/openid-connect-server-webapp/src/main/webapp/resources/js/client.js
index 2a5f16d67..5cb704b5e 100644
--- a/openid-connect-server-webapp/src/main/webapp/resources/js/client.js
+++ b/openid-connect-server-webapp/src/main/webapp/resources/js/client.js
@@ -644,20 +644,21 @@ var ClientFormView = Backbone.View.extend({
},
load:function(callback) {
- if (this.options.systemScopeList.isFetched) {
- $('#loadingbox').sheet('hide');
+ if (this.model.isFetched &&
+ this.options.systemScopeList.isFetched) {
callback();
return;
}
- if (this.model.get('id') == null) {
- // only show the box if this is a new client, otherwise the box is already showing
- $('#loadingbox').sheet('show');
- $('#loading').html('' + $.t("common.scopes") + ' ');
- }
-
- $.when(this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
- .done(function() {
+ $('#loadingbox').sheet('show');
+ $('#loading').html(
+ '' + $.t('common.clients') + ' ' +
+ '' + $.t("common.scopes") + ' '
+ );
+
+ $.when(this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}),
+ this.model.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}}))
+ .done(function() {
$('#loadingbox').sheet('hide');
callback();
});
diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/whitelist.js b/openid-connect-server-webapp/src/main/webapp/resources/js/whitelist.js
index 524e64ebb..a7b169a1a 100644
--- a/openid-connect-server-webapp/src/main/webapp/resources/js/whitelist.js
+++ b/openid-connect-server-webapp/src/main/webapp/resources/js/whitelist.js
@@ -261,7 +261,7 @@ var WhiteListFormView = Backbone.View.extend({
if (this.options.client) {
// we know what client we're dealing with already
if (this.model.isFetched &&
- this.options.client.isFetched()) {
+ this.options.client.isFetched) {
callback();
return;
}