spiderly 19.13.0 → 19.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -274,6 +274,23 @@ The table renders the store as a **chip bar** above the header: one chip per *ap
|
|
|
274
274
|
this.views = this.views.map((view) => ({ ...view, count: counts[view.id] }));
|
|
275
275
|
```
|
|
276
276
|
|
|
277
|
+
**A count can honor each view's saved filters**: the table's `viewFilterPayload(viewId)` returns the `filters` payload that view's own list request carries, so a count query that applies it counts the rows that tab lists (on screen for the active view, after a click for the others), including bar filters the user saved on that view. The active view answers with the live filters; any other view with what a click would enter: its saved filters, else its `apply` (always `apply` for a transient view). It switches nothing and sends no request. `apply` runs on a scratch store for this, so it must write only into the store it receives. It returns `{}` on a table without `[filters]` and `null` for an id not in `[views]` (yet). Call it beside each list load; a non-static `@ViewChild` is still unresolved during the first one, so hand the table in from a template reference:
|
|
278
|
+
|
|
279
|
+
```html
|
|
280
|
+
<spiderly-data-table #table [views]="views" (onLazyLoad)="refreshCounts(table)" ...></spiderly-data-table>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
refreshCounts(table: SpiderlyDataTableComponent): void {
|
|
285
|
+
const filtersByView: Record<string, Record<string, FilterRule[]>> = {};
|
|
286
|
+
for (const view of this.views) {
|
|
287
|
+
const filters = table.viewFilterPayload(view.id);
|
|
288
|
+
if (filters) filtersByView[view.id] = filters; // null: the table does not hold this view yet
|
|
289
|
+
}
|
|
290
|
+
// send filtersByView with your count query, then rebuild [views] with the counts
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
277
294
|
**A view can declare its columns**: `columns` is a field → visible map that overrides `Column.visible` in that view only, naming just the deviation — a column it does not name keeps its `Column.visible`. Visibility resolves per field as the user's own per-view choice ?? the view's `columns` ?? `Column.visible`; the user's choice is stored only where it differs from the view's declaration, *Reset to default* returns to the declaration, and `lockVisible` columns always show. To swap one column for another, declare them next to each other in `cols` (the swapped-in one `visible: false`) and the view's column takes the other's place. Type the row as the second generic to check the field names.
|
|
278
295
|
|
|
279
296
|
```typescript
|