Search in sources :

Example 1 with QuickMenuItem

use of com.axelor.ui.QuickMenuItem in project open-platform-demo by axelor.

the class AccessSaleQuickMenu method create.

@Override
public QuickMenu create() {
    QuickMenu menu = super.create();
    User user = AuthUtils.getUser();
    if (user == null || !Beans.get(JpaSecurity.class).isPermitted(JpaSecurity.CAN_READ, Order.class)) {
        return menu;
    }
    if (menu == null) {
        // can be null in case use doesn't have permission on Contact domain.
        menu = createAccessQuickMenu();
    }
    menu.setItems(Stream.of(menu.getItems(), List.of(new QuickMenuItem(I18n.get("Quotations"), "sale.orders.draft"), new QuickMenuItem(I18n.get("Sale Orders"), "sale.orders"))).flatMap(Collection::stream).collect(Collectors.toList()));
    return menu;
}
Also used : User(com.axelor.auth.db.User) JpaSecurity(com.axelor.db.JpaSecurity) QuickMenuItem(com.axelor.ui.QuickMenuItem) Collection(java.util.Collection) QuickMenu(com.axelor.ui.QuickMenu) AccessContactQuickMenu(com.axelor.contact.service.AccessContactQuickMenu)

Example 2 with QuickMenuItem

use of com.axelor.ui.QuickMenuItem in project open-platform-demo by axelor.

the class UpdateUserProjectQuickMenu method getItems.

public List<QuickMenuItem> getItems() {
    User user = AuthUtils.getUser();
    if (user == null || !Beans.get(JpaSecurity.class).isPermitted(JpaSecurity.CAN_READ, Project.class)) {
        return Collections.emptyList();
    }
    String action = ProjectController.class.getName() + ":updateDefaultProject";
    List<QuickMenuItem> items = new ArrayList<>();
    for (Project project : Query.of(Project.class).filter("?1 MEMBER OF self.members", user).fetch(10)) {
        boolean isDefaultProject = project.equals(user.getDefaultProject());
        QuickMenuItem item = new QuickMenuItem(project.getName(), action, new Context(project.getId(), Project.class), isDefaultProject);
        items.add(item);
    }
    return items;
}
Also used : Context(com.axelor.rpc.Context) Project(com.axelor.project.db.Project) User(com.axelor.auth.db.User) JpaSecurity(com.axelor.db.JpaSecurity) QuickMenuItem(com.axelor.ui.QuickMenuItem) ArrayList(java.util.ArrayList) ProjectController(com.axelor.project.web.ProjectController)

Example 3 with QuickMenuItem

use of com.axelor.ui.QuickMenuItem in project open-platform-demo by axelor.

the class AccessContactQuickMenu method create.

@Override
public QuickMenu create() {
    User user = AuthUtils.getUser();
    if (user == null || !Beans.get(JpaSecurity.class).isPermitted(JpaSecurity.CAN_READ, Contact.class)) {
        return null;
    }
    QuickMenu menu = createAccessQuickMenu();
    menu.getItems().add(new QuickMenuItem(I18n.get("Contacts"), "contact.all"));
    return menu;
}
Also used : User(com.axelor.auth.db.User) JpaSecurity(com.axelor.db.JpaSecurity) QuickMenuItem(com.axelor.ui.QuickMenuItem) QuickMenu(com.axelor.ui.QuickMenu)

Aggregations

User (com.axelor.auth.db.User)3 JpaSecurity (com.axelor.db.JpaSecurity)3 QuickMenuItem (com.axelor.ui.QuickMenuItem)3 QuickMenu (com.axelor.ui.QuickMenu)2 AccessContactQuickMenu (com.axelor.contact.service.AccessContactQuickMenu)1 Project (com.axelor.project.db.Project)1 ProjectController (com.axelor.project.web.ProjectController)1 Context (com.axelor.rpc.Context)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1