@teipublisher/pb-components 2.26.0-next-3.12 → 2.26.0-next-3.13
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/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +3 -3
- package/CHANGELOG.md +30 -0
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +58 -54
- package/dist/pb-components-bundle.js +1937 -1782
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +45 -45
- package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +56 -41
- package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
- package/dist/pb-odd-editor.js +923 -756
- package/dist/pb-tify.js +2 -2
- package/dist/{vaadin-element-mixin-49ab4037.js → vaadin-element-mixin-84fb7d82.js} +178 -163
- package/gh-pages.js +5 -3
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +1 -1
- package/package.json +2 -2
- package/pb-elements.json +45 -45
- package/src/assets/components.css +5 -5
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +23 -21
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +47 -42
- package/src/authority/kbga.js +137 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -67
- package/src/authority/registry.js +4 -4
- package/src/docs/pb-component-docs.js +2 -2
- package/src/docs/pb-component-view.js +5 -5
- package/src/docs/pb-components-list.js +2 -2
- package/src/docs/pb-demo-snippet.js +2 -2
- package/src/dts-client.js +299 -297
- package/src/dts-select-endpoint.js +90 -82
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +150 -146
- package/src/pb-authority-lookup.js +183 -146
- package/src/pb-autocomplete.js +292 -280
- package/src/pb-blacklab-highlight.js +264 -259
- package/src/pb-blacklab-results.js +236 -221
- package/src/pb-browse-docs.js +540 -475
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +79 -76
- package/src/pb-code-editor.js +110 -102
- package/src/pb-code-highlight.js +209 -204
- package/src/pb-codepen.js +79 -72
- package/src/pb-collapse.js +212 -207
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-custom-form.js +151 -149
- package/src/pb-dialog.js +94 -85
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +210 -198
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +98 -96
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +411 -413
- package/src/pb-formula.js +151 -153
- package/src/pb-geolocation.js +129 -131
- package/src/pb-grid-action.js +53 -56
- package/src/pb-grid.js +231 -228
- package/src/pb-highlight.js +140 -140
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +101 -104
- package/src/pb-image-strip.js +84 -78
- package/src/pb-lang.js +132 -128
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -426
- package/src/pb-login.js +291 -248
- package/src/pb-manage-odds.js +364 -318
- package/src/pb-map-icon.js +89 -89
- package/src/pb-map-layer.js +85 -85
- package/src/pb-markdown.js +90 -99
- package/src/pb-media-query.js +74 -72
- package/src/pb-mei.js +306 -295
- package/src/pb-message.js +144 -144
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -82
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1053 -955
- package/src/pb-odd-elementspec-editor.js +348 -297
- package/src/pb-odd-model-editor.js +1061 -901
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -421
- package/src/pb-paginate.js +202 -190
- package/src/pb-panel.js +191 -179
- package/src/pb-popover-themes.js +7 -5
- package/src/pb-popover.js +296 -287
- package/src/pb-print-preview.js +127 -127
- package/src/pb-progress.js +51 -51
- package/src/pb-repeat.js +105 -104
- package/src/pb-restricted.js +84 -77
- package/src/pb-search.js +252 -241
- package/src/pb-select-feature.js +127 -120
- package/src/pb-select-odd.js +132 -124
- package/src/pb-select-template.js +89 -78
- package/src/pb-select.js +251 -227
- package/src/pb-split-list.js +179 -174
- package/src/pb-svg.js +80 -79
- package/src/pb-table-column.js +54 -54
- package/src/pb-table-grid.js +221 -203
- package/src/pb-tabs.js +61 -63
- package/src/pb-tify.js +154 -154
- package/src/pb-timeline.js +271 -229
- package/src/pb-toggle-feature.js +182 -175
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +132 -98
- package/src/pb-view.js +1289 -1270
- package/src/pb-zoom.js +75 -59
- package/src/polymer-hack.js +1 -1
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +13 -20
- package/src/settings.js +4 -4
- package/src/theming.js +96 -96
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
package/src/pb-table-column.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
import { LitElement } from 'lit-element';
|
|
2
|
-
import { html } from
|
|
2
|
+
import { html } from 'gridjs';
|
|
3
3
|
import './pb-popover.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Defines a column within `pb-table-grid`.
|
|
7
7
|
*/
|
|
8
8
|
export class PbTableColumn extends LitElement {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
static get properties() {
|
|
10
|
+
return {
|
|
11
|
+
/**
|
|
12
|
+
* Column heading to display
|
|
13
|
+
*/
|
|
14
|
+
label: {
|
|
15
|
+
type: String,
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* Name of the JSON property containing the data
|
|
19
|
+
*/
|
|
20
|
+
property: {
|
|
21
|
+
type: String,
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Should the column support sorting?
|
|
25
|
+
*/
|
|
26
|
+
sort: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Optional fixed width of the column (e.g. '200px' or '30%')
|
|
31
|
+
*/
|
|
32
|
+
width: {
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
...super.properties,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
constructor() {
|
|
40
|
+
super();
|
|
41
|
+
this.label = 'no-label';
|
|
42
|
+
this.property = null;
|
|
43
|
+
this.sort = false;
|
|
44
|
+
this.width = null;
|
|
45
|
+
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
connectedCallback() {
|
|
48
|
+
super.connectedCallback();
|
|
49
|
+
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
return config;
|
|
51
|
+
data() {
|
|
52
|
+
const config = {
|
|
53
|
+
name: html(`<pb-i18n key="${this.label}">${this.label}</pb-i18n>`),
|
|
54
|
+
sort: { enabled: this.sort },
|
|
55
|
+
formatter: cell => html(cell),
|
|
56
|
+
};
|
|
57
|
+
if (this.property) {
|
|
58
|
+
config.id = this.property;
|
|
59
|
+
}
|
|
60
|
+
if (this.width) {
|
|
61
|
+
config.width = this.width;
|
|
64
62
|
}
|
|
63
|
+
return config;
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
|
-
customElements.define('pb-table-column', PbTableColumn);
|
|
66
|
+
customElements.define('pb-table-column', PbTableColumn);
|
package/src/pb-table-grid.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { Grid } from
|
|
2
|
+
import { Grid } from 'gridjs';
|
|
3
3
|
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
4
4
|
import { resolveURL } from './utils.js';
|
|
5
|
-
import { loadStylesheets, importStyles } from
|
|
5
|
+
import { loadStylesheets, importStyles } from './theming.js';
|
|
6
6
|
import '@polymer/paper-input/paper-input';
|
|
7
7
|
import '@polymer/iron-icons';
|
|
8
8
|
import '@polymer/iron-form';
|
|
9
9
|
import '@polymer/paper-icon-button';
|
|
10
10
|
import './pb-table-column.js';
|
|
11
|
-
import { registry } from
|
|
11
|
+
import { registry } from './urls.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A table grid based on [gridjs](https://gridjs.io/), which loads its data from a server endpoint
|
|
15
15
|
* specified in `source`. If `source` is a relative URI, it will be resolved relative to the
|
|
16
16
|
* TEI Publisher endpoint.
|
|
17
|
-
*
|
|
17
|
+
*
|
|
18
18
|
* The JSON data returned by the endpoint should be an object with two properties:
|
|
19
|
-
*
|
|
19
|
+
*
|
|
20
20
|
* * `count`: the overall number of rows available on the server
|
|
21
21
|
* * `results`: an array containing each record as an object
|
|
22
|
-
*
|
|
22
|
+
*
|
|
23
23
|
* The parameters send to the server are as follows:
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
26
|
* Parameter | Description
|
|
27
27
|
* ---------|----------
|
|
28
28
|
* limit | number of records to return for each page
|
|
@@ -30,9 +30,9 @@ import { registry } from "./urls.js";
|
|
|
30
30
|
* order | the id of the column to sort by
|
|
31
31
|
* dir | sort direction: either 'asc' or 'desc'
|
|
32
32
|
* search | an optional search string entered by the user
|
|
33
|
-
*
|
|
33
|
+
*
|
|
34
34
|
* Table columns are configured via nested `<pb-table-column>` elements:
|
|
35
|
-
*
|
|
35
|
+
*
|
|
36
36
|
* ```html
|
|
37
37
|
* <pb-table-column label="Name" property="name" sort width="33%"></pb-table-column>
|
|
38
38
|
* <pb-table-column label="Born" property="birth"></pb-table-column>
|
|
@@ -40,215 +40,233 @@ import { registry } from "./urls.js";
|
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
42
|
export class PbTableGrid extends pbMixin(LitElement) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
43
|
+
static get properties() {
|
|
44
|
+
return {
|
|
45
|
+
/**
|
|
46
|
+
* URI of the server-side endpoint to retrieve data from.
|
|
47
|
+
* Relative URIs are resolved relative to the configured TEI Publisher endpoint.
|
|
48
|
+
*/
|
|
49
|
+
source: {
|
|
50
|
+
type: String,
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Path to the gridjs theme CSS files.
|
|
54
|
+
*/
|
|
55
|
+
cssPath: {
|
|
56
|
+
type: String,
|
|
57
|
+
attribute: 'css-path',
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* If specified, columns (without a fixed width) will be resizable.
|
|
61
|
+
*/
|
|
62
|
+
resizable: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
},
|
|
65
|
+
subforms: {
|
|
66
|
+
type: String,
|
|
67
|
+
},
|
|
68
|
+
perPage: {
|
|
69
|
+
type: Number,
|
|
70
|
+
attribute: 'per-page',
|
|
71
|
+
},
|
|
72
|
+
height: {
|
|
73
|
+
type: String,
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* If specified, enable server-side search.
|
|
77
|
+
*/
|
|
78
|
+
search: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
},
|
|
81
|
+
_params: {
|
|
82
|
+
type: Object,
|
|
83
|
+
},
|
|
84
|
+
...super.properties,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
this.cssPath = '../css/gridjs';
|
|
91
|
+
this._params = {};
|
|
92
|
+
this.resizable = false;
|
|
93
|
+
this.search = false;
|
|
94
|
+
this.perPage = 10;
|
|
95
|
+
this.height = null;
|
|
96
|
+
this.fixedHeader = false;
|
|
97
|
+
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
async connectedCallback() {
|
|
100
|
+
super.connectedCallback();
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
this.subscribeTo('pb-search-resubmit', ev => {
|
|
103
|
+
this._submit();
|
|
104
|
+
});
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
registry.subscribe(this, state => {
|
|
107
|
+
this._params = state;
|
|
108
|
+
this._submit();
|
|
109
|
+
});
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!this.height) {
|
|
120
|
-
const property = getComputedStyle(this).getPropertyValue('--pb-table-grid-height');
|
|
121
|
-
if (property) {
|
|
122
|
-
this.height = property;
|
|
123
|
-
} else {
|
|
124
|
-
this.height = 'auto';
|
|
125
|
-
}
|
|
111
|
+
this.subscribeTo(
|
|
112
|
+
'pb-i18n-update',
|
|
113
|
+
ev => {
|
|
114
|
+
const needsRefresh = this.language && this.language !== ev.detail.language;
|
|
115
|
+
this.language = ev.detail.language;
|
|
116
|
+
if (needsRefresh) {
|
|
117
|
+
this._submit();
|
|
126
118
|
}
|
|
119
|
+
},
|
|
120
|
+
[],
|
|
121
|
+
);
|
|
127
122
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
123
|
+
if (!this.height) {
|
|
124
|
+
const property = getComputedStyle(this).getPropertyValue('--pb-table-grid-height');
|
|
125
|
+
if (property) {
|
|
126
|
+
this.height = property;
|
|
127
|
+
} else {
|
|
128
|
+
this.height = 'auto';
|
|
129
|
+
}
|
|
135
130
|
}
|
|
136
131
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.language = data.language;
|
|
146
|
-
}
|
|
147
|
-
this._params = registry.state;
|
|
148
|
-
const url = this.toAbsoluteURL(this.source);
|
|
149
|
-
const config = {
|
|
150
|
-
height: this.height,
|
|
151
|
-
fixedHeader: true,
|
|
152
|
-
columns,
|
|
153
|
-
resizable: this.resizable,
|
|
154
|
-
server: {
|
|
155
|
-
url,
|
|
156
|
-
then: data => data.results,
|
|
157
|
-
total: data => data.count
|
|
158
|
-
},
|
|
159
|
-
sort: {
|
|
160
|
-
multiColumn: false,
|
|
161
|
-
enabled: true,
|
|
162
|
-
server: {
|
|
163
|
-
url: (prev, cols) => {
|
|
164
|
-
if (!cols.length) return prev;
|
|
165
|
-
const col = cols[0];
|
|
166
|
-
return `${prev}${prev.indexOf('?') > -1 ? '&' : '?'}order=${columns[col.index].id}&dir=${col.direction === 1 ? 'asc' : 'desc'}`;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
pagination: {
|
|
171
|
-
enabled: true,
|
|
172
|
-
limit: this.perPage,
|
|
173
|
-
server: {
|
|
174
|
-
url: (prev, page, limit) => {
|
|
175
|
-
const form = this.shadowRoot.getElementById('form');
|
|
176
|
-
if (form) {
|
|
177
|
-
Object.assign(this._params, form.serializeForm());
|
|
178
|
-
}
|
|
179
|
-
this._params = this._paramsFromSubforms(this._params);
|
|
180
|
-
this._params.limit = limit;
|
|
181
|
-
this._params.start = page * limit + 1;
|
|
182
|
-
if (this.language) {
|
|
183
|
-
this._params.language = this.language;
|
|
184
|
-
}
|
|
185
|
-
registry.commit(this, this._params);
|
|
186
|
-
|
|
187
|
-
// copy params and remove null values
|
|
188
|
-
const urlParams = Object.assign({}, this._params);
|
|
189
|
-
Object.keys(urlParams).forEach(key => {
|
|
190
|
-
if (urlParams[key] === null) {
|
|
191
|
-
delete urlParams[key];
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
return `${prev}${prev.indexOf('?') > -1 ? '&' : '?'}${new URLSearchParams(urlParams).toString()}`;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
};
|
|
132
|
+
const gridjsTheme = await loadStylesheets([`${resolveURL(this.cssPath)}/mermaid.min.css`]);
|
|
133
|
+
const theme = importStyles(this);
|
|
134
|
+
const sheets = [...this.shadowRoot.adoptedStyleSheets, gridjsTheme];
|
|
135
|
+
if (theme) {
|
|
136
|
+
sheets.push(theme);
|
|
137
|
+
}
|
|
138
|
+
this.shadowRoot.adoptedStyleSheets = sheets;
|
|
139
|
+
}
|
|
199
140
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
141
|
+
firstUpdated() {
|
|
142
|
+
const table = this.shadowRoot.getElementById('table');
|
|
143
|
+
|
|
144
|
+
const pbColumns = this.querySelectorAll('pb-table-column');
|
|
145
|
+
const columns = [];
|
|
146
|
+
pbColumns.forEach(column => columns.push(column.data()));
|
|
147
|
+
waitOnce('pb-page-ready', data => {
|
|
148
|
+
if (data && data.language) {
|
|
149
|
+
this.language = data.language;
|
|
150
|
+
}
|
|
151
|
+
this._params = registry.state;
|
|
152
|
+
const url = this.toAbsoluteURL(this.source);
|
|
153
|
+
const config = {
|
|
154
|
+
height: this.height,
|
|
155
|
+
fixedHeader: true,
|
|
156
|
+
columns,
|
|
157
|
+
resizable: this.resizable,
|
|
158
|
+
server: {
|
|
159
|
+
url,
|
|
160
|
+
then: data => data.results,
|
|
161
|
+
total: data => data.count,
|
|
162
|
+
},
|
|
163
|
+
sort: {
|
|
164
|
+
multiColumn: false,
|
|
165
|
+
enabled: true,
|
|
166
|
+
server: {
|
|
167
|
+
url: (prev, cols) => {
|
|
168
|
+
if (!cols.length) return prev;
|
|
169
|
+
const col = cols[0];
|
|
170
|
+
return `${prev}${prev.indexOf('?') > -1 ? '&' : '?'}order=${
|
|
171
|
+
columns[col.index].id
|
|
172
|
+
}&dir=${col.direction === 1 ? 'asc' : 'desc'}`;
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
pagination: {
|
|
177
|
+
enabled: true,
|
|
178
|
+
limit: this.perPage,
|
|
179
|
+
server: {
|
|
180
|
+
url: (prev, page, limit) => {
|
|
181
|
+
const form = this.shadowRoot.getElementById('form');
|
|
182
|
+
if (form) {
|
|
183
|
+
Object.assign(this._params, form.serializeForm());
|
|
184
|
+
}
|
|
185
|
+
this._params = this._paramsFromSubforms(this._params);
|
|
186
|
+
this._params.limit = limit;
|
|
187
|
+
this._params.start = page * limit + 1;
|
|
188
|
+
if (this.language) {
|
|
189
|
+
this._params.language = this.language;
|
|
190
|
+
}
|
|
191
|
+
registry.commit(this, this._params);
|
|
192
|
+
|
|
193
|
+
// copy params and remove null values
|
|
194
|
+
const urlParams = { ...this._params };
|
|
195
|
+
Object.keys(urlParams).forEach(key => {
|
|
196
|
+
if (urlParams[key] === null) {
|
|
197
|
+
delete urlParams[key];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return `${prev}${prev.indexOf('?') > -1 ? '&' : '?'}${new URLSearchParams(
|
|
201
|
+
urlParams,
|
|
202
|
+
).toString()}`;
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
};
|
|
206
207
|
|
|
207
|
-
|
|
208
|
+
this.grid = new Grid(config);
|
|
209
|
+
this.grid.on('load', () => {
|
|
210
|
+
this.emitTo('pb-results-received', {
|
|
211
|
+
params: this._params,
|
|
208
212
|
});
|
|
209
|
-
|
|
213
|
+
});
|
|
210
214
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
this.grid.render(table);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
214
218
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
_submit() {
|
|
220
|
+
this.grid.forceRender();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
_paramsFromSubforms(params) {
|
|
224
|
+
if (this.subforms) {
|
|
225
|
+
document.querySelectorAll(this.subforms).forEach(form => {
|
|
226
|
+
if (form.serializeForm) {
|
|
227
|
+
Object.assign(params, form.serializeForm());
|
|
222
228
|
}
|
|
223
|
-
|
|
229
|
+
});
|
|
224
230
|
}
|
|
231
|
+
return params;
|
|
232
|
+
}
|
|
225
233
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
234
|
+
render() {
|
|
235
|
+
return html`
|
|
236
|
+
${this.search
|
|
237
|
+
? html`
|
|
238
|
+
<iron-form id="form">
|
|
239
|
+
<form action="">
|
|
240
|
+
<paper-input
|
|
241
|
+
id="search"
|
|
242
|
+
name="search"
|
|
243
|
+
label="Search"
|
|
244
|
+
value="${this._params.search || ''}"
|
|
245
|
+
@keyup="${e => (e.keyCode == 13 ? this._submit() : null)}"
|
|
246
|
+
>
|
|
247
|
+
<paper-icon-button
|
|
248
|
+
icon="search"
|
|
249
|
+
@click="${this._submit}"
|
|
250
|
+
slot="suffix"
|
|
251
|
+
></paper-icon-button>
|
|
252
|
+
</paper-input>
|
|
253
|
+
</form>
|
|
254
|
+
</iron-form>
|
|
255
|
+
`
|
|
256
|
+
: null}
|
|
257
|
+
<div id="table"></div>
|
|
258
|
+
`;
|
|
259
|
+
}
|
|
242
260
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
261
|
+
static get styles() {
|
|
262
|
+
return css`
|
|
263
|
+
:host {
|
|
264
|
+
display: block;
|
|
265
|
+
}
|
|
266
|
+
button {
|
|
267
|
+
border: 0;
|
|
268
|
+
}
|
|
269
|
+
`;
|
|
270
|
+
}
|
|
253
271
|
}
|
|
254
|
-
customElements.define('pb-table-grid', PbTableGrid);
|
|
272
|
+
customElements.define('pb-table-grid', PbTableGrid);
|