Refactor JS menu generation

for flex & predefined reports