Merge branch 'master' into uma
pulled in deep link checking and checkbox handlingpull/708/merge
commit
351ce3995a
|
@ -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,22 +640,12 @@ 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
|
||||
if (!client) {
|
||||
client = new ClientModel({id:id});
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
+ '<span class="label" id="loading-client">' + $.t('common.client') + '</span> ');
|
||||
|
||||
// re-sync the client every time
|
||||
client.fetch({
|
||||
success: function(client, response, options) {
|
||||
$('#loading-client').addClass('label-success');
|
||||
|
||||
var view = new ClientFormView({model:client, systemScopeList: app.systemScopeList});
|
||||
view.load(function() {
|
||||
if ($.inArray("refresh_token", client.get("grantTypes")) != -1) {
|
||||
client.set({
|
||||
allowRefresh: true
|
||||
|
@ -666,32 +657,10 @@ var AppRouter = Backbone.Router.extend({
|
|||
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
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
whiteList:function () {
|
||||
|
@ -729,13 +698,6 @@ var AppRouter = Backbone.Router.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
this.updateSidebar('admin/whitelists');
|
||||
|
||||
var client = this.clientList.get(cid);
|
||||
|
||||
// if there's no client this is an error
|
||||
if (client != null) {
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
|
@ -743,19 +705,28 @@ var AppRouter = Backbone.Router.extend({
|
|||
{text:$.t('whitelist.new'), href:"manage/#admin/whitelist/new/" + cid}
|
||||
]);
|
||||
|
||||
var whiteList = new WhiteListModel();
|
||||
whiteList.set({
|
||||
clientId: client.get('clientId'),
|
||||
allowedScopes: client.get('scope')
|
||||
}, { silent: true });
|
||||
this.updateSidebar('admin/whitelists');
|
||||
|
||||
this.whiteListFormView = new WhiteListFormView({model: whiteList, client: client, systemScopeList: this.systemScopeList});
|
||||
$('#content').html(this.whiteListFormView.render().el);
|
||||
setPageTitle($.t('whitelist.new'));
|
||||
} else {
|
||||
console.log('ERROR: no client found for ' + cid);
|
||||
var whiteList = new WhiteListModel();
|
||||
|
||||
var client = this.clientList.get(cid);
|
||||
if (!client) {
|
||||
client = new ClientModel({id: cid});
|
||||
}
|
||||
|
||||
var view = new WhiteListFormView({model: whiteList, client: client, systemScopeList: this.systemScopeList});
|
||||
|
||||
view.load(
|
||||
function() {
|
||||
|
||||
// set the scopes on the model now that everything's loaded
|
||||
whiteList.set({allowedScopes: client.get('scope')}, {silent: true});
|
||||
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
setPageTitle($.t('whitelist.manage'));
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
|
||||
|
@ -776,21 +747,20 @@ var AppRouter = Backbone.Router.extend({
|
|||
this.updateSidebar('admin/whitelists');
|
||||
|
||||
var whiteList = this.whiteListList.get(id);
|
||||
if (whiteList != null) {
|
||||
var client = app.clientList.getByClientId(whiteList.get('clientId'));
|
||||
|
||||
// if there's no client, this is an error
|
||||
if (client != null) {
|
||||
this.whiteListFormView = new WhiteListFormView({model: whiteList, client: client, systemScopeList: this.systemScopeList});
|
||||
$('#content').html(this.whiteListFormView.render().el);
|
||||
setPageTitle($.t('whitelist.edit'));
|
||||
|
||||
} else {
|
||||
console.log('ERROR: no client found for ' + whiteList.get('clientId'));
|
||||
if (!whiteList) {
|
||||
whiteList = new WhiteListModel({id: id});
|
||||
}
|
||||
} else {
|
||||
console.error('ERROR: no whitelist found for id ' + id);
|
||||
|
||||
var view = new WhiteListFormView({model: whiteList, clientList: this.clientList, systemScopeList: this.systemScopeList});
|
||||
|
||||
view.load(
|
||||
function() {
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
setPageTitle($.t('whitelist.manage'));
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
|
||||
approvedSites:function() {
|
||||
|
@ -912,9 +882,11 @@ var AppRouter = Backbone.Router.extend({
|
|||
|
||||
var scope = new SystemScopeModel();
|
||||
|
||||
this.systemScopeFormView = new SystemScopeFormView({model:scope});
|
||||
$('#content').html(this.systemScopeFormView.render().el);
|
||||
var view = new SystemScopeFormView({model:scope});
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('scope.system-scope-form.new'));
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
@ -935,10 +907,15 @@ var AppRouter = Backbone.Router.extend({
|
|||
this.updateSidebar('admin/scope');
|
||||
|
||||
var scope = this.systemScopeList.get(sid);
|
||||
if (!scope) {
|
||||
scope = new SystemScopeModel({id: sid});
|
||||
}
|
||||
|
||||
this.systemScopeFormView = new SystemScopeFormView({model:scope});
|
||||
$('#content').html(this.systemScopeFormView.render().el);
|
||||
setPageTitle($.t('scope.system-scope-form.edit'));
|
||||
var view = new SystemScopeFormView({model:scope});
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('scope.system-scope-form.new'));
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -644,19 +644,20 @@ 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('<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> ');
|
||||
}
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> '
|
||||
);
|
||||
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||
$.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();
|
||||
|
|
|
@ -284,6 +284,25 @@ var SystemScopeFormView = Backbone.View.extend({
|
|||
'change #isStructured input':'toggleStructuredParamDescription'
|
||||
},
|
||||
|
||||
load:function(callback) {
|
||||
if (this.model.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> '
|
||||
);
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||
.done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
toggleStructuredParamDescription:function(e) {
|
||||
if ($('#isStructured input', this.el).is(':checked')) {
|
||||
$('#structuredParamDescription', this.el).show();
|
||||
|
|
|
@ -254,6 +254,73 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
|
||||
this.listWidgetViews = [];
|
||||
|
||||
},
|
||||
|
||||
load:function(callback) {
|
||||
|
||||
if (this.options.client) {
|
||||
// we know what client we're dealing with already
|
||||
if (this.model.isFetched &&
|
||||
this.options.client.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-whitelist').addClass('label-success');}}),
|
||||
this.options.client.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||
.done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
||||
} else {
|
||||
// we need to get the client information from the list
|
||||
|
||||
if (this.model.isFetched &&
|
||||
this.options.clientList.isFetched &&
|
||||
this.options.systemScopeList.isFetched) {
|
||||
|
||||
var client = this.options.clientList.getByClientId(this.model.get('clientId'));
|
||||
this.options.client = client;
|
||||
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
|
||||
var _self = this;
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-whitelist').addClass('label-success');}}),
|
||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||
.done(function() {
|
||||
|
||||
var client = _self.options.clientList.getByClientId(_self.model.get('clientId'));
|
||||
_self.options.client = client;
|
||||
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
events:{
|
||||
|
@ -274,9 +341,7 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
// process allowed scopes
|
||||
var allowedScopes = this.scopeCollection.pluck("item");
|
||||
|
||||
if (this.model.get('id') == null) {
|
||||
this.model.set({clientId:$('#clientId input').val()});
|
||||
}
|
||||
this.model.set({clientId: this.options.client.get('clientId')}, {silent: true});
|
||||
|
||||
var valid = this.model.set({
|
||||
allowedScopes: allowedScopes
|
||||
|
@ -340,7 +405,7 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
|
||||
var scopeView = new ListWidgetView({
|
||||
placeholder: $.t('whitelist.whitelist-form.scope-placeholder'),
|
||||
autocomplete: this.options.client.scope,
|
||||
autocomplete: this.options.client.get("scope"),
|
||||
helpBlockText: $.t('whitelist.whitelist-form.scope-help'),
|
||||
collection: this.scopeCollection});
|
||||
$("#scope .controls",this.el).html(scopeView.render().el);
|
||||
|
|
|
@ -87,7 +87,6 @@
|
|||
<div class="control-group" id="clientId">
|
||||
<label class="control-label" data-i18n="common.client">Client</label>
|
||||
<div class="controls">
|
||||
<input type="hidden" name="clientId" value="<%- client.clientId %>" />
|
||||
<span title="<%- client.clientId %>"><%- client.clientName != null ? client.clientName : ( client.clientId.substr(0,8) + '...' ) %></span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue