Add default showcase selection per warehouse

- Add is_default field to Showcase model with unique constraint per warehouse
- Implement Showcase.save() to ensure only one default per warehouse
- Add SetDefaultShowcaseView for AJAX-based default selection
- Update ShowcaseForm to include is_default checkbox
- Add interactive checkbox UI in showcase list with AJAX functionality
- Update POS API to return showcase.is_default instead of warehouse.is_default
- Update terminal.js to auto-select showcase based on its is_default flag
- Add migration for is_default field

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 11:40:08 +03:00
parent 766ca3c87c
commit dd184265ee
9 changed files with 253 additions and 15 deletions

View File

@@ -932,20 +932,20 @@ async function loadShowcases() {
if (data.success && data.showcases.length > 0) {
let defaultShowcaseId = null;
data.showcases.forEach(showcase => {
const option = document.createElement('option');
option.value = showcase.id;
option.textContent = `${showcase.name} (${showcase.warehouse_name})`;
select.appendChild(option);
// Запоминаем витрину склада по умолчанию
if (showcase.is_default_warehouse) {
// Запоминаем витрину по умолчанию
if (showcase.is_default) {
defaultShowcaseId = showcase.id;
}
});
// Автовыбор витрины склада по умолчанию
// Автовыбор витрины по умолчанию
if (defaultShowcaseId) {
select.value = defaultShowcaseId;
}