Feature: crud reklame
This commit is contained in:
76
resources/js/data/advertisements/data-advertisements.js
Normal file
76
resources/js/data/advertisements/data-advertisements.js
Normal file
@@ -0,0 +1,76 @@
|
||||
import { Grid } from "gridjs/dist/gridjs.umd.js";
|
||||
import gridjs from "gridjs/dist/gridjs.umd.js";
|
||||
import "gridjs/dist/gridjs.umd.js";
|
||||
import GlobalConfig from "../../global-config.js";
|
||||
import GeneralTable from "../../table-generator.js";
|
||||
|
||||
const dataAdvertisementsColumns = [
|
||||
"No",
|
||||
"Nama Wajib Pajak",
|
||||
"NPWPD",
|
||||
"Jenis Reklame",
|
||||
"Isi Reklame",
|
||||
"Alamat Wajib Pajak",
|
||||
"Lokasi Reklame",
|
||||
"Desa",
|
||||
"Kecamatan",
|
||||
"Panjang",
|
||||
"Lebar",
|
||||
"Sudut Pandang",
|
||||
"Muka",
|
||||
"Luas",
|
||||
"Sudut",
|
||||
"Kontak",
|
||||
{
|
||||
name: "Actions",
|
||||
widht: "120px",
|
||||
formatter: function(cell, row) {
|
||||
const id = row.cells[16].data;
|
||||
const model = "data/advertisements";
|
||||
return gridjs.html(`
|
||||
<div class="d-flex justify-items-end gap-10">
|
||||
<button class="btn btn-yellow me-2 btn-edit"
|
||||
data-id="${id}"
|
||||
data-model="${model}">Update</button>
|
||||
<button class="btn btn-red btn-delete"
|
||||
data-id="${id}">Delete</button>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const table = new GeneralTable(
|
||||
"reklame-data-table",
|
||||
`${GlobalConfig.apiHost}/api/advertisements`,
|
||||
`${GlobalConfig.apiHost}`,
|
||||
dataAdvertisementsColumns
|
||||
);
|
||||
|
||||
table.processData = function (data) {
|
||||
return data.data.map((item) => {
|
||||
return [
|
||||
item.no,
|
||||
item.business_name,
|
||||
item.npwpd,
|
||||
item.advertisement_type,
|
||||
item.advertisement_content,
|
||||
item.business_address,
|
||||
item.advertisement_location,
|
||||
item.village_name,
|
||||
item.district_name,
|
||||
item.length,
|
||||
item.width,
|
||||
item.viewing_angle,
|
||||
item.face,
|
||||
item.area,
|
||||
item.angle,
|
||||
item.contact,
|
||||
item.id,
|
||||
];
|
||||
});
|
||||
};
|
||||
|
||||
table.init();
|
||||
});
|
||||
Reference in New Issue
Block a user