diff --git a/uma-server-webapp/src/main/webapp/resources/js/admin.js b/uma-server-webapp/src/main/webapp/resources/js/admin.js index fd2696e80..e8eebaad4 100644 --- a/uma-server-webapp/src/main/webapp/resources/js/admin.js +++ b/uma-server-webapp/src/main/webapp/resources/js/admin.js @@ -506,6 +506,7 @@ var AppRouter = Backbone.Router.extend({ "user/policy":"policy", "user/policy/:rsid":"editPolicies", + "user/policy/:rsid/new":"newPolicy", "user/policy/:rsid/:pid":"editPolicy", "dev/dynreg":"dynReg", @@ -1131,7 +1132,31 @@ var AppRouter = Backbone.Router.extend({ }, newPolicy:function(rsid) { + this.breadCrumbView.collection.reset(); + this.breadCrumbView.collection.add([ + {text:$.t('admin.home'), href:""}, + {text:$.t('policy.resource-sets'), href:"manage/#user/policy"}, + {text:$.t('policy.edit-policies'), href:"manage/#user/policy/" + rsid}, + {text:$.t('policy.edit-policy'), href:"manage/#user/policy/" + rsid + "/new"} + ]); + this.updateSidebar('user/policy'); + + var policy = policy = new PolicyModel({}, {rsid: rsid}); + + var rs = this.resourceSetList.get(rsid); + if (rs == null) { + // need to load it directly + rs = new ResourceSetModel({id: rsid}); + this.resourceSetList.add(rs); // it will be loaded below, don't need to load it again in the future + } + + var view = new PolicyFormView({model: policy, rs: rs, systemScopeList: this.systemScopeList}); + + view.load(function() { + $('#content').html(view.render().el); + setPageTitle($.t('policy.edit-policy')); + }); }, editPolicy:function(rsid, pid) { diff --git a/uma-server-webapp/src/main/webapp/resources/js/policy.js b/uma-server-webapp/src/main/webapp/resources/js/policy.js index 7c07fdcd2..952647720 100644 --- a/uma-server-webapp/src/main/webapp/resources/js/policy.js +++ b/uma-server-webapp/src/main/webapp/resources/js/policy.js @@ -270,6 +270,7 @@ var PolicyListView = Backbone.View.extend({ }, events:{ + 'click .btn-add':'addPolicy', 'click .btn-cancel':'cancel' }, @@ -290,6 +291,11 @@ var PolicyListView = Backbone.View.extend({ } }, + addPolicy:function(e) { + e.preventDefault(); + app.navigate('user/policy/' + this.options.rs.get('id') +'/new', {trigger: true}); + }, + render:function (eventName) { $(this.el).html($('#tmpl-policy-table').html()); @@ -442,8 +448,12 @@ var PolicyFormView = Backbone.View.extend({ var base = $('base').attr('href'); $.getJSON(base + '/api/emailsearch?' + $.param({'identifier': email}), function(data) { - - _self.model.set({ + + // grab the current state of the scopes checkboxes just in case + var scopes = $('#scopes input[type="checkbox"]:checked').map(function(idx, elem) { return $(elem).val(); }).get(); + + _self.model.set({ + scopes: scopes, claimsRequired: data }, {trigger: false}); diff --git a/uma-server-webapp/src/main/webapp/resources/template/policy.html b/uma-server-webapp/src/main/webapp/resources/template/policy.html index b792d9a21..48b859cfa 100644 --- a/uma-server-webapp/src/main/webapp/resources/template/policy.html +++ b/uma-server-webapp/src/main/webapp/resources/template/policy.html @@ -69,6 +69,7 @@