Skip to content

Commit

Permalink
Merge pull request #8 from smartcommunitylab/new-pgAziendale-console
Browse files Browse the repository at this point in the history
New pg aziendale console
  • Loading branch information
chin8 authored Nov 7, 2024
2 parents 7c5242e + 08b6b95 commit 5e273aa
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ export default {
this.disableMap();
}, 250);
},
resetPosition(lat,lng) {
this.position = { lat, lng };
},
disableMap() {
this.markerClick = false;
this.$refs.map.mapObject.invalidateSize();
Expand All @@ -127,6 +130,10 @@ export default {
this.$refs.map.mapObject.scrollWheelZoom.disable();
this.$refs.map.mapObject.boxZoom.disable();
this.$refs.map.mapObject.keyboard.disable();
this.$refs.map.mapObject.eachLayer(function (layer) {
if (layer?.options?.draggable)
layer.options.draggable=false;
});
if (this.$refs.map.mapObject.tap) this.$refs.map.mapObject.tap.disable();
},
Expand All @@ -138,7 +145,10 @@ export default {
this.$refs.map.mapObject.scrollWheelZoom.enable();
this.$refs.map.mapObject.boxZoom.enable();
this.$refs.map.mapObject.keyboard.enable();
this.$refs.map.mapObject.eachLayer(function (layer) {
if (layer?.options?.draggable)
layer.options.draggable=true;
});
if ( this.$refs.map.tap) this.$refs.map.tap.enable();
},
async changeAddress(value) {
Expand All @@ -150,20 +160,7 @@ export default {
this.$emit('returnGeosearch', results);
}, 500)
},
// getStringAddress(structuredValue) {
// var returnAddress = "";
// if (structuredValue.amenity) returnAddress += "<br />" + structuredValue.amenity;
// if (structuredValue.office) returnAddress += "<br />" + structuredValue.office;
// if (structuredValue.road) returnAddress += "<br />" + structuredValue.road;
// if (structuredValue.house_number)
// returnAddress += ", " + structuredValue.house_number;
// if (structuredValue.city) returnAddress += "<br />" + structuredValue.city;
// if (structuredValue.country) returnAddress += "<br />" + structuredValue.country;
// if (structuredValue.postcode) returnAddress += "<br />" + structuredValue.postcode;
// if (structuredValue.state) returnAddress += "<br />" + structuredValue.state;
// if (structuredValue.county) returnAddress += "<br />" + structuredValue.county;
// return returnAddress;
// },
async getAddress() {
this.loading = true;
let address = {
Expand Down Expand Up @@ -191,6 +188,10 @@ export default {
}
} catch (e) {
console.error("Reverse Geocode Error->", e);
address.pos = {
lat: this.position.lat,
lng: this.position.lng,
};
}
this.loading = false;
return address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,18 @@
/>
</div>
<v-row v-if="latitude && longitude">
<v-col cols="12">
<p class="text-subtitle-1 mt-5 bg-warning p-2 position-warning">
ATTENZIONE!!! La posizione sarà utilizzata per la validazione dei viaggi
dei dipendenti. Saranno validi solo i viaggi che iniziano o finiscono
all'interno della zona delimitata dal cerchio rosso.
</p>
</v-col>
</v-row>
<v-col cols="12">
<p class="text-subtitle-1 mt-5 bg-warning p-2 position-warning">
<b>ATTENZIONE!</b> La posizione sarà utilizzata per la validazione dei
viaggi dei dipendenti. Saranno validi solo i viaggi che iniziano o
finiscono all'interno della zona delimitata dal cerchio rosso.
</p>
</v-col>
</v-row>
</v-col>
<v-col cols="4">
<div class="tab-container">
<div v-if="addresIsValid">
<div v-if="addresIsValid && !showErrorLocation && !manualEnabling">
<p>
E’ possibile impostare la posizione della sede manualmente oppure
automaticamente in base all’indirizzo inserito.
Expand Down Expand Up @@ -273,7 +273,7 @@
inserito</i
>
</div>
<div>
<div class="text-center" >
<v-btn
color="primary"
:disabled="!addresIsValid"
Expand All @@ -290,14 +290,18 @@
corrisponda alla reale posizione della sede
</i>
</div>
<div>
<div v-if="!manualEnabling" class="text-center" >
<v-btn
color="primary"
@click="manualPosition()"
:disabled="!addressFormIsValid()"
>Imposta manualmente</v-btn
>
</div>
<div v-if="manualEnabling" class="text-center">
<v-btn color="error" outlined @click="cancelManualPosition()" class="m-2">Annulla</v-btn>
<v-btn color="error" @click="setManualPosition()">Conferma</v-btn>
</div>
</v-tab-item>
</v-tabs-items>
</div>
Expand Down Expand Up @@ -560,15 +564,17 @@ export default {
province: "",
region: "",
latitude: "",
tmpLatitude: "",
longitude: "",
tmpLongitude: "",
country: "",
radius: 200,
nonWorkingDays: [],
nonWorking: [],
arrayDays: [],
datepicker: null,
menu: false,
manualPositionSet: false,
// manualPositionSet: false,
zoom: 13,
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
attribution:
Expand All @@ -581,12 +587,14 @@ export default {
location: {},
selectedPosition: false,
key: 1,
tmpLocationSelected: null,
locationSelected: null,
listaProvince: listaProvince,
listaRegioni: listaRegioni,
listaStati: listaStati,
giorniSettimana: giorniSettimana,
disabled: false,
manualEnabling: false,
};
},
Expand Down Expand Up @@ -645,31 +653,50 @@ export default {
this.addresIsValid = false;
}
}
} else {
this.$refs.geolocationSelector.enableMap();
}
// else {
// this.$refs.geolocationSelector.enableMap();
// }
},
autoPosition() {
if (this.geoResults.length > 0) {
this.$refs.geolocationSelector.onSearch({ location: this.geoResults[0] });
}
},
manualPosition() {
console.log('manual');
this.$refs.geolocationSelector.enableMap();
this.addresIsValid = true;
this.manualPositionSet = true;
// this.manualPositionSet = true;
this.manualEnabling = true;
},
setManualPosition() {
//confirm location
this.locationSelected = this.tmpLocationSelected;
this.latitude = this.tmpLocationSelected?.pos?.lat?this.tmpLocationSelected?.pos?.lat:this.tmpLatitude;
this.longitude = this.tmpLocationSelected?.pos?.lng?this.tmpLocationSelected?.pos?.lng:this.tmpLongitude;
this.manualEnabling = false;
this.$refs.geolocationSelector.disableMap();
},
cancelManualPosition() {
//return to previous position
this.$refs.geolocationSelector.resetPosition(this.latitude,this.longitude )
this.$refs.geolocationSelector.disableMap();
this.manualEnabling = false;
},
locationChanged(input) {
if (this.manualPosition) {
this.locationSelected = input?.address;
this.latitude = this.locationSelected?.pos?.lat;
this.longitude = this.locationSelected?.pos?.lng;
if (
!this.address &&
this.locationSelected &&
this.locationSelected.structuredValue
)
this.changeParamForm(this.locationSelected?.structuredValue);
if (this.manualEnabling) {
//using tmp
this.tmpLocationSelected = input?.address;
this.tmpLatitude = this.locationSelected?.pos?.lat;
this.tmpLongitude = this.locationSelected?.pos?.lng;
// if (
// !this.address &&
// this.locationSelected &&
// this.locationSelected.structuredValue
// )
// this.changeParamForm(this.locationSelected?.structuredValue);
}
},
changeParamForm(structuredValue) {
Expand Down
Loading

0 comments on commit 5e273aa

Please sign in to comment.