@teipublisher/pb-components 1.44.1 → 2.0.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.
- package/CHANGELOG.md +67 -0
- package/dist/demo/demos.json +2 -1
- package/dist/demo/pb-browse-docs.html +2 -1
- package/dist/demo/pb-combo-box.html +1 -1
- package/dist/demo/pb-document.html +2 -2
- package/dist/demo/pb-load.html +2 -2
- package/dist/demo/pb-select-feature.html +1 -1
- package/dist/demo/pb-select-feature2.html +10 -3
- package/dist/demo/pb-select-feature3.html +1 -1
- package/dist/demo/pb-select-odd.html +1 -1
- package/dist/demo/pb-table-grid.html +1 -1
- package/dist/demo/pb-tabs.html +8 -2
- package/dist/demo/pb-toggle-feature.html +2 -2
- package/dist/demo/pb-toggle-feature2.html +2 -2
- package/dist/demo/pb-toggle-feature3.html +2 -2
- package/dist/demo/pb-view.html +1 -1
- package/dist/demo/pb-view4.html +86 -0
- package/dist/pb-code-editor.js +1 -1
- package/dist/pb-component-docs.js +33 -33
- package/dist/pb-components-bundle.js +173 -173
- package/dist/pb-edit-app.js +6 -6
- package/dist/pb-elements.json +94 -28
- package/dist/{pb-i18n-3963b098.js → pb-i18n-8a90c591.js} +1 -1
- package/dist/pb-leaflet-map.js +1 -1
- package/dist/pb-mixin-8a593923.js +158 -0
- package/dist/pb-odd-editor.js +47 -47
- package/dist/{vaadin-element-mixin-08cf11b5.js → vaadin-element-mixin-672938e3.js} +18 -18
- package/i18n/common/en.json +9 -1
- package/package.json +5 -4
- package/pb-elements.json +94 -28
- package/src/dts-client.js +14 -14
- package/src/dts-select-endpoint.js +5 -5
- package/src/pb-ajax.js +4 -4
- package/src/pb-authority-lookup.js +2 -2
- package/src/pb-autocomplete.js +9 -11
- package/src/pb-blacklab-highlight.js +3 -3
- package/src/pb-browse-docs.js +44 -27
- package/src/pb-browse.js +9 -3
- package/src/pb-combo-box.js +2 -2
- package/src/pb-document.js +15 -1
- package/src/pb-download.js +2 -2
- package/src/pb-edit-app.js +2 -2
- package/src/pb-edit-xml.js +2 -2
- package/src/pb-events.js +26 -18
- package/src/pb-facsimile.js +28 -4
- package/src/pb-grid.js +55 -53
- package/src/pb-lang.js +2 -2
- package/src/pb-link.js +10 -16
- package/src/pb-load.js +35 -25
- package/src/pb-login.js +2 -2
- package/src/pb-manage-odds.js +2 -2
- package/src/pb-markdown.js +2 -2
- package/src/pb-mei.js +2 -2
- package/src/pb-mixin.js +103 -196
- package/src/pb-odd-editor.js +2 -2
- package/src/pb-page.js +30 -21
- package/src/pb-paginate.js +24 -19
- package/src/pb-print-preview.js +2 -2
- package/src/pb-repeat.js +2 -1
- package/src/pb-search.js +34 -8
- package/src/pb-select-feature.js +62 -39
- package/src/pb-select-odd.js +8 -7
- package/src/pb-select-template.js +5 -4
- package/src/pb-select.js +31 -28
- package/src/pb-split-list.js +18 -11
- package/src/pb-table-grid.js +9 -8
- package/src/pb-tabs.js +29 -12
- package/src/pb-toggle-feature.js +51 -55
- package/src/pb-upload.js +10 -3
- package/src/pb-view.js +118 -95
- package/src/theming.js +148 -149
- package/src/urls.js +233 -0
- package/dist/pb-mixin-88125cb2.js +0 -158
package/src/pb-search.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
|
+
import { registry } from "./urls.js";
|
|
3
4
|
import { translate } from "./pb-i18n.js";
|
|
4
5
|
import '@polymer/paper-input/paper-input.js';
|
|
5
6
|
import '@polymer/paper-checkbox';
|
|
@@ -31,9 +32,15 @@ export class PbSearch extends pbMixin(LitElement) {
|
|
|
31
32
|
action: {
|
|
32
33
|
type: String
|
|
33
34
|
},
|
|
35
|
+
name: {
|
|
36
|
+
type: String
|
|
37
|
+
},
|
|
34
38
|
value: {
|
|
35
39
|
type: String
|
|
36
40
|
},
|
|
41
|
+
start: {
|
|
42
|
+
type: Number
|
|
43
|
+
},
|
|
37
44
|
placeHolder: {
|
|
38
45
|
type: String,
|
|
39
46
|
attribute: 'place-holder'
|
|
@@ -61,17 +68,34 @@ export class PbSearch extends pbMixin(LitElement) {
|
|
|
61
68
|
|
|
62
69
|
constructor() {
|
|
63
70
|
super();
|
|
71
|
+
this.name = 'query';
|
|
64
72
|
this.value = '';
|
|
65
73
|
this.redirect = false;
|
|
66
74
|
this.submitOnLoad = false;
|
|
67
75
|
this.placeHolder = 'search.placeholder';
|
|
68
76
|
this.disableAutocomplete = false;
|
|
77
|
+
this.start = 1;
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
connectedCallback() {
|
|
72
81
|
super.connectedCallback();
|
|
73
82
|
|
|
74
83
|
this.subscribeTo('pb-search-resubmit', this._doSearch.bind(this));
|
|
84
|
+
this.subscribeTo('pb-paginate', (ev) => {
|
|
85
|
+
this.start = ev.detail.params.start;
|
|
86
|
+
this._doSearch(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
registry.subscribe(this, (state) => {
|
|
90
|
+
this.value = state.query || '';
|
|
91
|
+
this.start = state.start || 1;
|
|
92
|
+
if (this.submitOnLoad) {
|
|
93
|
+
this.emitTo('pb-load', {
|
|
94
|
+
"url": this.action,
|
|
95
|
+
"params": state
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
75
99
|
}
|
|
76
100
|
|
|
77
101
|
firstUpdated() {
|
|
@@ -83,7 +107,7 @@ export class PbSearch extends pbMixin(LitElement) {
|
|
|
83
107
|
ironform.addEventListener('iron-form-response', (event) =>
|
|
84
108
|
event.detail.completes.then((r) => this.emitTo('pb-search', r.parseResponse()))
|
|
85
109
|
);
|
|
86
|
-
|
|
110
|
+
waitOnce('pb-page-ready', (options) => {
|
|
87
111
|
const loader = this.shadowRoot.getElementById('autocompleteLoader');
|
|
88
112
|
if (this.minApiVersion('1.0.0')) {
|
|
89
113
|
loader.url = `${options.endpoint}/api/search/autocomplete`;
|
|
@@ -93,7 +117,8 @@ export class PbSearch extends pbMixin(LitElement) {
|
|
|
93
117
|
});
|
|
94
118
|
|
|
95
119
|
if (this.submitOnLoad) {
|
|
96
|
-
const params =
|
|
120
|
+
const params = registry.state;
|
|
121
|
+
registry.replace(this, params);
|
|
97
122
|
this.emitTo('pb-load', {
|
|
98
123
|
"url": this.action,
|
|
99
124
|
"params": params
|
|
@@ -170,16 +195,17 @@ export class PbSearch extends pbMixin(LitElement) {
|
|
|
170
195
|
`;
|
|
171
196
|
}
|
|
172
197
|
|
|
173
|
-
_doSearch() {
|
|
198
|
+
_doSearch(pagination = false) {
|
|
174
199
|
let json = this.shadowRoot.getElementById('ironform').serializeForm();
|
|
175
200
|
json = this._paramsFromSubforms(json);
|
|
201
|
+
// remove unnecessary param added by autocomplete
|
|
202
|
+
delete json['autocomplete-custom-template'];
|
|
203
|
+
// always start on first result after submitting new search
|
|
204
|
+
json.start = pagination ? this.start : 1;
|
|
176
205
|
if (this.redirect) {
|
|
177
206
|
window.location.href = `${this.action}?${new URLSearchParams(json)}`;
|
|
178
207
|
} else {
|
|
179
|
-
|
|
180
|
-
this.pushHistory('search');
|
|
181
|
-
// always start on first result after submitting new search
|
|
182
|
-
json.start = 1;
|
|
208
|
+
registry.commit(this, json);
|
|
183
209
|
this.emitTo('pb-load', {
|
|
184
210
|
"url": this.action,
|
|
185
211
|
"params": json
|
package/src/pb-select-feature.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
3
|
import { translate } from "./pb-i18n.js";
|
|
4
4
|
import '@polymer/paper-dropdown-menu/paper-dropdown-menu.js';
|
|
5
5
|
import '@polymer/paper-listbox';
|
|
6
6
|
import '@polymer/paper-item';
|
|
7
|
+
import { registry } from './urls.js';
|
|
8
|
+
import { addSelector } from "./pb-toggle-feature.js";
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Similar to `pb-toggle-feature` but allows you to choose from a list of defined states instead of a simple
|
|
@@ -33,10 +35,13 @@ import '@polymer/paper-item';
|
|
|
33
35
|
* ```
|
|
34
36
|
*
|
|
35
37
|
* Each item in the `selectors` property above defines either a state or a command. *state* will simply add
|
|
36
|
-
* a css class `.
|
|
38
|
+
* a css class `.toggle` to the target element when true. If *command* is set to 'disable', it will entirely disable
|
|
37
39
|
* the functionality of selected elements - provided that they are
|
|
38
40
|
* publisher components implementing the corresponding `command` method of `pb-mixin`.
|
|
39
41
|
*
|
|
42
|
+
* Client-side you may also pass an optional property `"global": true` to toggle the state of elements which reside
|
|
43
|
+
* in the surrounding HTML context below `pb-page` (means: elements which are not inside a `pb-view` or `pb-load`).
|
|
44
|
+
*
|
|
40
45
|
* @fires pb-toggle - Fired when a feature is selected from the dropdown and sends the selected properties
|
|
41
46
|
*/
|
|
42
47
|
export class PbSelectFeature extends pbMixin(LitElement) {
|
|
@@ -74,17 +79,31 @@ export class PbSelectFeature extends pbMixin(LitElement) {
|
|
|
74
79
|
|
|
75
80
|
connectedCallback() {
|
|
76
81
|
super.connectedCallback();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
|
|
83
|
+
waitOnce('pb-page-ready', () => {
|
|
84
|
+
registry.subscribe(this, (state) => {
|
|
85
|
+
const param = state[this.name];
|
|
86
|
+
if (typeof param !== 'undefined') {
|
|
87
|
+
this.selected = parseInt(param, 10);
|
|
88
|
+
} else {
|
|
89
|
+
this.selected = 0;
|
|
90
|
+
}
|
|
91
|
+
this.shadowRoot.getElementById('list').selected = this.selected;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const param = registry.state[this.name];
|
|
95
|
+
if (typeof param !== 'undefined') {
|
|
96
|
+
this.selected = parseInt(param, 10);
|
|
97
|
+
} else if (this.items.length > 0) {
|
|
98
|
+
this.selected = 0;
|
|
86
99
|
}
|
|
87
|
-
|
|
100
|
+
|
|
101
|
+
this.shadowRoot.getElementById('list').selected = this.selected;
|
|
102
|
+
|
|
103
|
+
const newState = {};
|
|
104
|
+
newState[this.name] = this.selected;
|
|
105
|
+
registry.replace(this, newState);
|
|
106
|
+
|
|
88
107
|
this.signalReady();
|
|
89
108
|
});
|
|
90
109
|
}
|
|
@@ -92,43 +111,47 @@ export class PbSelectFeature extends pbMixin(LitElement) {
|
|
|
92
111
|
firstUpdated() {
|
|
93
112
|
super.firstUpdated();
|
|
94
113
|
|
|
95
|
-
this.shadowRoot.getElementById('menu').addEventListener('
|
|
114
|
+
this.shadowRoot.getElementById('menu').addEventListener('iron-select', this._selectionChanged.bind(this));
|
|
96
115
|
}
|
|
97
116
|
|
|
98
|
-
// updated(changedProperties) {
|
|
99
|
-
// super.updated();
|
|
100
|
-
// if (changedProperties.has('items')) {
|
|
101
|
-
// const current = this.shadowRoot.getElementById('list').selectedItem;
|
|
102
|
-
// if (!current && this.items.length > 0) {
|
|
103
|
-
// this.selected = 0;
|
|
104
|
-
// this._emit('refresh');
|
|
105
|
-
// }
|
|
106
|
-
// console.log('selected: %o', this.selected);
|
|
107
|
-
// }
|
|
108
|
-
// }
|
|
109
|
-
|
|
110
117
|
_selectionChanged() {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
const refresh = this._saveState();
|
|
119
|
+
if (this.initializing) {
|
|
120
|
+
this.initializing = false;
|
|
121
|
+
} else {
|
|
122
|
+
this.emitTo('pb-toggle', { refresh });
|
|
123
|
+
}
|
|
116
124
|
}
|
|
117
125
|
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
_saveState() {
|
|
127
|
+
const current = this.shadowRoot.getElementById('list').selected;
|
|
128
|
+
|
|
129
|
+
const state = registry.getState(this);
|
|
130
|
+
state[this.name] = current;
|
|
131
|
+
Object.assign(state, this.items[current].properties);
|
|
132
|
+
if (this.items[current].selectors) {
|
|
133
|
+
if (!state.selectors) {
|
|
134
|
+
state.selectors = [];
|
|
135
|
+
}
|
|
136
|
+
this.items[current].selectors.forEach((config) => {
|
|
137
|
+
if (config.global) {
|
|
138
|
+
this.dispatchEvent(new CustomEvent('pb-global-toggle', { detail: config, bubbles: true, composed: true }));
|
|
139
|
+
} else {
|
|
140
|
+
addSelector({
|
|
141
|
+
selector: config.selector,
|
|
142
|
+
state: config.state,
|
|
143
|
+
command: config.command
|
|
144
|
+
}, state.selectors);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return this.items[current].properties instanceof Object
|
|
126
149
|
}
|
|
127
150
|
|
|
128
151
|
render() {
|
|
129
152
|
return html`
|
|
130
153
|
<paper-dropdown-menu id="menu" label="${translate(this.label)}" .disabled="${this.disabled}">
|
|
131
|
-
<paper-listbox id="list" slot="dropdown-content" selected="${this.selected}">
|
|
154
|
+
<paper-listbox id="list" slot="dropdown-content" .selected="${this.selected}">
|
|
132
155
|
${this.items.map((item) => html`<paper-item>${item.name}</paper-item>`)}
|
|
133
156
|
</paper-listbox>
|
|
134
157
|
</paper-dropdown-menu>
|
package/src/pb-select-odd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
3
|
import { translate } from './pb-i18n.js';
|
|
4
4
|
import "@polymer/paper-listbox";
|
|
5
5
|
import "@polymer/paper-item";
|
|
@@ -7,6 +7,7 @@ import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js";
|
|
|
7
7
|
import "@polymer/iron-ajax";
|
|
8
8
|
import "web-animations-js";
|
|
9
9
|
import "@polymer/neon-animation";
|
|
10
|
+
import {registry} from "./urls.js";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* `pb-select-odd`: Switch between available ODDs.
|
|
@@ -15,7 +16,7 @@ import "@polymer/neon-animation";
|
|
|
15
16
|
*
|
|
16
17
|
* @fires pb-refresh - Fires a refresh event to subscribed views after a different ODD has been selected for display.
|
|
17
18
|
* @fires pb-update - When received, resets the ODD selected to the one passed in the event
|
|
18
|
-
*
|
|
19
|
+
*
|
|
19
20
|
*/
|
|
20
21
|
export class PbSelectOdd extends pbMixin(LitElement) {
|
|
21
22
|
static get properties() {
|
|
@@ -58,7 +59,7 @@ export class PbSelectOdd extends pbMixin(LitElement) {
|
|
|
58
59
|
|
|
59
60
|
firstUpdated() {
|
|
60
61
|
super.firstUpdated();
|
|
61
|
-
|
|
62
|
+
waitOnce('pb-page-ready', () => {
|
|
62
63
|
this._refresh();
|
|
63
64
|
});
|
|
64
65
|
}
|
|
@@ -66,7 +67,7 @@ export class PbSelectOdd extends pbMixin(LitElement) {
|
|
|
66
67
|
render() {
|
|
67
68
|
return html`
|
|
68
69
|
<paper-dropdown-menu id="menu" label="${translate(this.label)}" name="${this.name}">
|
|
69
|
-
<paper-listbox id="odds" slot="dropdown-content" class="dropdown-content" selected="${this.odd}"
|
|
70
|
+
<paper-listbox id="odds" slot="dropdown-content" class="dropdown-content" selected="${this.odd}"
|
|
70
71
|
attr-for-selected="value" @selected-item-changed="${this._selected}">
|
|
71
72
|
${this.odds.map((item) => html`<paper-item value="${item.name}">${item.label}</paper-item>`)}
|
|
72
73
|
</paper-listbox>
|
|
@@ -106,8 +107,8 @@ export class PbSelectOdd extends pbMixin(LitElement) {
|
|
|
106
107
|
if (doc) {
|
|
107
108
|
doc.odd = this.odd;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
registry.commit(this,{odd: this.odd});
|
|
111
|
+
|
|
111
112
|
this.emitTo('pb-refresh', {
|
|
112
113
|
odd: this.odd
|
|
113
114
|
});
|
|
@@ -141,4 +142,4 @@ export class PbSelectOdd extends pbMixin(LitElement) {
|
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
}
|
|
144
|
-
customElements.define('pb-select-odd', PbSelectOdd);
|
|
145
|
+
customElements.define('pb-select-odd', PbSelectOdd);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
3
|
import { translate } from './pb-i18n.js';
|
|
4
|
+
import { registry } from './urls.js';
|
|
5
|
+
|
|
4
6
|
import "@polymer/paper-listbox";
|
|
5
7
|
import "@polymer/paper-item";
|
|
6
8
|
import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js";
|
|
@@ -40,7 +42,7 @@ export class PbSelectTemplate extends pbMixin(LitElement) {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
firstUpdated() {
|
|
43
|
-
|
|
45
|
+
waitOnce('pb-page-ready', (options) => {
|
|
44
46
|
this.template = options.template;
|
|
45
47
|
const loader = this.shadowRoot.getElementById('getTemplates');
|
|
46
48
|
if (this.minApiVersion('1.0.0')) {
|
|
@@ -86,8 +88,7 @@ export class PbSelectTemplate extends pbMixin(LitElement) {
|
|
|
86
88
|
if (newTemplate === this.template) {
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
89
|
-
|
|
90
|
-
window.location = this.getUrl().toString();
|
|
91
|
+
registry.commit(this, { template: newTemplate });
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
_handleTemplatesResponse() {
|
package/src/pb-select.js
CHANGED
|
@@ -4,7 +4,7 @@ import "@polymer/paper-listbox";
|
|
|
4
4
|
import "@polymer/paper-item";
|
|
5
5
|
import "@polymer/iron-label/iron-label.js";
|
|
6
6
|
import { translate } from "./pb-i18n.js";
|
|
7
|
-
import { pbMixin } from './pb-mixin.js';
|
|
7
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -108,7 +108,7 @@ export class PbSelect extends pbMixin(LitElement) {
|
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
waitOnce('pb-page-ready', () => {
|
|
112
112
|
this._loadRemote();
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -134,33 +134,36 @@ export class PbSelect extends pbMixin(LitElement) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
_loadRemote() {
|
|
137
|
-
if (this.source) {
|
|
138
|
-
|
|
139
|
-
if (url.indexOf('?') > -1) {
|
|
140
|
-
url = `${url}&${this._getParameters()}`;
|
|
141
|
-
} else {
|
|
142
|
-
url = `${url}?${this._getParameters()}`;
|
|
143
|
-
}
|
|
144
|
-
console.log('<pb-select> loading items from %s', url);
|
|
145
|
-
fetch(url, {
|
|
146
|
-
method: 'GET',
|
|
147
|
-
mode: 'cors',
|
|
148
|
-
credentials: 'same-origin'
|
|
149
|
-
})
|
|
150
|
-
.then((response) => response.json())
|
|
151
|
-
.then((json) => {
|
|
152
|
-
this._clear('slot:not([name])');
|
|
153
|
-
const items = [];
|
|
154
|
-
json.forEach((item) => {
|
|
155
|
-
items.push({label: item.text, value: item.value});
|
|
156
|
-
});
|
|
157
|
-
console.log('<pb-select> loaded %d items', items.length);
|
|
158
|
-
this._items = items;
|
|
159
|
-
})
|
|
160
|
-
.catch(() => {
|
|
161
|
-
console.error('<pb-select> request to %s failed', url);
|
|
162
|
-
});
|
|
137
|
+
if (!this.source) {
|
|
138
|
+
return // nothing to do
|
|
163
139
|
}
|
|
140
|
+
|
|
141
|
+
let url = this.toAbsoluteURL(this.source);
|
|
142
|
+
url += url.includes('?') ? '&' : '?';
|
|
143
|
+
url += this._getParameters();
|
|
144
|
+
|
|
145
|
+
console.log('<pb-select> loading items from %s', url);
|
|
146
|
+
|
|
147
|
+
fetch(url, {
|
|
148
|
+
method: 'GET',
|
|
149
|
+
mode: 'cors',
|
|
150
|
+
credentials: 'same-origin'
|
|
151
|
+
})
|
|
152
|
+
.then((response) => response.json())
|
|
153
|
+
.then((json) => {
|
|
154
|
+
this._clear('slot:not([name])');
|
|
155
|
+
const items = json.map(PbSelect.jsonEntry2item);
|
|
156
|
+
console.log('<pb-select> loaded %d items', items.length);
|
|
157
|
+
this._items = items;
|
|
158
|
+
})
|
|
159
|
+
.catch(() => console.error('<pb-select> request to %s failed', url));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static jsonEntry2item (item) {
|
|
163
|
+
return {
|
|
164
|
+
label: item.text,
|
|
165
|
+
value: item.value
|
|
166
|
+
};
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
_getParameters() {
|
package/src/pb-split-list.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import {
|
|
3
|
-
import { pbMixin } from './pb-mixin.js';
|
|
2
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
4
3
|
import { themableMixin } from "./theming.js";
|
|
4
|
+
import { registry } from "./urls.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Implements a list which is split into different categories
|
|
@@ -98,17 +98,20 @@ export class PbSplitList extends themableMixin(pbMixin(LitElement)) {
|
|
|
98
98
|
this._params = {};
|
|
99
99
|
this.selected = null;
|
|
100
100
|
this.subforms = null;
|
|
101
|
+
this._initialized = false;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
connectedCallback() {
|
|
104
105
|
super.connectedCallback();
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
waitOnce('pb-page-ready', () => {
|
|
108
|
+
this.selected = registry.state.category || this.selected;
|
|
109
|
+
|
|
110
|
+
registry.subscribe(this, (state) => {
|
|
111
|
+
console.log('<pb-split-list> popstate: %o', state);
|
|
112
|
+
this.selected = state.category;
|
|
113
|
+
this.submit();
|
|
114
|
+
});
|
|
112
115
|
});
|
|
113
116
|
|
|
114
117
|
this.subscribeTo('pb-submit', this.load.bind(this));
|
|
@@ -117,7 +120,7 @@ export class PbSplitList extends themableMixin(pbMixin(LitElement)) {
|
|
|
117
120
|
firstUpdated() {
|
|
118
121
|
super.firstUpdated();
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
waitOnce('pb-page-ready', () => {
|
|
121
124
|
this.load();
|
|
122
125
|
});
|
|
123
126
|
}
|
|
@@ -128,8 +131,12 @@ export class PbSplitList extends themableMixin(pbMixin(LitElement)) {
|
|
|
128
131
|
|
|
129
132
|
load() {
|
|
130
133
|
const formParams = this._paramsFromSubforms({ category: this.selected });
|
|
131
|
-
this.
|
|
132
|
-
|
|
134
|
+
if (!this._initialized) {
|
|
135
|
+
registry.replace(this, formParams);
|
|
136
|
+
} else {
|
|
137
|
+
registry.commit(this, formParams);
|
|
138
|
+
}
|
|
139
|
+
this._initialized = true;
|
|
133
140
|
|
|
134
141
|
const params = new URLSearchParams(formParams);
|
|
135
142
|
|
package/src/pb-table-grid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { Grid } from "gridjs";
|
|
3
|
-
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
4
4
|
import { resolveURL } from './utils.js';
|
|
5
5
|
import { loadStylesheets, importStyles } from "./theming.js";
|
|
6
6
|
import '@polymer/paper-input/paper-input';
|
|
@@ -8,6 +8,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 "./urls.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* A table grid based on [gridjs](https://gridjs.io/), which loads its data from a server endpoint
|
|
@@ -100,10 +101,10 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
100
101
|
this._submit();
|
|
101
102
|
});
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
this._params =
|
|
104
|
+
registry.subscribe(this, (state) => {
|
|
105
|
+
this._params = state;
|
|
105
106
|
this._submit();
|
|
106
|
-
})
|
|
107
|
+
})
|
|
107
108
|
|
|
108
109
|
if (!this.height) {
|
|
109
110
|
const property = getComputedStyle(this).getPropertyValue('--pb-table-grid-height');
|
|
@@ -129,8 +130,8 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
129
130
|
const pbColumns = this.querySelectorAll('pb-table-column');
|
|
130
131
|
const columns = [];
|
|
131
132
|
pbColumns.forEach((column) => columns.push(column.data()));
|
|
132
|
-
|
|
133
|
-
this._params =
|
|
133
|
+
waitOnce('pb-page-ready', () => {
|
|
134
|
+
this._params = registry.state;
|
|
134
135
|
const url = this.toAbsoluteURL(this.source);
|
|
135
136
|
const config = {
|
|
136
137
|
height: this.height,
|
|
@@ -164,8 +165,8 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
164
165
|
}
|
|
165
166
|
this._params.limit = limit;
|
|
166
167
|
this._params.start = page * limit + 1;
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
|
|
169
|
+
registry.commit(this, this._params);
|
|
169
170
|
|
|
170
171
|
return `${prev}${prev.indexOf('?') > -1 ? '&' : '?'}${new URLSearchParams(this._params).toString()}`;
|
|
171
172
|
}
|
package/src/pb-tabs.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import '@polymer/paper-tabs';
|
|
3
3
|
import '@polymer/iron-pages';
|
|
4
|
-
import { pbMixin } from './pb-mixin.js';
|
|
4
|
+
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
5
|
+
import { registry } from "./urls.js";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -18,9 +19,6 @@ export class PbTabs extends pbMixin(LitElement) {
|
|
|
18
19
|
selected: {
|
|
19
20
|
type: Number,
|
|
20
21
|
reflect: true
|
|
21
|
-
},
|
|
22
|
-
_initial: {
|
|
23
|
-
type: Number
|
|
24
22
|
}
|
|
25
23
|
};
|
|
26
24
|
}
|
|
@@ -28,21 +26,40 @@ export class PbTabs extends pbMixin(LitElement) {
|
|
|
28
26
|
constructor() {
|
|
29
27
|
super();
|
|
30
28
|
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
29
|
+
this.selected = 0;
|
|
30
|
+
this._initialized = false;
|
|
33
31
|
}
|
|
32
|
+
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
super.connectedCallback();
|
|
35
|
+
|
|
36
|
+
waitOnce('pb-page-ready', () => {
|
|
37
|
+
this.selected = registry.state.tab || 0;
|
|
38
|
+
|
|
39
|
+
registry.subscribe(this, (state) => {
|
|
40
|
+
this.selected = state.tab;
|
|
41
|
+
});
|
|
34
42
|
|
|
35
|
-
_switchTab(ev) {
|
|
36
|
-
this.selected = ev.detail.value;
|
|
37
|
-
this.setParameter('tab', this.selected);
|
|
38
|
-
this.pushHistory('browse', {
|
|
39
|
-
tab: this.selected
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
|
|
46
|
+
_switchTab(ev) {
|
|
47
|
+
const current = parseInt(ev.detail.value, 10);
|
|
48
|
+
if (this.selected === current) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.selected = current;
|
|
52
|
+
if (this._initialized) {
|
|
53
|
+
registry.commit(this, { tab: this.selected });
|
|
54
|
+
} else {
|
|
55
|
+
registry.replace(this, { tab: this.selected });
|
|
56
|
+
}
|
|
57
|
+
this._initialized = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
43
60
|
render() {
|
|
44
61
|
return html`
|
|
45
|
-
<paper-tabs id="tabs" selected="${this.
|
|
62
|
+
<paper-tabs id="tabs" selected="${this.selected || 0 }" @selected-changed="${this._switchTab}">
|
|
46
63
|
<slot name="tab"></slot>
|
|
47
64
|
</paper-tabs>
|
|
48
65
|
<iron-pages part="pages" selected="${this.selected}">
|