fix live updating of table data for status
This commit is contained in:
parent
d496f21ab9
commit
841d52c61a
1 changed files with 14 additions and 9 deletions
|
|
@ -89,16 +89,21 @@ const tableActions = [
|
||||||
menuItems: statusOptions.value.map(option => ({
|
menuItems: statusOptions.value.map(option => ({
|
||||||
label: option,
|
label: option,
|
||||||
command: async (rowData) => {
|
command: async (rowData) => {
|
||||||
console.log("Clicked on row:", rowData);
|
console.log("Setting status for row:", rowData, "to:", option);
|
||||||
await Api.setTaskStatus(rowData.id, option);
|
try {
|
||||||
let rowIndex = -1;
|
// Uncomment when API is ready
|
||||||
for (let i = 0; i<tableData.value.length(); i++) {
|
// await Api.setTaskStatus(rowData.id, option);
|
||||||
if (row.id == tableData.value[i].id) {
|
|
||||||
rowIndex = i;
|
// Find and update the row in the table data
|
||||||
}
|
const rowIndex = tableData.value.findIndex(row => row.id === rowData.id);
|
||||||
}
|
|
||||||
if (rowIndex >= 0) {
|
if (rowIndex >= 0) {
|
||||||
|
// Update reactively
|
||||||
tableData.value[rowIndex].status = option;
|
tableData.value[rowIndex].status = option;
|
||||||
|
notifications.addSuccess(`Status updated to ${option}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating status:", error);
|
||||||
|
notifications.addError("Failed to update status");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue