Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
micnori committed Nov 7, 2024
2 parents 6b8beca + 5e273aa commit a1dcb41
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -524,43 +524,43 @@ public void importLocations(String companyId, InputStream inputStream) throws Ex
int i = 0;
List<CompanyLocation> locations = new LinkedList<>();
for (String[] l : lines) {
String id = stringValue(l[0], i+2, 0, true);
String id = stringValue(l[0], i+2, 1, true);
CompanyLocation loc = getCompanyLocation(c, id);
if (loc == null) {
loc = new CompanyLocation();
}

loc.setId(id);
loc.setName(stringValue(l[1], i+2, 1, false));
loc.setAddress(stringValue(l[2], i+2, 2, true));
loc.setStreetNumber(stringValue(l[3], i+2, 3, false));
loc.setZip(stringValue(l[4], i+2, 4, true));
loc.setCity(stringValue(l[5], i+2, 5, true));
loc.setProvince(stringValue(l[6], i+2, 6, false));
loc.setRegion(stringValue(l[7], i+2, 7, false));
loc.setCountry(stringValue(l[8], i+2, 8, false));
loc.setName(stringValue(l[1], i+2, 2, false));
loc.setAddress(stringValue(l[2], i+2, 3, true));
loc.setStreetNumber(stringValue(l[3], i+2, 4, false));
loc.setZip(stringValue(l[4], i+2, 5, true));
loc.setCity(stringValue(l[5], i+2, 6, true));
loc.setProvince(stringValue(l[6], i+2, 7, false));
loc.setRegion(stringValue(l[7], i+2, 8, false));
loc.setCountry(stringValue(l[8], i+2, 9, false));

//Double radius = doubeValue(l[9], i+1, 8, false);
//if (radius == null) radius = 200d;
loc.setRadius(200d);
loc.setLatitude(doubeValue(l[9], i+2, 9, true));
loc.setLongitude(doubeValue(l[10], i+2, 10, true));
loc.setLatitude(doubeValue(l[9], i+2, 10, true));
loc.setLongitude(doubeValue(l[10], i+2, 110, true));

// check non-working days
String nwDoW = stringValue(l[11], i + 2, 11, false);
String nwDoW = stringValue(l[11], i + 2, 12, false);
if (nwDoW.length() > 0) {
loc.setNonWorking(new LinkedList<>());
String[] days = nwDoW.toLowerCase().split(",");
for (String d: days) {
if (DW.containsKey(d.trim())) {
loc.getNonWorking().add(DW.get(d.trim()));
} else {
throw new ImportDataException(i + 2, 11);
throw new ImportDataException(i + 2, 12);
}
}
}
// check exception days
String nwDays = stringValue(l[12], i + 2, 12, false);
String nwDays = stringValue(l[12], i + 2, 13, false);
if (nwDays.length() > 0) {
loc.setNonWorkingDays(new HashSet<>());
String[] days = nwDays.toLowerCase().split(",");
Expand All @@ -572,7 +572,7 @@ public void importLocations(String companyId, InputStream inputStream) throws Ex
try {
date = LocalDate.parse(d.trim(), dateFormatter );
} catch (Exception e1) {
throw new ImportDataException(i + 2, 11);
throw new ImportDataException(i + 2, 13);
}
}
loc.getNonWorkingDays().add(date.toString());
Expand Down
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 a1dcb41

Please sign in to comment.