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 */ // Inital thing const itemList = $('#itemList'); // itemList.empty(); itemList.bootstrapTable({url: "/api/v1/items", search: true, showRefresh: true, responseHandler: dataResponseHandler, sidePagination: 'server', serverSort: true, silentSort: false}) setTimeout(() => { activateTooltips(); }, 1000); function loadPageData() { const itemList = $('#itemList'); // itemList.empty(); itemList.bootstrapTable('refresh') setTimeout(() => { activateTooltips(); }, 1000); } function dataResponseHandler(res) { json = JSON.parse(res); // console.log(json) totalNotFiltered = json.totalNotFiltered; total = json.total; json = json.items; json.forEach((item) => { colorStatus = ''; if(item.SKU == null) item.SKU = 'No SKU assigned'; 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 = `${item.status}`; item.actions = ` ` item.SKU = `

${item.SKU}

` }); ///// --------------------------------- ///// setTimeout(() => { activateTooltips(); }, 200); return {"rows": json, total: total, totalNotFiltered: totalNotFiltered, totalRows: total}; } loadPageData()