parent
17e7778d15
commit
35a9aa40cb
@ -23,8 +23,25 @@
|
|||||||
renderdatatable();
|
renderdatatable();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
table_visible = true;
|
if (trackscache.length > 0) {
|
||||||
|
table_visible = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
window.track__delete_handler = () => {
|
||||||
|
const trackid = parseInt(window.event.target.getAttribute("data-trackid"));
|
||||||
|
// const track = trackscache.find((e) => e.id == trackid);
|
||||||
|
// console.log(track);
|
||||||
|
// -----
|
||||||
|
// TODO: modal or double click confirmation?
|
||||||
|
TrackService.trackControllerRemove(trackid)
|
||||||
|
.then((resp) => {
|
||||||
|
const newStoreVal = trackscache.filter((obj) => obj.id !== trackid);
|
||||||
|
tracksstore.set(newStoreVal);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
function renderdatatable() {
|
function renderdatatable() {
|
||||||
let tabledata = [];
|
let tabledata = [];
|
||||||
trackscache.forEach((track) => {
|
trackscache.forEach((track) => {
|
||||||
@ -34,31 +51,33 @@
|
|||||||
track.minimumLapTime || 0,
|
track.minimumLapTime || 0,
|
||||||
html(`
|
html(`
|
||||||
<button class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gray-400 text-base font-medium text-white sm:w-auto sm:text-sm">Edit</button>
|
<button class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gray-400 text-base font-medium text-white sm:w-auto sm:text-sm">Edit</button>
|
||||||
<button class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-500 text-base font-medium text-white sm:w-auto sm:text-sm">Delete</button>
|
<button class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-500 text-base font-medium text-white sm:w-auto sm:text-sm" data-trackid="${track.id}" onclick="track__delete_handler()">Delete</button>
|
||||||
`),
|
`),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
if (datatable_inited === false) {
|
if (trackscache.length > 0) {
|
||||||
datatable = new Grid({
|
if (datatable_inited === false) {
|
||||||
columns: [
|
datatable = new Grid({
|
||||||
$_("track-name"),
|
columns: [
|
||||||
$_("track-length-in-m"),
|
$_("track-name"),
|
||||||
$_("minimum-lap-time-in-s"),
|
$_("track-length-in-m"),
|
||||||
$_("action"),
|
$_("minimum-lap-time-in-s"),
|
||||||
],
|
$_("action"),
|
||||||
language: getlang($json("datatable")),
|
],
|
||||||
sort: true,
|
language: getlang($json("datatable")),
|
||||||
search: { enabled: true },
|
sort: true,
|
||||||
data: tabledata,
|
search: { enabled: true },
|
||||||
pagination: {
|
data: tabledata,
|
||||||
enabled: true,
|
pagination: {
|
||||||
limit: 25,
|
enabled: true,
|
||||||
summary: false,
|
limit: 25,
|
||||||
},
|
summary: false,
|
||||||
}).render(table);
|
},
|
||||||
datatable_inited = true;
|
}).render(table);
|
||||||
} else {
|
datatable_inited = true;
|
||||||
datatable.updateConfig({ data: tabledata }).forceRender();
|
} else {
|
||||||
|
datatable.updateConfig({ data: tabledata }).forceRender();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let table_visible = false;
|
let table_visible = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user