diff --git a/backend/src/main/java/it/smartcommunitylab/pgazienda/service/CompanyService.java b/backend/src/main/java/it/smartcommunitylab/pgazienda/service/CompanyService.java index af4d84f..b8456a7 100644 --- a/backend/src/main/java/it/smartcommunitylab/pgazienda/service/CompanyService.java +++ b/backend/src/main/java/it/smartcommunitylab/pgazienda/service/CompanyService.java @@ -524,30 +524,30 @@ public void importLocations(String companyId, InputStream inputStream) throws Ex int i = 0; List 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(","); @@ -555,12 +555,12 @@ public void importLocations(String companyId, InputStream inputStream) throws Ex 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(","); @@ -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()); diff --git a/console_aziendale/src/components/leaflet-map/GeoLocationSelectorMap.vue b/console_aziendale/src/components/leaflet-map/GeoLocationSelectorMap.vue index 7c9736f..ffd068d 100644 --- a/console_aziendale/src/components/leaflet-map/GeoLocationSelectorMap.vue +++ b/console_aziendale/src/components/leaflet-map/GeoLocationSelectorMap.vue @@ -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(); @@ -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(); }, @@ -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) { @@ -150,20 +160,7 @@ export default { this.$emit('returnGeosearch', results); }, 500) }, - // getStringAddress(structuredValue) { - // var returnAddress = ""; - // if (structuredValue.amenity) returnAddress += "
" + structuredValue.amenity; - // if (structuredValue.office) returnAddress += "
" + structuredValue.office; - // if (structuredValue.road) returnAddress += "
" + structuredValue.road; - // if (structuredValue.house_number) - // returnAddress += ", " + structuredValue.house_number; - // if (structuredValue.city) returnAddress += "
" + structuredValue.city; - // if (structuredValue.country) returnAddress += "
" + structuredValue.country; - // if (structuredValue.postcode) returnAddress += "
" + structuredValue.postcode; - // if (structuredValue.state) returnAddress += "
" + structuredValue.state; - // if (structuredValue.county) returnAddress += "
" + structuredValue.county; - // return returnAddress; - // }, + async getAddress() { this.loading = true; let address = { @@ -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; diff --git a/console_aziendale/src/components/modal/specific-modals/LocationFormModal.vue b/console_aziendale/src/components/modal/specific-modals/LocationFormModal.vue index e84b61a..3f38f4a 100644 --- a/console_aziendale/src/components/modal/specific-modals/LocationFormModal.vue +++ b/console_aziendale/src/components/modal/specific-modals/LocationFormModal.vue @@ -229,18 +229,18 @@ /> - -

- 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. -

-
-
+ +

+ 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. +

+
+
-
+

E’ possibile impostare la posizione della sede manualmente oppure automaticamente in base all’indirizzo inserito. @@ -273,7 +273,7 @@ inserito

-
+
-
+
Imposta manualmente
+
+ Annulla + Conferma +
@@ -560,7 +564,9 @@ export default { province: "", region: "", latitude: "", + tmpLatitude: "", longitude: "", + tmpLongitude: "", country: "", radius: 200, nonWorkingDays: [], @@ -568,7 +574,7 @@ export default { arrayDays: [], datepicker: null, menu: false, - manualPositionSet: false, + // manualPositionSet: false, zoom: 13, url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", attribution: @@ -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, }; }, @@ -645,9 +653,10 @@ export default { this.addresIsValid = false; } } - } else { - this.$refs.geolocationSelector.enableMap(); } + // else { + // this.$refs.geolocationSelector.enableMap(); + // } }, autoPosition() { if (this.geoResults.length > 0) { @@ -655,21 +664,39 @@ export default { } }, 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) { diff --git a/console_aziendale/src/pages/employees/Employees.vue b/console_aziendale/src/pages/employees/Employees.vue index 0f963cd..256f011 100644 --- a/console_aziendale/src/pages/employees/Employees.vue +++ b/console_aziendale/src/pages/employees/Employees.vue @@ -7,7 +7,7 @@ color="secondary" rounded elevation="6" - @click="openModal({type:'employeeFormAdd', object:null})" + @click="openModal({ type: 'employeeFormAdd', object: null })" class="mr-4" > mdi-plus @@ -18,7 +18,7 @@ color="secondary" rounded elevation="6" - @click="openModal({type:'employeeImport', object:null})" + @click="openModal({ type: 'employeeImport', object: null })" > mdi-file-import Aggiungi da file @@ -40,7 +40,6 @@
Non ci sono Dipendenti
-
@@ -52,14 +51,21 @@ import ProfiloEmployee from "./Employee.vue"; import GenericTable from "@/components/data-table/GenericTable.vue"; export default { - components: { ProfiloEmployee, GenericTable }, + components: { ProfiloEmployee, GenericTable }, name: "Dipendenti", data: function () { return { tableTitle: "Dipendenti", - headerColumns: [{text:"Nome", value:"name"}, {text:"Cognome", value:"surname"}, {text:"Sede", value:"location"}, {text:"Codice dipendente", value:"code"}, {text: 'Bloccato', value: 'blockedStr'}, {text: 'Iscrizioni', value: "employeeCampaigns"}], + headerColumns: [ + { text: "Nome", value: "name" }, + { text: "Cognome", value: "surname" }, + { text: "Codice Sede", value: "location" }, + { text: "Codice dipendente", value: "code" }, + { text: "Bloccato", value: "blockedStr" }, + { text: "Iscrizioni", value: "employeeCampaigns" }, + ], editModalVisible: false, deleteModalVisible: false, currentEmployeeSelected: undefined, @@ -76,9 +82,9 @@ export default { inDragArea: false, }; }, - + methods: { - ...mapActions("modal", {openModal: 'openModal'}), + ...mapActions("modal", { openModal: "openModal" }), ...mapActions("employee", { getAllEmployees: "getAll", addEmployeeCall: "addEmployee", @@ -89,7 +95,8 @@ export default { }), ...mapActions("navigation", { changePage: "changePage" }), ...mapActions("campaign", { - getAllCampaigns: "getAll"}), + getAllCampaigns: "getAll", + }), showModal(title) { this.editModalVisible = true; this.newEmployee = true; @@ -105,7 +112,7 @@ export default { this.deleteModalVisible = false; }, closeImportModal() { - this.modalImportEmployeesOpen = false + this.modalImportEmployeesOpen = false; this.$v.$reset(); }, copyFormValues() { @@ -120,7 +127,7 @@ export default { employeeId: this.actualEmployee.item.id, }); }, - + showEmployeeInfo(employee) { if (this.currentEmployeeSelected == employee) { this.getEmployee(null); @@ -132,23 +139,36 @@ export default { } }, updateEmployeeCampaigns() { - if (this.allEmployees && this.allEmployees.items && this.allCampaigns && this.allCampaigns.items) { - let empList = this.allEmployees.items.slice(); - empList.forEach(e => { - let list = (e.campaigns || []).concat(e.trackingRecord ? Object.keys(e.trackingRecord) : []); - const arr = Array.from(new Set(list)).map(cId => { - let tr = e.trackingRecord && e.trackingRecord[cId] ? e.trackingRecord[cId] : {registration: new Date().getTime()} - tr.id = cId; - tr.title = (this.allCampaigns.items.find(c => c.id === cId) || {title: cId}).title; - return tr; - }).map(c => c.title) - arr.sort(); - e.employeeCampaigns = arr.join(', '); - e.blockedStr = e.blocked ? 'Si' : 'No' - }); - this.employees = empList; - } - + if ( + this.allEmployees && + this.allEmployees.items && + this.allCampaigns && + this.allCampaigns.items + ) { + let empList = this.allEmployees.items.slice(); + empList.forEach((e) => { + let list = (e.campaigns || []).concat( + e.trackingRecord ? Object.keys(e.trackingRecord) : [] + ); + const arr = Array.from(new Set(list)) + .map((cId) => { + let tr = + e.trackingRecord && e.trackingRecord[cId] + ? e.trackingRecord[cId] + : { registration: new Date().getTime() }; + tr.id = cId; + tr.title = ( + this.allCampaigns.items.find((c) => c.id === cId) || { title: cId } + ).title; + return tr; + }) + .map((c) => c.title); + arr.sort(); + e.employeeCampaigns = arr.join(", "); + e.blockedStr = e.blocked ? "Si" : "No"; + }); + this.employees = empList; + } }, // onFileUploaderChange() { // console.log(this.$refs["file"]); @@ -162,21 +182,21 @@ export default { // this.importData({ companyId: this.actualCompany.item.id, file: formData }); // }, }, - + computed: { ...mapState("employee", ["allEmployees", "actualEmployee"]), ...mapState("company", ["actualCompany"]), - ...mapState("campaign", ["allCampaigns"]), + ...mapState("campaign", ["allCampaigns"]), // fileName() { // return this.fileUploaded.item(0).name; // }, - nColsTable_calculator: function() { - if(this.actualEmployee){ + nColsTable_calculator: function () { + if (this.actualEmployee) { return 8; - }else if(this.actualEmployee == null){ + } else if (this.actualEmployee == null) { return 12; - }else{ + } else { return 12; } }, @@ -190,12 +210,12 @@ export default { }, watch: { allEmployees() { - this.updateEmployeeCampaigns(); + this.updateEmployeeCampaigns(); }, allCampaigns() { - this.updateEmployeeCampaigns(); - } - } + this.updateEmployeeCampaigns(); + }, + }, }; diff --git a/console_aziendale/src/pages/locations/Location.vue b/console_aziendale/src/pages/locations/Location.vue index 1ff7e7c..45b7ac6 100644 --- a/console_aziendale/src/pages/locations/Location.vue +++ b/console_aziendale/src/pages/locations/Location.vue @@ -127,18 +127,21 @@ export default { initMap() {}, getNonWorking(days) { var returnDays = ""; - if (days) + if (days?.length>0) days.forEach((element) => { returnDays += locationService.getDayByInt(element) + "
"; }); + else returnDays="Nessuno"; return returnDays; }, getNonWorkingDays(days) { + console.log('nn working days') var returnDays = ""; - if (days) + if (days?.length>0) days.forEach((element) => { returnDays += moment(element).format('DD-MM-YYYY') + "
"; }); + else returnDays="Nessuno"; return returnDays; }, }, diff --git a/console_aziendale/src/store/campaign.module.js b/console_aziendale/src/store/campaign.module.js index 4e1e7f7..45158d9 100644 --- a/console_aziendale/src/store/campaign.module.js +++ b/console_aziendale/src/store/campaign.module.js @@ -117,7 +117,7 @@ const actions = { campaignService.updateCampaign(companyId, campaign).then( () => { commit('createCompanyCampaignSuccess', campaign); - dispatch('alert/success', "Campagna cancellata con successo", { root: true }); + dispatch('alert/success', "Campagna associata con successo", { root: true }); }, error => {