fix(web): el formulario de documentos dibuja los campos Sí/No (checkbox) de las extensiones
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7da6663e4b
commit
f25037f651
3 files changed
+54
-2
No files matched your search
@@ -91,6 +91,14 @@
|
||||
(picked)="onPartner($event)"
|
||||
/>
|
||||
}
|
||||
@case ('checkbox') {
|
||||
<sbo-checkbox-field
|
||||
[label]="f.label"
|
||||
[readonly]="readOnly() || !!f.readonly || locked(f)"
|
||||
[value]="header()[f.key] === 'tYES'"
|
||||
(valueChange)="setHeader(f.key, $event ? 'tYES' : 'tNO')"
|
||||
/>
|
||||
}
|
||||
@case ('lookup') {
|
||||
<sbo-lookup-field
|
||||
[label]="f.label"
|
||||
|
||||
@@ -8,7 +8,7 @@ import { map } from 'rxjs';
|
||||
import { API_URL, apiErrorMessage } from '../../core/api';
|
||||
import { formatNumber } from '../../core/format';
|
||||
import { SlDocumentApi } from '../../core/sl/sl-document';
|
||||
import { DateField, LookupField, NumberField, NumberInput, SboField, SelectField, SelectInput, TextField, TextInput, TextareaField } from '../../shared/form';
|
||||
import { CheckboxField, DateField, LookupField, NumberField, NumberInput, SboField, SelectField, SelectInput, TextField, TextInput, TextareaField } from '../../shared/form';
|
||||
import type { GridLine, GridMultiAdd } from '../../shared/grid/grid.types';
|
||||
import { LinesGrid } from '../../shared/grid/lines-grid';
|
||||
import type { VhLookup } from '../../shared/value-help/value-help.types';
|
||||
@@ -63,7 +63,7 @@ const folioAsNumber = (h: DocRecord): DocRecord => {
|
||||
@Component({
|
||||
selector: 'sbo-document-form-page',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [DateField, Icon, LinesGrid, LookupField, MenuButton, NgTemplateOutlet, NumberField, NumberInput, RouterLink, SboField, SelectField, SelectInput, SboWindow, TextField, TextInput, TextareaField, Toolbar, ValueHelp],
|
||||
imports: [CheckboxField, DateField, Icon, LinesGrid, LookupField, MenuButton, NgTemplateOutlet, NumberField, NumberInput, RouterLink, SboField, SelectField, SelectInput, SboWindow, TextField, TextInput, TextareaField, Toolbar, ValueHelp],
|
||||
templateUrl: './document-form.page.html',
|
||||
styles: `
|
||||
h1 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
|
||||
|
||||
@@ -344,3 +344,47 @@ describe('formulario con campos ocultos o de solo lectura', () => {
|
||||
expect(input('Indicador')!.readOnly).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('campos Sí/No (checkbox) en los documentos', () => {
|
||||
it('un campo de usuario de tipo casilla se dibuja como casilla y guarda tYES / tNO', async () => {
|
||||
TestBed.resetTestingModule();
|
||||
const screen = by(
|
||||
applyExtensions(BASE_SCREENS, { '/ventas/ordenes': { headerLeft: [{ type: 'checkbox', key: 'U_Urgente', label: 'Urgente' }] } }),
|
||||
'/ventas/ordenes',
|
||||
);
|
||||
const route = {
|
||||
snapshot: { data: { screen, title: 'Documento' }, paramMap: convertToParamMap({ docEntry: '5' }) },
|
||||
paramMap: of(convertToParamMap({ docEntry: '5' })),
|
||||
};
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [DocumentFormPage],
|
||||
providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting(), { provide: ActivatedRoute, useValue: route }],
|
||||
}).compileComponents();
|
||||
const ctrl = TestBed.inject(HttpTestingController);
|
||||
vi.spyOn(TestBed.inject(Router), 'navigate').mockResolvedValue(true);
|
||||
const fixture = TestBed.createComponent(DocumentFormPage);
|
||||
const tick = async () => {
|
||||
fixture.detectChanges();
|
||||
await new Promise((r) => setTimeout(r));
|
||||
fixture.detectChanges();
|
||||
};
|
||||
await tick();
|
||||
ctrl.match((r) => r.url === '/api/sl/SalesTaxCodes').forEach((r) => r.flush({ value: [] }));
|
||||
ctrl.match((r) => r.url === '/api/sl/AdditionalExpenses').forEach((r) => r.flush({ value: [] }));
|
||||
ctrl.match((r) => r.url.includes('SeriesService')).forEach((r) => r.flush({ value: [] }));
|
||||
ctrl.expectOne('/api/sl/Orders/5').flush({
|
||||
'odata.etag': 'W/"1"', DocEntry: 5, DocNum: 5, CardCode: 'C1', CardName: 'ACME', U_Urgente: 'tNO',
|
||||
DocDate: '2026-09-11T00:00:00Z', DocDueDate: '2026-09-20T00:00:00Z', DocumentStatus: 'bost_Open', Cancelled: 'tNO',
|
||||
DocumentLines: [{ LineNum: 0, ItemCode: 'A1', ItemDescription: 'Pieza', Quantity: 1, Price: 10, TaxCode: '', LineTotal: 10 }],
|
||||
});
|
||||
await tick();
|
||||
const el = fixture.nativeElement as HTMLElement;
|
||||
const box = [...el.querySelectorAll('sbo-checkbox-field')].find((f) => f.querySelector('label')?.textContent?.trim() === 'Urgente')!.querySelector('input[type=checkbox]') as HTMLInputElement;
|
||||
expect(box.checked).toBe(false);
|
||||
box.click();
|
||||
await tick();
|
||||
(el.querySelector('.actions .btn.main') as HTMLElement).click();
|
||||
await tick();
|
||||
expect(ctrl.expectOne((r) => r.method === 'PATCH').request.body).toEqual({ U_Urgente: 'tYES' });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user