2023-07-08 00:09:54 +02:00
|
|
|
const FLAG_supports_new_data_loader = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Should we ever implement items in items, have a look at this:
|
|
|
|
* https://examples.bootstrap-table.com/index.html?extensions/treegrid.html#extensions/treegrid.html
|
|
|
|
*/
|
|
|
|
|
2023-07-08 00:22:09 +02:00
|
|
|
// Inital thing
|
|
|
|
const itemList = $('#itemList');
|
|
|
|
// itemList.empty();
|
2023-07-08 00:25:33 +02:00
|
|
|
itemList.bootstrapTable({url: "/api/v1/items", search: true, showRefresh: true, responseHandler: dataResponseHandler, sidePagination: 'server', serverSort: true, silentSort: false})
|
2023-07-08 00:22:09 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
activateTooltips();
|
|
|
|
}, 1000);
|
|
|
|
|
2023-07-08 00:09:54 +02:00
|
|
|
function loadPageData() {
|
|
|
|
const itemList = $('#itemList');
|
|
|
|
// itemList.empty();
|
2023-07-08 00:22:09 +02:00
|
|
|
itemList.bootstrapTable('refresh')
|
|
|
|
|
2023-07-08 00:09:54 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
activateTooltips();
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
|
2023-07-09 18:07:28 +02:00
|
|
|
function dataResponseHandler(json) {
|
2023-07-08 00:09:54 +02:00
|
|
|
// console.log(json)
|
|
|
|
totalNotFiltered = json.totalNotFiltered;
|
|
|
|
total = json.total;
|
|
|
|
json = json.items;
|
|
|
|
json.forEach((item) => {
|
|
|
|
colorStatus = '';
|
|
|
|
if(item.SKU == null) item.SKU = '<i>No SKU assigned</i>';
|
|
|
|
switch (item.status) {
|
|
|
|
case 'normal':
|
|
|
|
colorStatus = 'success';
|
|
|
|
break;
|
|
|
|
case 'stolen':
|
|
|
|
colorStatus = 'danger';
|
|
|
|
break;
|
|
|
|
case 'lost':
|
|
|
|
colorStatus = 'warning';
|
|
|
|
break;
|
|
|
|
case 'borrowed':
|
|
|
|
colorStatus = 'info';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
colorStatus = 'secondary';
|
|
|
|
}
|
|
|
|
item.status = `<span class="badge text-bg-${colorStatus}">${item.status}</span>`;
|
|
|
|
item.actions = `
|
|
|
|
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#itemModifyModal" onclick="primeEdit(); getDataForEdit('${item.id}')">
|
|
|
|
<i class="bi bi-pencil"></i>
|
|
|
|
</button>
|
|
|
|
<button class="btn btn-danger" onclick="preFillDeleteModalNxt('${item.id}','items','Item')" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
|
|
|
|
<i class="bi bi-trash"></i>
|
|
|
|
</button>`
|
|
|
|
item.SKU = `<p data-bs-toggle="tooltip" data-bs-placement="left" data-bs-title="ID: ${item.id}">${item.SKU}</p>`
|
|
|
|
});
|
|
|
|
///// --------------------------------- /////
|
2023-07-08 00:45:22 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
activateTooltips();
|
|
|
|
}, 200);
|
2023-07-08 00:09:54 +02:00
|
|
|
return {"rows": json, total: total, totalNotFiltered: totalNotFiltered, totalRows: total};
|
2023-07-08 00:45:22 +02:00
|
|
|
|
2023-07-08 00:09:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
loadPageData()
|