Commit 1fe573c2 authored by Andrzej Obracaj's avatar Andrzej Obracaj
Browse files

multi delete

parent 5e3256e3
......@@ -132,20 +132,20 @@ export default {
this.assessmentthresholdexceedances = await AssessmentRegimesService.assessmentthresholdexceedances();
this.assessmentdataAll = await AssessmentRegimesService.assessmentdataAll();
},
async deleteAssessmentRegimes(response) {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await AssessmentRegimesService.delete(row.id);
const activeEditor = hot.getActiveEditor();
activeEditor.autoResize.unObserve = () => {};
hot.alter("remove_row", clickedRow, 1);
}
);
Notify.success("Assessment Regimes deleted!");
}
},
// async deleteAssessmentRegimes(response) {
// if (response) {
// await Notify.loadData(
// "Please wait while data is deleting",
// async () => {
// const rowsAffected = await AssessmentRegimesService.delete(row.id);
// const activeEditor = hot.getActiveEditor();
// activeEditor.autoResize.unObserve = () => {};
// hot.alter("remove_row", clickedRow, 1);
// }
// );
// Notify.success("Assessment Regimes deleted!");
// }
// },
async saveAssessmentRegimes(ra) {
const rowsAffected = await AssessmentRegimesService.update(ra.regime);
......@@ -207,7 +207,6 @@ export default {
},
onNewAssessmentRegimes(t, o) {
// debugger;
const hot = this.$refs.hot.hotInstance;
let row = hot.getSourceDataAtRow(0);
var newRow = Object.assign({}, row);
......
......@@ -73,7 +73,6 @@ export default {
};
},
mounted() {
// // debugger
this.settings.afterSelectionEnd = this.selectRowOnly;
this.settings.dropdownMenu = false;
this.settings.contextMenu = ContextMenu(this);
......@@ -95,20 +94,20 @@ export default {
this.attainments = await AttainmentsService.attainments();
this.assessmentregimes = await AttainmentsService.assessmentregimes();
},
async deleteAttainments(response) {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await AttainmentsService.delete(row.id);
const activeEditor = hot.getActiveEditor();
activeEditor.autoResize.unObserve = () => {};
hot.alter("remove_row", clickedRow, 1);
}
);
Notify.success("Attainments deleted!");
}
},
// async deleteAttainments(response) {
// if (response) {
// await Notify.loadData(
// "Please wait while data is deleting",
// async () => {
// const rowsAffected = await AttainmentsService.delete(row.id);
// const activeEditor = hot.getActiveEditor();
// activeEditor.autoResize.unObserve = () => {};
// hot.alter("remove_row", clickedRow, 1);
// }
// );
// Notify.success("Attainments deleted!");
// }
// },
async saveAttainments(ra) {
const rowsAffected = await AttainmentsService.update(ra);
console.log("SAVED TO DB");
......@@ -165,7 +164,6 @@ export default {
},
onNewAttainments(t, o) {
// debugger;
const hot = this.$refs.hot.hotInstance;
let row = hot.getSourceDataAtRow(0);
var newRow = Object.assign({}, row);
......
......@@ -126,20 +126,20 @@ export default {
this.exceedancereason = await ExceedanceDescriptionsService.exceedancereason();
this.exceedingdataAll = await ExceedanceDescriptionsService.exceedingmethods();
},
async deleteExceedanceDescriptions(response) {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await ExceedanceDescriptionsService.delete(row.id);
const activeEditor = hot.getActiveEditor();
activeEditor.autoResize.unObserve = () => {};
hot.alter("remove_row", clickedRow, 1);
}
);
Notify.success("ExceedanceDescriptions deleted!");
}
},
// async deleteExceedanceDescriptions(response) {
// if (response) {
// await Notify.loadData(
// "Please wait while data is deleting",
// async () => {
// const rowsAffected = await ExceedanceDescriptionsService.delete(row.id);
// const activeEditor = hot.getActiveEditor();
// activeEditor.autoResize.unObserve = () => {};
// hot.alter("remove_row", clickedRow, 1);
// }
// );
// Notify.success("ExceedanceDescriptions deleted!");
// }
// },
async saveExceedanceDescriptions(ed) {
const rowsAffected = await ExceedanceDescriptionsService.update(ed.exceedingdesc);
......@@ -191,7 +191,6 @@ export default {
this.selected = row;
this.isnew = false;
this.edit = true;
var id = row.id;
// this.exceedingMethods.forEach(function(part, index) {
......
......@@ -48,10 +48,8 @@ import { HotTable, HotColumn } from "@handsontable/vue";
import Handsontable from "handsontable";
import NetworksService from "@/helpers/services/management/networks.service";
import LLEdit from "./LLEdit";
import LCsvImport from "@/components/LCsvImport";
import { LInput, LButton } from "@/components/forms";
import Notify from "@/helpers/notify";
import LInfoBox from "@/components/LInfoBox";
......@@ -82,7 +80,7 @@ export default {
};
},
mounted() {
this.settings.afterSelectionEnd = this.selectRowOnly;
//this.settings.afterSelectionEnd = this.selectRowOnly;
this.settings.dropdownMenu = false;
this.settings.contextMenu = ContextMenu(this);
Notify.loadData(null, this.loadInitialData);
......@@ -106,19 +104,19 @@ export default {
this.responsible_authorities = await NetworksService.responsible_authorities();
this.networks = await NetworksService.networks();
},
async deleteNetwork(response) {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await NetworksService.delete(row.id);
const activeEditor = hot.getActiveEditor();
hot.alter("remove_row", clickedRow, 1);
}
);
Notify.success("Network deleted!");
}
},
// async deleteNetwork(response) {
// if (response) {
// await Notify.loadData(
// "Please wait while data is deleting",
// async () => {
// const rowsAffected = await NetworksService.delete(row.id);
// const activeEditor = hot.getActiveEditor();
// hot.alter("remove_row", clickedRow, 1);
// }
// );
// Notify.success("Network deleted!");
// }
// },
async saveNetwork(network) {
const rowsAffected = await NetworksService.update(network);
const current = this.networks.find(n => n.id == network.id);
......@@ -162,24 +160,26 @@ export default {
this.edit = true;
},
onDeleteNetwork(t, o) {
const clickedRow = o[0].start.row;
const endRow = o[0].end.row;
const startRow = o[0].start.row;
const hot = this.$refs.hot.hotInstance;
const physicalIndex = hot.toPhysicalRow(clickedRow);
let row = hot.getSourceDataAtRow(physicalIndex);
Notify.prompt(async response => {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await NetworksService.delete(row.id);
for (let index = startRow; index < endRow+1; index++) {
var row = hot.getDataAtRow(index);
const rowsAffected = await NetworksService.delete(row[0]);
}
const activeEditor = hot.getActiveEditor();
hot.alter("remove_row", clickedRow, 1);
hot.alter('remove_row', startRow, endRow-startRow+1);
Notify.success("Network deleted!");
}
);
}
}, "This will delete all data connected to this Network. <br/><br/>Do you want to continue?");
}, "This will delete all data connected to this Network(s). <br/><br/>Do you want to continue?");
},
async onSaveNetwork(network) {
......
......@@ -21,7 +21,7 @@ const ContextMenu = (instance) => {
callback: instance.onNewNetwork
},
delete: {
name: "<div class='flex'><i class='fas fa-trash-alt text-red-500 mr-1 mt-1'></i><div>Delete network</div></div>",
name: "<div class='flex'><i class='fas fa-trash-alt text-red-500 mr-1 mt-1'></i><div>Delete network(s)</div></div>",
renderer: HandsontableHelper.contextMenuRenderer,
callback: instance.onDeleteNetwork
}
......
<template>
<div class="p-4">
<l-container class="mb-4">
<l-container-title slot="toolbar" text="Observations" icon="network-wired" color="bg-pastel-purple" />
<l-csv-import @on-import="onImportObservations" />
</l-container>
<l-container class="mb-4">
<l-container-title slot="toolbar" text="Observations" icon="network-wired" color="bg-pastel-purple" />
<l-csv-import @on-import="onImportObservations" />
</l-container>
</div>
</template>
<script>
......@@ -18,12 +14,9 @@ import "handsontable/dist/handsontable.full.css";
import { HotTable, HotColumn } from "@handsontable/vue";
import Handsontable from "handsontable";
import ObservationsService from "./observations.service";
import LLEdit from "./LLEdit";
import LCsvImport from "@/components/LCsvImport";
import { LInput, LButton } from "@/components/forms";
import Notify from "@/helpers/notify";
import LInfoBox from "@/components/LInfoBox";
......@@ -49,7 +42,6 @@ export default {
};
},
mounted() {
// debugger;
this.settings.afterSelectionEnd = this.selectRowOnly;
this.settings.dropdownMenu = false;
this.settings.contextMenu = ContextMenu(this);
......@@ -68,26 +60,24 @@ export default {
hot.selectCells([[r, 0, r, hot.countCols() - 1]], false, false);
},
async loadInitialData() {
// debugger;
this.observations = await ObservationsService.observations();
},
async deleteObservations(response) {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await Observations.delete(row.id);
const activeEditor = hot.getActiveEditor();
hot.alter("remove_row", clickedRow, 1);
}
);
Notify.success("Observations deleted!");
}
},
// async deleteObservations(response) {
// if (response) {
// await Notify.loadData(
// "Please wait while data is deleting",
// async () => {
// const rowsAffected = await Observations.delete(row.id);
// const activeEditor = hot.getActiveEditor();
// hot.alter("remove_row", clickedRow, 1);
// }
// );
// Notify.success("Observations deleted!");
// }
// },
async saveObservations(ra) {
const rowsAffected = await ObservationsService.update(ra);
console.log("SAVED TO DB");
// debugger;
const current = this.observations.find(n => n.id == ra.id);
for (var prop in current) {
if (Object.prototype.hasOwnProperty.call(current, prop)) {
......@@ -137,7 +127,6 @@ export default {
},
async onSaveObservations(observations) {
// debugger;
await Notify.loadData(
"Saving changes to Observations " + observations.id,
this.saveObservations,
......@@ -145,10 +134,7 @@ export default {
);
this.selected = {};
}
}
};
</script>
......@@ -95,7 +95,7 @@ export default {
};
},
mounted() {
this.settings.afterSelectionEnd = this.selectRowOnly;
//this.settings.afterSelectionEnd = this.selectRowOnly;
this.settings.dropdownMenu = false;
this.settings.contextMenu = ContextMenu(this);
Notify.loadData(null, this.loadInitialData);
......@@ -123,19 +123,19 @@ export default {
this.processes = await ObservingCapabilitiesService.processes();
this.samples = await ObservingCapabilitiesService.samples();
},
async deleteObservingCapabilities(response) {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await ObservingCapabilitiesService.delete(row.id);
const activeEditor = hot.getActiveEditor();
hot.alter("remove_row", clickedRow, 1);
}
);
Notify.success("Observing Capabilities deleted!");
}
},
// async deleteObservingCapabilities(response) {
// if (response) {
// await Notify.loadData(
// "Please wait while data is deleting",
// async () => {
// const rowsAffected = await ObservingCapabilitiesService.delete(row.id);
// const activeEditor = hot.getActiveEditor();
// hot.alter("remove_row", clickedRow, 1);
// }
// );
// Notify.success("Observing Capabilities deleted!");
// }
// },
async saveObservingCapabilities(ra) {
const rowsAffected = await ObservingCapabilitiesService.update(ra);
console.log("SAVED TO DB");
......@@ -184,26 +184,26 @@ export default {
this.edit = true;
},
onDeleteObservingCapabilities(t, o) {
const clickedRow = o[0].start.row;
const endRow = o[0].end.row;
const startRow = o[0].start.row;
const hot = this.$refs.hot.hotInstance;
const physicalIndex = hot.toPhysicalRow(clickedRow);
let row = hot.getSourceDataAtRow(physicalIndex);
Notify.prompt(async response => {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await ObservingCapabilitiesService.delete(
row.id
);
for (let index = startRow; index < endRow+1; index++) {
var row = hot.getDataAtRow(index);
const rowsAffected = await ObservingCapabilitiesService.delete(row[0]);
}
const activeEditor = hot.getActiveEditor();
hot.alter("remove_row", clickedRow, 1);
hot.alter('remove_row', startRow, endRow-startRow+1);
}
);
Notify.success("Observing Capabilities deleted!");
}
}, "This will delete all data connected to this Observing Capability. <br/><br/>Do you want to continue?");
}, "This will delete all data connected to this Observing Capability(ies). <br/><br/>Do you want to continue?");
},
async onSaveObservingCapabilities(observingcapabilities) {
......
......@@ -21,7 +21,7 @@ const ContextMenu = (instance) => {
callback: instance.onNewObservingCapabilities
},
delete: {
name: "<div class='flex'><i class='fas fa-trash-alt text-red-500 mr-1 mt-1'></i><div>Delete row</div></div>",
name: "<div class='flex'><i class='fas fa-trash-alt text-red-500 mr-1 mt-1'></i><div>Delete row(s)</div></div>",
renderer: HandsontableHelper.contextMenuRenderer,
callback: instance.onDeleteObservingCapabilities
}
......
......@@ -64,12 +64,9 @@ import "handsontable/dist/handsontable.full.css";
import { HotTable, HotColumn } from "@handsontable/vue";
import Handsontable from "handsontable";
import ProcessesService from "./processes.service";
import LLEdit from "./LLEdit";
import LCsvImport from "@/components/LCsvImport";
import { LInput, LButton } from "@/components/forms";
import Notify from "@/helpers/notify";
import LInfoBox from "@/components/LInfoBox";
......@@ -103,7 +100,7 @@ export default {
};
},
mounted() {
this.settings.afterSelectionEnd = this.selectRowOnly;
//this.settings.afterSelectionEnd = this.selectRowOnly;
this.settings.dropdownMenu = false;
this.settings.contextMenu = ContextMenu(this);
Notify.loadData(null, this.loadInitialData);
......@@ -129,25 +126,23 @@ export default {
this.concentrations = await ProcessesService.concentrations();
this.times = await ProcessesService.times();
this.responsibleauthorities = await ProcessesService.responsibleauthorities();
// debugger;
},
async deleteProcesses(response) {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await Processes.delete(row.id);
const activeEditor = hot.getActiveEditor();
hot.alter("remove_row", clickedRow, 1);
}
);
Notify.success("Processes deleted!");
}
},
// async deleteProcesses(response) {
// if (response) {
// await Notify.loadData(
// "Please wait while data is deleting",
// async () => {
// const rowsAffected = await Processes.delete(row.id);
// const activeEditor = hot.getActiveEditor();
// hot.alter("remove_row", clickedRow, 1);
// }
// );
// Notify.success("Processes deleted!");
// }
// },
async saveProcesses(ra) {
const rowsAffected = await ProcessesService.update(ra);
console.log("SAVED TO DB");
// debugger;
const current = this.processes.find(n => n.id == ra.id);
for (var prop in current) {
if (Object.prototype.hasOwnProperty.call(current, prop)) {
......@@ -189,28 +184,29 @@ export default {
this.edit = true;
},
onDeleteProcesses(t, o) {
const clickedRow = o[0].start.row;
const endRow = o[0].end.row;
const startRow = o[0].start.row;
const hot = this.$refs.hot.hotInstance;
const physicalIndex = hot.toPhysicalRow(clickedRow);
let row = hot.getSourceDataAtRow(physicalIndex);
Notify.prompt(async response => {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await ProcessesService.delete(row.id);
for (let index = startRow; index < endRow+1; index++) {
var row = hot.getDataAtRow(index);
const rowsAffected = await ProcessesService.delete(row[0]);
}
const activeEditor = hot.getActiveEditor();
hot.alter("remove_row", clickedRow, 1);
hot.alter('remove_row', startRow, endRow-startRow+1);
}
);
Notify.success("Processes deleted!");
}
}, "This will delete all data connected to this Process. <br/><br/>Do you want to continue?");
}, "This will delete all data connected to this Process(es). <br/><br/>Do you want to continue?");
},
async onSaveProcesses(processes) {
// debugger;
await Notify.loadData(
"Saving changes to Processes " + processes.id,
this.saveProcesses,
......
......@@ -21,7 +21,7 @@ const ContextMenu = (instance) => {
callback: instance.onNewProcesses
},
delete: {
name: "<div class='flex'><i class='fas fa-trash-alt text-red-500 mr-1 mt-1'></i><div>Delete row</div></div>",
name: "<div class='flex'><i class='fas fa-trash-alt text-red-500 mr-1 mt-1'></i><div>Delete row(s)</div></div>",
renderer: HandsontableHelper.contextMenuRenderer,
callback: instance.onDeleteProcesses
}
......
......@@ -74,7 +74,7 @@ export default {
};
},
mounted() {
this.settings.afterSelectionEnd = this.selectRowOnly;
//this.settings.afterSelectionEnd = this.selectRowOnly;
this.settings.dropdownMenu = false;
this.settings.contextMenu = ContextMenu(this);
Notify.loadData(null, this.loadInitialData);
......@@ -94,19 +94,19 @@ export default {
async loadInitialData() {
this.responsibleAuthorities = await ResponsibleAuthoritiesService.responsibleAuthorities();
},
async deleteResponsibleAuthorities(response) {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {
const rowsAffected = await ResponsibleAuthorities.delete(row.id);
const activeEditor = hot.getActiveEditor();
hot.alter("remove_row", clickedRow, 1);
}
);
Notify.success("Responsible Authorities deleted!");
}
},
// async deleteResponsibleAuthorities(response) {
// if (response) {
// await Notify.loadData(
// "Please wait while data is deleting",
// async () => {
// const rowsAffected = await ResponsibleAuthorities.delete(row.id);
// const activeEditor = hot.getActiveEditor();
// hot.alter("remove_row", clickedRow, 1);
// }
// );
// Notify.success("Responsible Authorities deleted!");
// }
// },
async saveResponsibleAuthorities(ra) {
const rowsAffected = await ResponsibleAuthoritiesService.update(ra);
console.log("SAVED TO DB");
......@@ -154,26 +154,26 @@ export default {
this.edit = true;
},
onDeleteResponsibleAuthorities(t, o) {
const clickedRow = o[0].start.row;
const endRow = o[0].end.row;
const startRow = o[0].start.row;
const hot = this.$refs.hot.hotInstance;
const physicalIndex = hot.toPhysicalRow(clickedRow);
let row = hot.getSourceDataAtRow(physicalIndex);
Notify.prompt(async response => {
if (response) {
await Notify.loadData(
"Please wait while data is deleting",
async () => {