use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class NumberPatternDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity numberPattern = form.getPersistedEntityWithIncludedFormValues();
if (numberPattern.getBooleanField(NumberPatternFields.USED)) {
form.setFormEnabled(false);
GridComponent grid = (GridComponent) view.getComponentByReference("numberPatternElements");
grid.setEditable(false);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup actions = window.getRibbon().getGroupByName("actions");
RibbonActionItem save = actions.getItemByName("save");
save.setEnabled(false);
save.requestUpdate(true);
RibbonActionItem saveBack = actions.getItemByName("saveBack");
saveBack.setEnabled(false);
saveBack.requestUpdate(true);
RibbonActionItem saveNew = actions.getItemByName("saveNew");
saveNew.setEnabled(false);
saveNew.requestUpdate(true);
window.requestRibbonRender();
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class CompaniesListListeners method disabledRibbonForOwnerOrExternal.
public void disabledRibbonForOwnerOrExternal(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
List<Entity> companies = grid.getSelectedEntities();
boolean isEnabled = true;
String buttonMessage = "basic.company.isOwner";
for (Entity company : companies) {
Entity companyFromDB = companyService.getCompany(company.getId());
if (Objects.nonNull(companyFromDB)) {
isEnabled = !companyService.isCompanyOwner(companyFromDB);
if (!StringUtils.isEmpty(company.getStringField(CompanyFields.EXTERNAL_NUMBER))) {
buttonMessage = "basic.company.isExternalNumber";
isEnabled = false;
}
} else {
isEnabled = false;
}
if (!isEnabled) {
break;
}
}
companyService.disableButton(view, L_ACTIONS, L_DELETE, isEnabled, buttonMessage);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class CompaniesListListeners method assignToGroupABC.
public void assignToGroupABC(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent gridComponent = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.companiesIds", gridComponent.getSelectedEntitiesIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
StringBuilder url = new StringBuilder("../page/basic/assignCompanyToGroupABC.html");
view.openModal(url.toString(), parameters);
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class ReplacementsListeners method addManyReplacements.
public final void addManyReplacements(final ViewDefinitionState view, final ComponentState state, final String[] args) throws JSONException {
JSONObject obj = view.getJsonContext();
if (obj.has("window.mainTab.product.productId")) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Long productId = obj.getLong("window.mainTab.product.productId");
for (Long sub : grid.getSelectedEntitiesIds()) {
Entity substituteComponent = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_SUBSTITUTE_COMPONENT).create();
substituteComponent.setField(SubstituteComponentFields.BASE_PRODUCT, productId);
substituteComponent.setField(SubstituteComponentFields.PRODUCT, sub);
substituteComponent.setField(SubstituteComponentFields.QUANTITY, 1);
substituteComponent.getDataDefinition().save(substituteComponent);
}
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference("generated");
generated.setChecked(true);
}
}
use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.
the class AddActionsForPlannedEventHooks method setCriteriaModifiers.
private void setCriteriaModifiers(final ViewDefinitionState view) throws JSONException {
Long plannedEventId = Long.valueOf(view.getJsonContext().get("window.mainTab.plannedEvent").toString());
if (plannedEventId != null) {
Entity event = getPlannedEventDD().get(plannedEventId);
Entity workstation = event.getBelongsToField(PlannedEventFields.WORKSTATION);
Entity subassembly = event.getBelongsToField(PlannedEventFields.SUBASSEMBLY);
if (workstation != null) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
FilterValueHolder filter = grid.getFilterValue();
filter.put(PlannedEventFields.WORKSTATION, workstation.getId());
if (subassembly != null) {
Entity workstationType = subassembly.getBelongsToField(SubassemblyFields.WORKSTATION_TYPE);
filter.put(PlannedEventFields.SUBASSEMBLY, subassembly.getId());
filter.put(WorkstationFields.WORKSTATION_TYPE, workstationType.getId());
} else {
Entity workstationType = workstation.getBelongsToField(WorkstationFields.WORKSTATION_TYPE);
filter.put(WorkstationFields.WORKSTATION_TYPE, workstationType.getId());
}
grid.setFilterValue(filter);
}
}
}
Aggregations