agper-agen/modules/regulasi.html

74 lines
2.6 KiB
HTML

<div style="text-align: center; font-weight: 600; margin: .8em 0; font-size: 1.1em;">
Daftar Dokumen Regulasi
</div>
<a-button id="newReg" style="margin: 0 2ch;">Entri Regulasi Baru</a-button>
<div style="max-height: calc(83vh - 6em); overflow: auto; margin: 0 0 1em 0; padding: 0 2ch 2ch 2ch;" id="rgWrapper">
<table id="regs" class="bordered selectable">
<colgroup>
<col style="width: 25ch;">
<col style="min-width: 10ch;">
<col style="width: 20ch;">
<col style="width: 19ch;">
</colgroup>
<thead>
<tr>
<th>Nomor/Judul</th>
<th>Abstrak</th>
<th>Diupload Oleh</th>
<th>Pada</th>
</tr>
</thead>
<tbody id="empty">
<tr>
<td colspan="4" style="text-align: center;">Data Kosong</td>
</tr>
</tbody>
<tbody id="rgContent" hidden>
</tbody>
</table>
</div>
<script type="module">
let regulations = [];
async function getRegs()
{
regulations = [];
const regs = await getJson("/api/regs");
if (regs.status != 200) return;
regulations = regs.data;
µ('#empty').prop("hidden",!(regulations.length < 1));
µ('#rgContent').prop("hidden",(regulations.length < 1));
µ('#rgContent').empty();
$.each(regulations,(_,v)=>{
v.timeStamp = v.timeStamp.replace("T"," ")
const ro = moly.newElement("tr");
const jd = moly.newElement("td");
const ab = moly.newElement("td");
const ag = moly.newElement("td");
const ts = moly.newElement("td");
ro.append(jd);
ro.append(ab);
ro.append(ag);
ro.append(ts);
jd.append(v.judul);
ab.append(v.abstrak);
v.uploader = agents.find(a=>a.agentID == v.agentID).name;
ag.append(v.uploader);
ts.append(v.timeStamp);
$(ro).click(async()=>{
const rem = await moly.dialog.show({title: "Lihat Regulasi", content: "/modules/regulasi-view.html", fetching: true, data: v});
if (rem) getRegs();
});
µ('#rgContent').append(ro);
})
}
function µ(selector)
{
if (selector) return $('body>#main>#content').find(selector);
return $('body>#main>#content');
}
µ('#newReg').click(async()=>{
const rg = await moly.dialog.show({title: "Entri Dokumen Regulasi", content:"/modules/regulasi-new.html",fetching: true, data: regulations})
if(rg) getRegs();
});
getRegs();
</script>