Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cspace.permissions.expander = function (options, container, key, config) {
- fluid.expect("Permissions expander", ["tree", "permissions", "operations", "method"], options);
- // If the path isn't provided take a whole model as a driver to expand permissions.
- var path = fluid.extractContextualPath(options.controlledBy, {ELstyle: "ALL"}, fluid.threadLocal()) || "";
- var model = fluid.model.getBeanValue(config.model, path);
- var togo = {};
- if (!model) {
- return options.ifEmpty? config.expander(options.ifEmpty) : togo;
- }
- var permManager = cspace.permissions.manager({
- permissions: options.permissions
- });
- // Go through the model and remove fields that are not permitted.
- fluid.remove_if(model, function (elem) {
- return !permManager["resolve" + (options.method || "")](elem, options.operations);
- });
- var expanded = {};
- fluid.withEnvironment({model: model},
- function () {
- expanded = fluid.expander.expandLight(options.tree);
- }
- );
- return expanded;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement