fixed whitelist deep linking, closes #718
parent
8caaf3ae20
commit
692e8418d6
|
@ -729,33 +729,33 @@ var AppRouter = Backbone.Router.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.breadCrumbView.collection.reset();
|
||||||
|
this.breadCrumbView.collection.add([
|
||||||
|
{text:$.t('admin.home'), href:""},
|
||||||
|
{text:$.t('whitelist.manage'), href:"manage/#admin/whitelists"},
|
||||||
|
{text:$.t('whitelist.new'), href:"manage/#admin/whitelist/new/" + cid}
|
||||||
|
]);
|
||||||
|
|
||||||
this.updateSidebar('admin/whitelists');
|
this.updateSidebar('admin/whitelists');
|
||||||
|
|
||||||
|
////
|
||||||
|
var whiteList = this.whiteListList.get(id);
|
||||||
|
whiteList = new WhiteListModel({id: id});
|
||||||
|
|
||||||
var client = this.clientList.get(cid);
|
var client = this.clientList.get(cid);
|
||||||
|
if (!client) {
|
||||||
// if there's no client this is an error
|
client = new ClientModel({id: cid});
|
||||||
if (client != null) {
|
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
|
||||||
this.breadCrumbView.collection.add([
|
|
||||||
{text:$.t('admin.home'), href:""},
|
|
||||||
{text:$.t('whitelist.manage'), href:"manage/#admin/whitelists"},
|
|
||||||
{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.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 view = new WhiteListFormView({model: whiteList, client: client, systemScopeList: this.systemScopeList});
|
||||||
|
|
||||||
|
view.load(
|
||||||
|
function() {
|
||||||
|
$('#content').html(view.render().el);
|
||||||
|
view.delegateEvents();
|
||||||
|
setPageTitle($.t('whitelist.manage'));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -776,21 +776,20 @@ var AppRouter = Backbone.Router.extend({
|
||||||
this.updateSidebar('admin/whitelists');
|
this.updateSidebar('admin/whitelists');
|
||||||
|
|
||||||
var whiteList = this.whiteListList.get(id);
|
var whiteList = this.whiteListList.get(id);
|
||||||
if (whiteList != null) {
|
if (!whiteList) {
|
||||||
var client = app.clientList.getByClientId(whiteList.get('clientId'));
|
whiteList = new WhiteListModel({id: id});
|
||||||
|
|
||||||
// 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'));
|
|
||||||
}
|
|
||||||
} 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() {
|
approvedSites:function() {
|
||||||
|
|
|
@ -254,6 +254,73 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
|
|
||||||
this.listWidgetViews = [];
|
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:{
|
events:{
|
||||||
|
@ -274,9 +341,7 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
// process allowed scopes
|
// process allowed scopes
|
||||||
var allowedScopes = this.scopeCollection.pluck("item");
|
var allowedScopes = this.scopeCollection.pluck("item");
|
||||||
|
|
||||||
if (this.model.get('id') == null) {
|
this.model.set(this.options.client.get('clientId'));
|
||||||
this.model.set({clientId:$('#clientId input').val()});
|
|
||||||
}
|
|
||||||
|
|
||||||
var valid = this.model.set({
|
var valid = this.model.set({
|
||||||
allowedScopes: allowedScopes
|
allowedScopes: allowedScopes
|
||||||
|
|
|
@ -87,7 +87,6 @@
|
||||||
<div class="control-group" id="clientId">
|
<div class="control-group" id="clientId">
|
||||||
<label class="control-label" data-i18n="common.client">Client</label>
|
<label class="control-label" data-i18n="common.client">Client</label>
|
||||||
<div class="controls">
|
<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>
|
<span title="<%- client.clientId %>"><%- client.clientName != null ? client.clientName : ( client.clientId.substr(0,8) + '...' ) %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue