Fix service edit UI
This commit is contained in:
parent
fcaec8921e
commit
2d681ecea1
|
@ -10,8 +10,11 @@ import "leaflet.locatecontrol";
|
|||
styleUrls: ['./map-picker.component.scss']
|
||||
})
|
||||
export class MapPickerComponent implements OnInit {
|
||||
@Input() lat = 45.88283872530;
|
||||
@Input() lng = 10.18226623535;
|
||||
lat = 45.88283872530;
|
||||
lng = 10.18226623535;
|
||||
|
||||
@Input() selectLat = "";
|
||||
@Input() selectLng = "";
|
||||
|
||||
@Output() onMarkerSet = new EventEmitter<any>();
|
||||
|
||||
|
@ -36,7 +39,12 @@ export class MapPickerComponent implements OnInit {
|
|||
this.map = undefined as unknown as Map;
|
||||
}
|
||||
|
||||
ngOnInit(): void { }
|
||||
ngOnInit() {
|
||||
if(this.selectLat !== "" && this.selectLng !== "") {
|
||||
console.log(this.selectLat, this.selectLng);
|
||||
this.setMarker(latLng(parseFloat(this.selectLat), parseFloat(this.selectLng)));
|
||||
}
|
||||
}
|
||||
|
||||
setMarker(latLng: LatLng) {
|
||||
this.onMarkerSet.emit({
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<th>Luogo</th>
|
||||
<th>Note</th>
|
||||
<th>Tipo</th>
|
||||
<th hidden>Modifica</th>
|
||||
<th>Modifica</th>
|
||||
<th>Rimuovi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -86,7 +86,7 @@
|
|||
</td>
|
||||
<td>{{ row.notes }}</td>
|
||||
<td>{{ row.type }}</td>
|
||||
<td hidden><i class="fa fa-edit"></i></td>
|
||||
<td (click)="editService(row.id)"><i class="fa fa-edit"></i></td>
|
||||
<td (click)="deleteService(row.id)"><i class="fa fa-trash"></i></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -83,6 +83,10 @@ export class TableComponent implements OnInit, OnDestroy {
|
|||
this.router.navigate(['/place-details', lat, lng]);
|
||||
}
|
||||
|
||||
editService(id: number) {
|
||||
this.router.navigate(['/services', id]);
|
||||
}
|
||||
|
||||
deleteService(id: number) {
|
||||
console.log(id);
|
||||
Swal.fire({
|
||||
|
|
|
@ -65,7 +65,8 @@
|
|||
</div>
|
||||
<div [class.is-invalid-div]="!isFieldValid('place')" class="mb-2">
|
||||
<label>Luogo dell'intervento</label>
|
||||
<map-picker (onMarkerSet)="setPlace($event.lat, $event.lng)"></map-picker>
|
||||
<map-picker *ngIf="addingService" (onMarkerSet)="setPlace($event.lat, $event.lng)"></map-picker>
|
||||
<map-picker *ngIf="!addingService && loadedServiceLat !== ''" (onMarkerSet)="setPlace($event.lat, $event.lng)" [selectLat]="loadedServiceLat" [selectLng]="loadedServiceLng"></map-picker>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="notes">Note (es. altre informazioni)</label><br>
|
||||
|
|
|
@ -23,6 +23,8 @@ export class EditServiceComponent implements OnInit {
|
|||
notes: '',
|
||||
type: ''
|
||||
};
|
||||
loadedServiceLat = "";
|
||||
loadedServiceLng = "";
|
||||
|
||||
users: any[] = [];
|
||||
types: any[] = [];
|
||||
|
@ -73,6 +75,8 @@ export class EditServiceComponent implements OnInit {
|
|||
} else {
|
||||
this.api.get(`services/${this.serviceId}`).then((service) => {
|
||||
this.loadedService = service;
|
||||
this.loadedServiceLat = service.lat;
|
||||
this.loadedServiceLng = service.lng;
|
||||
|
||||
let patch = Object.assign({}, service);
|
||||
patch.start = new Date(parseInt(patch.start));
|
||||
|
|
Loading…
Reference in New Issue