Fix entry form date defaults and input overflow.
Wire date fields so Date defaults to today and Next Control tracks +6 months; constrain inputs to the form column width. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -154,6 +154,7 @@ form {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
@@ -163,6 +164,9 @@ label {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input, select {
|
input, select {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
background: rgba(15, 23, 42, 0.5);
|
background: rgba(15, 23, 42, 0.5);
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
|
|||||||
@@ -1,21 +1,29 @@
|
|||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const productSelect = document.getElementById('product');
|
const productSelect = document.getElementById('product');
|
||||||
|
const dateInput = document.getElementById('prod-date');
|
||||||
|
const nextControlInput = document.getElementById('next-control');
|
||||||
const totalWeightInput = document.getElementById('total-weight');
|
const totalWeightInput = document.getElementById('total-weight');
|
||||||
const canisterWeightInput = document.getElementById('canister-weight');
|
const canisterWeightInput = document.getElementById('canister-weight');
|
||||||
const canistersPerBoxInput = document.getElementById('canisters-per-box');
|
const canistersPerBoxInput = document.getElementById('canisters-per-box');
|
||||||
const previewDisplay = document.getElementById('preview-display');
|
const previewDisplay = document.getElementById('preview-display');
|
||||||
const form = document.getElementById('order-form');
|
const form = document.getElementById('order-form');
|
||||||
|
|
||||||
// Default dates
|
// Default dates (local calendar — valueAsDate is UTC and shifts in +0330)
|
||||||
const today = new Date();
|
function localYmd(d) {
|
||||||
dateInput.valueAsDate = today;
|
const y = d.getFullYear();
|
||||||
|
const m = String(d.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(d.getDate()).padStart(2, '0');
|
||||||
|
return `${y}-${m}-${day}`;
|
||||||
|
}
|
||||||
|
dateInput.value = localYmd(new Date());
|
||||||
|
|
||||||
// Auto calculate +6 months
|
// Auto calculate +6 months
|
||||||
function updateNextControl() {
|
function updateNextControl() {
|
||||||
const d = new Date(dateInput.value);
|
const [y, m, day] = (dateInput.value || '').split('-').map(Number);
|
||||||
if (isNaN(d)) return;
|
if (!y) return;
|
||||||
|
const d = new Date(y, m - 1, day);
|
||||||
d.setMonth(d.getMonth() + 6);
|
d.setMonth(d.getMonth() + 6);
|
||||||
nextControlInput.valueAsDate = d;
|
nextControlInput.value = localYmd(d);
|
||||||
}
|
}
|
||||||
updateNextControl();
|
updateNextControl();
|
||||||
dateInput.addEventListener('change', updateNextControl);
|
dateInput.addEventListener('change', updateNextControl);
|
||||||
@@ -74,7 +82,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
showToast(currentLang === 'fa' ? 'سفارش به صف چاپ اضافه شد' : 'Order added to print queue!');
|
showToast(currentLang === 'fa' ? 'سفارش به صف چاپ اضافه شد' : 'Order added to print queue!');
|
||||||
form.reset();
|
form.reset();
|
||||||
dateInput.valueAsDate = today;
|
dateInput.value = localYmd(new Date());
|
||||||
updateNextControl();
|
updateNextControl();
|
||||||
updatePreview();
|
updatePreview();
|
||||||
setTimeout(() => window.location.reload(), 1000);
|
setTimeout(() => window.location.reload(), 1000);
|
||||||
|
|||||||
Reference in New Issue
Block a user