@teipublisher/pb-components 3.2.0 → 3.2.1
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/.github/workflows/node.js.yml +39 -2
- package/CHANGELOG.md +11 -0
- package/dist/pb-components-bundle.js +64 -67
- package/i18n/common/de.json +17 -0
- package/i18n/common/en.json +17 -0
- package/i18n/common/pl.json +17 -0
- package/package.json +1 -1
- package/src/pb-table-grid.js +86 -30
- package/.github/workflows/release.js.yml +0 -42
package/i18n/common/de.json
CHANGED
|
@@ -126,6 +126,23 @@
|
|
|
126
126
|
"content": "Inhalte durchsuchen",
|
|
127
127
|
"scope": "Suchbereich"
|
|
128
128
|
},
|
|
129
|
+
"tableGrid": {
|
|
130
|
+
"search": "Suche",
|
|
131
|
+
"searchPlaceholder": "Schlüsselwort eingeben...",
|
|
132
|
+
"sortAsc": "Spalte aufsteigend sortieren",
|
|
133
|
+
"sortDesc": "Spalte absteigend sortieren",
|
|
134
|
+
"previous": "Vorherige",
|
|
135
|
+
"next": "Nächste",
|
|
136
|
+
"navigate": "Seite {{page}} von {{pages}}",
|
|
137
|
+
"page": "Seite {{page}}",
|
|
138
|
+
"showing": "Anzeigen",
|
|
139
|
+
"to": "zu",
|
|
140
|
+
"of": "von",
|
|
141
|
+
"results": "Ergebnisse",
|
|
142
|
+
"loading": "Laden...",
|
|
143
|
+
"noRecordsFound": "Keine passenden Einträge gefunden",
|
|
144
|
+
"error": "Ein Fehler ist aufgetreten, während die Daten abgerufen wurden"
|
|
145
|
+
},
|
|
129
146
|
"dts": {
|
|
130
147
|
"endpoint": "Server wählen",
|
|
131
148
|
"note": "Experimentell: Zugriff auf externe Editionen über DTS API",
|
package/i18n/common/en.json
CHANGED
|
@@ -126,6 +126,23 @@
|
|
|
126
126
|
"content": "Search content",
|
|
127
127
|
"scope": "Query scope"
|
|
128
128
|
},
|
|
129
|
+
"tableGrid": {
|
|
130
|
+
"search": "Search",
|
|
131
|
+
"searchPlaceholder": "Type a keyword...",
|
|
132
|
+
"sortAsc": "Sort column ascending",
|
|
133
|
+
"sortDesc": "Sort column descending",
|
|
134
|
+
"previous": "Previous",
|
|
135
|
+
"next": "Next",
|
|
136
|
+
"navigate": "Page {{page}} of {{pages}}",
|
|
137
|
+
"page": "Page {{page}}",
|
|
138
|
+
"showing": "Showing",
|
|
139
|
+
"to": "to",
|
|
140
|
+
"of": "of",
|
|
141
|
+
"results": "results",
|
|
142
|
+
"loading": "Loading...",
|
|
143
|
+
"noRecordsFound": "No matching records found",
|
|
144
|
+
"error": "An error occurred while fetching data"
|
|
145
|
+
},
|
|
129
146
|
"dts": {
|
|
130
147
|
"endpoint": "Select Endpoint",
|
|
131
148
|
"note": "Experimental: access other editions which expose the DTS API",
|
package/i18n/common/pl.json
CHANGED
|
@@ -126,6 +126,23 @@
|
|
|
126
126
|
"content": "Przeszukaj zawartość",
|
|
127
127
|
"scope": "Obszar kwerendy"
|
|
128
128
|
},
|
|
129
|
+
"tableGrid": {
|
|
130
|
+
"search": "Szukaj",
|
|
131
|
+
"searchPlaceholder": "Wpisz słowo kluczowe...",
|
|
132
|
+
"sortAsc": "Sortuj kolumnę rosnąco",
|
|
133
|
+
"sortDesc": "Sortuj kolumnę malejąco",
|
|
134
|
+
"previous": "Poprzednia",
|
|
135
|
+
"next": "Następna",
|
|
136
|
+
"navigate": "Strona {{page}} z {{pages}}",
|
|
137
|
+
"page": "Strona {{page}}",
|
|
138
|
+
"showing": "Wyświetlanie",
|
|
139
|
+
"to": "do",
|
|
140
|
+
"of": "z",
|
|
141
|
+
"results": "wyników",
|
|
142
|
+
"loading": "Ładowanie...",
|
|
143
|
+
"noRecordsFound": "Brak pasujących rekordów",
|
|
144
|
+
"error": "Wystąpił błąd podczas pobierania danych"
|
|
145
|
+
},
|
|
129
146
|
"dts": {
|
|
130
147
|
"endpoint": "Wybierz Endpoint",
|
|
131
148
|
"note": "Wersja eksperymentalna: uzyskaj dostęp do edycji, które udostępniają API DTS",
|
package/package.json
CHANGED
package/src/pb-table-grid.js
CHANGED
|
@@ -3,13 +3,9 @@ import { Grid, PluginPosition } from 'gridjs';
|
|
|
3
3
|
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
4
4
|
import { resolveURL } from './utils.js';
|
|
5
5
|
import { importStyles, loadStylesheets, themableMixin } from './theming.js';
|
|
6
|
-
import '@polymer/paper-input/paper-input';
|
|
7
|
-
import '@polymer/iron-icons';
|
|
8
|
-
import '@polymer/iron-form';
|
|
9
|
-
import '@polymer/paper-icon-button';
|
|
10
6
|
import './pb-table-column.js';
|
|
11
7
|
import { registry } from './urls.js';
|
|
12
|
-
import { translate } from './pb-i18n.js';
|
|
8
|
+
import { get as i18n, translate } from './pb-i18n.js';
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
11
|
* A table grid based on [gridjs](https://gridjs.io/), which loads its data from a server endpoint
|
|
@@ -114,10 +110,24 @@ export class PbTableGrid extends themableMixin(pbMixin(LitElement)) {
|
|
|
114
110
|
this._pbColumns = [];
|
|
115
111
|
this._columns = [];
|
|
116
112
|
this._selectedRow = null;
|
|
113
|
+
this._gridI18nInitialized = false;
|
|
117
114
|
this._onTableClick = this._onTableClick.bind(this);
|
|
118
115
|
this._onDocumentClick = this._onDocumentClick.bind(this);
|
|
119
116
|
}
|
|
120
117
|
|
|
118
|
+
_applyPaginationPosition() {
|
|
119
|
+
if (!this.grid || !this.grid.plugin) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const paginationPlugin = this.grid.plugin.get('pagination');
|
|
123
|
+
if (!paginationPlugin) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
paginationPlugin.position = this.paginationTop
|
|
127
|
+
? PluginPosition.Header
|
|
128
|
+
: PluginPosition.Footer;
|
|
129
|
+
}
|
|
130
|
+
|
|
121
131
|
async connectedCallback() {
|
|
122
132
|
super.connectedCallback();
|
|
123
133
|
document.addEventListener('click', this._onDocumentClick);
|
|
@@ -134,10 +144,15 @@ export class PbTableGrid extends themableMixin(pbMixin(LitElement)) {
|
|
|
134
144
|
this.subscribeTo(
|
|
135
145
|
'pb-i18n-update',
|
|
136
146
|
ev => {
|
|
137
|
-
const needsRefresh = this.language
|
|
147
|
+
const needsRefresh = this.language !== ev.detail.language;
|
|
138
148
|
this.language = ev.detail.language;
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
const needsInitialI18nRefresh = !this._gridI18nInitialized;
|
|
150
|
+
if ((needsRefresh || needsInitialI18nRefresh) && this.grid) {
|
|
151
|
+
this._gridI18nInitialized = true;
|
|
152
|
+
if (needsRefresh) {
|
|
153
|
+
this._applyPaginationPosition();
|
|
154
|
+
this._submit();
|
|
155
|
+
}
|
|
141
156
|
}
|
|
142
157
|
},
|
|
143
158
|
[],
|
|
@@ -186,6 +201,7 @@ export class PbTableGrid extends themableMixin(pbMixin(LitElement)) {
|
|
|
186
201
|
height: this.height,
|
|
187
202
|
fixedHeader: true,
|
|
188
203
|
columns: this._columns,
|
|
204
|
+
language: this._gridLanguageConfig(),
|
|
189
205
|
resizable: this.resizable,
|
|
190
206
|
server: {
|
|
191
207
|
url,
|
|
@@ -210,9 +226,9 @@ export class PbTableGrid extends themableMixin(pbMixin(LitElement)) {
|
|
|
210
226
|
limit: this.perPage,
|
|
211
227
|
server: {
|
|
212
228
|
url: (prev, page, limit) => {
|
|
213
|
-
const form = this.shadowRoot.getElementById('form');
|
|
229
|
+
const form = this.shadowRoot.getElementById('search-form');
|
|
214
230
|
if (form) {
|
|
215
|
-
Object.assign(this._params,
|
|
231
|
+
Object.assign(this._params, this._serializeForm(form));
|
|
216
232
|
}
|
|
217
233
|
this._params = this._paramsFromSubforms(this._params);
|
|
218
234
|
this._params.limit = limit;
|
|
@@ -238,11 +254,13 @@ export class PbTableGrid extends themableMixin(pbMixin(LitElement)) {
|
|
|
238
254
|
};
|
|
239
255
|
|
|
240
256
|
this.grid = new Grid(config);
|
|
241
|
-
|
|
242
|
-
this.grid.plugin.get('pagination').position = PluginPosition.Header;
|
|
243
|
-
}
|
|
257
|
+
this._applyPaginationPosition();
|
|
244
258
|
this.grid.on('load', () => {
|
|
245
259
|
this._clearRowSelection();
|
|
260
|
+
if (this.paginationTop) {
|
|
261
|
+
// `forceRender()` can reset GridJS plugin state; re-apply after each load.
|
|
262
|
+
this.grid.plugin.get('pagination').position = PluginPosition.Header;
|
|
263
|
+
}
|
|
246
264
|
this.emitTo('pb-results-received', {
|
|
247
265
|
params: this._params,
|
|
248
266
|
});
|
|
@@ -329,6 +347,38 @@ export class PbTableGrid extends themableMixin(pbMixin(LitElement)) {
|
|
|
329
347
|
this.grid.forceRender();
|
|
330
348
|
}
|
|
331
349
|
|
|
350
|
+
_gridLanguageConfig() {
|
|
351
|
+
return {
|
|
352
|
+
search: {
|
|
353
|
+
placeholder: () => i18n('tableGrid.searchPlaceholder'),
|
|
354
|
+
},
|
|
355
|
+
sort: {
|
|
356
|
+
sortAsc: () => i18n('tableGrid.sortAsc'),
|
|
357
|
+
sortDesc: () => i18n('tableGrid.sortDesc'),
|
|
358
|
+
},
|
|
359
|
+
pagination: {
|
|
360
|
+
previous: () => i18n('tableGrid.previous'),
|
|
361
|
+
next: () => i18n('tableGrid.next'),
|
|
362
|
+
navigate: (page, pages) =>
|
|
363
|
+
i18n('tableGrid.navigate', {
|
|
364
|
+
page,
|
|
365
|
+
pages,
|
|
366
|
+
}),
|
|
367
|
+
page: page =>
|
|
368
|
+
i18n('tableGrid.page', {
|
|
369
|
+
page,
|
|
370
|
+
}),
|
|
371
|
+
showing: () => i18n('tableGrid.showing'),
|
|
372
|
+
to: () => i18n('tableGrid.to'),
|
|
373
|
+
of: () => i18n('tableGrid.of'),
|
|
374
|
+
results: () => i18n('tableGrid.results'),
|
|
375
|
+
},
|
|
376
|
+
loading: () => i18n('tableGrid.loading'),
|
|
377
|
+
noRecordsFound: () => i18n('tableGrid.noRecordsFound'),
|
|
378
|
+
error: () => i18n('tableGrid.error'),
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
332
382
|
_paramsFromSubforms(params) {
|
|
333
383
|
if (this.subforms) {
|
|
334
384
|
document.querySelectorAll(this.subforms).forEach(form => {
|
|
@@ -340,27 +390,33 @@ export class PbTableGrid extends themableMixin(pbMixin(LitElement)) {
|
|
|
340
390
|
return params;
|
|
341
391
|
}
|
|
342
392
|
|
|
393
|
+
_serializeForm(form) {
|
|
394
|
+
const data = {};
|
|
395
|
+
const formData = new FormData(form);
|
|
396
|
+
formData.forEach((value, key) => {
|
|
397
|
+
data[key] = value;
|
|
398
|
+
});
|
|
399
|
+
return data;
|
|
400
|
+
}
|
|
401
|
+
|
|
343
402
|
render() {
|
|
344
403
|
return html`
|
|
345
404
|
${this.search
|
|
346
405
|
? html`
|
|
347
|
-
<
|
|
348
|
-
<
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
</paper-input>
|
|
362
|
-
</form>
|
|
363
|
-
</iron-form>
|
|
406
|
+
<form id="search-form" action="">
|
|
407
|
+
<input
|
|
408
|
+
id="search"
|
|
409
|
+
name="search"
|
|
410
|
+
type="search"
|
|
411
|
+
.value="${this._params.search || ''}"
|
|
412
|
+
aria-label="${translate('tableGrid.search')}"
|
|
413
|
+
placeholder="${translate('tableGrid.searchPlaceholder')}"
|
|
414
|
+
@keyup="${e => (e.key === 'Enter' ? this._submit() : null)}"
|
|
415
|
+
/>
|
|
416
|
+
<button type="button" @click="${this._submit}">
|
|
417
|
+
${translate('tableGrid.search')}
|
|
418
|
+
</button>
|
|
419
|
+
</form>
|
|
364
420
|
`
|
|
365
421
|
: null}
|
|
366
422
|
<div id="table"></div>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
name: Release npm package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
- next-3
|
|
8
|
-
|
|
9
|
-
permissions:
|
|
10
|
-
contents: read # for checkout
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
release:
|
|
14
|
-
name: Release
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
permissions:
|
|
17
|
-
contents: write # to be able to publish a GitHub release
|
|
18
|
-
issues: write # to be able to comment on released issues
|
|
19
|
-
pull-requests: write # to be able to comment on released pull requests
|
|
20
|
-
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v5
|
|
23
|
-
- uses: actions/setup-node@v5
|
|
24
|
-
with:
|
|
25
|
-
node-version: "22"
|
|
26
|
-
- name: npm install and build
|
|
27
|
-
run:
|
|
28
|
-
npm ci
|
|
29
|
-
npm run build:production
|
|
30
|
-
- name: Build docker image
|
|
31
|
-
run: docker build -t exist-db -f Dockerfile .
|
|
32
|
-
- name: Start docker image
|
|
33
|
-
run: docker run --publish 8080:8080 --detach exist-db
|
|
34
|
-
- name: Wait for eXist
|
|
35
|
-
uses: iFaxity/wait-on-action@v1
|
|
36
|
-
with:
|
|
37
|
-
resource: http-get://localhost:8080/exist/apps/tei-publisher/api/version
|
|
38
|
-
- run: npm test
|
|
39
|
-
- run: npx semantic-release
|
|
40
|
-
env:
|
|
41
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
42
|
-
NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|