Policy delete works!
parent
72bb09550c
commit
8b8db24179
|
@ -503,8 +503,10 @@ var AppRouter = Backbone.Router.extend({
|
||||||
"user/approved":"approvedSites",
|
"user/approved":"approvedSites",
|
||||||
"user/tokens":"tokens",
|
"user/tokens":"tokens",
|
||||||
"user/profile":"profile",
|
"user/profile":"profile",
|
||||||
|
|
||||||
"user/policy":"policy",
|
"user/policy":"policy",
|
||||||
"user/policy/:rsid":"editPolicy",
|
"user/policy/:rsid":"editPolicies",
|
||||||
|
"user/policy/:rsid/:pid":"editPolicy",
|
||||||
|
|
||||||
"dev/dynreg":"dynReg",
|
"dev/dynreg":"dynReg",
|
||||||
"dev/dynreg/new":"newDynReg",
|
"dev/dynreg/new":"newDynReg",
|
||||||
|
@ -1096,12 +1098,12 @@ var AppRouter = Backbone.Router.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
editPolicy:function(rsid) {
|
editPolicies:function(rsid) {
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([
|
||||||
{text:$.t('admin.home'), href:""},
|
{text:$.t('admin.home'), href:""},
|
||||||
{text:$.t('policy.resource-sets'), href:"manage/#user/policy"},
|
{text:$.t('policy.resource-sets'), href:"manage/#user/policy"},
|
||||||
{text:$.t('policy.edit-policy'), href:"manage/#user/policy/" + rsid}
|
{text:$.t('policy.edit-policies'), href:"manage/#user/policy/" + rsid}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.updateSidebar('user/policy');
|
this.updateSidebar('user/policy');
|
||||||
|
@ -1116,7 +1118,7 @@ var AppRouter = Backbone.Router.extend({
|
||||||
policy.isFetched = true;
|
policy.isFetched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var view = new PolicyListView({model: policy, rs: rs});
|
var view = new PolicyListView({model: policy, rs: rs, systemScopeList: this.systemScopeList});
|
||||||
|
|
||||||
view.load(function() {
|
view.load(function() {
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
|
|
|
@ -241,17 +241,20 @@ var PolicyListView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load:function(callback) {
|
||||||
if (this.model.isFetched) {
|
if (this.model.isFetched &&
|
||||||
|
this.options.systemScopeList.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html(
|
||||||
'<span class="label" id="loading-policies">' + $.t('policy.loading-policies') + '</span> '
|
'<span class="label" id="loading-policies">' + $.t('policy.loading-policies') + '</span> ' +
|
||||||
|
'<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> '
|
||||||
);
|
);
|
||||||
|
|
||||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-policies').addClass('label-success');}}))
|
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-policies').addClass('label-success');}}),
|
||||||
|
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||||
.done(function() {
|
.done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
|
@ -353,7 +356,7 @@ var PolicyListView = Backbone.View.extend({
|
||||||
|
|
||||||
_.each(this.model.models, function (policy) {
|
_.each(this.model.models, function (policy) {
|
||||||
|
|
||||||
var view = new PolicyView({model: policy});
|
var view = new PolicyView({model: policy, systemScopeList: _self.options.systemScopeList});
|
||||||
view.parentView = _self;
|
view.parentView = _self;
|
||||||
$('#policy-table', this.el).append(view.render().el);
|
$('#policy-table', this.el).append(view.render().el);
|
||||||
|
|
||||||
|
@ -375,6 +378,11 @@ var PolicyView = Backbone.View.extend({
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-policy').html());
|
this.template = _.template($('#tmpl-policy').html());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.scopeTemplate) {
|
||||||
|
this.scopeTemplate = _.template($('#tmpl-scope-list').html());
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events:{
|
||||||
|
@ -384,17 +392,37 @@ var PolicyView = Backbone.View.extend({
|
||||||
removePolicy:function(e) {
|
removePolicy:function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (confirm($.t('policy.policy-table.policy-confirm'))) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
this.model.destroy({
|
||||||
this.model.collection.remove(this.model);
|
success:function () {
|
||||||
_self.$el.fadeTo("fast", 0.00, function () { //fade
|
_self.$el.fadeTo("fast", 0.00, function () { //fade
|
||||||
$(this).slideUp("fast", function () { //slide up
|
$(this).slideUp("fast", function () { //slide up
|
||||||
$(this).remove(); //then remove from the DOM
|
$(this).remove(); //then remove from the DOM
|
||||||
_self.parentView.togglePlaceholder();
|
_self.parentView.togglePlaceholder();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
error:function (error, response) {
|
||||||
|
console.log("An error occurred when deleting a client");
|
||||||
|
|
||||||
|
//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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_self.parentView.delegateEvents();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
render:function (eventName) {
|
||||||
|
@ -402,7 +430,9 @@ var PolicyView = Backbone.View.extend({
|
||||||
|
|
||||||
this.$el.html(this.template(json));
|
this.$el.html(this.template(json));
|
||||||
|
|
||||||
$(this.el).i18n();
|
$('.scope-list', this.el).html(this.scopeTemplate({scopes: this.model.get('scopes'), systemScopes: this.options.systemScopeList}));
|
||||||
|
|
||||||
|
//$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue