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"));
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations