Search in sources :

Example 1 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project qcadoo by qcadoo.

the class GridComponentPatternTest method shouldNotFilterOutColumnsVisibleForTenant.

@Test
public void shouldNotFilterOutColumnsVisibleForTenant() throws Exception {
    // given
    PluginStateResolver pluginStateResolver = mock(PluginStateResolver.class);
    PluginUtilsService pluginUtil = new PluginUtilsService(pluginStateResolver);
    pluginUtil.init();
    given(pluginStateResolver.isEnabled("disabledPlugin")).willReturn(true);
    InternalViewDefinitionState viewDefinitionState = mock(InternalViewDefinitionState.class);
    DataDefinition dataDefinition = mock(DataDefinition.class);
    InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
    given(viewDefinition.getDataDefinition()).willReturn(dataDefinition);
    ComponentDefinition componentDefinition = getComponentDefinition(QcadooViewConstants.L_GRID, viewDefinition);
    componentDefinition.setTranslationService(translationService);
    componentDefinition.setApplicationContext(applicationContext);
    componentDefinition.setDataDefinition(dataDefinition);
    GridComponentPattern pattern = new GridComponentPattern(componentDefinition);
    FieldDefinition nameFieldDefinition = mock(FieldDefinition.class);
    given(nameFieldDefinition.getType()).willReturn(new EnumType(translationService, "", true, "v1", "v2"));
    given(dataDefinition.getField("name")).willReturn(nameFieldDefinition);
    pattern.addOption(new ComponentOption("column", ImmutableMap.of("name", "name", "fields", "name", "hidden", "true")));
    pattern.addOption(new ComponentOption("order", ImmutableMap.of("column", "name", "direction", "asc")));
    ViewGridColumnModuleColumnModel columnModel = new ViewGridColumnModuleColumnModel("invisible", "name");
    columnModel.setWidth(100);
    pattern.addColumn("disabledPlugin", columnModel);
    pattern.initialize();
    // when
    ComponentState state = pattern.createComponentState(viewDefinitionState);
    // then
    assertTrue(state instanceof GridComponent);
    @SuppressWarnings("unchecked") Map<String, GridComponentColumn> patternColumns = (Map<String, GridComponentColumn>) getField(pattern, "columns");
    @SuppressWarnings("unchecked") Map<String, GridComponentColumn> stateColumns = (Map<String, GridComponentColumn>) getField(state, "columns");
    assertEquals(2, patternColumns.size());
    assertEquals(2, stateColumns.size());
    assertTrue(patternColumns.keySet().contains("name"));
    assertNotNull(patternColumns.get("name"));
    assertTrue(patternColumns.keySet().contains("invisible"));
    assertNotNull(patternColumns.get("invisible"));
    assertTrue(stateColumns.keySet().contains("name"));
    assertNotNull(stateColumns.get("name"));
    assertTrue(stateColumns.keySet().contains("invisible"));
    assertNotNull(stateColumns.get("invisible"));
}
Also used : PluginUtilsService(com.qcadoo.plugin.internal.PluginUtilsService) ViewGridColumnModuleColumnModel(com.qcadoo.view.internal.module.gridColumn.ViewGridColumnModuleColumnModel) InternalViewDefinitionState(com.qcadoo.view.internal.api.InternalViewDefinitionState) InternalViewDefinition(com.qcadoo.view.internal.api.InternalViewDefinition) ComponentOption(com.qcadoo.view.internal.ComponentOption) GridComponent(com.qcadoo.view.api.components.GridComponent) FieldDefinition(com.qcadoo.model.api.FieldDefinition) GridComponentColumn(com.qcadoo.view.internal.components.grid.GridComponentColumn) DataDefinition(com.qcadoo.model.api.DataDefinition) GridComponentPattern(com.qcadoo.view.internal.components.grid.GridComponentPattern) PluginStateResolver(com.qcadoo.plugin.api.PluginStateResolver) EnumType(com.qcadoo.model.internal.types.EnumType) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ComponentDefinition(com.qcadoo.view.internal.ComponentDefinition) ComponentState(com.qcadoo.view.api.ComponentState) AbstractPatternTest(com.qcadoo.view.internal.patterns.AbstractPatternTest) Test(org.junit.Test)

Example 2 with GridComponent

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

the class TechnologyDetailsListenersPFTD method setWorkstationsLookup.

public void setWorkstationsLookup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    if (!(componentState instanceof GridComponent)) {
        return;
    }
    GridComponent grid = (GridComponent) componentState;
    if (grid.getSelectedEntities().isEmpty()) {
        return;
    }
    LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference("workstationsForTOClookup");
    Entity productionLine = grid.getSelectedEntities().get(0).getBelongsToField("productionLine");
    FilterValueHolder filter = workstationLookup.getFilterValue();
    if (Objects.nonNull(productionLine)) {
        filter.put(OperationFields.PRODUCTION_LINE, productionLine.getId());
    } else {
        filter.remove(OperationFields.PRODUCTION_LINE);
    }
    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)

Example 3 with GridComponent

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

the class ProductsToIssueListListeners method correctReservations.

public void correctReservations(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    List<Long> selectedEntities = Lists.newArrayList(grid.getSelectedEntitiesIds());
    if (selectedEntities.isEmpty()) {
        view.addMessage("productFlowThruDivision.productsToIssueList.noSelectedEntities", ComponentState.MessageType.INFO);
        return;
    }
    Entity firstProduct = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_PRODUCTS_TO_ISSUE).get(selectedEntities.get(0));
    Map<String, Object> parameters = Maps.newHashMap();
    parameters.put("form.productsToIssueIds", selectedEntities.stream().map(Object::toString).collect(Collectors.joining(",")));
    if (firstProduct != null) {
        parameters.put("form.locationFrom", firstProduct.getBelongsToField(ProductsToIssueFields.LOCATION).getId());
        parameters.put("form.placeOfIssue", firstProduct.getBelongsToField(ProductsToIssueFields.WAREHOUSE_ISSUE).getBelongsToField(WarehouseIssueFields.PLACE_OF_ISSUE).getId());
    }
    String url = "../page/productFlowThruDivision/productToIssueCorrectionHelperDetails.html";
    view.redirectTo(url, false, true, parameters);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 4 with GridComponent

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

the class TechnologyDetailsHooksPFTD method enableRangeGrids.

private void enableRangeGrids(final ViewDefinitionState view, final boolean editable) {
    GridComponent rangeTechnologyOperationComponent = (GridComponent) view.getComponentByReference(RANGE_TECHNOLOGY_OPERATION_COMPONENT);
    GridComponent productionLines = (GridComponent) view.getComponentByReference(TechnologyFields.PRODUCTION_LINES);
    GridComponent workstationsTechnologyOperationComponent = (GridComponent) view.getComponentByReference(WORKSTATIONS_TECHNOLOGY_OPERATION_COMPONENT);
    GridComponent workstations = (GridComponent) view.getComponentByReference(WORKSTATIONS);
    productionLines.setEnabled(editable);
    workstations.setEnabled(editable && !workstationsTechnologyOperationComponent.getSelectedEntities().isEmpty());
    rangeTechnologyOperationComponent.setEnabled(true);
    rangeTechnologyOperationComponent.setEditable(editable);
}
Also used : GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 5 with GridComponent

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

the class TechnologyDetailsHooksPFTD method showHideDivisionField.

public void showHideDivisionField(final ViewDefinitionState view) {
    FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
    FieldComponent divisionField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.DIVISION);
    String range = (String) rangeField.getFieldValue();
    GridComponent rangeTechnologyOperationComponent = (GridComponent) view.getComponentByReference(RANGE_TECHNOLOGY_OPERATION_COMPONENT);
    ComponentState operationRangeDescriptionLabel = view.getComponentByReference(OPERATION_RANGE_DESCRIPTION);
    if (Range.ONE_DIVISION.getStringValue().equals(range)) {
        showField(divisionField, true);
        rangeTechnologyOperationComponent.setVisible(false);
        operationRangeDescriptionLabel.setVisible(false);
    } else {
        showField(divisionField, false);
        rangeTechnologyOperationComponent.setVisible(true);
        operationRangeDescriptionLabel.setVisible(true);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) ComponentState(com.qcadoo.view.api.ComponentState)

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