Search in sources :

Example 86 with FilterValueHolder

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

the class ProductionLineAddMultiHooks method onBeforeRender.

public final void onBeforeRender(final ViewDefinitionState view) throws JSONException {
    JSONObject context = view.getJsonContext();
    GridComponent grid = (GridComponent) view.getComponentByReference("productionLineGrid");
    FilterValueHolder filter = grid.getFilterValue();
    filter.put(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID, context.getLong("window.mainTab.form.gridLayout.technologyId"));
    if (context.has("window.mainTab.form.gridLayout.divisionId")) {
        filter.put(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID, context.getLong("window.mainTab.form.gridLayout.divisionId"));
    } else if (filter.has(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID)) {
        filter.remove(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID);
    }
    grid.setFilterValue(filter);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) JSONObject(org.json.JSONObject) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 87 with FilterValueHolder

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

the class LocationDetailsPFTD method setCriteriaModifierParameters.

public void setCriteriaModifierParameters(final ViewDefinitionState view) {
    FormComponent locationForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent divisionsGrid = (GridComponent) view.getComponentByReference(L_DIVISIONS);
    Entity location = locationForm.getEntity();
    if (location.getId() != null) {
        FilterValueHolder filterValueHolder = divisionsGrid.getFilterValue();
        filterValueHolder.put(L_LOCATION, location.getId());
        divisionsGrid.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) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 88 with FilterValueHolder

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

the class IssueCriteriaModifiers method restrictToUserLocations.

public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filter) {
    Long currentUserId = securityService.getCurrentUserId();
    if (Objects.nonNull(currentUserId)) {
        EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS);
        if (!userLocations.isEmpty()) {
            Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)).mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet());
            scb.add(SearchRestrictions.in("locationId", locationIds));
        }
    }
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) QcadooSecurityConstants(com.qcadoo.security.constants.QcadooSecurityConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) DataDefinition(com.qcadoo.model.api.DataDefinition) Collectors(java.util.stream.Collectors) EntityList(com.qcadoo.model.api.EntityList) FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Objects(java.util.Objects) UserFieldsMF(com.qcadoo.mes.materialFlow.constants.UserFieldsMF) UserLocationFields(com.qcadoo.mes.materialFlow.constants.UserLocationFields) Service(org.springframework.stereotype.Service) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SecurityService(com.qcadoo.security.api.SecurityService) EntityList(com.qcadoo.model.api.EntityList)

Example 89 with FilterValueHolder

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

the class GeneratorViewHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    GeneratorView generatorView = GeneratorView.from(view);
    generateProductNumber(view);
    showRibbonButtons(generatorView, view);
    GridComponent grid = (GridComponent) view.getComponentByReference("generatorTechnologiesForProducts");
    FilterValueHolder gridHolder = grid.getFilterValue();
    gridHolder.put(TechnologiesForProductsCM.PARAMETER, generatorView.getFormEntity().getId());
    grid.setFilterValue(gridHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) GridComponent(com.qcadoo.view.api.components.GridComponent) GeneratorView(com.qcadoo.mes.technologiesGenerator.view.GeneratorView)

Example 90 with FilterValueHolder

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

the class OperationDetailsHooks method setWorkstationsCriteriaModifiers.

private void setWorkstationsCriteriaModifiers(final ViewDefinitionState view) {
    LookupComponent divisionLookup = (LookupComponent) view.getComponentByReference(OperationFields.DIVISION);
    LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(L_WORKSTATION_LOOKUP);
    GridComponent workstations = (GridComponent) view.getComponentByReference(OperationFields.WORKSTATIONS);
    Entity division = divisionLookup.getEntity();
    FilterValueHolder filter = workstationLookup.getFilterValue();
    if (division != null) {
        filter.put(OperationFields.DIVISION, division.getId());
        workstations.setEditable(true);
    } else {
        filter.remove(OperationFields.DIVISION);
        workstations.setEditable(false);
    }
    workstationLookup.setFilterValue(filter);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)119 LookupComponent (com.qcadoo.view.api.components.LookupComponent)69 Entity (com.qcadoo.model.api.Entity)64 FormComponent (com.qcadoo.view.api.components.FormComponent)45 GridComponent (com.qcadoo.view.api.components.GridComponent)26 FieldComponent (com.qcadoo.view.api.components.FieldComponent)13 Collectors (java.util.stream.Collectors)11 Autowired (org.springframework.beans.factory.annotation.Autowired)11 Service (org.springframework.stereotype.Service)11 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)10 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)10 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)10 Objects (java.util.Objects)10 DataDefinition (com.qcadoo.model.api.DataDefinition)9 JSONObject (org.json.JSONObject)9 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)8 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)8 EntityList (com.qcadoo.model.api.EntityList)8 SecurityService (com.qcadoo.security.api.SecurityService)8 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)8