use of io.imunity.furms.ui.components.support.models.allocation.AllocationCommunityComboBoxModel in project furms by unity-idm.
the class ProjectAllocationDashboardFormView method communityAllocation.
private ComboBox<AllocationCommunityComboBoxModel> communityAllocation(Label availableAmountLabel) {
final ComboBox<AllocationCommunityComboBoxModel> communityAllocationComboBox = new ComboBox<>();
communityAllocationComboBox.setItemLabelGenerator(resourceType -> resourceType.name);
communityAllocationComboBox.setReadOnly(true);
communityAllocationComboBox.setItems(binder.getBean().getAllocationCommunity());
AllocationCommunityComboBoxModel allocationCommunity = binder.getBean().getAllocationCommunity();
availableAmount = projectAllocationService.getAvailableAmount(binder.getBean().getCommunityId(), allocationCommunity.id);
availableAmountLabel.setText(createAvailableLabelContent(allocationCommunity.split));
binder.forField(communityAllocationComboBox).bind(ProjectAllocationViewModel::getAllocationCommunity, ProjectAllocationViewModel::setAllocationCommunity);
return communityAllocationComboBox;
}
use of io.imunity.furms.ui.components.support.models.allocation.AllocationCommunityComboBoxModel in project furms by unity-idm.
the class ProjectAllocationDashboardFormView method amountField.
private BigDecimalField amountField() {
final BigDecimalField amountField = new BigDecimalField();
amountField.setValueChangeMode(EAGER);
Optional<AllocationCommunityComboBoxModel> communityAlloc = Optional.ofNullable(binder.getBean().getAllocationCommunity());
amountField.setReadOnly(!communityAlloc.map(alloc -> alloc.split).orElse(true));
createUnitLabel(amountField, binder.getBean().getResourceType().unit);
binder.forField(amountField).withValidator(Objects::nonNull, getTranslation("view.community-admin.project-allocation.form.error.validation.field.amount")).withValidator(this::isAmountCorrect, getTranslation("view.community-admin.project-allocation.form.error.validation.field.amount.range")).bind(ProjectAllocationViewModel::getAmount, ProjectAllocationViewModel::setAmount);
amountField.setValue(availableAmount);
return amountField;
}
use of io.imunity.furms.ui.components.support.models.allocation.AllocationCommunityComboBoxModel in project furms by unity-idm.
the class ProjectAllocationDashboardFormView method createViewModel.
private ProjectAllocationViewModel createViewModel() {
final ResourceAllocationsGridItem item = ComponentUtil.getData(UI.getCurrent(), ResourceAllocationsGridItem.class);
ComponentUtil.setData(UI.getCurrent(), ResourceAllocationsGridItem.class, null);
return ProjectAllocationViewModel.builder().communityId(item.getCommunityId()).resourceType(new ResourceTypeComboBoxModel(item.getResourceType().id, item.getResourceType().name, item.getResourceType().unit)).allocationCommunity(new AllocationCommunityComboBoxModel(item.getId(), item.getName(), item.isSplit(), item.getCredit().getUnit())).build();
}
Aggregations