Search in sources :

Example 76 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class SkillOperationDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity opSkill = form.getEntity();
    FieldComponent maxSkillLevelField = (FieldComponent) view.getComponentByReference(MAX_LEVEL);
    maxSkillLevelField.setFieldValue(opSkill.getBelongsToField(OperationSkillFields.SKILL).getIntegerField(SkillFields.MAXIMUM_LEVEL));
    LookupComponent operationLookup = (LookupComponent) view.getComponentByReference(OperationSkillFields.OPERATION);
    FilterValueHolder filterValueHolder = operationLookup.getFilterValue();
    Long skillId = opSkill.getBelongsToField(StaffSkillsFields.SKILL).getId();
    if (Objects.isNull(skillId)) {
        filterValueHolder.remove(L_SKILL_ID);
    } else {
        filterValueHolder.put(L_SKILL_ID, skillId);
    }
    operationLookup.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 77 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class TOCProcessListDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    Long operationId = ((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getPersistedEntityWithIncludedFormValues().getBelongsToField(TechnologyOperationComponentFields.OPERATION).getId();
    LookupComponent technologicalProcessList = (LookupComponent) view.getComponentByReference(TechnologyOperationComponentFields.TECHNOLOGICAL_PROCESS_LIST);
    FilterValueHolder filterValueHolder = technologicalProcessList.getFilterValue();
    filterValueHolder.put(TechnologicalProcessListFields.OPERATION, operationId);
    technologicalProcessList.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 78 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class AddProcessesListeners method addProcesses.

public void addProcesses(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent technologicalProcesses = (GridComponent) view.getComponentByReference(L_TECHNOLOGICAL_PROCESSES);
    Set<Long> selectedEntities = technologicalProcesses.getSelectedEntitiesIds();
    if (selectedEntities.isEmpty()) {
        view.addMessage("technologies.addProcesses.noSelectedProcesses", ComponentState.MessageType.INFO);
        return;
    }
    for (Long technologicalProcessId : selectedEntities) {
        Entity technologicalProcess = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS).get(technologicalProcessId);
        Entity technologicalProcessComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_COMPONENT).create();
        technologicalProcessComponent.setField(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS, technologicalProcess);
        technologicalProcessComponent.setField(TechnologiesConstants.MODEL_TECHNOLOGICAL_PROCESS_LIST, form.getEntityId());
        technologicalProcessComponent.setField(TechnologicalProcessFields.TPZ, technologicalProcess.getField(TechnologicalProcessFields.TPZ));
        technologicalProcessComponent.setField(TechnologicalProcessFields.TJ, technologicalProcess.getField(TechnologicalProcessFields.TJ));
        technologicalProcessComponent.setField(TechnologicalProcessFields.ADDITIONAL_TIME, technologicalProcess.getField(TechnologicalProcessFields.ADDITIONAL_TIME));
        technologicalProcessComponent.setField(TechnologicalProcessFields.EXTENDED_TIME_FOR_SIZE_GROUP, technologicalProcess.getField(TechnologicalProcessFields.EXTENDED_TIME_FOR_SIZE_GROUP));
        technologicalProcessComponent.setField(TechnologicalProcessFields.INCREASE_PERCENT, technologicalProcess.getField(TechnologicalProcessFields.INCREASE_PERCENT));
        technologicalProcessComponent.setField(TechnologicalProcessFields.SIZE_GROUP, technologicalProcess.getField(TechnologicalProcessFields.SIZE_GROUP));
        technologicalProcessComponent.getDataDefinition().save(technologicalProcessComponent);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 79 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class TOCDetailsListeners method addUpTheNumberOfWorkstations.

public void addUpTheNumberOfWorkstations(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    int size = form.getPersistedEntityWithIncludedFormValues().getHasManyField(TechnologyOperationComponentFields.WORKSTATIONS).size();
    FieldComponent quantityOfWorkstations = (FieldComponent) view.getComponentByReference(TechnologyOperationComponentFields.QUANTITY_OF_WORKSTATIONS);
    quantityOfWorkstations.setFieldValue(size);
    quantityOfWorkstations.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 80 with FormComponent

use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.

the class TechnologiesWithUsingProductListListeners method goToModifyTechnology.

public void goToModifyTechnology(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    List<Integer> entitiesId = Lists.newArrayList();
    Set<Long> selected = grid.getSelectedEntitiesIds();
    List<Entity> entities = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, "operationProductInProductDto").find().add(SearchRestrictions.in("id", selected)).list().getEntities();
    boolean isProductBySize = entities.stream().anyMatch(entry -> selected.contains(entry.getId()) && entry.getBooleanField("sizeProduct"));
    for (Entity entity : entities) {
        if (selected.contains(entity.getId())) {
            if (isProductBySize) {
                if (!entitiesId.contains(entity.getIntegerField("productBySizeGroupId"))) {
                    entitiesId.add(entity.getIntegerField("productBySizeGroupId"));
                }
            } else {
                if (!entitiesId.contains(entity.getIntegerField("operationProductInComponentId"))) {
                    entitiesId.add(entity.getIntegerField("operationProductInComponentId"));
                }
            }
        }
    }
    Entity modifyTechnology = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODIFY_TECHNOLOGY_HELPER).create();
    modifyTechnology.setField("product", form.getEntityId());
    modifyTechnology.setField("sizeProduct", isProductBySize);
    modifyTechnology.setField("selectedEntities", entitiesId.stream().map(e -> e.toString()).collect(Collectors.joining(",")));
    modifyTechnology = modifyTechnology.getDataDefinition().save(modifyTechnology);
    Map<String, Object> parameters = Maps.newHashMap();
    parameters.put("form.id", modifyTechnology.getId());
    String url = "../page/technologies/modifyTechnology.html";
    view.openModal(url, parameters);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

FormComponent (com.qcadoo.view.api.components.FormComponent)644 Entity (com.qcadoo.model.api.Entity)501 FieldComponent (com.qcadoo.view.api.components.FieldComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)104 GridComponent (com.qcadoo.view.api.components.GridComponent)83 BigDecimal (java.math.BigDecimal)55 WindowComponent (com.qcadoo.view.api.components.WindowComponent)52 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)45 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)42 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)39 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)36 Date (java.util.Date)33 DataDefinition (com.qcadoo.model.api.DataDefinition)29 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)28 JSONObject (org.json.JSONObject)28 ComponentState (com.qcadoo.view.api.ComponentState)27 Transactional (org.springframework.transaction.annotation.Transactional)20 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)17 Optional (com.google.common.base.Optional)16 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)16