Add Pattern Templates for Key Colors targets with visual canvas editor

Introduce Pattern Template entity as a reusable rectangle layout that
Key Colors targets reference via pattern_template_id. This replaces
inline rectangle storage with a shared template system.

Backend:
- New PatternTemplate data model, store (JSON persistence), CRUD API
- KC targets now reference pattern_template_id instead of inline rectangles
- ProcessorManager resolves pattern template at KC processing start
- Picture source test endpoint supports capture_duration=0 for single frame
- Delete protection: 409 when template is referenced by a KC target

Frontend:
- Pattern Templates section in Key Colors sub-tab with card UI
- Visual canvas editor with drag-to-move, 8-point resize handles
- Background capture from any picture source for visual alignment
- Precise coordinate list synced bidirectionally with canvas
- Resizable editor container, viewport-constrained modal
- KC target editor uses pattern template dropdown instead of inline rects
- Localization (en/ru) for all new UI elements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 18:07:40 +03:00
parent 5f9bc9a37e
commit 87e7eee743
21 changed files with 1423 additions and 150 deletions

View File

@@ -2706,3 +2706,157 @@ input:-webkit-autofill:focus {
padding: 4px 0;
}
/* Pattern Template Visual Editor */
.modal-content-wide {
max-width: 900px !important;
width: 95% !important;
max-height: calc(100vh - 40px);
display: flex;
flex-direction: column;
}
.modal-content-wide .modal-body {
overflow-y: auto;
flex: 1 1 auto;
min-height: 0;
}
.pattern-canvas-container {
position: relative;
border-radius: 8px;
overflow: hidden;
background: var(--bg-color);
border: 1px solid var(--border-color);
margin-bottom: 12px;
resize: vertical;
min-height: 200px;
height: 450px;
max-height: calc(100vh - 400px);
}
#pattern-canvas {
width: 100%;
height: 100%;
display: block;
cursor: crosshair;
}
.pattern-canvas-toolbar {
display: flex;
gap: 0.5rem;
padding: 8px 0;
align-items: center;
}
.pattern-canvas-toolbar .btn {
flex: 0 0 auto;
min-width: auto;
padding: 6px 12px;
font-size: 0.85rem;
}
.pattern-bg-row {
display: flex;
gap: 0.5rem;
align-items: center;
margin-bottom: 8px;
}
.pattern-bg-row select {
flex: 1;
}
.pattern-capture-btn {
flex: 0 0 auto;
min-width: 36px !important;
width: 36px;
height: 36px;
padding: 0 !important;
font-size: 1.1rem;
line-height: 36px;
text-align: center;
}
.pattern-rect-list {
display: flex;
flex-direction: column;
gap: 6px;
margin-top: 8px;
max-height: 200px;
overflow-y: auto;
}
.pattern-rect-row {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
background: var(--bg-color);
border: 1px solid var(--border-color);
border-radius: 6px;
font-size: 0.85rem;
cursor: pointer;
transition: border-color 0.15s;
}
.pattern-rect-row.selected {
border-color: var(--primary-color);
background: rgba(76, 175, 80, 0.08);
}
.pattern-rect-row input[type="text"] {
flex: 2;
min-width: 0;
padding: 4px 6px;
font-size: 0.8rem;
}
.pattern-rect-row input[type="number"] {
flex: 1;
min-width: 0;
width: 55px;
padding: 4px 6px;
font-size: 0.8rem;
}
.pattern-rect-row .pattern-rect-remove-btn {
background: none;
border: none;
color: #777;
font-size: 0.9rem;
cursor: pointer;
padding: 2px 4px;
border-radius: 4px;
flex-shrink: 0;
transition: color 0.2s, background 0.2s;
}
.pattern-rect-row .pattern-rect-remove-btn:hover {
color: var(--danger-color);
background: rgba(244, 67, 54, 0.1);
}
.pattern-rect-labels {
display: flex;
gap: 6px;
padding: 0 8px;
margin-bottom: 2px;
font-size: 0.7rem;
color: var(--text-secondary);
font-weight: 600;
}
.pattern-rect-labels span:first-child {
flex: 2;
}
.pattern-rect-labels span {
flex: 1;
text-align: center;
}
.pattern-rect-labels span:last-child {
width: 24px;
flex: 0 0 24px;
}