@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
|
@@ -2,17 +2,17 @@ import { LitElement, html, css } from 'lit-element';
|
|
|
2
2
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
3
3
|
import { themableMixin } from './theming.js';
|
|
4
4
|
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
5
|
-
import { translate } from
|
|
6
|
-
import { createConnectors } from
|
|
7
|
-
import
|
|
5
|
+
import { translate } from './pb-i18n.js';
|
|
6
|
+
import { createConnectors } from './authority/connectors.js';
|
|
7
|
+
import './pb-restricted.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Performs authority lookups via configurable connectors.
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
* @fires pb-authority-select - Fired when user selects an entry from the list
|
|
13
13
|
* @fires pb-authority-edit-entity - Fired when user clicks the edit button next to an entry
|
|
14
|
-
* @fires pb-authority-new-entity -
|
|
15
|
-
* @fires pb-authority-lookup - When received, starts a lookup using the passed in query string and
|
|
14
|
+
* @fires pb-authority-new-entity - Fired when user clicks the add new entity button
|
|
15
|
+
* @fires pb-authority-lookup - When received, starts a lookup using the passed in query string and
|
|
16
16
|
* authority type
|
|
17
17
|
*/
|
|
18
18
|
export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
@@ -31,7 +31,7 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
31
31
|
*/
|
|
32
32
|
sortByLabel: {
|
|
33
33
|
type: Boolean,
|
|
34
|
-
attribute: 'sort-by-label'
|
|
34
|
+
attribute: 'sort-by-label',
|
|
35
35
|
},
|
|
36
36
|
/**
|
|
37
37
|
* A list of comma-separated stopwords which should be excluded
|
|
@@ -39,16 +39,16 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
39
39
|
* HTML text
|
|
40
40
|
*/
|
|
41
41
|
stopwords: {
|
|
42
|
-
type: String
|
|
42
|
+
type: String,
|
|
43
43
|
},
|
|
44
44
|
/**
|
|
45
45
|
* A list of space- or comma-separated group names, whose members will be
|
|
46
46
|
* allowed to add or edit entries in the local register (if enabled).
|
|
47
|
-
*
|
|
47
|
+
*
|
|
48
48
|
* @default "tei"
|
|
49
49
|
*/
|
|
50
50
|
group: {
|
|
51
|
-
type: String
|
|
51
|
+
type: String,
|
|
52
52
|
},
|
|
53
53
|
/**
|
|
54
54
|
* The authority type to use. Should correspond to a name defined for one of the connectors.
|
|
@@ -94,19 +94,21 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
94
94
|
|
|
95
95
|
this._stopwordSet = new Set();
|
|
96
96
|
if (this.stopwords) {
|
|
97
|
-
this.stopwords.split(/\s*,\s*/).forEach(
|
|
97
|
+
this.stopwords.split(/\s*,\s*/).forEach(sw => this._stopwordSet.add(sw.toLowerCase()));
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
this.subscribeTo('pb-authority-lookup', ev => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
this.query = ev.detail.query;
|
|
102
|
+
this.type = ev.detail.type;
|
|
103
|
+
this._results = [];
|
|
104
|
+
this._query();
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
waitOnce('pb-page-ready', () => {
|
|
108
108
|
const connectors = createConnectors(this.getEndpoint(), this);
|
|
109
|
-
connectors.forEach(connector => {
|
|
109
|
+
connectors.forEach(connector => {
|
|
110
|
+
this._authorities[connector.register] = connector;
|
|
111
|
+
});
|
|
110
112
|
if (this.autoLookup) {
|
|
111
113
|
this._query();
|
|
112
114
|
}
|
|
@@ -117,33 +119,41 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
117
119
|
|
|
118
120
|
render() {
|
|
119
121
|
return html`
|
|
120
|
-
|
|
122
|
+
<header>
|
|
121
123
|
<input
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
id="query"
|
|
125
|
+
type="search"
|
|
126
|
+
placeholder="${translate('annotations.lookup')}"
|
|
127
|
+
.value="${this.query}"
|
|
128
|
+
@input="${e => this._queryChanged(e)}"
|
|
129
|
+
@change="${e => this._queryChanged(e)}"
|
|
130
|
+
aria-label="${translate('annotations.lookup')}"
|
|
129
131
|
/>
|
|
130
|
-
${
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
<pb-restricted group="${this.group}">
|
|
132
|
+
${this._authorities[this.type] && this._authorities[this.type].editable
|
|
133
|
+
? html`
|
|
134
|
+
<pb-restricted group="${this.group}">
|
|
134
135
|
<button @click="${this._addEntity}" title="${translate('annotations.add-entity')}">
|
|
135
|
-
|
|
136
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">
|
|
137
|
+
<path
|
|
138
|
+
fill="none"
|
|
139
|
+
stroke="currentColor"
|
|
140
|
+
stroke-linecap="round"
|
|
141
|
+
stroke-linejoin="round"
|
|
142
|
+
stroke-width="32"
|
|
143
|
+
d="M256 112v288M400 256H112"
|
|
144
|
+
/>
|
|
145
|
+
</svg>
|
|
136
146
|
</button>
|
|
137
|
-
|
|
138
|
-
`
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
</pb-restricted>
|
|
148
|
+
`
|
|
149
|
+
: null}
|
|
150
|
+
</header>
|
|
151
|
+
<slot name="authform"></slot>
|
|
152
|
+
<div id="output">
|
|
153
|
+
<ul part="output">
|
|
154
|
+
${this._results.map(item => this._formatItem(item))}
|
|
155
|
+
</ul>
|
|
156
|
+
</div>
|
|
147
157
|
`;
|
|
148
158
|
}
|
|
149
159
|
|
|
@@ -154,11 +164,16 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
154
164
|
return Promise.resolve();
|
|
155
165
|
}
|
|
156
166
|
const authority = this._authorities[register];
|
|
157
|
-
console.log(
|
|
167
|
+
console.log(
|
|
168
|
+
'<pb-authority-lookup> Retrieving info for %s from %s using %s',
|
|
169
|
+
id,
|
|
170
|
+
register,
|
|
171
|
+
authority.constructor.name,
|
|
172
|
+
);
|
|
158
173
|
let info = await authority.info(id, container);
|
|
159
174
|
if (info.strings) {
|
|
160
175
|
info = Object.assign(info, {
|
|
161
|
-
strings: info.strings.filter(
|
|
176
|
+
strings: info.strings.filter(s => s && !this._stopwordSet.has(s.toLowerCase())),
|
|
162
177
|
});
|
|
163
178
|
}
|
|
164
179
|
return info;
|
|
@@ -166,111 +181,134 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
166
181
|
|
|
167
182
|
_formatItem(item) {
|
|
168
183
|
return html`
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
184
|
+
<li>
|
|
185
|
+
<div>
|
|
186
|
+
<button @click="${() => this._select(item)}" title="link to">
|
|
187
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">
|
|
188
|
+
<path
|
|
189
|
+
d="M208 352h-64a96 96 0 010-192h64M304 160h64a96 96 0 010 192h-64M163.29 256h187.42"
|
|
190
|
+
fill="none"
|
|
191
|
+
stroke="currentColor"
|
|
192
|
+
stroke-linecap="round"
|
|
193
|
+
stroke-linejoin="round"
|
|
194
|
+
stroke-width="36"
|
|
195
|
+
/>
|
|
196
|
+
</svg>
|
|
197
|
+
</button>
|
|
198
|
+
${item.link
|
|
199
|
+
? html`<a target="_blank" href="${item.link}">${unsafeHTML(item.label)}</a>`
|
|
200
|
+
: html`${unsafeHTML(item.label)}`}
|
|
201
|
+
<div class="badges">
|
|
202
|
+
${item.occurrences > 0
|
|
203
|
+
? html`<span class="occurrences badge" part="occurrences">${item.occurrences}</span>`
|
|
204
|
+
: null}
|
|
205
|
+
${item.provider
|
|
206
|
+
? html`<span class="source badge" part="source">${item.provider}</span>`
|
|
207
|
+
: null}
|
|
208
|
+
<span class="register badge" part="register">${item.register}</span>
|
|
209
|
+
${this._authorities[this.type] && this._authorities[this.type].editable
|
|
210
|
+
? html` <pb-restricted group="${this.group}">
|
|
211
|
+
<button
|
|
212
|
+
@click="${() => this._editEntity(item)}"
|
|
213
|
+
title="${translate('annotations.edit-entity')}"
|
|
214
|
+
>
|
|
215
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">
|
|
216
|
+
<path
|
|
217
|
+
d="M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48"
|
|
218
|
+
fill="none"
|
|
219
|
+
stroke="currentColor"
|
|
220
|
+
stroke-linecap="round"
|
|
221
|
+
stroke-linejoin="round"
|
|
222
|
+
stroke-width="32"
|
|
223
|
+
/>
|
|
224
|
+
<path
|
|
225
|
+
d="M459.94 53.25a16.06 16.06 0 00-23.22-.56L424.35 65a8 8 0 000 11.31l11.34 11.32a8 8 0 0011.34 0l12.06-12c6.1-6.09 6.67-16.01.85-22.38zM399.34 90L218.82 270.2a9 9 0 00-2.31 3.93L208.16 299a3.91 3.91 0 004.86 4.86l24.85-8.35a9 9 0 003.93-2.31L422 112.66a9 9 0 000-12.66l-9.95-10a9 9 0 00-12.71 0z"
|
|
226
|
+
/>
|
|
227
|
+
</svg>
|
|
228
|
+
</button>
|
|
229
|
+
</pb-restricted>`
|
|
230
|
+
: null}
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
${item.details ? html`<div class="details" part="details">${item.details}</div>` : null}
|
|
196
234
|
</li>
|
|
197
235
|
`;
|
|
198
236
|
}
|
|
199
237
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
238
|
+
static get styles() {
|
|
239
|
+
return css`
|
|
240
|
+
:host {
|
|
241
|
+
display: flex;
|
|
242
|
+
flex-direction: column;
|
|
243
|
+
}
|
|
206
244
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
245
|
+
header {
|
|
246
|
+
display: flex;
|
|
247
|
+
justify-content: space-between;
|
|
248
|
+
align-items: center;
|
|
249
|
+
margin-bottom: 1rem;
|
|
250
|
+
}
|
|
213
251
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
252
|
+
header > input {
|
|
253
|
+
flex-grow: 1;
|
|
254
|
+
}
|
|
217
255
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
#output {
|
|
223
|
-
overflow: auto;
|
|
224
|
-
/*FireFox*/
|
|
225
|
-
scrollbar-width: none;
|
|
226
|
-
}
|
|
256
|
+
.link {
|
|
257
|
+
flex-grow: 2;
|
|
258
|
+
}
|
|
227
259
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
260
|
+
#output {
|
|
261
|
+
overflow: auto;
|
|
262
|
+
/*FireFox*/
|
|
263
|
+
scrollbar-width: none;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
#output > ul {
|
|
267
|
+
width: 100%;
|
|
268
|
+
padding: 0;
|
|
269
|
+
list-style: none;
|
|
270
|
+
}
|
|
233
271
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
272
|
+
#output > ul > li {
|
|
273
|
+
border-bottom: 1px solid var(--pb-color-border);
|
|
274
|
+
}
|
|
237
275
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
276
|
+
#output > ul > li > div {
|
|
277
|
+
display: flex;
|
|
278
|
+
justify-content: space-between;
|
|
279
|
+
align-items: center;
|
|
280
|
+
flex-wrap: wrap;
|
|
281
|
+
gap: 0.125rem;
|
|
282
|
+
}
|
|
245
283
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
284
|
+
#output > ul > li > div > a {
|
|
285
|
+
flex-grow: 2;
|
|
286
|
+
}
|
|
249
287
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
288
|
+
.badges {
|
|
289
|
+
display: inline-flex;
|
|
290
|
+
gap: 0.125rem;
|
|
291
|
+
align-items: center;
|
|
292
|
+
}
|
|
255
293
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
294
|
+
.badge {
|
|
295
|
+
font-size: 0.75rem;
|
|
296
|
+
border-radius: 4px;
|
|
297
|
+
padding: 4px;
|
|
298
|
+
color: var(--pb-color-inverse);
|
|
299
|
+
}
|
|
262
300
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
301
|
+
.source {
|
|
302
|
+
background-color: #637b8c;
|
|
303
|
+
}
|
|
304
|
+
.register {
|
|
305
|
+
background-color: var(--pb-color-lighter, #35424b);
|
|
306
|
+
}
|
|
307
|
+
.occurrences {
|
|
308
|
+
background-color: var(--pb-color-focus, #f6a623);
|
|
309
|
+
}
|
|
272
310
|
`;
|
|
273
|
-
|
|
311
|
+
}
|
|
274
312
|
|
|
275
313
|
_select(item) {
|
|
276
314
|
const connector = this._authorities[item.register];
|
|
@@ -279,13 +317,13 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
279
317
|
type: item.register,
|
|
280
318
|
properties: {
|
|
281
319
|
ref: item.id,
|
|
282
|
-
}
|
|
320
|
+
},
|
|
283
321
|
};
|
|
284
322
|
if (connector) {
|
|
285
323
|
connector
|
|
286
324
|
.select(item)
|
|
287
325
|
.then(() => this.emitTo('pb-authority-select', options))
|
|
288
|
-
.catch(
|
|
326
|
+
.catch(e => this.emitTo('pb-authority-error', { status: e.message }));
|
|
289
327
|
} else {
|
|
290
328
|
this.emitTo('pb-authority-select', options);
|
|
291
329
|
}
|
|
@@ -296,24 +334,23 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
296
334
|
if (connector) {
|
|
297
335
|
connector
|
|
298
336
|
.select(item)
|
|
299
|
-
.then(() => this.emitTo('pb-authority-edit-entity', {id: item.id, type: item.register}));
|
|
337
|
+
.then(() => this.emitTo('pb-authority-edit-entity', { id: item.id, type: item.register }));
|
|
300
338
|
} else {
|
|
301
|
-
this.emitTo('pb-authority-edit-entity', {id: item.id, type: item.register});
|
|
339
|
+
this.emitTo('pb-authority-edit-entity', { id: item.id, type: item.register });
|
|
302
340
|
}
|
|
303
341
|
}
|
|
304
342
|
|
|
305
343
|
_queryChanged(e) {
|
|
306
344
|
this._results = [];
|
|
307
|
-
|
|
308
|
-
|
|
345
|
+
this.query = e.target.value;
|
|
346
|
+
this._query();
|
|
309
347
|
}
|
|
310
348
|
|
|
311
349
|
_query() {
|
|
312
350
|
this.emitTo('pb-start-update');
|
|
313
351
|
this._authorities[this.type].query(this.query).then(results => {
|
|
314
|
-
this._occurrences(results.items)
|
|
315
|
-
.
|
|
316
|
-
this._results = merged;
|
|
352
|
+
this._occurrences(results.items).then(merged => {
|
|
353
|
+
this._results = merged;
|
|
317
354
|
});
|
|
318
355
|
this.emitTo('pb-end-update');
|
|
319
356
|
// this.shadowRoot.getElementById('query').focus();
|
|
@@ -321,7 +358,7 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
321
358
|
}
|
|
322
359
|
|
|
323
360
|
_addEntity() {
|
|
324
|
-
this.emitTo('pb-authority-new-entity', {query: this.query, type: this.type});
|
|
361
|
+
this.emitTo('pb-authority-new-entity', { query: this.query, type: this.type });
|
|
325
362
|
}
|
|
326
363
|
|
|
327
364
|
_occurrences(items) {
|
|
@@ -330,13 +367,13 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
330
367
|
}
|
|
331
368
|
const params = new FormData();
|
|
332
369
|
params.append('register', this.type);
|
|
333
|
-
items.forEach(
|
|
370
|
+
items.forEach(item => {
|
|
334
371
|
params.append('id', item.id);
|
|
335
372
|
});
|
|
336
|
-
return new Promise(
|
|
373
|
+
return new Promise(resolve => {
|
|
337
374
|
fetch(`${this.getEndpoint()}/api/annotations/occurrences`, {
|
|
338
375
|
method: 'POST',
|
|
339
|
-
body: params
|
|
376
|
+
body: params,
|
|
340
377
|
})
|
|
341
378
|
.then(response => {
|
|
342
379
|
if (response.ok) {
|
|
@@ -344,7 +381,7 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
344
381
|
}
|
|
345
382
|
})
|
|
346
383
|
.then(json => {
|
|
347
|
-
items.forEach(
|
|
384
|
+
items.forEach(item => {
|
|
348
385
|
if (json[item.id]) {
|
|
349
386
|
item.occurrences = json[item.id];
|
|
350
387
|
} else {
|
|
@@ -366,7 +403,7 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
366
403
|
});
|
|
367
404
|
resolve(items);
|
|
368
405
|
});
|
|
369
|
-
|
|
406
|
+
});
|
|
370
407
|
}
|
|
371
408
|
}
|
|
372
409
|
customElements.define('pb-authority-lookup', PbAuthorityLookup);
|