@teipublisher/pb-components 2.26.0-next-3.11 → 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 +38 -0
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/dist/demo/components.css +2 -8
- 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-6633322b.js → vaadin-element-mixin-84fb7d82.js} +181 -143
- 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 +96 -60
- 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-select-feature.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
|
-
import { translate } from
|
|
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
7
|
import { registry } from './urls.js';
|
|
8
|
-
import { addSelector } from
|
|
8
|
+
import { addSelector } from './pb-toggle-feature.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Similar to `pb-toggle-feature` but allows you to choose from a list of defined states instead of a simple
|
|
12
|
-
* on/off toggle. Like `pb-toggle-feature` it can change state server-side as well as client-side.
|
|
13
|
-
*
|
|
12
|
+
* on/off toggle. Like `pb-toggle-feature` it can change state server-side as well as client-side.
|
|
13
|
+
*
|
|
14
14
|
* The list of states is passed as a JSON array to property `items`:
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* # Server-side
|
|
17
|
-
*
|
|
17
|
+
*
|
|
18
18
|
* Properties to be passed to the server are specified as follows:
|
|
19
|
-
*
|
|
19
|
+
*
|
|
20
20
|
* ```javascript
|
|
21
21
|
* [
|
|
22
22
|
* {"name": "Diplomatic View", "properties": {"mode": "diplomatic", "view": "page"}},
|
|
23
23
|
* {"name": "Normalized View", "properties": {"mode": "norm", "view": "single"}}
|
|
24
24
|
* ]
|
|
25
25
|
* ```
|
|
26
|
-
*
|
|
26
|
+
*
|
|
27
27
|
* If the `name` property references the path to a translated label, the translation will be used instead.
|
|
28
28
|
* # Client-side
|
|
29
|
-
*
|
|
29
|
+
*
|
|
30
30
|
* ```javascript
|
|
31
31
|
* [
|
|
32
32
|
* {"name": "Diplomatic View", "selectors": [{"selector": ".choice,.choice-alternate,br", "state": false},{"selector": ".tei-foreign,pb-highlight,pb-popover", "command": "disable"}]},
|
|
@@ -34,141 +34,148 @@ import { addSelector } from "./pb-toggle-feature.js";
|
|
|
34
34
|
* {"name": "Plain Reading View", "selectors": [{"selector": ".choice,.choice-alternate,br", "state": true}, {"selector": ".tei-foreign,pb-highlight,pb-popover", "command": "disable", "state": true}]}
|
|
35
35
|
* ]
|
|
36
36
|
* ```
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* Each item in the `selectors` property above defines either a state or a command. *state* will simply add
|
|
39
39
|
* a css class `.toggle` to the target element when true. If *command* is set to 'disable', it will entirely disable
|
|
40
40
|
* the functionality of selected elements - provided that they are
|
|
41
41
|
* publisher components implementing the corresponding `command` method of `pb-mixin`.
|
|
42
|
-
*
|
|
42
|
+
*
|
|
43
43
|
* Client-side you may also pass an optional property `"global": true` to toggle the state of elements which reside
|
|
44
44
|
* in the surrounding HTML context below `pb-page` (means: elements which are not inside a `pb-view` or `pb-load`).
|
|
45
|
-
*
|
|
45
|
+
*
|
|
46
46
|
* @fires pb-toggle - Fired when a feature is selected from the dropdown and sends the selected properties
|
|
47
47
|
*/
|
|
48
48
|
export class PbSelectFeature extends pbMixin(LitElement) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
static get properties() {
|
|
50
|
+
return {
|
|
51
|
+
...super.properties,
|
|
52
|
+
/**
|
|
53
|
+
* The name of the feature (required). This will correspond to the name of the custom parameter
|
|
54
|
+
* passed to the ODD.
|
|
55
|
+
*/
|
|
56
|
+
name: {
|
|
57
|
+
type: String,
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* The label to display on top of the drop down
|
|
61
|
+
*/
|
|
62
|
+
label: {
|
|
63
|
+
type: String,
|
|
64
|
+
},
|
|
65
|
+
selected: {
|
|
66
|
+
type: Number,
|
|
67
|
+
},
|
|
68
|
+
items: {
|
|
69
|
+
type: Array,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
constructor() {
|
|
75
|
+
super();
|
|
76
|
+
this.initializing = true;
|
|
77
|
+
this.items = [];
|
|
78
|
+
this.label = 'document.selectFeature';
|
|
79
|
+
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
connectedCallback() {
|
|
82
|
+
super.connectedCallback();
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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;
|
|
99
|
+
}
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
const newState = {};
|
|
102
|
+
newState[this.name] = this.selected;
|
|
103
|
+
registry.replace(this, newState);
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
this.signalReady();
|
|
106
|
+
}
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
firstUpdated() {
|
|
109
|
+
super.firstUpdated();
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
this.shadowRoot.getElementById('list').selected = this.selected;
|
|
112
|
+
this.shadowRoot
|
|
113
|
+
.getElementById('menu')
|
|
114
|
+
.addEventListener('iron-select', this._selectionChanged.bind(this));
|
|
115
|
+
}
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
117
|
+
_selectionChanged() {
|
|
118
|
+
const refresh = this._saveState();
|
|
119
|
+
if (this.initializing) {
|
|
120
|
+
this.initializing = false;
|
|
121
|
+
} else {
|
|
122
|
+
this.emitTo('pb-toggle', { refresh });
|
|
122
123
|
}
|
|
124
|
+
}
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
_saveState() {
|
|
127
|
+
const current = this.shadowRoot.getElementById('list').selected;
|
|
126
128
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
+
registry.commit(this, state);
|
|
139
|
+
this.dispatchEvent(
|
|
140
|
+
new CustomEvent('pb-global-toggle', { detail: config, bubbles: true, composed: true }),
|
|
141
|
+
);
|
|
142
|
+
} else {
|
|
143
|
+
addSelector(
|
|
144
|
+
{
|
|
145
|
+
selector: config.selector,
|
|
146
|
+
state: config.state,
|
|
147
|
+
command: config.command,
|
|
148
|
+
},
|
|
149
|
+
state.selectors,
|
|
150
|
+
);
|
|
146
151
|
}
|
|
147
|
-
|
|
152
|
+
});
|
|
148
153
|
}
|
|
154
|
+
return this.items[current].properties instanceof Object;
|
|
155
|
+
}
|
|
149
156
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
render() {
|
|
158
|
+
return html`
|
|
159
|
+
<paper-dropdown-menu id="menu" label="${translate(this.label)}" .disabled="${this.disabled}">
|
|
160
|
+
<paper-listbox id="list" slot="dropdown-content" .selected="${this.selected}">
|
|
161
|
+
${this.items.map(item => html`<paper-item>${translate(item.name)}</paper-item>`)}
|
|
162
|
+
</paper-listbox>
|
|
163
|
+
</paper-dropdown-menu>
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
159
166
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
167
|
+
static get styles() {
|
|
168
|
+
return css`
|
|
169
|
+
:host {
|
|
170
|
+
display: block;
|
|
171
|
+
}
|
|
165
172
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
#menu {
|
|
174
|
+
width: inherit;
|
|
175
|
+
min-width: inherit;
|
|
176
|
+
max-width: inherit;
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
}
|
|
173
180
|
}
|
|
174
|
-
customElements.define('pb-select-feature', PbSelectFeature);
|
|
181
|
+
customElements.define('pb-select-feature', PbSelectFeature);
|
package/src/pb-select-odd.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
3
3
|
import { translate } from './pb-i18n.js';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {registry} from
|
|
4
|
+
import '@polymer/paper-listbox';
|
|
5
|
+
import '@polymer/paper-item';
|
|
6
|
+
import '@polymer/paper-dropdown-menu/paper-dropdown-menu.js';
|
|
7
|
+
import '@polymer/iron-ajax';
|
|
8
|
+
import 'web-animations-js';
|
|
9
|
+
import '@polymer/neon-animation';
|
|
10
|
+
import { registry } from './urls.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* `pb-select-odd`: Switch between available ODDs.
|
|
@@ -19,127 +19,135 @@ import {registry} from "./urls.js";
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
export class PbSelectOdd extends pbMixin(LitElement) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
static get properties() {
|
|
23
|
+
return {
|
|
24
|
+
...super.properties,
|
|
25
|
+
/** The label to show on top of the dropdown menu */
|
|
26
|
+
label: {
|
|
27
|
+
type: String,
|
|
28
|
+
},
|
|
29
|
+
/** The ODDs to show. */
|
|
30
|
+
odds: {
|
|
31
|
+
type: Array,
|
|
32
|
+
},
|
|
33
|
+
name: {
|
|
34
|
+
type: String,
|
|
35
|
+
},
|
|
36
|
+
/** Currently selected ODD. If this property is set, the component
|
|
37
|
+
* will immediately load the list of ODDs from the server and select
|
|
38
|
+
* the given ODD.
|
|
39
|
+
*/
|
|
40
|
+
odd: {
|
|
41
|
+
type: String,
|
|
42
|
+
notify: true,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
|
|
50
|
+
this.label = 'document.selectODD';
|
|
51
|
+
this.odds = [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
connectedCallback() {
|
|
55
|
+
super.connectedCallback();
|
|
56
|
+
|
|
57
|
+
this.subscribeTo('pb-update', this._onTargetUpdate.bind(this));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
firstUpdated() {
|
|
61
|
+
super.firstUpdated();
|
|
62
|
+
waitOnce('pb-page-ready', () => {
|
|
63
|
+
this._refresh();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
render() {
|
|
68
|
+
return html`
|
|
69
|
+
<paper-dropdown-menu id="menu" label="${translate(this.label)}" name="${this.name}">
|
|
70
|
+
<paper-listbox
|
|
71
|
+
id="odds"
|
|
72
|
+
slot="dropdown-content"
|
|
73
|
+
class="dropdown-content"
|
|
74
|
+
selected="${this.odd}"
|
|
75
|
+
attr-for-selected="value"
|
|
76
|
+
@selected-item-changed="${this._selected}"
|
|
77
|
+
>
|
|
78
|
+
${this.odds.map(
|
|
79
|
+
item => html`<paper-item value="${item.name}">${item.label}</paper-item>`,
|
|
80
|
+
)}
|
|
81
|
+
</paper-listbox>
|
|
82
|
+
</paper-dropdown-menu>
|
|
83
|
+
|
|
84
|
+
<iron-ajax
|
|
85
|
+
id="load"
|
|
86
|
+
verbose
|
|
87
|
+
handle-as="json"
|
|
88
|
+
method="get"
|
|
89
|
+
with-credentials
|
|
90
|
+
@response="${this._update}"
|
|
91
|
+
></iron-ajax>
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static get styles() {
|
|
96
|
+
return css`
|
|
97
|
+
:host {
|
|
98
|
+
display: block;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
paper-dropdown-menu {
|
|
102
|
+
--paper-listbox-background-color: white;
|
|
103
|
+
width: 100%;
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_selected() {
|
|
109
|
+
const newOdd = this.shadowRoot.getElementById('odds').selected;
|
|
110
|
+
if (newOdd === this.odd) {
|
|
111
|
+
return;
|
|
45
112
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.odds = [];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
connectedCallback() {
|
|
55
|
-
super.connectedCallback();
|
|
56
|
-
|
|
57
|
-
this.subscribeTo('pb-update', this._onTargetUpdate.bind(this));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
firstUpdated() {
|
|
61
|
-
super.firstUpdated();
|
|
62
|
-
waitOnce('pb-page-ready', () => {
|
|
63
|
-
this._refresh();
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
render() {
|
|
68
|
-
return html`
|
|
69
|
-
<paper-dropdown-menu id="menu" label="${translate(this.label)}" name="${this.name}">
|
|
70
|
-
<paper-listbox id="odds" slot="dropdown-content" class="dropdown-content" selected="${this.odd}"
|
|
71
|
-
attr-for-selected="value" @selected-item-changed="${this._selected}">
|
|
72
|
-
${this.odds.map((item) => html`<paper-item value="${item.name}">${item.label}</paper-item>`)}
|
|
73
|
-
</paper-listbox>
|
|
74
|
-
</paper-dropdown-menu>
|
|
75
|
-
|
|
76
|
-
<iron-ajax
|
|
77
|
-
id="load"
|
|
78
|
-
verbose
|
|
79
|
-
handle-as="json"
|
|
80
|
-
method="get"
|
|
81
|
-
with-credentials
|
|
82
|
-
@response="${this._update}"></iron-ajax>
|
|
83
|
-
`;
|
|
113
|
+
this.odd = newOdd;
|
|
114
|
+
console.log('<pb-select-odd> Switching to ODD %s', this.odd);
|
|
115
|
+
const doc = this.getDocument();
|
|
116
|
+
if (doc) {
|
|
117
|
+
doc.odd = this.odd;
|
|
84
118
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
_selected() {
|
|
100
|
-
const newOdd = this.shadowRoot.getElementById('odds').selected;
|
|
101
|
-
if (newOdd === this.odd) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
this.odd = newOdd;
|
|
105
|
-
console.log('<pb-select-odd> Switching to ODD %s', this.odd);
|
|
106
|
-
const doc = this.getDocument();
|
|
107
|
-
if (doc) {
|
|
108
|
-
doc.odd = this.odd;
|
|
109
|
-
}
|
|
110
|
-
registry.commit(this,{odd: this.odd});
|
|
111
|
-
|
|
112
|
-
this.emitTo('pb-refresh', {
|
|
113
|
-
odd: this.odd
|
|
114
|
-
});
|
|
119
|
+
registry.commit(this, { odd: this.odd });
|
|
120
|
+
|
|
121
|
+
this.emitTo('pb-refresh', {
|
|
122
|
+
odd: this.odd,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_refresh() {
|
|
127
|
+
const load = this.shadowRoot.getElementById('load');
|
|
128
|
+
if (this.minApiVersion('1.0.0')) {
|
|
129
|
+
load.url = `${this.getEndpoint()}/api/odd`;
|
|
130
|
+
} else {
|
|
131
|
+
load.url = `${this.getEndpoint()}/modules/lib/components-list-odds.xql`;
|
|
115
132
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
load.params = { odd: this.odd };
|
|
134
|
+
load.generateRequest();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_update() {
|
|
138
|
+
const load = this.shadowRoot.getElementById('load');
|
|
139
|
+
this.odds = load.lastResponse;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
_onTargetUpdate(ev) {
|
|
143
|
+
let newOdd = ev.detail.data.odd;
|
|
144
|
+
if (newOdd) {
|
|
145
|
+
newOdd = newOdd.replace(/^(.*?)\.[^\.]+$/, '$1');
|
|
126
146
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const load = this.shadowRoot.getElementById('load');
|
|
130
|
-
this.odds = load.lastResponse;
|
|
147
|
+
if (newOdd !== this.odd) {
|
|
148
|
+
console.log('<pb-select-odd> Set current ODD from %s to %s', this.odd, newOdd);
|
|
131
149
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
let newOdd = ev.detail.data.odd;
|
|
135
|
-
if (newOdd) {
|
|
136
|
-
newOdd = newOdd.replace(/^(.*?)\.[^\.]+$/, '$1');
|
|
137
|
-
}
|
|
138
|
-
if (newOdd !== this.odd) {
|
|
139
|
-
console.log('<pb-select-odd> Set current ODD from %s to %s', this.odd, newOdd);
|
|
140
|
-
}
|
|
141
|
-
this.odd = newOdd;
|
|
142
|
-
}
|
|
143
|
-
|
|
150
|
+
this.odd = newOdd;
|
|
151
|
+
}
|
|
144
152
|
}
|
|
145
153
|
customElements.define('pb-select-odd', PbSelectOdd);
|