Features:
- Configuration versioning: immutable snapshots in local_configuration_versions
- Revisions UI: /configs/:uuid/revisions page to view version history
- Clone from version: ability to clone configuration from specific revision
- Project variant deletion: DELETE /api/projects/:uuid endpoint
- Updated CLAUDE.md with new architecture details and endpoints
Architecture updates:
- local_configuration_versions table for immutable snapshots
- Version tracking on each configuration save
- Rollback capability to previous versions
- Variant deletion with main variant protection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root cause: Projects with duplicate (code, variant) pairs fail to sync
due to unique constraint on server. Example: multiple "OPS-1934" projects
with variant="Dell" where one already exists on server.
Fixes:
1. Sync service now detects duplicate (code, variant) on server and links
local project to existing server project instead of failing
2. Local repair checks for duplicate (code, variant) pairs and deduplicates
by appending UUID suffix to variant
3. Modal now scrollable with fixed header/footer (max-h-90vh)
This allows users to sync projects that were created offline with
conflicting codes/variants without losing data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements automatic repair mechanism for pending changes with sync errors:
- Projects: validates and fixes empty name/code fields
- Configurations: ensures project references exist or assigns system project
- Clears errors and resets attempts to give changes another sync chance
Backend:
- LocalDB.RepairPendingChanges() with smart validation logic
- POST /api/sync/repair endpoint
- Detailed repair results with remaining errors
Frontend:
- Auto-repair section in sync modal shown when errors exist
- "ИСПРАВИТЬ" button with clear explanation of actions
- Real-time feedback with result messages
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unified export filename format across both ExportCSV and ExportConfigCSV:
- Format: YYYY-MM-DD (project_name) config_name BOM.csv
- Use PriceUpdatedAt if available, otherwise CreatedAt
- Extract project name from ProjectUUID for ExportCSV via projectService
- Pass project_uuid from frontend to backend in export request
- Add projectUUID and projectName state variables to track project context
This ensures consistent naming whether exporting from form or project view,
and uses most recent price update timestamp in filename.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
After the recent refactor that removed CurrentPrice from local_components,
the configurator's autocomplete was filtering out all components because
it checked for the now-removed current_price field.
Instead, now load prices from the API when the user starts typing in a
component search field:
- Added ensurePricesLoaded() to fetch prices via /api/quote/price-levels
- Added componentPricesCache to store loaded prices
- Updated all 3 autocomplete modes (single, multi, section) to load prices
- Changed price checks from c.current_price to hasComponentPrice()
- Updated cart item creation to use cached prices
Components without prices are still filtered out as required, but the check
now uses API data rather than a removed database field.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Solve pagination issue where configs reference projects not in the
paginated list (default 10 items, but there could be 50+ projects).
Changes:
- Add GET /api/projects/all endpoint that returns ALL projects without
pagination as simple {uuid, name} objects
- Update frontend loadProjectsForConfigUI() to use /api/projects/all
instead of /api/projects?status=all
- Ensures all projects are available in projectNameByUUID for config
display, regardless of total project count
This fixes cases where project names don't display in /configs page
for configs that reference projects outside the paginated range.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Fix issue where frontend was ignoring server's Content-Disposition
header and using only config name + '.csv' for exported files.
Added getFilenameFromResponse() helper to extract proper filename
from Content-Disposition header and use it for downloaded files.
Applied to both:
- exportCSV() function
- exportCSVWithCustomPrice() function
Now files are downloaded with correct format:
YYYY-MM-DD (PROJECT-NAME) BOM.csv
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Remove unused stockMappingsCache variable (dead code after selectStockMappingRow removal)
- Move data-description from SVG to button element for reliable access
- Add disabled guard on bulk add/ignore buttons to prevent duplicate requests
- Return explicit error in UpsertIgnoreRule when rule already exists
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix nil pointer dereference in PricingHandler alert methods
- Add automatic MariaDB connection on startup if settings exist
- Update setupRouter to accept mariaDB as parameter
- Fix offline mode checks: use h.db instead of h.alertService
- Update setup handler to show restart required message
- Add warning status support in setup.html UI
This ensures that after saving connection settings, the application
works correctly in online mode after restart. All repositories are
properly initialized with MariaDB connection on startup.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
**Changes:**
1. **Admin menu always visible** (base.html)
- Removed 'hidden' class from "Администратор цен" link
- Menu no longer depends on write permission check
- Users can access pricing/pricelists pages in offline mode
2. **Online status checks for mutations** (admin_pricing.html)
- Added checkOnlineStatus() helper function
- createPricelist() checks online before creating
- deletePricelist() checks online before deleting
- Clear user feedback when operations blocked offline
**User Impact:**
- Admin menu accessible in both online and offline modes
- View-only access to pricelists when offline
- Clear error messages when attempting mutations offline
- Better offline-first UX
Part of Phase 2.5: Full Offline Mode
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixed application freezing in offline mode by preventing unnecessary
reconnection attempts:
**Changes:**
1. **DSN timeouts** (localdb.go)
- Added timeout=3s, readTimeout=3s, writeTimeout=3s to MySQL DSN
- Reduces connection timeout from 75s to 3s when MariaDB unreachable
2. **Fast /api/db-status** (main.go)
- Check connection status before attempting GetDB()
- Avoid reconnection attempts on every status request
- Returns cached offline status instantly
3. **Optimized sync service** (sync/service.go)
- GetStatus() checks connection status before GetDB()
- NeedSync() skips server check if already offline
- Prevents repeated 3s timeouts on every sync info request
4. **Local pricelist fallback** (pricelist.go)
- GetLatest() returns local pricelists when server offline
- UI can now display pricelist version in offline mode
5. **Better UI error messages** (configs.html)
- 404 shows "Не загружен" instead of "Ошибка загрузки"
- Network errors show "Не доступен" in gray
- Distinguishes between missing data and real errors
**Performance:**
- Before: 75s timeout on every offline request
- After: <5ms response time in offline mode
- Cached error state prevents repeated connection attempts
**User Impact:**
- UI no longer freezes when loading pages offline
- Instant page loads and API responses
- Pricelist version displays correctly in offline mode
- Clear visual feedback for offline state
Fixes Phase 2.5 offline mode performance issues.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Added CountErroredChanges() method to count only pending changes with LastError
- Previously, error count included all pending changes, not just failed ones
- Added /api/sync/info endpoint with proper error count and error list
- Added sync info modal to display sync status, error count, and error details
- Made sync status indicators clickable to open the modal
- Fixed disconnect between "Error count: 4" and "No errors" in the list
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Root cause: admin_pricing.html declared 'const showToast' while base.html
already defined 'function showToast', causing SyntaxError that prevented
all JavaScript from executing on the admin pricing page.
Changes:
- Removed duplicate showToast declaration from admin_pricing.html (lines 206-210)
- Removed debug logging added in previous commit
- Kept immediate function calls in base.html to ensure early initialization
This fixes the issue where username and "Администратор цен" link
disappeared when navigating to /admin/pricing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Added immediate calls to checkDbStatus() and checkWritePermission() in base.html
- Calls happen right after function definitions, before DOMContentLoaded
- Added console.log statements to track function execution and API responses
- Removed duplicate calls from admin_pricing.html to avoid conflicts
- This will help diagnose why username and admin link disappear on admin pricing page
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Parse URLSearchParams to detect ?tab=pricelists on page load
- Load tab from URL or default to 'alerts'
- Fixes redirect from /pricelists to /admin/pricing?tab=pricelists
This resolves the critical UX issue where users redirected from
/pricelists would see the 'alerts' tab instead of 'pricelists'.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Pass originalHTML through syncAction function chain
- Simplify finally block by restoring original button innerHTML
- Remove hardcoded button HTML values (5 lines reduction)
- Improve maintainability: button text changes won't break code
- Preserve any custom classes, attributes, or nested elements
This fixes the issue where originalHTML was declared but never used.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>