This commit is contained in:
parent
5ce169a3b2
commit
e3a25ede59
@ -59,7 +59,7 @@ export default defineNuxtComponent({
|
||||
this.apiURL = `${this.apiBaseURL}/locations`;
|
||||
if (input) {
|
||||
await this.getDatabaseLocations(true);
|
||||
let idx = 0;
|
||||
var idx = 0;
|
||||
for (let i = 0; i < this.cmpDatabaseLocations.length; i++) {
|
||||
if (
|
||||
this.databaseLocations[i]['name'].includes(input.name) &&
|
||||
@ -88,11 +88,16 @@ export default defineNuxtComponent({
|
||||
});
|
||||
this.closeModal('add');
|
||||
} else {
|
||||
idx = this.databaseLocations.length + 1;
|
||||
idx = 0;
|
||||
for (let i = 0; i < this.databaseLocations.length; i++) {
|
||||
if (this.databaseLocations[i]['id'] > idx) {
|
||||
idx = this.databaseLocations[i]['id'];
|
||||
}
|
||||
}
|
||||
await $fetch(this.apiURL, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
id: idx,
|
||||
id: idx + 1,
|
||||
name: input.name,
|
||||
country: input.country,
|
||||
longitude: input.longitude,
|
||||
@ -100,7 +105,8 @@ export default defineNuxtComponent({
|
||||
user: this.userId,
|
||||
}),
|
||||
});
|
||||
this.fetchWeatherData(false, idx);
|
||||
await this.addNewLocID(idx + 1);
|
||||
await this.fetchWeatherData(false, idx + 1);
|
||||
this.displayNotification('add', input);
|
||||
this.closeModal('add');
|
||||
}
|
||||
|
@ -49,19 +49,17 @@ export default defineNuxtComponent({
|
||||
await this.removeLocID(input);
|
||||
await delete this.weatherData[input];
|
||||
|
||||
if (this.deleteBootstrapData == true) {
|
||||
await fetch(`${this.apiBaseURL}/locations/${input}`, {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify({
|
||||
id: input,
|
||||
user: this.userId,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then(async (json) => {
|
||||
console.log('Deleted: ' + input);
|
||||
});
|
||||
}
|
||||
|
||||
this.apiURL = '';
|
||||
await this.getDatabaseLocations();
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user