Browse Source

claim removal and policy saving

pull/708/merge
Justin Richer 10 years ago
parent
commit
1ad1813239
  1. 9
      openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json
  2. 61
      openid-connect-server-webapp/src/main/webapp/resources/js/policy.js
  3. 20
      openid-connect-server-webapp/src/main/webapp/resources/template/policy.html

9
openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json

@ -345,9 +345,14 @@
"required-claims": "Required Claims",
"policy-table": {
"edit": "Edit Policies",
"email-address": "email address",
"required-claims": "Users that you share this resource will with need to be able to present the following claims in order to access the resource.",
"no-resource-sets": "There are no resource sets registered. Introduce a protected to this authorization server to let it register some.",
"no-required-claims": "There are no required claims for this resource set.",
"share-email": "Share with email address"
"no-required-claims": "There are no required claims for this resource set: This resource set is inaccessible by others.",
"share-email": "Share with email address",
"issuers": "Issuers",
"claim": "Claim",
"value": "Value"
}
},
"copyright": "Powered by <a href=\"https://github.com/mitreid-connect/\">MITREid Connect <span class=\"label\">{0}</span></a> <span class=\"pull-right\">&copy; 2015 The MITRE Corporation and MIT KIT.</span>.",

61
openid-connect-server-webapp/src/main/webapp/resources/js/policy.js

@ -211,6 +211,47 @@ var ClaimListView = Backbone.View.extend({
});
},
events:{
'click .btn-save':'savePolicy',
'click .btn-cancel':'cancel',
'click .btn-share':'addClaim'
},
cancel:function(e) {
e.preventDefault();
app.navigate('user/policy', {trigger: true});
},
savePolicy:function(e) {
e.preventDefault();
var _self = this;
console.log(this);
this.model.sync('update', this.model, {
success:function() {
app.navigate('user/policy', {trigger: true});
},
error:function (error, response) {
console.log("An error occurred when saving a policy set");
//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
});
}
});
},
togglePlaceholder:function() {
if (this.model.length > 0) {
$('#required-claim-table', this.el).show();
@ -252,6 +293,26 @@ var ClaimView = Backbone.View.extend({
}
},
events:{
'click .btn-remove':'removeClaim'
},
removeClaim:function(e) {
e.preventDefault();
var _self = this;
this.model.collection.remove(this.model);
_self.$el.fadeTo("fast", 0.00, function () { //fade
$(this).slideUp("fast", function () { //slide up
$(this).remove(); //then remove from the DOM
_self.parentView.togglePlaceholder();
});
});
},
render:function (eventName) {
var json = this.model.toJSON();

20
openid-connect-server-webapp/src/main/webapp/resources/template/policy.html

@ -63,25 +63,29 @@
<button class="btn btn-small btn-cancel"><i class="icon-ban-circle"></i> <span data-i18n="common.cancel">Cancel</span></button>
</div>
<div id="required-claim-table-empty" class="alert alert-info" data-i18n="policy.policy-table.no-required-claims">
There are no required claims for this resource set.
</div>
<div id="add-required-claim">
<form class="form-horizontal">
<fieldset>
<input type="text" id="email" placeholder="email address" />
<input type="text" id="email" placeholder="email address" data-i18n="[placeholder]policy.policy-table.email-address" />
<button id="add-email" class="btn btn-info"><i class="icon-share icon-white"></i> <span data-i18n="policy.policy-table.share-email">Share with email address</span></button>
</fieldset>
</form>
</div>
<div class="alert alert-info" data-i18n="policy.policy-table.required-claims">
Users that you share this resource will with need to be able to present the following claims in order to access the resource.
</div>
<div id="required-claim-table-empty" class="alert alert-danger" data-i18n="policy.policy-table.no-required-claims">
There are no required claims for this resource set: This resource set is inaccessible by others.
</div>
<table id="required-claim-table" class="table table-hover table-striped">
<thead>
<tr>
<th>Issuers</th>
<th>Claim</th>
<th>Value</th>
<th data-i18n="policy.policy-table.issuers">Issuers</th>
<th data-i18n="policy.policy-table.claim">Claim</th>
<th data-i18n="policy.policy-table.value">Value</th>
<th></th>
</thead>
<tbody>

Loading…
Cancel
Save