Search in sources :

Example 36 with CheckBoxComponent

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

the class ResourcesListHooks method applyFilters.

public void applyFilters(ViewDefinitionState view) {
    boolean isShortFilter = ((CheckBoxComponent) view.getComponentByReference(ResourceDtoFields.IS_SHORT_FILTER)).isChecked();
    boolean isDeadlineFilter = ((CheckBoxComponent) view.getComponentByReference(ResourceDtoFields.IS_DEADLINE_FILTER)).isChecked();
    GridComponent resourcesGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Integer shortExpiryDate = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT_POSITION_PARAMETERS).find().setMaxResults(1).uniqueResult().getIntegerField(DocumentPositionParametersFields.SHORT_EXPIRY_DATE);
    if (isShortFilter) {
        if (shortExpiryDate == null) {
            resourcesGrid.addMessage("materialFlowResources.resource.missing.parameter.shortExpiryDate.error", ComponentState.MessageType.FAILURE);
        } else {
            resourcesGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.and(SearchRestrictions.ge(ResourceDtoFields.EXPIRATION_DATE, DateTime.now().withTimeAtStartOfDay().toDate()), SearchRestrictions.le(ResourceDtoFields.EXPIRATION_DATE, DateTime.now().withTimeAtStartOfDay().plusDays(shortExpiryDate).toDate()))));
        }
    } else if (isDeadlineFilter) {
        resourcesGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.lt(ResourceDtoFields.EXPIRATION_DATE, DateTime.now().withTimeAtStartOfDay().toDate())));
    }
}
Also used : DocumentPositionParametersFields(com.qcadoo.mes.materialFlowResources.constants.DocumentPositionParametersFields) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) DateTime(org.joda.time.DateTime) ComponentState(com.qcadoo.view.api.ComponentState) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) GridComponent(com.qcadoo.view.api.components.GridComponent) MaterialFlowResourcesConstants(com.qcadoo.mes.materialFlowResources.constants.MaterialFlowResourcesConstants) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Service(org.springframework.stereotype.Service) ResourceDtoFields(com.qcadoo.mes.materialFlowResources.constants.ResourceDtoFields) GridComponent(com.qcadoo.view.api.components.GridComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 37 with CheckBoxComponent

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

the class PalletStorageStateListHooks method applyFilters.

public void applyFilters(ViewDefinitionState view) {
    boolean isShiftFilter = ((CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_SHIFT_FILTER)).isChecked();
    boolean isFreeFilter = ((CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_FREE_FILTER)).isChecked();
    GridComponent palletGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Integer palletToShift = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT_POSITION_PARAMETERS).find().setMaxResults(1).uniqueResult().getIntegerField(DocumentPositionParametersItemValues.PALLET_TO_SHIFT);
    Integer palletWithFreePlace = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT_POSITION_PARAMETERS).find().setMaxResults(1).uniqueResult().getIntegerField(DocumentPositionParametersItemValues.PALLET_WITH_FREE_PALECE);
    if (isShiftFilter) {
        if (palletToShift == null) {
            palletGrid.addMessage("materialFlowResources.pallet.missing.parameter.palletToShift.error", ComponentState.MessageType.FAILURE);
        } else {
            palletGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.lt(PalletStorageStateDtoFields.TOTAL_QUANTITY, BigDecimal.valueOf(palletToShift))));
        }
    } else if (isFreeFilter) {
        if (palletWithFreePlace == null) {
            palletGrid.addMessage("materialFlowResources.pallet.missing.parameter.palletWithFreeSpace.error", ComponentState.MessageType.FAILURE);
        } else {
            palletGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.lt(PalletStorageStateDtoFields.TOTAL_QUANTITY, BigDecimal.valueOf(palletWithFreePlace))));
        }
    }
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) ComponentState(com.qcadoo.view.api.ComponentState) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) DocumentPositionParametersItemValues(com.qcadoo.mes.materialFlowResources.constants.DocumentPositionParametersItemValues) GridComponent(com.qcadoo.view.api.components.GridComponent) MaterialFlowResourcesConstants(com.qcadoo.mes.materialFlowResources.constants.MaterialFlowResourcesConstants) BigDecimal(java.math.BigDecimal) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Service(org.springframework.stereotype.Service) PalletStorageStateDtoFields(com.qcadoo.mes.materialFlowResources.constants.PalletStorageStateDtoFields) GridComponent(com.qcadoo.view.api.components.GridComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 38 with CheckBoxComponent

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

the class StorageLocationsMultiAddHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FieldComponent number = (FieldComponent) view.getComponentByReference(StorageLocationHelperFields.NUMBER);
    number.setRequired(true);
    number.requestComponentUpdateState();
    FieldComponent prefix = (FieldComponent) view.getComponentByReference(StorageLocationHelperFields.PREFIX);
    prefix.setRequired(true);
    prefix.requestComponentUpdateState();
    FieldComponent location = (FieldComponent) view.getComponentByReference(StorageLocationHelperFields.LOCATION);
    location.setRequired(true);
    location.requestComponentUpdateState();
    FieldComponent numberOf = (FieldComponent) view.getComponentByReference(StorageLocationHelperFields.NUMBER_OF_STORAGE_LOCATIONS);
    numberOf.setRequired(true);
    numberOf.requestComponentUpdateState();
    FieldComponent maximumNumber = (FieldComponent) view.getComponentByReference(StorageLocationFields.MAXIMUM_NUMBER_OF_PALLETS);
    CheckBoxComponent isPlace = (CheckBoxComponent) view.getComponentByReference(StorageLocationFields.PLACE_STORAGE_LOCATION);
    if (isPlace.isChecked()) {
        maximumNumber.setEnabled(true);
    } else {
        maximumNumber.setEnabled(false);
        maximumNumber.setFieldValue(null);
        maximumNumber.requestComponentUpdateState();
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 39 with CheckBoxComponent

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

the class PalletStorageStateListListeners method showPalletsWithProductToShift.

public void showPalletsWithProductToShift(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    CheckBoxComponent isShiftFilter = (CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_SHIFT_FILTER);
    CheckBoxComponent isFreeFilter = (CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_FREE_FILTER);
    isShiftFilter.setChecked(true);
    isFreeFilter.setChecked(false);
    isShiftFilter.requestComponentUpdateState();
    isFreeFilter.requestComponentUpdateState();
}
Also used : CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 40 with CheckBoxComponent

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

the class PalletStorageStateListListeners method showPallestWithFreeSpace.

public void showPallestWithFreeSpace(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    CheckBoxComponent isShiftFilter = (CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_SHIFT_FILTER);
    CheckBoxComponent isFreeFilter = (CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_FREE_FILTER);
    isShiftFilter.setChecked(false);
    isFreeFilter.setChecked(true);
    isShiftFilter.requestComponentUpdateState();
    isFreeFilter.requestComponentUpdateState();
}
Also used : CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Aggregations

CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)100 FormComponent (com.qcadoo.view.api.components.FormComponent)38 Entity (com.qcadoo.model.api.Entity)33 FieldComponent (com.qcadoo.view.api.components.FieldComponent)30 GridComponent (com.qcadoo.view.api.components.GridComponent)19 LookupComponent (com.qcadoo.view.api.components.LookupComponent)11 Date (java.util.Date)7 JSONObject (org.json.JSONObject)7 BigDecimal (java.math.BigDecimal)6 ComponentState (com.qcadoo.view.api.ComponentState)4 WindowComponent (com.qcadoo.view.api.components.WindowComponent)4 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)4 IOException (java.io.IOException)4 MaterialFlowResourcesConstants (com.qcadoo.mes.materialFlowResources.constants.MaterialFlowResourcesConstants)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)2 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)2 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)2 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)2