added "add new policy" controls

pull/820/merge
Justin Richer 2015-07-03 17:23:35 -04:00
parent 214097584a
commit d4e3639236
3 changed files with 39 additions and 2 deletions

View File

@ -506,6 +506,7 @@ var AppRouter = Backbone.Router.extend({
"user/policy":"policy", "user/policy":"policy",
"user/policy/:rsid":"editPolicies", "user/policy/:rsid":"editPolicies",
"user/policy/:rsid/new":"newPolicy",
"user/policy/:rsid/:pid":"editPolicy", "user/policy/:rsid/:pid":"editPolicy",
"dev/dynreg":"dynReg", "dev/dynreg":"dynReg",
@ -1131,7 +1132,31 @@ var AppRouter = Backbone.Router.extend({
}, },
newPolicy:function(rsid) { 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) { editPolicy:function(rsid, pid) {

View File

@ -270,6 +270,7 @@ var PolicyListView = Backbone.View.extend({
}, },
events:{ events:{
'click .btn-add':'addPolicy',
'click .btn-cancel':'cancel' '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) { render:function (eventName) {
$(this.el).html($('#tmpl-policy-table').html()); $(this.el).html($('#tmpl-policy-table').html());
@ -443,7 +449,11 @@ var PolicyFormView = Backbone.View.extend({
var base = $('base').attr('href'); var base = $('base').attr('href');
$.getJSON(base + '/api/emailsearch?' + $.param({'identifier': email}), function(data) { $.getJSON(base + '/api/emailsearch?' + $.param({'identifier': email}), function(data) {
// 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({ _self.model.set({
scopes: scopes,
claimsRequired: data claimsRequired: data
}, {trigger: false}); }, {trigger: false});

View File

@ -69,6 +69,7 @@
<script type="text/html" id="tmpl-policy-table"> <script type="text/html" id="tmpl-policy-table">
<div class="well well-small"> <div class="well well-small">
<button class="btn btn-small btn-success btn-add"><i class="icon-plus icon-white"></i> <span data-i18n="policy.policy-table.new">Add New Policy</span></button>
<button class="btn btn-small btn-cancel"><i class="icon-list"></i> <span data-i18n="policy.policy-table.return">Return to list</span></button> <button class="btn btn-small btn-cancel"><i class="icon-list"></i> <span data-i18n="policy.policy-table.return">Return to list</span></button>
</div> </div>
@ -92,6 +93,7 @@
</table> </table>
<div class="well well-small"> <div class="well well-small">
<button class="btn btn-small btn-success btn-add"><i class="icon-plus icon-white"></i> <span data-i18n="policy.policy-table.new">Add New Policy</span></button>
<button class="btn btn-small btn-cancel"><i class="icon-list"></i> <span data-i18n="policy.policy-table.return">Return to list</span></button> <button class="btn btn-small btn-cancel"><i class="icon-list"></i> <span data-i18n="policy.policy-table.return">Return to list</span></button>
</div> </div>