Skip to content

Commit

Permalink
release 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegerrits committed Nov 25, 2024
1 parent 19431d0 commit 1669374
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 35 deletions.
62 changes: 33 additions & 29 deletions src/components/ObservationDetailsComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class="btn btn-sm btn-outline-danger" @click="cancelReservation">Reservatie annuleren</button>
</div>

<div v-if="canViewRestrictedFields && canEdit" class="mb-3" id="edit">
<div v-if="canViewRestrictedFields" class="mb-3" id="edit">
<button class="btn btn-sm btn-outline-success" @click="confirmUpdate">Wijzigingen opslaan</button>
</div>
<div v-if="successMessage" class="alert alert-success alert-dismissible fade show" role="alert">
Expand Down Expand Up @@ -59,8 +59,9 @@
:class="{ 'is-invalid': eradicationResultError }" :disabled="!canEdit">
<option :value="null">Geen</option>
<option v-for="(label, value) in eradicationResultEnum" :key="value"
:value="value">{{ label
}}</option>
:value="value">
{{ label }}
</option>
</select>
<div v-if="eradicationResultError" class="invalid-feedback">
{{ eradicationResultError }}
Expand Down Expand Up @@ -266,14 +267,15 @@
</div>
<div>
<div class="row mb-2">
<label class="col-4 col-form-label">Validatiestatus</label>
<div class="col-8" v-if="selectedObservation.wn_validation_status !== undefined">
<p :value="null">Geen</p>
<p v-for="(label, value) in validationStatusEnum" :key="value" :value="value">{{
label }}</p>
<label class="col-4 col-form-label">Validatie</label>
<div class="col-8">
<p>
{{ validationStatusEnum[selectedObservation.wn_validation_status] || "Geen"
}}
</p>
</div>
</div>
<div v-if="canViewRestrictedFields" class="row mb-2">
<div class="row mb-2">
<label class="col-4 col-form-label">Opmerking validator</label>
<div class="col-8">
<p class="form-control-plaintext">{{ selectedObservation.notes }}</p>
Expand Down Expand Up @@ -320,7 +322,8 @@
<div class="row mb-2">
<label class="col-4 col-form-label">Telefoon</label>
<div class="col-8">
<p class="form-control-plaintext">{{ selectedObservation.observer_phone_number }}</p>
<p class="form-control-plaintext">{{ selectedObservation.observer_phone_number }}
</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -528,7 +531,7 @@ export default {
}
});
const canViewRestrictedFields = computed(() => {
return vespaStore.isAdmin ||
return vespaStore.isAdmin ||
(isLoggedIn.value && vespaStore.userMunicipalities.includes(selectedObservation.value?.municipality_name));
});
Expand Down Expand Up @@ -643,23 +646,23 @@ export default {
];
const hasEradicationData = eradicationFields.some(field => editableObservation.value[field]);
if (
editableObservation.value.eradication_result &&
!editableObservation.value.eradication_date
) {
const today = new Date();
editableObservation.value.eradication_date = today.toISOString().split('T')[0];
}
// if (
// editableObservation.value.eradication_result &&
// !editableObservation.value.eradication_date
// ) {
// const today = new Date();
// editableObservation.value.eradication_date = today.toISOString().split('T')[0];
// }
// Format eradication_date if provided, and check for valid eradication result
if (editableObservation.value.eradication_date) {
const date = new Date(editableObservation.value.eradication_date);
if (!isNaN(date.getTime())) {
editableObservation.value.eradication_date = date.toISOString().split('T')[0];
} else {
throw new Error("Invalid eradication date format");
}
}
// if (editableObservation.value.eradication_date) {
// const date = new Date(editableObservation.value.eradication_date);
// if (!isNaN(date.getTime())) {
// editableObservation.value.eradication_date = date.toISOString().split('T')[0];
// } else {
// throw new Error("Invalid eradication date format");
// }
// }
if (hasEradicationData && !editableObservation.value.eradication_result) {
eradicationResultError.value = 'Resultaat is verplicht wanneer andere bestrijdingsgegevens zijn ingevuld.';
Expand All @@ -679,7 +682,7 @@ export default {
errorMessage.value = 'Er is een fout opgetreden bij het opslaan van de wijzigingen.';
}
console.error('Error updating observation:', error);
}finally {
} finally {
isUpdating.value = false;
}
};
Expand Down Expand Up @@ -769,7 +772,8 @@ export default {
editableObservation,
errorMessage,
eradicationResultError,
canViewRestrictedFields
canViewRestrictedFields,
validationStatusEnum
};
}
};
Expand Down
5 changes: 3 additions & 2 deletions src/stores/vespaStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export const useVespaStore = defineStore('vespaStore', {
)?.name;
return (
state.isLoggedIn &&
state.userMunicipalities.includes(municipalityName) &&
!observation.reserved_by
state.userMunicipalities.includes(municipalityName)
);
},
canEditAdminFields: (state) => state.isAdmin,
Expand Down Expand Up @@ -457,6 +456,8 @@ export const useVespaStore = defineStore('vespaStore', {
return '#198754';
} else if (status === 'eradicated') {
return '#198754';
} else if (status === 'unsuccessful') {
return '#198754';
} else if (status === 'reserved') {
return '#ea792a';
}
Expand Down
1 change: 0 additions & 1 deletion vespadb/observations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class ObservationAdmin(gis_admin.GISModelAdmin):
"source",
"wn_id",
"wn_validation_status",
"wn_admin_notes",
"observer_name",
"observer_phone_number",
"created_datetime",
Expand Down
6 changes: 3 additions & 3 deletions vespadb/observations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from vespadb.observations.cache import invalidate_geojson_cache, invalidate_observation_cache
from vespadb.observations.filters import ObservationFilter
from vespadb.observations.helpers import parse_and_convert_to_utc
from vespadb.observations.models import Municipality, Observation, Province
from vespadb.observations.models import Municipality, Observation, Province, EradicationResultEnum
from vespadb.observations.serializers import (
MunicipalitySerializer,
ObservationSerializer,
Expand Down Expand Up @@ -393,7 +393,7 @@ def geojson(self, request: Request) -> HttpResponse:
"properties": {
"id": obs.id,
"status": "eradicated"
if obs.eradication_result == "successful"
if obs.eradication_result is not None
else "reserved"
if obs.reserved_by
else "default",
Expand Down Expand Up @@ -744,7 +744,7 @@ def serialize_observation(self, obj: Observation, headers: list[str], allowed_fi
elif field == "anb_domain":
data.append(str(obj.anb))
elif field == "eradication_result":
data.append(obj.eradication_result.value if obj.eradication_result else "")
data.append(obj.eradication_result if obj.eradication_result else "")
elif field == "nest_status":
logger.info("Getting status for observation %s", obj.eradication_result)
# This is handled as requested with eradication result
Expand Down

0 comments on commit 1669374

Please sign in to comment.