Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. cspace.permissions.expander = function (options, container, key, config) {
  2. fluid.expect("Permissions expander", ["tree", "permissions", "operations", "method"], options);
  3.  
  4. // If the path isn't provided take a whole model as a driver to expand permissions.
  5. var path = fluid.extractContextualPath(options.controlledBy, {ELstyle: "ALL"}, fluid.threadLocal()) || "";
  6. var model = fluid.model.getBeanValue(config.model, path);
  7. var togo = {};
  8. if (!model) {
  9. return options.ifEmpty? config.expander(options.ifEmpty) : togo;
  10. }
  11.  
  12. var permManager = cspace.permissions.manager({
  13. permissions: options.permissions
  14. });
  15.  
  16. // Go through the model and remove fields that are not permitted.
  17. fluid.remove_if(model, function (elem) {
  18. return !permManager["resolve" + (options.method || "")](elem, options.operations);
  19. });
  20. var expanded = {};
  21. fluid.withEnvironment({model: model},
  22. function () {
  23. expanded = fluid.expander.expandLight(options.tree);
  24. }
  25. );
  26. return expanded;
  27. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement