Search in sources :

Example 11 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class LeaveController method historicLeave.

public void historicLeave(ActionRequest request, ActionResponse response) {
    try {
        User user = AuthUtils.getUser();
        Employee employee = user.getEmployee();
        ActionViewBuilder actionView = ActionView.define(I18n.get("Colleague Leave Requests")).model(LeaveRequest.class.getName()).add("grid", "leave-request-grid").add("form", "leave-request-form").param("search-filters", "leave-request-filters");
        actionView.domain("(self.statusSelect = 3 OR self.statusSelect = 4)");
        if (employee == null || !employee.getHrManager()) {
            actionView.domain(actionView.get().getDomain() + " AND self.user.employee.managerUser = :_user").context("_user", user);
        }
        response.setView(actionView.map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) AxelorException(com.axelor.exception.AxelorException)

Example 12 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class LeaveController method showSubordinateLeaves.

public void showSubordinateLeaves(ActionRequest request, ActionResponse response) {
    try {
        User user = AuthUtils.getUser();
        String domain = "self.user.employee.managerUser.employee.managerUser = :_user AND self.statusSelect = 2";
        long nbLeaveRequests = Query.of(LeaveRequest.class).filter(domain).bind("_user", user).count();
        if (nbLeaveRequests == 0) {
            response.setNotify(I18n.get("No Leave Request to be validated by your subordinates"));
        } else {
            ActionViewBuilder actionView = ActionView.define(I18n.get("Leaves to be Validated by your subordinates")).model(LeaveRequest.class.getName()).add("grid", "leave-request-grid").add("form", "leave-request-form").param("search-filters", "leave-request-filters");
            response.setView(actionView.domain(domain).context("_user", user).map());
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : User(com.axelor.auth.db.User) LeaveRequest(com.axelor.apps.hr.db.LeaveRequest) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) AxelorException(com.axelor.exception.AxelorException)

Example 13 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class InventoryController method showStockMoves.

public void showStockMoves(ActionRequest request, ActionResponse response) {
    try {
        Inventory inventory = request.getContext().asType(Inventory.class);
        List<StockMove> stockMoveList = Beans.get(InventoryService.class).findStockMoves(inventory);
        ActionViewBuilder builder = ActionView.define(I18n.get("Internal Stock Moves")).model(StockMove.class.getName()).add("grid", "stock-move-grid").add("form", "stock-move-form").param("search-filters", "internal-stock-move-filters");
        if (stockMoveList.isEmpty()) {
            response.setFlash(I18n.get("No stock moves found for this inventory."));
        } else {
            builder.context("_showSingle", true).domain(String.format("self.originTypeSelect = '%s' AND self.originId = %s", StockMoveRepository.ORIGIN_INVENTORY, inventory.getId()));
            response.setView(builder.map());
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove) InventoryService(com.axelor.apps.stock.service.InventoryService) Inventory(com.axelor.apps.stock.db.Inventory) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) BirtException(org.eclipse.birt.core.exception.BirtException) NoResultException(javax.persistence.NoResultException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 14 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class WkfModelController method showRecord.

@SuppressWarnings("unchecked")
public void showRecord(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        String status = context.get("status").toString();
        String tableName = null;
        String jsonModel = null;
        ActionViewBuilder actionViewBuilder = null;
        if (context.get("metaModel") != null) {
            Long id = Long.parseLong(((Map<String, Object>) context.get("metaModel")).get("id").toString());
            MetaModel metaModel = Beans.get(MetaModelRepository.class).find(id);
            tableName = metaModel.getTableName();
            actionViewBuilder = createActionBuilder(status, metaModel);
        } else if (context.get("metaJsonModel") != null) {
            Long id = Long.parseLong(((Map<String, Object>) context.get("metaJsonModel")).get("id").toString());
            MetaJsonModel metaJsonModel = Beans.get(MetaJsonModelRepository.class).find(id);
            jsonModel = metaJsonModel.getName();
            tableName = MetaJsonRecord.class.getAnnotation(Table.class).name();
            actionViewBuilder = createActionBuilder(status, metaJsonModel);
        }
        List<Long> idList = getRecordIds(context, tableName, jsonModel);
        response.setView(actionViewBuilder.context("ids", !idList.isEmpty() ? idList : 0).map());
        response.setCanClose(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) MetaJsonModel(com.axelor.meta.db.MetaJsonModel) MetaModelRepository(com.axelor.meta.db.repo.MetaModelRepository) Table(javax.persistence.Table) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) AxelorException(com.axelor.exception.AxelorException) MetaModel(com.axelor.meta.db.MetaModel) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) MetaJsonRecord(com.axelor.meta.db.MetaJsonRecord)

Example 15 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class WkfModelController method createActionBuilder.

private ActionViewBuilder createActionBuilder(String status, MetaJsonModel metaJsonModel) {
    String title = Strings.isNullOrEmpty(status) ? metaJsonModel.getTitle() : metaJsonModel.getTitle() + "-" + status;
    ActionViewBuilder actionViewBuilder = ActionView.define(title).model(MetaJsonRecord.class.getName()).add("grid", metaJsonModel.getGridView().getName()).add("form", metaJsonModel.getFormView().getName()).domain("self.jsonModel = :jsonModel AND self.id IN (:ids)").context("jsonModel", metaJsonModel.getName());
    return actionViewBuilder;
}
Also used : ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) MetaJsonRecord(com.axelor.meta.db.MetaJsonRecord)

Aggregations

ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)54 AxelorException (com.axelor.exception.AxelorException)18 User (com.axelor.auth.db.User)17 List (java.util.List)15 Employee (com.axelor.apps.hr.db.Employee)14 Map (java.util.Map)14 ArrayList (java.util.ArrayList)13 Company (com.axelor.apps.base.db.Company)10 Partner (com.axelor.apps.base.db.Partner)9 Wizard (com.axelor.apps.base.db.Wizard)9 Invoice (com.axelor.apps.account.db.Invoice)8 Currency (com.axelor.apps.base.db.Currency)7 PriceList (com.axelor.apps.base.db.PriceList)7 LinkedHashMap (java.util.LinkedHashMap)6 SaleOrder (com.axelor.apps.sale.db.SaleOrder)5 StockMove (com.axelor.apps.stock.db.StockMove)5 MetaJsonRecord (com.axelor.meta.db.MetaJsonRecord)5 HRMenuValidateService (com.axelor.apps.hr.service.HRMenuValidateService)4 StockMoveMultiInvoiceService (com.axelor.apps.supplychain.service.StockMoveMultiInvoiceService)4 MetaJsonModel (com.axelor.meta.db.MetaJsonModel)4