RoleEntitlementsEditView.js revision fcfeab652394e5fddf0101c230ea3d30b9649538
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2011-2015 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
/*global define, $, form2js, _, JSONEditor */
/**
* @author huck.elliott
*/
"bootstrap-dialog",
], function(AbstractView, eventManager, constants, cookieHelper, uiUtils, resourceDelegate, messagesManager, BootstrapDialog, conf, InlineScriptEditor) {
element: "#dialogs",
noBaseTemplate: true,
events: {
"click #btn-add-attribute": "addAttribute",
"click .btn-delete-attribute": "deleteAttribute"
},
var _this = this,
dialogTitle = (assignmentName) ? $.t("templates.admin.RoleEntitlementsTemplate.editEntitlement",{entitlementName: assignmentName}) : $.t("templates.admin.RoleEntitlementsTemplate.addEntitlement");
this.currentDialog = $('<div id="roleEntitlementsEditContainer"></div>');
this.data.JSONEditors = [];
this.setElement(this.currentDialog);
message: this.currentDialog,
function () {
} else {
}
_this.setScripts();
if(callback){
callback();
}
}, "replace");
},
buttons: [{
label: $.t("common.form.cancel"),
id:"entitlementEditDialogCancel",
}
}, {
label: $.t('common.form.save'),
id: "entitlementEditDialogSubmit",
cssClass: "btn-primary",
_this.saveAssignment(function() {
});
}
}]
});
},
disable_edit_json: true,
disable_array_reorder: true,
disable_collapse: true,
schema:{},
});
}, this));
return editor;
},
setJSONEditors: function() {
}, this);
},
setScripts: function() {
var emptyScript = {
type: "text/javascript",
globals: {},
file: ""
};
"eventName": "onAssignment",
"noValidation": true,
});
"eventName": "onUnassignment",
"noValidation": true,
});
},
addAttribute: function(e) {
if(e) {
e.preventDefault();
}
this.setAttributeOperationsPopovers();
},
deleteAttribute: function(e) {
var editorIndex = this.$el.find(".assignment-attributes .list-group-item").find(e.target).closest(".list-group-item").index();
e.preventDefault();
//remove the JSONEditor for this attribute
},
getAttributes: function() {
var attr = {};
return attr;
}, this);
},
saveAssignment: function(callback) {
var invalid = false,
if(onAssignment) {
}
if(onUnassignment) {
}
resourceDelegate.updateResource(this.data.serviceUrl, this.data.role._id, this.data.role, _.bind(function() {
var msg = (this.data.newAssignment) ? "templates.admin.RoleEntitlementsTemplate.assignmentAddSuccess" : "templates.admin.RoleEntitlementsTemplate.assignmentSaveSuccess";
messagesManager.messages.addMessage({"message": $.t(msg,{ assignment: this.data.assignmentName })});
if(callback) {
callback();
}
}, this));
}, this);
if(!this.data.assignment) {
invalid = true;
}
}
if(invalid) {
messagesManager.messages.addMessage({"type": "error","message": $.t("templates.admin.RoleEntitlementsTemplate.entitlementDuplicationError")});
} else {
doSave();
}
},
setAttributeOperationsPopovers: function() {
placement:'bottom',
html: true,
}).on('shown.bs.popover', function () {
var popup = $(this),
e.preventDefault();
});
});
});
}
});
return new RoleEntitlementsEditView();
});