Skip to content
Snippets Groups Projects

REDMINE_ISSUE-18736 | Parcours de signalement & édition rapide - erreur de détection de changement avec booléens

Merged REDMINE_ISSUE-18736 | Parcours de signalement & édition rapide - erreur de détection de changement avec booléens
Merged Timothee P requested to merge redmine-issues/18736 into develop
1 file
+ 6
4
Compare changes
  • Side-by-side
  • Inline
@@ -172,6 +172,7 @@
@@ -172,6 +172,7 @@
</template>
</template>
<script>
<script>
 
import { isEqual } from 'lodash';
import { mapState, mapActions, mapMutations, mapGetters } from 'vuex';
import { mapState, mapActions, mapMutations, mapGetters } from 'vuex';
import mapService from '@/services/map-service';
import mapService from '@/services/map-service';
@@ -274,10 +275,11 @@ export default {
@@ -274,10 +275,11 @@ export default {
if (this.form.status.value !== this.currentFeature.properties.status) return true;
if (this.form.status.value !== this.currentFeature.properties.status) return true;
for (const xForm of this.$store.state.feature.extra_forms) {
for (const xForm of this.$store.state.feature.extra_forms) {
const originalValue = this.currentFeature.properties[xForm.name];
const originalValue = this.currentFeature.properties[xForm.name];
if (xForm.value === null && originalValue === undefined) { // prevent detecting changes when null & undefined ...
if (
return false; // ... because when deactivating a conditional field we empty the value by setting it to null, since commonly undefined should not be used to manually set a variable
!isEqual(xForm.value, originalValue) && // check if values changed
} // ... and original value would be undefined by default if no value found in feature property
!(!xForm.value && !originalValue) // if the value is not defined, null, an empty string or a boolean with false, no need to warn the user before leaving page without saving (when a conditional field is unactivated or in case of boolean not set by user the value is null which is equivalent to false)
if (xForm.value !== originalValue) {
) {
 
console.log('In custom form [',xForm.name, '], the current form value [', xForm.value, '] differs from original value [', originalValue, ']');
return true;
return true;
}
}
}
}
Loading