mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-06 06:02:05 +02:00
fix(labels): replace incorrect ams_30x15 preset with correct AMS holder sizes (#1426)
Reporter — the same person who originally requested the labels feature in #809 — discovered that the ams_30x15 preset's 30x15 mm dimension didn't actually fit any variant of the MakerWorld AMS Filament Label Holder (model 752566) it advertised. Two new presets replace it: - ams_holder_74x33 (74 x 33 mm) matches the printable label STL bundled in the MakerWorld project - ams_holder_75x55 (75 x 55 mm) fits the cardstock-insert variant the reporter validated on bench Both cross the 20 mm height threshold so they land in the roomy layout branch — swatch on the left, QR on the right, multi-line text (brand, material, hex code, spool ID) in the middle. The old 30x15 mm preset couldn't fit a QR code; the new ones do. No DB migration: the preset name was never persisted. Callers scripting the old ams_30x15 value get a clean 422 at the route's Literal validator with the new valid values listed. i18n: replaced inventory.labels.templates.ams.{label,hint} with amsHolderSmall and amsHolderLarge across all 8 locales with real translations; parity guard cleaned of the stale English-fallback cognate entries. Parity holds at 4856 leaves per locale. Tests: backend label renderer + integration tests cover both new presets; LabelTemplatePickerModal test updated for the 6-button grid and the new template value in the API-call assertion.
This commit is contained in:
@@ -176,7 +176,13 @@ describe('LabelTemplatePickerModal', () => {
|
||||
spoolmanMode={false}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText(/AMS holder/i).closest('button')).toBeDisabled();
|
||||
// Two AMS holder variants exist (#1426). Both must be disabled when no
|
||||
// spools are selected — the empty-selection guard is global, not per-template.
|
||||
const amsButtons = screen.getAllByText(/AMS holder/i).map((el) => el.closest('button'));
|
||||
expect(amsButtons).toHaveLength(2);
|
||||
for (const btn of amsButtons) {
|
||||
expect(btn).toBeDisabled();
|
||||
}
|
||||
});
|
||||
|
||||
it('sends only the currently checked IDs to the local endpoint', async () => {
|
||||
@@ -218,12 +224,14 @@ describe('LabelTemplatePickerModal', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByText(/AMS holder/i));
|
||||
// Pick the larger AMS holder variant explicitly (#1426: two AMS templates
|
||||
// exist now — pin which one the test sends so the assertion stays meaningful).
|
||||
fireEvent.click(screen.getByText(/AMS holder — large \(75 × 55 mm\)/i));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(api.printSpoolmanSpoolLabels).toHaveBeenCalledWith({
|
||||
spool_ids: [1],
|
||||
template: 'ams_30x15',
|
||||
template: 'ams_holder_75x55',
|
||||
});
|
||||
});
|
||||
expect(api.printSpoolLabels).not.toHaveBeenCalled();
|
||||
@@ -296,9 +304,10 @@ describe('LabelTemplatePickerModal', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
// All five templates must be in the DOM. Use the dimension suffix to
|
||||
// disambiguate the two "Box label …" entries.
|
||||
expect(screen.getByText(/AMS holder/i)).toBeInTheDocument();
|
||||
// All six templates must be in the DOM (#1426 added two AMS variants).
|
||||
// Use the dimension suffix to disambiguate same-family entries.
|
||||
expect(screen.getByText(/AMS holder — small \(74 × 33 mm\)/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/AMS holder — large \(75 × 55 mm\)/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Box label \(40 × 30 mm\)/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Box label \(62 × 29 mm\)/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Avery L7160/i)).toBeInTheDocument();
|
||||
@@ -311,7 +320,7 @@ describe('LabelTemplatePickerModal', () => {
|
||||
const templatesSection = container.querySelector('div.grid.sm\\:grid-cols-2');
|
||||
expect(templatesSection).not.toBeNull();
|
||||
expect(templatesSection!.className).toContain('grid-cols-1');
|
||||
expect(templatesSection!.querySelectorAll('button').length).toBe(5);
|
||||
expect(templatesSection!.querySelectorAll('button').length).toBe(6);
|
||||
|
||||
// Spool list still uses min-h-0 so it can yield further on very tight viewports.
|
||||
const spoolListScroller = container.querySelector('div.flex-1.overflow-y-auto');
|
||||
|
||||
@@ -2415,7 +2415,13 @@ export interface SpoolmanFilamentEntry {
|
||||
|
||||
// Inventory types
|
||||
// Label printing (#809). Mirror of backend.app.services.label_renderer.TemplateName.
|
||||
export type SpoolLabelTemplate = 'ams_30x15' | 'box_40x30' | 'box_62x29' | 'avery_5160' | 'avery_l7160';
|
||||
export type SpoolLabelTemplate =
|
||||
| 'ams_holder_74x33'
|
||||
| 'ams_holder_75x55'
|
||||
| 'box_40x30'
|
||||
| 'box_62x29'
|
||||
| 'avery_5160'
|
||||
| 'avery_l7160';
|
||||
|
||||
export interface InventorySpool {
|
||||
id: number;
|
||||
|
||||
@@ -33,10 +33,16 @@ interface TemplateOption {
|
||||
|
||||
const TEMPLATE_OPTIONS: TemplateOption[] = [
|
||||
{
|
||||
value: 'ams_30x15',
|
||||
i18nKey: 'ams',
|
||||
fallbackLabel: 'AMS holder (30 × 15 mm)',
|
||||
fallbackHint: 'Single label per page; fits the popular AMS filament label holder.',
|
||||
value: 'ams_holder_74x33',
|
||||
i18nKey: 'amsHolderSmall',
|
||||
fallbackLabel: 'AMS holder — small (74 × 33 mm)',
|
||||
fallbackHint: 'Single label per page; matches the printable label from MakerWorld model 752566 (AMS Filament Label Holder).',
|
||||
},
|
||||
{
|
||||
value: 'ams_holder_75x55',
|
||||
i18nKey: 'amsHolderLarge',
|
||||
fallbackLabel: 'AMS holder — large (75 × 55 mm)',
|
||||
fallbackHint: 'Single label per page; fits the cardstock-insert variant of the AMS Filament Label Holder. Roomy enough for swatch, brand, material, ID, and QR code.',
|
||||
},
|
||||
{
|
||||
value: 'box_40x30',
|
||||
|
||||
@@ -3542,9 +3542,13 @@ export default {
|
||||
color: 'Nach Farbe',
|
||||
},
|
||||
templates: {
|
||||
ams: {
|
||||
label: 'AMS holder (30 × 15 mm)',
|
||||
hint: 'Ein Etikett pro Seite; passt in den beliebten AMS-Filament-Etikettenhalter.',
|
||||
amsHolderSmall: {
|
||||
label: 'AMS-Halter — klein (74 × 33 mm)',
|
||||
hint: 'Ein Etikett pro Seite; passt zum druckbaren Etikett aus dem MakerWorld-Modell 752566 (AMS-Filament-Etikettenhalter).',
|
||||
},
|
||||
amsHolderLarge: {
|
||||
label: 'AMS-Halter — groß (75 × 55 mm)',
|
||||
hint: 'Ein Etikett pro Seite; passt zur Kartoneinleger-Variante des AMS-Filament-Etikettenhalters. Genug Platz für Farbprobe, Marke, Material, ID und QR-Code.',
|
||||
},
|
||||
box40x30: {
|
||||
label: 'Boxetikett (40 × 30 mm)',
|
||||
|
||||
@@ -3545,9 +3545,13 @@ export default {
|
||||
color: 'By colour',
|
||||
},
|
||||
templates: {
|
||||
ams: {
|
||||
label: 'AMS holder (30 × 15 mm)',
|
||||
hint: 'Single label per page; fits the popular AMS filament label holder.',
|
||||
amsHolderSmall: {
|
||||
label: 'AMS holder — small (74 × 33 mm)',
|
||||
hint: 'Single label per page; matches the printable label from MakerWorld model 752566 (AMS Filament Label Holder).',
|
||||
},
|
||||
amsHolderLarge: {
|
||||
label: 'AMS holder — large (75 × 55 mm)',
|
||||
hint: 'Single label per page; fits the cardstock-insert variant of the AMS Filament Label Holder. Roomy enough for swatch, brand, material, ID, and QR code.',
|
||||
},
|
||||
box40x30: {
|
||||
label: 'Box label (40 × 30 mm)',
|
||||
|
||||
@@ -3531,9 +3531,13 @@ export default {
|
||||
color: 'Par couleur',
|
||||
},
|
||||
templates: {
|
||||
ams: {
|
||||
label: 'AMS holder (30 × 15 mm)',
|
||||
hint: 'Une étiquette par page ; convient au support d\'étiquettes AMS populaire.',
|
||||
amsHolderSmall: {
|
||||
label: 'Support AMS — petit (74 × 33 mm)',
|
||||
hint: 'Une étiquette par page ; correspond à l\'étiquette imprimable du modèle MakerWorld 752566 (Support d\'étiquettes pour filament AMS).',
|
||||
},
|
||||
amsHolderLarge: {
|
||||
label: 'Support AMS — grand (75 × 55 mm)',
|
||||
hint: 'Une étiquette par page ; s\'adapte à la variante carton du support d\'étiquettes pour filament AMS. Assez d\'espace pour pastille, marque, matériau, ID et QR code.',
|
||||
},
|
||||
box40x30: {
|
||||
label: 'Étiquette boîte (40 × 30 mm)',
|
||||
|
||||
@@ -3530,9 +3530,13 @@ export default {
|
||||
color: 'Per colore',
|
||||
},
|
||||
templates: {
|
||||
ams: {
|
||||
label: 'AMS holder (30 × 15 mm)',
|
||||
hint: 'Una etichetta per pagina; adatta al popolare portaetichette AMS.',
|
||||
amsHolderSmall: {
|
||||
label: 'Supporto AMS — piccolo (74 × 33 mm)',
|
||||
hint: 'Un\'etichetta per pagina; corrisponde all\'etichetta stampabile del modello MakerWorld 752566 (Porta-etichette filamento AMS).',
|
||||
},
|
||||
amsHolderLarge: {
|
||||
label: 'Supporto AMS — grande (75 × 55 mm)',
|
||||
hint: 'Un\'etichetta per pagina; si adatta alla variante cartoncino del porta-etichette filamento AMS. Spazio sufficiente per campione colore, marca, materiale, ID e codice QR.',
|
||||
},
|
||||
box40x30: {
|
||||
label: 'Etichetta scatola (40 × 30 mm)',
|
||||
|
||||
@@ -3542,9 +3542,13 @@ export default {
|
||||
color: '色順',
|
||||
},
|
||||
templates: {
|
||||
ams: {
|
||||
label: 'AMS holder (30 × 15 mm)',
|
||||
hint: '1ページに1ラベル、人気のAMSフィラメントラベルホルダーに適合。',
|
||||
amsHolderSmall: {
|
||||
label: 'AMS ホルダー — 小 (74 × 33 mm)',
|
||||
hint: '1ページにつき1枚;MakerWorld モデル 752566 (AMS フィラメントラベルホルダー) の印刷可能なラベルに対応します。',
|
||||
},
|
||||
amsHolderLarge: {
|
||||
label: 'AMS ホルダー — 大 (75 × 55 mm)',
|
||||
hint: '1ページにつき1枚;AMS フィラメントラベルホルダーのカード紙挿入バージョンに対応します。色見本、ブランド、素材、ID、QR コードを表示できる広さです。',
|
||||
},
|
||||
box40x30: {
|
||||
label: 'ボックスラベル (40 × 30 mm)',
|
||||
|
||||
@@ -3530,9 +3530,13 @@ export default {
|
||||
color: 'Por cor',
|
||||
},
|
||||
templates: {
|
||||
ams: {
|
||||
label: 'AMS holder (30 × 15 mm)',
|
||||
hint: 'Uma etiqueta por página; serve no porta-etiquetas AMS popular.',
|
||||
amsHolderSmall: {
|
||||
label: 'Suporte AMS — pequeno (74 × 33 mm)',
|
||||
hint: 'Uma etiqueta por página; corresponde à etiqueta imprimível do modelo MakerWorld 752566 (Suporte de etiquetas de filamento AMS).',
|
||||
},
|
||||
amsHolderLarge: {
|
||||
label: 'Suporte AMS — grande (75 × 55 mm)',
|
||||
hint: 'Uma etiqueta por página; encaixa na variante com inserto em cartão do Suporte de etiquetas de filamento AMS. Espaço suficiente para amostra de cor, marca, material, ID e QR code.',
|
||||
},
|
||||
box40x30: {
|
||||
label: 'Etiqueta de caixa (40 × 30 mm)',
|
||||
|
||||
@@ -3530,9 +3530,13 @@ export default {
|
||||
color: '按颜色',
|
||||
},
|
||||
templates: {
|
||||
ams: {
|
||||
label: 'AMS holder (30 × 15 mm)',
|
||||
hint: '每页一个标签;适用于流行的 AMS 耗材标签托架。',
|
||||
amsHolderSmall: {
|
||||
label: 'AMS 支架 — 小 (74 × 33 mm)',
|
||||
hint: '每页一个标签;适配 MakerWorld 模型 752566 (AMS 耗材标签支架) 中可打印的标签。',
|
||||
},
|
||||
amsHolderLarge: {
|
||||
label: 'AMS 支架 — 大 (75 × 55 mm)',
|
||||
hint: '每页一个标签;适配 AMS 耗材标签支架的卡片插入款。空间充足,可放置色板、品牌、材料、ID 与二维码。',
|
||||
},
|
||||
box40x30: {
|
||||
label: '盒标签 (40 × 30 mm)',
|
||||
|
||||
@@ -3530,9 +3530,13 @@ export default {
|
||||
color: '按顏色',
|
||||
},
|
||||
templates: {
|
||||
ams: {
|
||||
label: 'AMS holder (30 × 15 mm)',
|
||||
hint: '每頁一個標籤;適用於熱門的 AMS 耗材標籤托架。',
|
||||
amsHolderSmall: {
|
||||
label: 'AMS 支架 — 小 (74 × 33 mm)',
|
||||
hint: '每頁一個標籤;對應 MakerWorld 模型 752566 (AMS 耗材標籤支架) 中可列印的標籤。',
|
||||
},
|
||||
amsHolderLarge: {
|
||||
label: 'AMS 支架 — 大 (75 × 55 mm)',
|
||||
hint: '每頁一個標籤;對應 AMS 耗材標籤支架的紙卡插入款。空間足夠放置色塊、品牌、材質、ID 與 QR 碼。',
|
||||
},
|
||||
box40x30: {
|
||||
label: '盒標籤 (40 × 30 mm)',
|
||||
|
||||
Reference in New Issue
Block a user