Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed error state from starts and error dates if they are valid (#2303
- Loading branch information
1 parent
4dc180b
commit de6f51e
Showing
3 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...va/org/eclipse/kapua/app/console/module/api/client/util/validator/AfterDateValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017, 2019 Eurotech and/or its affiliates and others | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.app.console.module.api.client.util.validator; | ||
|
||
import com.extjs.gxt.ui.client.widget.form.DateField; | ||
import com.extjs.gxt.ui.client.widget.form.Field; | ||
import com.extjs.gxt.ui.client.widget.form.Validator; | ||
import com.google.gwt.core.client.GWT; | ||
import org.eclipse.kapua.app.console.module.api.client.messages.ValidationMessages; | ||
|
||
public class AfterDateValidator implements Validator { | ||
|
||
private final DateField otherDateField; | ||
private static final ValidationMessages VAL_MSGS = GWT.create(ValidationMessages.class); | ||
|
||
public AfterDateValidator(DateField otherDateField) { | ||
this.otherDateField = otherDateField; | ||
} | ||
|
||
@Override | ||
public String validate(Field<?> field, String s) { | ||
if (otherDateField.getValue() != null) { | ||
DateField thisDateField = (DateField) field; | ||
if (thisDateField.getValue().before(otherDateField.getValue())) { | ||
otherDateField.clearInvalid(); | ||
} else { | ||
return VAL_MSGS.startsOnDateLaterThanEndsOn(); | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters