anmolbabu has uploaded a new change for review. Change subject: webadmin : Handle multi-tab validation error ......................................................................
webadmin : Handle multi-tab validation error Snapshot create popup has 2 tabs : 1. General 2. Schedule Editors in both tabs have validations for each input elements in the tabs.However, although the validations validate as expected, the problem was as under: When user in some tab and a validation fails in an input element of the other tab, although tab complained of error, it used to go unnoticed as the tab reporting the error is not the one that is active. This patch, activates the tab that has the errors in the following order: 1. If the general tab has any validation failures, it opens up the general tab. 2. If the schedule tab has any failures, it opens up the schedule tab. In accordance with above 2 steps, if both the tabs have validation failures, immaterial of the number of failures in each tab or any other criteria, general tab opens up(Does nothing if its already open). Change-Id: I88c05aa369758ce174b0dc85f83a253e608d6c0e Signed-off-by: Anmol Babu <anb...@redhat.com> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotCreatePopupPresenterWidget.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml 6 files changed, 70 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/40680/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java index d2e52c8..214ad50 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java @@ -7,6 +7,7 @@ import org.ovirt.engine.ui.common.widget.renderer.StringRenderer; import com.google.gwt.dom.client.Style.BorderStyle; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.editor.client.IsEditor; import com.google.gwt.text.shared.Renderer; @@ -45,6 +46,7 @@ @Override public void markAsInvalid(List<String> validationHints) { super.markAsInvalid(validationHints); + getValidatedWidgetStyle().setHeight(50, Unit.PX); } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java index 3cc6d7d..af61443 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java @@ -518,6 +518,8 @@ volume_restore_snapshot_confirmation( "volume_restore_snapshot_confirmation", HelpTagType.WEBADMIN, "[gluster] Volumes main tab -> Snapshots sub-tab -> 'Restore Snapshot' dialog"), //$NON-NLS-1$//$NON-NLS-2$ + volume_snapshot_create_validation_failed("volume_snapshot_create_validation_failed", HelpTagType.WEBADMIN, "'[gluster] Volumes main tab -> Snapshot -> New' validation error"), //$NON-NLS-1$//$NON-NLS-2$ + volume_delete_snapshot_confirmation( "volume_delete_snapshot_confirmation", HelpTagType.WEBADMIN, "[gluster] Volumes main tab -> Snapshots sub-tab -> 'Remove Snapshot' dialog"), //$NON-NLS-1$//$NON-NLS-2$ diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java index 0d36213..d985fba 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotModel.java @@ -17,6 +17,7 @@ import org.ovirt.engine.ui.uicommonweb.validation.LengthValidation; import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; import org.ovirt.engine.ui.uicompat.ConstantsManager; +import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; public class GlusterVolumeSnapshotModel extends Model { private EntityModel<String> dataCenter; @@ -228,15 +229,21 @@ && (getDaysOfTheWeek().getSelectedItem() == null || getDaysOfTheWeek().getSelectedItem().isEmpty())) { setMessage(ConstantsManager.getInstance().getConstants().noWeekDaysSelectedMessage()); validWeekDays = false; + getDaysOfTheWeek().setInvalidityReasons(new ArrayList<String>()); + getDaysOfTheWeek().setIsValid(false); } if (getRecurrence().getSelectedItem() == GlusterVolumeSnapshotScheduleRecurrence.MONTHLY) { if (getDaysOfMonth().getSelectedItem() == null || getDaysOfMonth().getSelectedItem().equals("")) {//$NON-NLS-1$ setMessage(ConstantsManager.getInstance().getConstants().noMonthDaysSelectedMessage()); validMonthDays = false; + getDaysOfMonth().setInvalidityReasons(new ArrayList<String>()); + getDaysOfMonth().setIsValid(false); } else if (getDaysOfMonth().getSelectedItem().contains(",L") || getDaysOfMonth().getSelectedItem().contains("L,")) {//$NON-NLS-1$//$NON-NLS-2$ setMessage(ConstantsManager.getInstance().getConstants().lastDayMonthCanBeSelectedAlone()); validMonthDays = false; + getDaysOfMonth().setInvalidityReasons(new ArrayList<String>()); + getDaysOfMonth().setIsValid(false); } } @@ -245,8 +252,12 @@ && getEndDate().getEntity().compareTo(getStartAt().getEntity()) <= 0) { setMessage(ConstantsManager.getInstance().getConstants().endDateBeforeStartDate()); validEndDate = false; + getEndDate().setInvalidityReasons(new ArrayList<String>()); + getEndDate().setIsValid(false); } + onPropertyChanged(new PropertyChangedEventArgs("validationResult"));//$NON-NLS-1$ + return getSnapshotName().getIsValid() && getDaysOfTheWeek().getIsValid() && getDaysOfMonth().getIsValid() && validWeekDays && validMonthDays && validEndDate; } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotCreatePopupPresenterWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotCreatePopupPresenterWidget.java index 6948643..2cbfc27 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotCreatePopupPresenterWidget.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotCreatePopupPresenterWidget.java @@ -7,6 +7,7 @@ import org.ovirt.engine.ui.uicompat.Event; import org.ovirt.engine.ui.uicompat.EventArgs; import org.ovirt.engine.ui.uicompat.IEventListener; +import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; import com.google.gwt.event.shared.EventBus; import com.google.inject.Inject; @@ -49,6 +50,15 @@ getView().setEndDateVisibility(model); } }); + + model.getPropertyChangedEvent().addListener(new IEventListener<PropertyChangedEventArgs>() { + @Override + public void eventRaised(Event<? extends PropertyChangedEventArgs> ev, Object sender, PropertyChangedEventArgs args) { + if(args.propertyName.equalsIgnoreCase("validationResult")) {//$NON-NLS-1$ + getView().handleValidationErrors(model); + } + } + }); } public interface ViewDef extends AbstractModelBoundPopupPresenterWidget.ViewDef<GlusterVolumeSnapshotModel> { @@ -57,5 +67,7 @@ public void setEndDateVisibility(GlusterVolumeSnapshotModel object); public void setCriticalIntervalLabelVisibility(GlusterVolumeSnapshotModel object, int value); + + public void handleValidationErrors(GlusterVolumeSnapshotModel object); } } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java index 89260b7..4ae8900 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java @@ -1,5 +1,8 @@ package org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster; +import java.util.Collections; +import java.util.List; + import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotScheduleRecurrence; import org.ovirt.engine.core.compat.DayOfWeek; import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; @@ -8,6 +11,7 @@ import org.ovirt.engine.ui.common.widget.dialog.InfoIcon; import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; import org.ovirt.engine.ui.common.widget.dialog.tab.DialogTab; +import org.ovirt.engine.ui.common.widget.dialog.tab.DialogTabPanel; import org.ovirt.engine.ui.common.widget.editor.EntityModelDateTimeBoxEditor; import org.ovirt.engine.ui.common.widget.editor.GwtBootstrapDateTimePicker; import org.ovirt.engine.ui.common.widget.editor.ListModelCheckBoxGroupEditor; @@ -53,6 +57,9 @@ } @UiField + DialogTabPanel tabContainer; + + @UiField WidgetStyle style; @UiField @@ -80,6 +87,11 @@ @Path(value = "description.entity") @WithElementId StringEntityModelTextBoxEditor snapshotDescriptionEditor; + + @UiField + @Ignore + @WithElementId + Label generalTabErrorMsgLabel; @UiField DialogTab scheduleTab; @@ -256,6 +268,34 @@ errorMsgLabel.setText(msg); } + @Override + public void handleValidationErrors(GlusterVolumeSnapshotModel object) { + StringBuilder generalTabErrorBuilder = new StringBuilder(); + if (!snapshotNameEditor.isValid()){ + appendErrors(Collections.singletonList(constants.volumeSnapshotNamePrefixLabel()), generalTabErrorBuilder); + appendErrors(object.getSnapshotName().getInvalidityReasons(), generalTabErrorBuilder); + } + + generalTabErrorMsgLabel.setText(generalTabErrorBuilder.toString()); + generalTabErrorMsgLabel.setVisible(generalTabErrorBuilder.toString() != null || !generalTabErrorBuilder.toString().isEmpty()); + + if (!clusterNameEditor.isValid() || !volumeNameEditor.isValid() || !snapshotNameEditor.isValid() + || !snapshotDescriptionEditor.isValid()) { + tabContainer.switchTab(generalTab); + } else if (!recurrenceEditor.isValid() || !intervalEditor.isValid() || !timeZoneEditor.isValid() + || !startAtEditor.isValid() || !executionTimeEditor.isValid() || !daysOfWeekEditor.isValid() + || !daysOfMonthEditor.isValid() || !endByOptionsEditor.isValid() || !endDate.isValid()) { + tabContainer.switchTab(scheduleTab); + } + } + + private void appendErrors(List<String> errors, StringBuilder sBuilder) { + for(String currentError : errors) { + sBuilder.append(currentError); + sBuilder.append("\n");//$NON-NLS-1$ + } + } + private void updateTabVisibilities(GlusterVolumeSnapshotModel object) { generalTab.setVisible(object.isGeneralTabVisible()); scheduleTab.setVisible(object.isScheduleTabVisible()); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml index bd18806..4723058 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.ui.xml @@ -57,7 +57,7 @@ <d:SimpleDialogPanel width="700px" height="500px"> <d:content> - <t:DialogTabPanel height="100%" width="100%"> + <t:DialogTabPanel ui:field="tabContainer" height="100%" width="100%"> <t:tab> <t:DialogTab ui:field="generalTab"> <t:content> @@ -74,6 +74,8 @@ </g:HorizontalPanel> <ge:StringEntityModelTextBoxEditor ui:field="snapshotDescriptionEditor" /> + <g:Label ui:field="generalTabErrorMsgLabel" + addStyleNames="{style.errMsgLabel}" /> </g:FlowPanel> </t:content> </t:DialogTab> -- To view, visit https://gerrit.ovirt.org/40680 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I88c05aa369758ce174b0dc85f83a253e608d6c0e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: anmolbabu <anb...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches