@itrocks/list 0.0.15 → 0.0.16

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.
package/build.js CHANGED
@@ -1,11 +1,14 @@
1
1
  import { build } from '../build/build.js';
2
2
  import { xTargetCall } from '../xtarget/xtarget.js';
3
+ import { TableFeed } from '../table/feed.js';
3
4
  import { TableFreeze } from '../table/freeze.js';
4
5
  import { TableFreezeInheritBackground } from '../table/freeze/inherit-background.js';
5
6
  import { TableFreezeInheritBorder } from '../table/freeze/inherit-border.js';
6
7
  import { tableByElement } from '../table/table.js';
7
8
  build('article[data-action="list"] > form > table.objects', element => {
8
- tableByElement(element, { plugins: [TableFreeze, TableFreezeInheritBackground, TableFreezeInheritBorder] });
9
+ tableByElement(element, {
10
+ plugins: [TableFeed, TableFreeze, TableFreezeInheritBackground, TableFreezeInheritBorder]
11
+ });
9
12
  element.querySelector(':scope > tbody')?.addEventListener('click', async (event) => {
10
13
  const td = event.target;
11
14
  if (!(td instanceof HTMLTableCellElement))
package/cjs/list.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Action } from '@itrocks/action';
2
2
  import { Request } from '@itrocks/action-request';
3
3
  export declare class List<T extends object = object> extends Action<T> {
4
+ lineHeight: number;
4
5
  html(request: Request<T>): Promise<import("@itrocks/core-responses").HtmlResponse>;
5
6
  json(request: Request<T>): Promise<import("@itrocks/core-responses").JsonResponse>;
6
7
  }
package/cjs/list.html CHANGED
@@ -17,7 +17,7 @@
17
17
  <article data-action="list" data-class="{type.name}" data-route="{type.@route}">
18
18
  <header>
19
19
  <h2>{type.@output.ucFirst} list</h2>
20
- <section class="summary">{objects.length} elements</section>
20
+ <section class="summary">{count} elements</section>
21
21
  <ul class="general actions">
22
22
  <!--generalActions-->
23
23
  <li class="{action}">{{template}}</li>
package/cjs/list.js CHANGED
@@ -42,6 +42,7 @@ const route_1 = require("@itrocks/route");
42
42
  const route_2 = require("@itrocks/route");
43
43
  const storage_1 = require("@itrocks/storage");
44
44
  const storage_2 = require("@itrocks/storage");
45
+ const storage_3 = require("@itrocks/storage");
45
46
  let List = (() => {
46
47
  let _classDecorators = [(0, action_3.Need)('Store', 'new'), (0, route_1.Route)('/list')];
47
48
  let _classDescriptor;
@@ -57,9 +58,14 @@ let List = (() => {
57
58
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
58
59
  __runInitializers(_classThis, _classExtraInitializers);
59
60
  }
61
+ lineHeight = 30;
60
62
  async html(request) {
63
+ const header = request.request.headers['xhr-info'];
64
+ const xhrInfo = header ? JSON.parse(header) : {};
65
+ const limit = Math.ceil((xhrInfo.targetHeight ?? 1000) / this.lineHeight);
61
66
  const type = request.type;
62
- const objects = await (0, storage_1.dataSource)().readAll(type, storage_2.Sort);
67
+ const count = await (0, storage_1.dataSource)().count(type);
68
+ const objects = await (0, storage_1.dataSource)().readAll(type, [new storage_2.Limit(limit, +request.request.data.offset), storage_3.Sort]);
63
69
  const generalActions = [];
64
70
  const selectionActions = [];
65
71
  const route = (0, route_2.routeOf)(this);
@@ -67,7 +73,7 @@ let List = (() => {
67
73
  const actions = (action.need === 'object') ? selectionActions : generalActions;
68
74
  actions.push(action);
69
75
  }
70
- return this.htmlTemplateResponse({ generalActions, objects, selectionActions, type }, request, __dirname + '/list.html');
76
+ return this.htmlTemplateResponse({ count, generalActions, objects, selectionActions, type }, request, __dirname + '/list.html');
71
77
  }
72
78
  async json(request) {
73
79
  const objects = await (0, storage_1.dataSource)().search(request.type);
package/package.json CHANGED
@@ -63,5 +63,5 @@
63
63
  "build:front": "tsc -p esm/tsconfig.json && ../prepare-module/prepare-module.js esm"
64
64
  },
65
65
  "types": "./cjs/list.d.ts",
66
- "version": "0.0.15"
66
+ "version": "0.0.16"
67
67
  }