Fix Favorites placing on filter

This commit is contained in:
Jack Anderson 2024-12-16 09:17:46 +00:00 committed by j.anderson
parent bf07231225
commit 1ad34e7f55
2 changed files with 28 additions and 18 deletions

View file

@ -27,7 +27,7 @@
import {Directive, Input, OnDestroy, OnInit} from '@angular/core';
import {Subscription} from 'rxjs';
import {BreakpointObserver, Breakpoints, BreakpointState} from '@angular/cdk/layout';
import {FieldGridRow, LabelDisplay} from './field-grid.model';
import {FieldGridColumn, FieldGridRow, LabelDisplay} from './field-grid.model';
import {ScreenSizeMap} from '../../common/services/ui/resize.model';
@ -153,26 +153,41 @@ export abstract class BaseFieldGridComponent implements OnInit, OnDestroy {
});
} else {
const lastNeededCol = this.colNumber - neededSlots.length;
let lastRow = grid[grid.length - 1];
if (lastRow.cols[lastNeededCol].field) {
lastRow = {
cols: []
} as FieldGridRow;
this.fillRow(lastRow);
grid.push(lastRow);
}
let rowLength = lastRow.cols.length;
let place = this.colNumber - 1;
neededSlots.forEach(type => {
lastRow.cols[place][type] = true;
place--;
neededSlots.reverse().forEach(type => {
let actionSlot = false;
if (type === 'actionSlot') {
actionSlot = true;
}
if (rowLength === this.colNumber || actionSlot) {
lastRow = this.addNewRow();
grid.push(lastRow);
rowLength = actionSlot ? (this.colNumber - 1) : 0;
}
lastRow.cols[rowLength] = [] as FieldGridColumn;
lastRow.cols[rowLength][type] = true;
this.fillRow(lastRow);
rowLength++;
});
}
}
protected addNewRow(): FieldGridRow {
const row = {
cols: []
} as FieldGridRow
this.fillRow(row);
return row;
}
protected getNeededExtraSlots(): string[] {
const neededSlots = [];

View file

@ -81,11 +81,6 @@ export class FieldGridComponent extends BaseFieldGridComponent implements OnChan
col++;
});
const lastRow = grid[grid.length - 1];
if (col < this.colNumber) {
this.fillRow(lastRow);
}
this.addSpecialSlots(grid);
this.fieldGrid = grid;