use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class DetailedProductionCountingAndProgressListHooks method setGridEditableDependsOfOrderState.
public void setGridEditableDependsOfOrderState(final ViewDefinitionState view) {
FormComponent orderForm = (FormComponent) view.getComponentByReference(L_ORDER);
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Long orderId = orderForm.getEntityId();
if (orderId == null) {
return;
}
if (disable(orderService.getOrder(orderId))) {
grid.setEnabled(false);
} else {
boolean isLocked = progressModifyLockHelper.isLocked(orderService.getOrder(orderId));
grid.setEnabled(!isLocked);
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class DetailedProductionCountingAndProgressListHooks method onRemoveSelectedProductionCountingQuantities.
public void onRemoveSelectedProductionCountingQuantities(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = ((GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID));
List<Entity> selectedEntities = grid.getSelectedEntities();
List<Long> ids = new ArrayList<>();
boolean deleteSuccessful = true;
List<ErrorMessage> errors = Lists.newArrayList();
for (Entity productionCountingQuantity : selectedEntities) {
String typeOfMaterial = productionCountingQuantity.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL);
if (GlobalTypeOfMaterial.FINAL_PRODUCT.getStringValue().equals(typeOfMaterial)) {
state.addMessage("basicProductionCounting.productionCountingQuantity.error.cantDeleteFinal", ComponentState.MessageType.INFO);
} else {
ids.add(productionCountingQuantity.getId());
if (deleteSuccessful) {
EntityOpResult result = productionCountingQuantity.getDataDefinition().delete(productionCountingQuantity.getId());
if (!result.isSuccessfull()) {
deleteSuccessful = false;
errors.addAll(result.getMessagesHolder().getGlobalErrors());
}
}
}
}
if (ids.size() == 1 && deleteSuccessful) {
state.addMessage("qcadooView.message.deleteMessage", ComponentState.MessageType.SUCCESS);
} else if (ids.size() > 1 && deleteSuccessful) {
state.addMessage("qcadooView.message.deleteMessages", ComponentState.MessageType.SUCCESS, String.valueOf(ids.size()));
} else if (!deleteSuccessful) {
errors.stream().forEach(error -> state.addMessage(error));
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class ProductFamilySizesHooks method addOnBeforeRender.
public void addOnBeforeRender(final ViewDefinitionState view) throws JSONException {
JSONObject obj = view.getJsonContext();
if (obj.has("window.mainTab.product.productId")) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
FilterValueHolder holder = grid.getFilterValue();
holder.put(ProductFamilySizesCriteriaModifiers.L_PRODUCT_ID, obj.getLong("window.mainTab.product.productId"));
grid.setFilterValue(holder);
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class ProductReplacementsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) throws JSONException {
JSONObject obj = view.getJsonContext();
if (obj.has("window.mainTab.product.productId")) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
FilterValueHolder holder = grid.getFilterValue();
holder.put("PRODUCT_ID", obj.getLong("window.mainTab.product.productId"));
grid.setFilterValue(holder);
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class PalletNumberHelpersListHooks method addDiscriminatorRestrictionToGrid.
public final void addDiscriminatorRestrictionToGrid(final ViewDefinitionState view) {
GridComponent palletNumberHelpersGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
palletNumberHelpersGrid.setCustomRestriction(new CustomRestriction() {
@Override
public void addRestriction(final SearchCriteriaBuilder searchBuilder) {
searchBuilder.add(SearchRestrictions.eq(PalletNumberHelperFields.TEMPORARY, false));
}
});
}
Aggregations