Commit 920c3590 authored by PECQUOT's avatar PECQUOT

[fix] RuleControl: The model can be valid if control is valid; For now, only...

[fix] RuleControl: The model can be valid if control is valid; For now, only HomeUI is done... (Mantis #50538)
Signed-off-by: PECQUOT's avatarlp1ee9d <ludovic.pecquot@e-is.pro>
parent c8ac7149
## Sprint 81 - v3.9.0
- Pas de mise à jour de modèle
## Sprint 80 - v3.8.1
......
......@@ -171,7 +171,7 @@
<maven.compiler.debug>true</maven.compiler.debug>
<!-- Quadrige3 Core version -->
<quadrige3-core.version>3.6.5-SNAPSHOT</quadrige3-core.version>
<quadrige3-core.version>3.6.5</quadrige3-core.version>
<!-- Last ReefDb launcher version -->
<launcherVersion>3.0.3</launcherVersion>
......
......@@ -68,7 +68,8 @@ public class CloseAction extends AbstractCheckBeforeChangeScreenAction<HomeUIMod
/** {@inheritDoc} */
@Override
protected boolean isModelValid() {
return getModel().isValid();
// the model can be valid if control is valid (Mantis #50538)
return getModel().isValid() || getModel().isControlValid();
}
/** {@inheritDoc} */
......
......@@ -172,7 +172,7 @@ JLocalDatePicker {
toolTipText: "reefdb.action.save.observations";
_applicationAction: {SaveAction.class};
_applicationActionKey: {fr.ifremer.reefdb.ui.swing.util.ReefDbKeyStrokes.SAVE};
enabled: {model.isValid() && model.isModify()};
enabled: {(model.isValid() || model.isControlValid()) && model.isModify()};
}
#surveysTable {
......
......@@ -12,24 +12,27 @@ package fr.ifremer.reefdb.ui.swing.content.home;
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
import fr.ifremer.quadrige3.ui.swing.model.AbstractEmptyUIModel;
import fr.ifremer.reefdb.dto.ReefDbBeans;
import fr.ifremer.reefdb.dto.SearchDateDTO;
import fr.ifremer.reefdb.dto.StateDTO;
import fr.ifremer.reefdb.dto.SynchronizationStatusDTO;
import fr.ifremer.reefdb.dto.configuration.context.ContextDTO;
import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO;
import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
import fr.ifremer.reefdb.dto.data.survey.CampaignDTO;
import fr.ifremer.reefdb.dto.data.survey.SurveyDTO;
import fr.ifremer.reefdb.dto.referential.LocationDTO;
import fr.ifremer.reefdb.ui.swing.content.home.operation.OperationsTableUIModel;
import fr.ifremer.reefdb.ui.swing.content.home.survey.SurveysTableRowModel;
......@@ -85,6 +88,36 @@ public class HomeUIModel extends AbstractEmptyUIModel<HomeUIModel> {
private OperationsTableUIModel operationsTableUIModel;
private SurveysTableRowModel selectedSurvey;
/**
* Check if there is real error (if not, means control is valid, then the save is enabled) (Mantis #50538)
*
* @return true if already valid or there is only control errors
*/
public boolean isControlValid() {
if (isValid())
return true;
if (getSurveysTableUIModel() == null)
return false;
boolean controlValid = true;
for (SurveyDTO survey : getSurveysTableUIModel().getBeans()) {
if (ReefDbBeans.isSurveyValidated(survey))
continue;
if (!ReefDbBeans.getErrors(survey, false).isEmpty()) {
controlValid = false;
break;
} else {
for (SamplingOperationDTO operation : survey.getSamplingOperations()) {
if (!ReefDbBeans.getErrors(operation, false).isEmpty()) {
controlValid = false;
break;
}
}
}
}
return controlValid;
}
/**
* <p>isAdjusting.</p>
*
......
......@@ -110,7 +110,8 @@ public class SaveAction extends AbstractReefDbSaveAction<HomeUIModel, HomeUI, Ho
return false;
}
// Model is valid
if (!getModel().isValid()) {
// the model can be valid if control is valid (Mantis #50538)
if (!getModel().isValid() && !getModel().isControlValid()) {
// Remove error
displayErrorMessage(t("reefdb.action.save.errors.title"), t("reefdb.action.save.errors.remove"));
......
......@@ -35,7 +35,7 @@
</field-validator>
<field-validator type="controltableexpression">
<param name="level">error</param>
<param name="controlLevel">none</param>
<param name="controlLevel">error</param>
<message/>
</field-validator>
</field>
......@@ -46,7 +46,7 @@
</field-validator>
<field-validator type="controltableexpression">
<param name="level">error</param>
<param name="controlLevel">none</param>
<param name="controlLevel">error</param>
<message/>
</field-validator>
</field>
......
......@@ -31,14 +31,14 @@
<field name='surveysTableUIModel'>
<field-validator type="controltableexpression">
<param name="level">warning</param>
<param name="controlLevel">all</param>
<param name="controlLevel">warning</param>
<message/>
</field-validator>
</field>
<field name='operationsTableUIModel'>
<field-validator type="controltableexpression">
<param name="level">warning</param>
<param name="controlLevel">all</param>
<param name="controlLevel">warning</param>
<message/>
</field-validator>
</field>
......
......@@ -63,6 +63,10 @@
<action dev="ludovic.pecquot@e-is.pro" type="add" issue="50011">
DuplicateSurveyAction: Change message and buttons
</action>
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="50538">
RuleControl: The model can be valid if control is valid
For now, only HomeUI is done...
</action>
</release>
<release version="3.8.1" date="2020-01-16" description="Stable release">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment