Skip to content

Commit 0781592

Browse files
committed
added "clear all claims" function
1 parent cf70a20 commit 0781592

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

uma-server-webapp/src/main/webapp/resources/js/locale/en/uma.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@
3737
"email-address": "email address",
3838
"share-email": "Share with email address",
3939
"new": "New Policy",
40-
"edit": "Edit Policy"
41-
40+
"edit": "Edit Policy",
41+
"claim-name": "claim name",
42+
"friendly-claim-name": "friendly claim name",
43+
"claim-value": "claim value",
44+
"value-type-text": "Text",
45+
"value-type-number": "Number",
46+
"clear-all": "Clear all claims",
47+
"clear-all-confirm": "Are you sure you want to clear all claims from this policy?"
4248
},
4349
"webfinger-error": "Error",
4450
"webfinger-error-description": "The server was unable to find an identity provider for <code>__email__</code>.",

uma-server-webapp/src/main/webapp/resources/js/policy.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ var PolicyFormView = Backbone.View.extend({
413413
events:{
414414
'click .btn-share': 'addWebfingerClaim',
415415
'click .btn-share-advanced': 'addAdvancedClaim',
416+
'click .btn-clear': 'clearAllClaims',
416417
'click .btn-save': 'savePolicy',
417418
'click .btn-cancel': 'cancel'
418419
},
@@ -522,14 +523,12 @@ var PolicyFormView = Backbone.View.extend({
522523
if (!claimsRequired) {
523524
claimsRequired = [];
524525
}
525-
console.log(claimsRequired);
526526
claimsRequired.push({
527527
name: name,
528528
friendlyName: friendly,
529529
value: value,
530530
issuer: issuers
531531
});
532-
console.log(claimsRequired);
533532

534533
this.model.set({
535534
scopes: scopes,
@@ -559,11 +558,25 @@ var PolicyFormView = Backbone.View.extend({
559558
"keyboard" : true,
560559
"show" : true // ensure the modal is shown immediately
561560
});
562-
}
563-
564-
565-
561+
}
562+
},
563+
564+
clearAllClaims:function(e) {
565+
e.preventDefault();
566+
567+
if (confirm($.t('policy.policy-form.clear-all-confirm'))) {
566568

569+
var scopes = $('#scopes input[type="checkbox"]:checked').map(function(idx, elem) { return $(elem).val(); }).get();
570+
571+
var claimsRequired = [];
572+
573+
this.model.set({
574+
scopes: scopes,
575+
claimsRequired: claimsRequired
576+
}, {trigger: false});
577+
578+
this.render();
579+
}
567580
},
568581

569582
savePolicy:function(e) {

uma-server-webapp/src/main/webapp/resources/template/policy.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ <h1 data-i18n="policy.policy-form.edit">Edit Policy</h1>
196196
<div class="control-group">
197197
<div class="controls">
198198
<button class="btn btn-info btn-share-advanced"><i class="icon-share icon-white"></i> <span data-i18n="policy.policy-form.share-advanced">Add to claim set</span></button>
199+
<button class="btn btn-danger btn-clear"><i class="icon-trash icon-white"></i> <span data-i18n="policy.policy-form.clear-all">Clear all claims</span></button>
199200
</div>
200201
</div>
201202
</fieldset>

0 commit comments

Comments
 (0)