Skip to content

Commit

Permalink
feb r03 (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
mainlyIt authored Feb 27, 2025
1 parent 9d0ff2b commit 6a934c6
Show file tree
Hide file tree
Showing 11 changed files with 797 additions and 631 deletions.
536 changes: 343 additions & 193 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"pinia": "^2.1.7",
"roboto-fontface": "*",
"vue": "^3.3.0",
"vue-multiselect": "^3.2.0",
"vue-router": "^4.3.0",
"vuetify": "^3.0.0",
"vuex": "^4.1.0"
Expand Down
26 changes: 19 additions & 7 deletions src/components/MapPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default {
const selectedMarker = vespaStore.markerClusterGroup.getLayers().find(marker => marker.feature.properties.id === selectedObservation.value.id);
if (selectedMarker) {
selectedMarker.setStyle({
fillColor: fillColor,
fillColor: selectedMarker.options.fillColor,
color: '#ea792a',
weight: 4
});
Expand Down Expand Up @@ -278,17 +278,29 @@ export default {
if (observationId) {
await vespaStore.fetchObservationDetails(observationId);
const location = selectedObservation.value.location;
const [longitude, latitude] = location
.slice(location.indexOf('(') + 1, location.indexOf(')'))
.split(' ')
.map(parseFloat);
const loc = selectedObservation.value.location;
let longitude, latitude;
if (typeof loc === 'string') {
// If location is in WKT format, e.g. "POINT(5.6899 50.8084)"
const coords = loc.slice(loc.indexOf('(') + 1, loc.indexOf(')')).split(' ');
[longitude, latitude] = coords.map(parseFloat);
} else if (loc && loc.coordinates) {
// If location is a GeoJSON object { type: "Point", coordinates: [lng, lat] }
[longitude, latitude] = loc.coordinates;
} else {
// Fallback center
longitude = 4.3517;
latitude = 50.8503;
}
map.value = L.map('map', {
center: [latitude, longitude],
zoom: 16,
maxZoom: 19,
layers: [
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', tileLayerOptions),
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © OpenStreetMap contributors',
maxZoom: 19,
}),
],
});
vespaStore.isDetailsPaneOpen = true;
Expand Down
188 changes: 146 additions & 42 deletions src/components/ObservationDetailsComponent.vue

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import { useVespaStore } from './stores/vespaStore';
import Multiselect from 'vue-multiselect';
import 'vue-multiselect/dist/vue-multiselect.min.css'

// Import CSS
import '@fortawesome/fontawesome-free/css/all.css';
Expand All @@ -21,6 +23,7 @@ const pinia = createPinia();
app.use(pinia);
app.use(router);

app.component('Multiselect', Multiselect);
registerPlugins(app);

const vespaStore = useVespaStore();
Expand Down
10 changes: 9 additions & 1 deletion src/stores/vespaStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,15 @@ export const useVespaStore = defineStore('vespaStore', {
},
async updateObservation(observation) {
try {
const response = await ApiService.patch(`/observations/${observation.id}/`, observation);
// Make a copy to ensure we don't modify the original
const observationToSend = { ...observation };

// Convert boolean queen_present to explicit true/false
if ('queen_present' in observationToSend) {
observationToSend.queen_present = observationToSend.queen_present === true;
}

const response = await ApiService.patch(`/observations/${observation.id}/`, observationToSend);
if (response.status === 200) {
this.selectedObservation = response.data;
const colorByResult = this.getColorByStatus(response.data.eradication_result);
Expand Down
18 changes: 18 additions & 0 deletions vespadb/observations/migrations/0036_observation_queen_present.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1.4 on 2025-02-12 19:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('observations', '0035_alter_observation_options_and_more'),
]

operations = [
migrations.AddField(
model_name='observation',
name='queen_present',
field=models.BooleanField(blank=True, help_text='Shows if the queen was present during the eradication', null=True),
),
]
6 changes: 6 additions & 0 deletions vespadb/observations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ class Observation(models.Model):
help_text="Problems encountered during the eradication",
)
eradication_notes = models.TextField(blank=True, null=True, help_text="Notes about the eradication")

queen_present = models.BooleanField(
null=True,
blank=True,
help_text="Shows if the queen was present during the eradication",
)

municipality = models.ForeignKey(
Municipality,
Expand Down
Loading

0 comments on commit 6a934c6

Please sign in to comment.