Update Koperasi
This commit is contained in:
+66
-28
@@ -191,9 +191,10 @@ body > .select2-container--open {
|
||||
inline-size: auto !important;
|
||||
}
|
||||
|
||||
/* Tipografi profil Kelompok Tani dan BUMDes */
|
||||
/* Tipografi profil Kelompok Tani, BUMDes, dan Koperasi */
|
||||
.kelompok-tani-page,
|
||||
.bumdes-page {
|
||||
.bumdes-page,
|
||||
.koperasi-profile-page {
|
||||
font-family: var(--bs-body-font-family);
|
||||
font-size: var(--bs-body-font-size);
|
||||
font-weight: var(--bs-body-font-weight);
|
||||
@@ -201,7 +202,8 @@ body > .select2-container--open {
|
||||
}
|
||||
|
||||
.kelompok-tani-page :is(.form-control, .form-select, .form-check-label, .select2-container),
|
||||
.bumdes-page :is(.form-control, .form-select, .form-check-label, .select2-container) {
|
||||
.bumdes-page :is(.form-control, .form-select, .form-check-label, .select2-container),
|
||||
.koperasi-profile-page :is(.form-control, .form-select, .form-check-label, .select2-container) {
|
||||
font-family: var(--bs-body-font-family);
|
||||
}
|
||||
|
||||
@@ -212,10 +214,15 @@ body > .select2-container--open {
|
||||
}
|
||||
|
||||
#bumdes-notifications,
|
||||
.koperasi-profile-page [data-koperasi-section],
|
||||
.bumdes-page #section-kepengurusan {
|
||||
scroll-margin-top: 7rem;
|
||||
}
|
||||
|
||||
.koperasi-profile-page [data-koperasi-section]:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.bumdes-page .pengurus-status-switch-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -294,22 +301,22 @@ body > .select2-container--open {
|
||||
|
||||
.bumdes-row { cursor: pointer; }
|
||||
.bumdes-filter-row { padding-block: 1.5rem; }
|
||||
.bumdes-filter-line { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
|
||||
.bumdes-filter-label { display: flex; align-items: center; font-weight: 500; margin-right: .5rem; white-space: nowrap; }
|
||||
.bumdes-filter-line .form-select,
|
||||
.bumdes-filter-line .btn { min-height: 31px; }
|
||||
.bumdes-filter-line .form-select {
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
|
||||
:is(.bumdes-filter-label, .koperasi-filter-label) { display: flex; align-items: center; font-weight: 500; margin-right: .5rem; white-space: nowrap; }
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .form-select,
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .btn { min-height: 31px; }
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .form-select {
|
||||
background-color: var(--bs-paper-bg);
|
||||
border-color: var(--bs-border-color);
|
||||
border-radius: var(--bs-border-radius);
|
||||
color: var(--bs-body-color);
|
||||
}
|
||||
.bumdes-filter-line .form-select:focus {
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .form-select:focus {
|
||||
border-color: rgba(40, 167, 69, .55);
|
||||
box-shadow: 0 0 0 .2rem rgba(40, 167, 69, .12);
|
||||
}
|
||||
.bumdes-filter-line .btn { white-space: nowrap; }
|
||||
.bumdes-filter-static {
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .btn { white-space: nowrap; }
|
||||
:is(.bumdes-filter-static, .koperasi-filter-static) {
|
||||
display: flex; align-items: center; min-height: 31px;
|
||||
padding: .25rem .75rem; font-size: .8125rem;
|
||||
background-color: var(--bs-paper-bg);
|
||||
@@ -317,19 +324,19 @@ body > .select2-container--open {
|
||||
border-radius: var(--bs-border-radius);
|
||||
color: var(--bs-body-color);
|
||||
}
|
||||
.bumdes-filter-line .input-group-sm { width: 240px; }
|
||||
.bumdes-data-filters > div:not(.bumdes-filter-label) {
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .input-group-sm { width: 240px; }
|
||||
.bumdes-data-filters > div:not(:is(.bumdes-filter-label, .koperasi-filter-label)) {
|
||||
flex: 1 1 11rem;
|
||||
min-inline-size: 0;
|
||||
}
|
||||
.bumdes-data-filters .form-select { text-overflow: ellipsis; }
|
||||
.bumdes-data-filters .input-group-sm { width: 100%; }
|
||||
@media (max-width: 767.98px) {
|
||||
.bumdes-filter-line { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
|
||||
.bumdes-filter-label { margin-right: 0; }
|
||||
.bumdes-filter-line .btn { justify-content: center; width: 100%; }
|
||||
.bumdes-filter-line .input-group-sm { width: 100%; }
|
||||
.bumdes-filter-line .input-group .btn { width: auto; }
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
|
||||
:is(.bumdes-filter-label, .koperasi-filter-label) { margin-right: 0; }
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .btn { justify-content: center; width: 100%; }
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .input-group-sm { width: 100%; }
|
||||
:is(.bumdes-filter-line, .koperasi-filter-line) .input-group .btn { width: auto; }
|
||||
}
|
||||
|
||||
|
||||
@@ -367,7 +374,34 @@ body > .select2-container--open {
|
||||
}
|
||||
}
|
||||
|
||||
/* Tabel dan ringkasan profil BUMDes. */
|
||||
/* Tabel dan ringkasan profil. */
|
||||
.koperasi-filter-row {
|
||||
padding-block: 1.5rem;
|
||||
}
|
||||
|
||||
.koperasi-filter-row .form-select {
|
||||
min-inline-size: 0;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.koperasi-list-table .koperasi-list-identity {
|
||||
min-inline-size: 14rem;
|
||||
max-inline-size: 20rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.koperasi-list-table .koperasi-list-type,
|
||||
.koperasi-list-table .koperasi-list-services,
|
||||
.koperasi-list-table .koperasi-list-documents {
|
||||
min-inline-size: 10rem;
|
||||
max-inline-size: 16rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.koperasi-list-table [data-koperasi-row] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bumdes-list-table .bumdes-list-identity {
|
||||
min-inline-size: 12rem;
|
||||
max-inline-size: 16rem;
|
||||
@@ -384,19 +418,22 @@ body > .select2-container--open {
|
||||
}
|
||||
|
||||
.bumdes-profile-summary .bumdes-summary-content,
|
||||
.kelompok-profile-summary .kelompok-summary-content {
|
||||
.kelompok-profile-summary .kelompok-summary-content,
|
||||
.koperasi-profile-summary .koperasi-summary-content {
|
||||
min-inline-size: 0;
|
||||
}
|
||||
|
||||
.bumdes-profile-summary .bumdes-summary-label,
|
||||
.kelompok-profile-summary .kelompok-summary-label {
|
||||
.kelompok-profile-summary .kelompok-summary-label,
|
||||
.koperasi-profile-summary .koperasi-summary-label {
|
||||
color: var(--bs-secondary-color);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.bumdes-profile-summary .badge,
|
||||
.kelompok-profile-summary .badge {
|
||||
.kelompok-profile-summary .badge,
|
||||
.koperasi-profile-summary .badge {
|
||||
max-inline-size: 100%;
|
||||
line-height: 1.45;
|
||||
white-space: normal;
|
||||
@@ -405,18 +442,19 @@ body > .select2-container--open {
|
||||
}
|
||||
|
||||
.bumdes-profile-summary .bumdes-summary-more,
|
||||
.kelompok-profile-summary .kelompok-summary-more {
|
||||
.kelompok-profile-summary .kelompok-summary-more,
|
||||
.koperasi-profile-summary .koperasi-summary-more {
|
||||
min-block-size: 1.5rem;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
/* Daftar kelompok tani. */
|
||||
@media (min-width: 768px) {
|
||||
.kelompok-tani-page .nav-pills-custom-spacing { display: flex; width: 100%; gap: .5rem; flex-wrap: nowrap !important; overflow-x: auto; }
|
||||
.kelompok-tani-page .nav-pills-custom-spacing::-webkit-scrollbar { display: none; }
|
||||
.kelompok-tani-page .nav-pills-custom-spacing .nav-item { margin-right: 0 !important; flex: 1; }
|
||||
.kelompok-tani-page .nav-pills-custom-spacing .nav-link { display: flex; justify-content: center; align-items: center; padding-left: .5rem !important; padding-right: .5rem !important; width: 100%; white-space: nowrap; font-size: var(--bs-body-font-size) !important; }
|
||||
.kelompok-tani-page .nav-pills-custom-spacing .nav-link i { margin-right: .4rem !important; }
|
||||
:is(.kelompok-tani-page, .koperasi-profile-page) .nav-pills-custom-spacing { display: flex; width: 100%; gap: .5rem; flex-wrap: nowrap !important; overflow-x: auto; }
|
||||
:is(.kelompok-tani-page, .koperasi-profile-page) .nav-pills-custom-spacing::-webkit-scrollbar { display: none; }
|
||||
:is(.kelompok-tani-page, .koperasi-profile-page) .nav-pills-custom-spacing .nav-item { margin-right: 0 !important; flex: 1; }
|
||||
:is(.kelompok-tani-page, .koperasi-profile-page) .nav-pills-custom-spacing .nav-link { display: flex; justify-content: center; align-items: center; padding-left: .5rem !important; padding-right: .5rem !important; width: 100%; white-space: nowrap; font-size: var(--bs-body-font-size) !important; }
|
||||
:is(.kelompok-tani-page, .koperasi-profile-page) .nav-pills-custom-spacing .nav-link i { margin-right: .4rem !important; }
|
||||
}
|
||||
.kelompok-tani-row { cursor: pointer; }
|
||||
.kelompok-filter-row { padding-block: 1.5rem; }
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const page = document.querySelector('.koperasi-list-page');
|
||||
if (!page) return;
|
||||
|
||||
page.querySelector('#koperasi-per-page').addEventListener('change', event => event.target.form.requestSubmit());
|
||||
|
||||
page.querySelectorAll('[data-koperasi-row]').forEach(row => {
|
||||
row.addEventListener('click', event => {
|
||||
if (event.target.closest('a, button, input, select, textarea, label, form')) return;
|
||||
window.location.href = row.querySelector('.edit-record').href;
|
||||
});
|
||||
});
|
||||
|
||||
page.querySelectorAll('[data-koperasi-delete]').forEach(form => {
|
||||
form.addEventListener('submit', event => {
|
||||
event.preventDefault();
|
||||
Swal.fire({
|
||||
title: 'Hapus koperasi?',
|
||||
text: `Data koperasi "${form.dataset.nama}" akan dihapus.`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Ya, hapus',
|
||||
cancelButtonText: 'Batal',
|
||||
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
|
||||
buttonsStyling: false
|
||||
}).then(result => {
|
||||
if (result.isConfirmed) form.submit();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.querySelectorAll('[data-koperasi-wilayah], #koperasi-filter-form').forEach(container => {
|
||||
const levels = ['provinsi', 'kabupaten', 'kecamatan', 'desa']
|
||||
.map(name => ({ name, input: container.querySelector(`[data-wilayah-${name}]`) }))
|
||||
.filter(level => level.input);
|
||||
const controllers = new Map();
|
||||
const updateRequired = () => {
|
||||
if (!container.matches('[data-koperasi-wilayah]')) return;
|
||||
const hasSelection = levels.some(level => level.input.value);
|
||||
levels.forEach(level => { level.input.required = hasSelection; });
|
||||
};
|
||||
const reset = level => {
|
||||
controllers.get(level.name)?.abort();
|
||||
level.input.replaceChildren(new Option(level.input.options[0].textContent, ''));
|
||||
level.input.disabled = true;
|
||||
};
|
||||
levels.forEach((level, index) => {
|
||||
if (index === levels.length - 1) return;
|
||||
level.input.addEventListener('change', async () => {
|
||||
levels.slice(index + 1).forEach(reset);
|
||||
updateRequired();
|
||||
if (!level.input.value) return;
|
||||
const child = levels[index + 1];
|
||||
const controller = new AbortController();
|
||||
controllers.set(child.name, controller);
|
||||
const url = new URL(container.dataset[`${child.name}Url`].replace(':id', encodeURIComponent(level.input.value)), window.location.href);
|
||||
url.searchParams.set('all_wilayah', '1');
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
signal: controller.signal,
|
||||
headers: { 'Accept': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || '' }
|
||||
});
|
||||
if (!response.ok) throw new Error('Wilayah gagal dimuat');
|
||||
const options = await response.json();
|
||||
if (controller.signal.aborted) return;
|
||||
options.forEach(option => child.input.add(new Option(option.nama, option.id)));
|
||||
child.input.disabled = false;
|
||||
updateRequired();
|
||||
} catch (error) {
|
||||
if (error.name === 'AbortError') return;
|
||||
child.input.add(new Option('Gagal memuat wilayah, pilih ulang wilayah induk', '', false, true));
|
||||
}
|
||||
});
|
||||
});
|
||||
updateRequired();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,119 @@
|
||||
'use strict';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const page = document.querySelector('.koperasi-profile-page');
|
||||
if (!page) return;
|
||||
|
||||
page.querySelectorAll('[data-koperasi-locked-tab]').forEach(tab => {
|
||||
tab.addEventListener('click', event => event.preventDefault());
|
||||
});
|
||||
|
||||
page.querySelectorAll('[data-koperasi-survey]').forEach(operasional => {
|
||||
const fields = Array.from(operasional.querySelectorAll('[data-koperasi-survey-field]'));
|
||||
const conditions = new Map(fields.map(wrapper => [wrapper.dataset.koperasiSurveyField, JSON.parse(wrapper.dataset.koperasiConditions)]));
|
||||
const context = JSON.parse(operasional.dataset.koperasiContext);
|
||||
const requiredFields = JSON.parse(operasional.dataset.koperasiRequired);
|
||||
const selectedValues = name => Array.from(operasional.elements)
|
||||
.filter(input => input.name === name || input.name === name + '[]')
|
||||
.filter(input => !['checkbox', 'radio'].includes(input.type) || input.checked)
|
||||
.map(input => input.value);
|
||||
const matches = condition => {
|
||||
if (condition.any) return condition.any.some(matches);
|
||||
if (condition.source === 'profile') return condition.values.includes(context[condition.field]);
|
||||
return active(condition.field) && condition.values.some(value => selectedValues(condition.field).includes(value));
|
||||
};
|
||||
const active = field => (conditions.get(field) || []).every(matches);
|
||||
const updateDependencies = () => {
|
||||
fields.forEach(wrapper => {
|
||||
const field = wrapper.dataset.koperasiSurveyField;
|
||||
const visible = active(field);
|
||||
const required = visible && requiredFields.includes(field);
|
||||
wrapper.classList.toggle('d-none', !visible);
|
||||
wrapper.querySelectorAll('input, select, textarea').forEach(input => {
|
||||
input.disabled = !visible;
|
||||
input.required = required && input.type !== 'checkbox';
|
||||
input.setCustomValidity('');
|
||||
});
|
||||
const checkboxes = wrapper.querySelectorAll('input[type="checkbox"]');
|
||||
if (required && checkboxes.length && !Array.from(checkboxes).some(input => input.checked)) {
|
||||
checkboxes[0].setCustomValidity('Pilih sedikitnya satu pilihan.');
|
||||
}
|
||||
const indicator = wrapper.querySelector('[data-koperasi-required-indicator]');
|
||||
if (indicator) indicator.classList.toggle('d-none', !required);
|
||||
});
|
||||
};
|
||||
operasional.addEventListener('change', event => {
|
||||
const input = event.target;
|
||||
const group = input.closest('[data-koperasi-exclusive]');
|
||||
if (group && input.type === 'checkbox' && input.checked) {
|
||||
group.querySelectorAll('input[type="checkbox"]').forEach(option => {
|
||||
if (option !== input && (input.value === group.dataset.koperasiExclusive || option.value === group.dataset.koperasiExclusive)) {
|
||||
option.checked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
updateDependencies();
|
||||
});
|
||||
updateDependencies();
|
||||
});
|
||||
|
||||
const activeSection = document.getElementById(window.location.hash.slice(1));
|
||||
if (activeSection && page.contains(activeSection) && activeSection.matches('[data-koperasi-section]')) {
|
||||
const showSection = () => {
|
||||
activeSection.scrollIntoView({ behavior: 'instant', block: 'start' });
|
||||
activeSection.focus({ preventScroll: true });
|
||||
};
|
||||
if (document.readyState === 'complete') {
|
||||
requestAnimationFrame(showSection);
|
||||
} else {
|
||||
window.addEventListener('load', () => requestAnimationFrame(showSection), { once: true });
|
||||
}
|
||||
}
|
||||
|
||||
const form = page.querySelector('[data-koperasi-profile]');
|
||||
if (form) {
|
||||
const jenis = form.querySelector('[name="jenis_koperasi"]');
|
||||
const wrapper = form.querySelector('#koperasi-jenis-lainnya-wrapper');
|
||||
const lainnya = form.querySelector('[name="jenis_koperasi_lainnya"]');
|
||||
const toggleJenisLainnya = () => {
|
||||
const isLainnya = jenis.value === form.dataset.jenisLainnya;
|
||||
wrapper.classList.toggle('d-none', !isLainnya);
|
||||
lainnya.disabled = !isLainnya;
|
||||
};
|
||||
jenis.addEventListener('change', toggleJenisLainnya);
|
||||
toggleJenisLainnya();
|
||||
|
||||
const fokus = form.querySelector('[name="fokus_komoditas"]');
|
||||
const detail = form.querySelector('[name="detail_fokus_komoditas"]');
|
||||
const fokusWrapper = form.querySelector('#koperasi-detail-fokus-wrapper');
|
||||
const toggleFokus = () => {
|
||||
const aktif = fokus.value === fokus.dataset.fokusYa;
|
||||
fokusWrapper.classList.toggle('d-none', !aktif);
|
||||
detail.disabled = !aktif;
|
||||
};
|
||||
fokus.addEventListener('change', toggleFokus);
|
||||
toggleFokus();
|
||||
}
|
||||
|
||||
const formatRupiah = value => {
|
||||
const negative = value.trimStart().startsWith('-');
|
||||
const digits = value.replace(/\D/g, '').replace(/^0+(?=\d)/, '');
|
||||
return (negative ? '-' : '') + digits.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
};
|
||||
|
||||
page.querySelectorAll('[data-koperasi-rupiah]').forEach(input => {
|
||||
if (/^-?[\d.]+$/.test(input.value)) input.value = formatRupiah(input.value);
|
||||
input.addEventListener('input', () => {
|
||||
const digitsBefore = input.value.slice(0, input.selectionStart).replace(/\D/g, '').length;
|
||||
input.value = formatRupiah(input.value);
|
||||
let cursor = input.value.startsWith('-') ? 1 : 0;
|
||||
let count = 0;
|
||||
while (cursor < input.value.length && count < digitsBefore) {
|
||||
if (/\d/.test(input.value[cursor])) count++;
|
||||
cursor++;
|
||||
}
|
||||
input.setSelectionRange(cursor, cursor);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user