implementovane ulozenie do backend presuvanie reportov v dashboad
This commit is contained in:
@ -20,7 +20,9 @@ export const backend = {
|
||||
}
|
||||
var form_data = new FormData();
|
||||
Object.keys(data).forEach(key => {
|
||||
form_data.append(key, data[key]);
|
||||
let val = data[key];
|
||||
if (typeof val == 'object') val = JSON.stringify(val);
|
||||
form_data.append(key, val);
|
||||
});
|
||||
xhttp.open('POST', this.endpont + '?action=' + method);
|
||||
//xhttp.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
|
||||
@ -53,7 +55,7 @@ export const backend = {
|
||||
|
||||
update(id, title, description, status, group, priority) {
|
||||
return this.callPromise('update', {
|
||||
id: id,
|
||||
report_id: id,
|
||||
title: title,
|
||||
description: description,
|
||||
status: status,
|
||||
@ -62,11 +64,11 @@ export const backend = {
|
||||
},
|
||||
|
||||
delete(id) {
|
||||
return this.callPromise('delete', {id: id});
|
||||
return this.callPromise('delete', {report_id: id});
|
||||
},
|
||||
|
||||
get(id) {
|
||||
return this.callPromise('get', {id: id});
|
||||
return this.callPromise('get', {report_id: id});
|
||||
},
|
||||
|
||||
getAll() {
|
||||
@ -77,4 +79,12 @@ export const backend = {
|
||||
return this.callPromise('getallgrouped', {});
|
||||
},
|
||||
|
||||
updateOrdnum(ordnums) {
|
||||
return this.callPromise('updateordnum', {ordnums: ordnums});
|
||||
},
|
||||
|
||||
updateStatus(id, status) {
|
||||
return this.callPromise('updatestatus', {report_id: id, status: status});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@ -144,26 +144,73 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
loadData() {
|
||||
backend.getAllGrouped(Array(0,1,2,3)).then((all_grouped) => {
|
||||
backend.getAllGrouped(Array(0, 1, 2, 3)).then((all_grouped) => {
|
||||
this.itemsUncategorized = all_grouped[0];
|
||||
this.itemsWaiting = all_grouped[1];
|
||||
this.itemsInProgress = all_grouped[2];
|
||||
this.itemsDone = all_grouped[3];
|
||||
})
|
||||
});
|
||||
},
|
||||
getDataByStatus(report_status) {
|
||||
let for_reorder = null;
|
||||
switch (report_status) {
|
||||
case 0:
|
||||
for_reorder = this.itemsUncategorized;
|
||||
break;
|
||||
case 1:
|
||||
for_reorder = this.itemsWaiting;
|
||||
break;
|
||||
case 2:
|
||||
for_reorder = this.itemsInProgress;
|
||||
break;
|
||||
case 3:
|
||||
for_reorder = this.itemsDone;
|
||||
break;
|
||||
}
|
||||
return for_reorder;
|
||||
},
|
||||
searchStatusByReportId(report_id) {
|
||||
for (let i = 0; i < this.itemsUncategorized.length; i++) {
|
||||
if (this.itemsUncategorized[i].report_id === report_id) return 0;
|
||||
}
|
||||
for (let i = 0; i < this.itemsWaiting.length; i++) {
|
||||
if (this.itemsWaiting[i].report_id === report_id) return 1;
|
||||
}
|
||||
for (let i = 0; i < this.itemsInProgress.length; i++) {
|
||||
if (this.itemsInProgress[i].report_id === report_id) return 2;
|
||||
}
|
||||
for (let i = 0; i < this.itemsDone.length; i++) {
|
||||
if (this.itemsDone[i].report_id === report_id) return 3;
|
||||
}
|
||||
},
|
||||
onDragChange(event) {
|
||||
// console.log("Presunuté:", event);
|
||||
// Napr. uložiť poradie do API
|
||||
// console.log("onDragChange", event);
|
||||
if (event.added) {
|
||||
console.log("Pridané:", event.added.element);
|
||||
// console.log("Pridané:", event.added.element);
|
||||
let report_id = event.added.element.report_id;
|
||||
let new_reprort_status = this.searchStatusByReportId(report_id);
|
||||
let for_reorder = this.getDataByStatus(new_reprort_status);
|
||||
backend.updateStatus(report_id, new_reprort_status).then(() => {
|
||||
this.updateOrdnum(for_reorder);
|
||||
});
|
||||
}
|
||||
if (event.moved) {
|
||||
console.log("Presunuté:", event.moved.element);
|
||||
// console.log("Presunuté:", event.moved.element);
|
||||
let report_status = event.moved.element.report_status;
|
||||
let for_reorder = this.getDataByStatus(report_status);
|
||||
this.updateOrdnum(for_reorder);
|
||||
}
|
||||
if (event.removed) {
|
||||
console.log("Odstranené:", event.removed.element);
|
||||
// console.log("Odstranené:", event.removed.element);
|
||||
}
|
||||
},
|
||||
updateOrdnum(for_reorder) {
|
||||
let new_ordnums = {};
|
||||
for (let i = 0; i < for_reorder.length; i++) {
|
||||
new_ordnums[for_reorder[i].report_id] = i;
|
||||
}
|
||||
backend.updateOrdnum(new_ordnums);
|
||||
},
|
||||
vypisData() {
|
||||
console.log(this.itemsUncategorized);
|
||||
console.log(this.itemsWaiting);
|
||||
|
||||
Reference in New Issue
Block a user