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);
}
}
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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations