feat(web): celdas de cuenta con código con formato (asientos y documentos): se ven con separadores y se pueden escribir por FormatCode
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a10de1ff29
commit
2733339c7f
9 files changed
+201
-5
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
Injector,
|
||||
afterNextRender,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
model,
|
||||
@@ -57,6 +58,17 @@ export class LinesGrid {
|
||||
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
||||
private readonly injector = inject(Injector);
|
||||
|
||||
constructor() {
|
||||
// las celdas de código con texto propio (la cuenta con su formato) piden los textos de las líneas que se cargan
|
||||
effect(() => {
|
||||
const lines = this.lines();
|
||||
for (const c of this.columns()) {
|
||||
const codes = c.lookup?.config.codes;
|
||||
if (codes) codes.ensure(lines.map((l) => String(l[c.key] ?? '')).filter((v) => v !== ''));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected readonly lookupTarget = signal<LookupTarget | null>(null);
|
||||
protected readonly detailTarget = signal<{ row: number; detail: GridDetail } | null>(null);
|
||||
protected readonly detailHintFn = computed(() => {
|
||||
@@ -104,6 +116,8 @@ export class LinesGrid {
|
||||
if (column.format) return column.format(line);
|
||||
const value = line[column.key];
|
||||
if (column.type === 'number') return formatNumber(value, column.decimals);
|
||||
const codes = column.lookup?.config.codes;
|
||||
if (codes && typeof value === 'string' && value !== '') return codes.display(value);
|
||||
return value === null || value === undefined ? '' : String(value);
|
||||
}
|
||||
|
||||
@@ -142,7 +156,7 @@ export class LinesGrid {
|
||||
const value = parsed === null || d === undefined ? parsed : Math.round((parsed + Number.EPSILON) * 10 ** d) / 10 ** d;
|
||||
this.update(row, column.key, value);
|
||||
input.value = formatNumber(value, column.decimals);
|
||||
} else if (text !== String(line[column.key] ?? '')) {
|
||||
} else if (text !== String(line[column.key] ?? '') && text !== this.cellText(line, column)) {
|
||||
if (column.lookup && text.trim() !== '') void this.resolveTyped(row, column, input, text.trim());
|
||||
else this.update(row, column.key, text);
|
||||
}
|
||||
@@ -164,7 +178,10 @@ export class LinesGrid {
|
||||
const found = await this.injector.get(SlLookupApi).find(lookup.config, code);
|
||||
const line = this.lines()[row];
|
||||
if (!line) return;
|
||||
if (found) this.replace(row, lookup.apply(found, line), column.key);
|
||||
if (found) {
|
||||
lookup.config.codes?.remember(found);
|
||||
this.replace(row, lookup.apply(found, line), column.key);
|
||||
}
|
||||
else {
|
||||
input.value = this.cellText(line, column);
|
||||
this.notice.emit(`No existe «${code}» en ${lookup.config.title.toLowerCase()}.`);
|
||||
@@ -287,6 +304,7 @@ export class LinesGrid {
|
||||
const line = target ? this.lines()[target.row] : undefined;
|
||||
if (!target || !picked || !line || !target.column.lookup) return;
|
||||
const lookup = target.column.lookup;
|
||||
lookup.config.codes?.remember(picked);
|
||||
this.replace(target.row, lookup.apply(picked, line), target.column.key);
|
||||
const rest = rows.slice(1).map((r) => {
|
||||
const added = lookup.apply(r, this.newLine()());
|
||||
|
||||
Reference in new issue
Block a user