methods for creating, editing, and deleting whitelist sites all function
parent
321172c40c
commit
845c11ad3a
|
@ -147,6 +147,15 @@
|
||||||
//this.fetch();
|
//this.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getByClientId: function(clientId) {
|
||||||
|
var clients = this.where({clientId: clientId});
|
||||||
|
if (clients.length == 1) {
|
||||||
|
return clients[0];
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
model: WhiteListModel,
|
model: WhiteListModel,
|
||||||
url: "api/whitelist"
|
url: "api/whitelist"
|
||||||
|
|
||||||
|
@ -286,13 +295,25 @@
|
||||||
|
|
||||||
events:{
|
events:{
|
||||||
"click .btn-edit":"editClient",
|
"click .btn-edit":"editClient",
|
||||||
"click .btn-delete":"deleteClient"
|
"click .btn-delete":"deleteClient",
|
||||||
|
"click .btn-whitelist":"whiteListClient"
|
||||||
},
|
},
|
||||||
|
|
||||||
editClient:function () {
|
editClient:function () {
|
||||||
app.navigate('admin/client/' + this.model.id, {trigger: true});
|
app.navigate('admin/client/' + this.model.id, {trigger: true});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
whiteListClient:function() {
|
||||||
|
var whiteList = app.whiteListList.getByClientId(this.model.get('clientId'));
|
||||||
|
if (whiteList == null) {
|
||||||
|
// create a new one
|
||||||
|
app.navigate('admin/whitelist/new/' + this.model.id, {trigger: true});
|
||||||
|
} else {
|
||||||
|
// edit the existing one
|
||||||
|
app.navigate('admin/whitelist/' + whiteList.id, {trigger: true});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
deleteClient:function () {
|
deleteClient:function () {
|
||||||
|
|
||||||
if (confirm("Are you sure sure you would like to delete this client?")) {
|
if (confirm("Are you sure sure you would like to delete this client?")) {
|
||||||
|
@ -764,7 +785,7 @@
|
||||||
"admin/client/:id":"editClient",
|
"admin/client/:id":"editClient",
|
||||||
|
|
||||||
"admin/whitelists":"whiteList",
|
"admin/whitelists":"whiteList",
|
||||||
"admin/whitelist/new":"newWhitelist",
|
"admin/whitelist/new/:cid":"newWhitelist",
|
||||||
"admin/whitelist/:id":"editWhitelist"
|
"admin/whitelist/:id":"editWhitelist"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -887,7 +908,31 @@
|
||||||
this.whiteListListView.delegateEvents();
|
this.whiteListListView.delegateEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
newWhitelist:function() {
|
newWhitelist:function(cid) {
|
||||||
|
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:"Home", href:""},
|
||||||
|
{text:"Manage Whitelisted Sites", href:"manage/#admin/whitelists"},
|
||||||
|
{text:"Manage Whitelisted Sites", 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});
|
||||||
|
$('#content').html(this.whiteListFormView.render().el);
|
||||||
|
} else {
|
||||||
|
console.log('ERROR: no client found for ' + cid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -900,14 +945,19 @@
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var whiteList = this.whiteListList.get(id);
|
var whiteList = this.whiteListList.get(id);
|
||||||
var client = app.clientList.getByClientId(whiteList.get('clientId'));
|
if (whiteList != null) {
|
||||||
|
var client = app.clientList.getByClientId(whiteList.get('clientId'));
|
||||||
|
|
||||||
// if there's no client, this is an error
|
// if there's no client, this is an error
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
this.whiteListFormView = new WhiteListFormView({model: whiteList, client: client});
|
this.whiteListFormView = new WhiteListFormView({model: whiteList, client: client});
|
||||||
$('#content').html(this.whiteListFormView.render().el);
|
$('#content').html(this.whiteListFormView.render().el);
|
||||||
|
} else {
|
||||||
|
console.log('ERROR: no client found for ' + whiteList.get('clientId'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error('ERROR: no whitelist found for id ' + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-edit">edit</button> <button class="btn btn-danger btn-delete">delete</button> <button class="btn btn-warning btn-whitelist>whitelist</button>
|
<button class="btn btn-edit">edit</button> <button class="btn btn-danger btn-delete">delete</button> <button class="btn btn-warning btn-whitelist">whitelist</button>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -47,8 +47,6 @@
|
||||||
|
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Details</legend>
|
|
||||||
|
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<button class="btn btn-small btn-primary">Save</button> <button class="btn btn-small btn-cancel">Cancel</button>
|
<button class="btn btn-small btn-primary">Save</button> <button class="btn btn-small btn-cancel">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -282,10 +280,6 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="tmpl-whitelist-table">
|
<script type="text/html" id="tmpl-whitelist-table">
|
||||||
<div class="well">
|
|
||||||
<button class="btn btn-small btn-primary">New Whitelisted Site</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table id="whitelist-table" class="table">
|
<table id="whitelist-table" class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -298,9 +292,6 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="well">
|
|
||||||
<button class="btn btn-small btn-primary">New Whitelisted Site</button>
|
|
||||||
</div>
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="tmpl-whitelist-form">
|
<script type="text/html" id="tmpl-whitelist-form">
|
||||||
|
@ -310,8 +301,6 @@
|
||||||
|
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Details</legend>
|
|
||||||
|
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<button class="btn btn-small btn-primary">Save</button> <button class="btn btn-small btn-cancel">Cancel</button>
|
<button class="btn btn-small btn-primary">Save</button> <button class="btn btn-small btn-cancel">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue