Search in sources :

Example 56 with GridComponent

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();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 57 with GridComponent

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 58 with GridComponent

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);
}
Also used : GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 59 with GridComponent

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);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) JSONObject(org.json.JSONObject) GridComponent(com.qcadoo.view.api.components.GridComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 60 with GridComponent

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);
        }
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12