SHARE
TWEET

Untitled

a guest Jul 12th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 1
  2.  
  3.         this.menu = [];
  4.         const tmp = this.menuItems.getAll();
  5.         tmp.forEach(level => {
  6.             const firstLevel = { label: level.label, main: [] };
  7.             level.main.forEach(item => {
  8.                 let result = true;
  9.                 if (item.roles !== undefined) {
  10.                     result = false;
  11.                     item.roles.forEach(role => {
  12.                         if (!result && this.auth.isInRole(role)) {
  13.                             result = true;
  14.                         }
  15.                     });
  16.                 }
  17.  
  18.                 if (result) {
  19.                     firstLevel.main.push(item);
  20.                 }
  21.             });
  22.             this.menu.push(firstLevel);
  23.         });
  24.  
  25. // 2
  26.  
  27.         this.menu = this.menuItems.getAll()
  28.             .map(top => ({
  29.                 label: top.label,
  30.                 main: top.main.filter(item => !item.roles || item.roles.some(r => this.auth.isInRole(r)))
  31.             }));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top