Search in sources :

Example 81 with FormComponent

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

the class TechnologyDetailsListeners method removeOnlySelectedOperation.

public void removeOnlySelectedOperation(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    final TreeComponent technologyTree = (TreeComponent) view.getComponentByReference(L_TECHNOLOGY_TREE_REFERENCE);
    final Long selectedEntityId = technologyTree.getSelectedEntityId();
    Entity selectedOperation = getTechnologyOperationComponentDD().get(selectedEntityId);
    boolean removed = removeTOCService.removeOnlySelectedOperation(selectedOperation, view);
    if (removed) {
        FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
        technologyForm.performEvent(view, "reset");
        view.addMessage("technologies.technologyDetails.window.treeTab.technologyTree.success", ComponentState.MessageType.SUCCESS);
    }
}
Also used : TreeComponent(com.qcadoo.view.api.components.TreeComponent) Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent)

Example 82 with FormComponent

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

the class TechnologyDetailsListeners method acceptTemplate.

public void acceptTemplate(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    CheckBoxComponent isTemplateAcceptedCheckBox = (CheckBoxComponent) view.getComponentByReference(TechnologyFields.IS_TEMPLATE_ACCEPTED);
    Entity technology = technologyForm.getEntity();
    Long technologyId = technology.getId();
    boolean isTemplateAccepted = isTemplateAcceptedCheckBox.isChecked();
    if (Objects.nonNull(technologyId)) {
        technology = technology.getDataDefinition().save(technology);
        if (isTemplateAccepted || validateTemplate(technologyForm, technology.getDataDefinition().get(technologyId))) {
            isTemplateAcceptedCheckBox.setChecked(!isTemplateAccepted);
            technologyForm.performEvent(view, "save");
            if (technologyForm.isHasError()) {
                isTemplateAcceptedCheckBox.setChecked(isTemplateAccepted);
            }
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 83 with FormComponent

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

the class TechnologyDetailsListeners method openOperationProductInComponentsImportPage.

public void openOperationProductInComponentsImportPage(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity technology = technologyForm.getPersistedEntityWithIncludedFormValues();
    Long technologyId = technology.getId();
    if (Objects.nonNull(technologyId)) {
        Map<String, Object> parameters = Maps.newHashMap();
        parameters.put("form.id", technologyId);
        JSONObject context = new JSONObject(parameters);
        String url = "../page/technologies/operationProductInComponentsImport.html?context=" + context.toString();
        view.openModal(url);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject)

Example 84 with FormComponent

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

the class ModifyTechnologyListeners method createTechnologies.

public void createTechnologies(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    componentState.performEvent(view, L_SAVE, args);
    CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(L_GENERATED);
    FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (!formComponent.isValid()) {
        return;
    }
    Entity mt = formComponent.getEntity().getDataDefinition().get(formComponent.getEntityId());
    ModifyTechnologyResult modifyTechnologyResult = new ModifyTechnologyResult();
    createModifiedTechnology(view, componentState, mt, modifyTechnologyResult);
    if (!modifyTechnologyResult.getCreatedTechnologies().isEmpty()) {
        view.addMessage("technologies.modifyTechnology.createdTechnologies", ComponentState.MessageType.SUCCESS, String.join(",", modifyTechnologyResult.getCreatedTechnologies()));
    }
    if (!modifyTechnologyResult.getNotCreatedTechnologies().isEmpty()) {
        view.addMessage("technologies.modifyTechnology.notCreatedTechnologies", ComponentState.MessageType.FAILURE, String.join(",", modifyTechnologyResult.getNotCreatedTechnologies()));
    }
    generated.setChecked(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) ModifyTechnologyResult(com.qcadoo.mes.technologies.dto.ModifyTechnologyResult) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 85 with FormComponent

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

the class OperationDetailsListeners 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(OperationFields.WORKSTATIONS).size();
    FieldComponent quantityOfWorkstations = (FieldComponent) view.getComponentByReference(OperationFields.QUANTITY_OF_WORKSTATIONS);
    quantityOfWorkstations.setFieldValue(size);
    quantityOfWorkstations.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

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