[Operator] Kelengkapan Laman Konsentrasi
This commit is contained in:
@@ -936,6 +936,27 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
select.value = next === null || next === undefined ? '' : String(next);
|
||||
window.jQuery(select).trigger('change.select2');
|
||||
});
|
||||
|
||||
// Daftar centang bertingkat: pilihan yang bukan milik induk terpilih dibuang (mis. ganti kurikulum)
|
||||
Object.entries(this.form?.checklists ?? {}).forEach(([name, list]) => {
|
||||
const allowed = new Set((list.options[this.formData[list.parent]] ?? []).map(([value]) => Number(value)));
|
||||
const current = Array.isArray(this.formData[name]) ? this.formData[name] : [];
|
||||
const kept = current.filter((value) => allowed.has(Number(value)));
|
||||
if (kept.length !== current.length) this.formData[name] = kept;
|
||||
});
|
||||
},
|
||||
|
||||
// Pilihan daftar centang {name} menurut nilai induknya: [[nilai, label, id pemilik|null, nama pemilik|null], ...]
|
||||
checklist(name) {
|
||||
const list = (this.form?.checklists ?? {})[name];
|
||||
return list ? (list.options[this.formData[list.parent]] ?? []) : [];
|
||||
},
|
||||
|
||||
// Pilihan yang tampil: cocok dengan kata cari dan, bila diminta, hanya yang sudah dicentang
|
||||
checklistShown(name, term, pickedOnly) {
|
||||
const q = String(term ?? '').trim().toLowerCase();
|
||||
const picked = new Set((Array.isArray(this.formData[name]) ? this.formData[name] : []).map(Number));
|
||||
return this.checklist(name).filter(([value, label]) => (q === '' || String(label).toLowerCase().includes(q)) && (!pickedOnly || picked.has(Number(value))));
|
||||
},
|
||||
|
||||
openForm() {
|
||||
|
||||
Reference in New Issue
Block a user