zmiany w logice i endpoitach

This commit is contained in:
Mateusz Gruszczyński
2025-08-28 12:42:57 +02:00
parent d42ce7fcc4
commit 62e40d5aee
8 changed files with 316 additions and 396 deletions

View File

@@ -292,4 +292,15 @@ select.form-select:focus {
border-color: var(--accent-600);
color: var(--text);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 50%, transparent);
}
/* pole edycji ciemne */
.CodeMirror {
background-color: #1e1e1e !important;
color: #e0e0e0 !important;
}
/* kursor */
.CodeMirror-cursor {
border-left: 1px solid #e0e0e0 !important;
}

View File

@@ -1,37 +0,0 @@
(function () {
const opis = document.getElementById('opis');
const opisCount = document.getElementById('opisCount');
if (opis && opisCount) {
const updateCount = () => opisCount.textContent = opis.value.length.toString();
opis.addEventListener('input', updateCount);
updateCount();
}
const iban = document.getElementById('numer_konta');
if (iban) {
iban.addEventListener('input', () => {
const digits = iban.value.replace(/\D/g, '').slice(0, 26);
const chunked = digits.replace(/(.{4})/g, '$1 ').trim();
iban.value = chunked;
});
}
const tel = document.getElementById('numer_telefonu_blik');
if (tel) {
tel.addEventListener('input', () => {
const digits = tel.value.replace(/\D/g, '').slice(0, 9);
const parts = [];
if (digits.length > 0) parts.push(digits.substring(0, 3));
if (digits.length > 3) parts.push(digits.substring(3, 6));
if (digits.length > 6) parts.push(digits.substring(6, 9));
tel.value = parts.join(' ');
});
}
const cel = document.getElementById('cel');
if (cel) {
cel.addEventListener('change', () => {
if (cel.value && Number(cel.value) < 0.01) cel.value = '0.01';
});
}
})();

View File

@@ -3,7 +3,7 @@
const opis = document.getElementById('opis');
const opisCount = document.getElementById('opisCount');
if (opis && opisCount) {
const updateCount = () => opisCount.textContent = opis.value.length.toString();
const updateCount = () => (opisCount.textContent = String(opis.value.length));
opis.addEventListener('input', updateCount);
updateCount();
}
@@ -12,7 +12,7 @@
const iban = document.getElementById('numer_konta');
if (iban) {
iban.addEventListener('input', () => {
const digits = iban.value.replace(/\D/g, '').slice(0, 26); // 26 cyfr po "PL"
const digits = iban.value.replace(/\D/g, '').slice(0, 26); // 26 cyfr po PL
const chunked = digits.replace(/(.{4})/g, '$1 ').trim();
iban.value = chunked;
});
@@ -31,22 +31,25 @@
});
}
// „Ustaw globalne” z data-atrybutów (bez wstrzykiwania wartości w JS)
// „Ustaw globalne” jest tylko w trybie edycji; odpalamy warunkowo
const setGlobalBtn = document.getElementById('ustaw-globalne');
if (setGlobalBtn && iban && tel) {
setGlobalBtn.addEventListener('click', () => {
const gIban = setGlobalBtn.dataset.iban || '';
const gBlik = setGlobalBtn.dataset.blik || '';
if (gIban) {
iban.value = gIban.replace(/\D/g, '').replace(/(.{4})/g, '$1 ').trim();
iban.dispatchEvent(new Event('input'));
}
if (gBlik) {
const d = gBlik.replace(/\D/g, '').slice(0, 9);
const p = [d.slice(0, 3), d.slice(3, 6), d.slice(6, 9)].filter(Boolean).join(' ');
const p = [d.slice(0, 3), d.slice(3, 6), d.slice(6, 9)]
.filter(Boolean)
.join(' ');
tel.value = p;
tel.dispatchEvent(new Event('input'));
}
iban.dispatchEvent(new Event('input'));
tel.dispatchEvent(new Event('input'));
});
}
@@ -57,4 +60,4 @@
if (cel.value && Number(cel.value) < 0.01) cel.value = '0.01';
});
}
})();
})();