@teipublisher/pb-components 2.16.0 → 2.18.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/pb-elements.json CHANGED
@@ -642,6 +642,12 @@
642
642
  "type": "boolean",
643
643
  "default": "false"
644
644
  },
645
+ {
646
+ "name": "group",
647
+ "description": "A list of space- or comma-separated group names, whose members will be\nallowed to add or edit entries in the local register (if enabled).",
648
+ "type": "string",
649
+ "default": "\"\\\"tei\\\"\""
650
+ },
645
651
  {
646
652
  "name": "subscribe",
647
653
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -698,6 +704,13 @@
698
704
  "type": "boolean",
699
705
  "default": "false"
700
706
  },
707
+ {
708
+ "name": "group",
709
+ "attribute": "group",
710
+ "description": "A list of space- or comma-separated group names, whose members will be\nallowed to add or edit entries in the local register (if enabled).",
711
+ "type": "string",
712
+ "default": "\"\\\"tei\\\"\""
713
+ },
701
714
  {
702
715
  "name": "subscribe",
703
716
  "attribute": "subscribe",
@@ -5436,7 +5449,7 @@
5436
5449
  {
5437
5450
  "name": "pb-leaflet-map",
5438
5451
  "path": "./src/pb-leaflet-map.js",
5439
- "description": "A wrapper component for [leaflet](https://leafletjs.com/) displaying a map.\r\n\r\nThe map layers displayed can be configured via nested `pb-map-layer` (see docs) elements,\r\nicons via `pb-map-icon`.",
5452
+ "description": "A wrapper component for [leaflet](https://leafletjs.com/) displaying a map.\n\nThe map layers displayed can be configured via nested `pb-map-layer` (see docs) elements,\nicons via `pb-map-icon`.",
5440
5453
  "attributes": [
5441
5454
  {
5442
5455
  "name": "latitude",
@@ -5475,7 +5488,7 @@
5475
5488
  },
5476
5489
  {
5477
5490
  "name": "toggle",
5478
- "description": "If enabled, the map will remain invisible until an event is received from `pb-geolocation`.\r\nIn this case the map also offers a close button to hide it again.",
5491
+ "description": "If enabled, the map will remain invisible until an event is received from `pb-geolocation`.\nIn this case the map also offers a close button to hide it again.",
5479
5492
  "type": "boolean",
5480
5493
  "default": "false"
5481
5494
  },
@@ -5487,7 +5500,7 @@
5487
5500
  },
5488
5501
  {
5489
5502
  "name": "cluster",
5490
- "description": "If set, combine markers into clusters if they are located too close together\r\nto display as single markers",
5503
+ "description": "If set, combine markers into clusters if they are located too close together\nto display as single markers",
5491
5504
  "type": "boolean",
5492
5505
  "default": "false"
5493
5506
  },
@@ -5499,9 +5512,15 @@
5499
5512
  },
5500
5513
  {
5501
5514
  "name": "disable-clustering-at",
5502
- "description": "Limits up to which zoom level markers are arranged into clusters.\r\nUsing a higher zoom level here will result in more markers to be shown.\r\n\r\nRequires `cluster` option to be enabled.",
5515
+ "description": "Limits up to which zoom level markers are arranged into clusters.\nUsing a higher zoom level here will result in more markers to be shown.\n\nRequires `cluster` option to be enabled.",
5503
5516
  "type": "number"
5504
5517
  },
5518
+ {
5519
+ "name": "geo-coding",
5520
+ "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: single clicking on the map will request information\nabout the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5521
+ "type": "boolean",
5522
+ "default": "false"
5523
+ },
5505
5524
  {
5506
5525
  "name": "subscribe",
5507
5526
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -5537,7 +5556,7 @@
5537
5556
  "properties": [
5538
5557
  {
5539
5558
  "name": "map",
5540
- "description": "The underlying leafletjs map. Can be used for custom scripts.\r\n\r\nWill be null until the component is fully loaded. Listen to `pb-ready` on the component to\r\nbe sure it has initialized."
5559
+ "description": "The underlying leafletjs map. Can be used for custom scripts.\n\nWill be null until the component is fully loaded. Listen to `pb-ready` on the component to\nbe sure it has initialized."
5541
5560
  },
5542
5561
  {
5543
5562
  "name": "latitude",
@@ -5584,7 +5603,7 @@
5584
5603
  {
5585
5604
  "name": "toggle",
5586
5605
  "attribute": "toggle",
5587
- "description": "If enabled, the map will remain invisible until an event is received from `pb-geolocation`.\r\nIn this case the map also offers a close button to hide it again.",
5606
+ "description": "If enabled, the map will remain invisible until an event is received from `pb-geolocation`.\nIn this case the map also offers a close button to hide it again.",
5588
5607
  "type": "boolean",
5589
5608
  "default": "false"
5590
5609
  },
@@ -5598,7 +5617,7 @@
5598
5617
  {
5599
5618
  "name": "cluster",
5600
5619
  "attribute": "cluster",
5601
- "description": "If set, combine markers into clusters if they are located too close together\r\nto display as single markers",
5620
+ "description": "If set, combine markers into clusters if they are located too close together\nto display as single markers",
5602
5621
  "type": "boolean",
5603
5622
  "default": "false"
5604
5623
  },
@@ -5612,9 +5631,16 @@
5612
5631
  {
5613
5632
  "name": "disableClusteringAt",
5614
5633
  "attribute": "disable-clustering-at",
5615
- "description": "Limits up to which zoom level markers are arranged into clusters.\r\nUsing a higher zoom level here will result in more markers to be shown.\r\n\r\nRequires `cluster` option to be enabled.",
5634
+ "description": "Limits up to which zoom level markers are arranged into clusters.\nUsing a higher zoom level here will result in more markers to be shown.\n\nRequires `cluster` option to be enabled.",
5616
5635
  "type": "number"
5617
5636
  },
5637
+ {
5638
+ "name": "geoCoding",
5639
+ "attribute": "geo-coding",
5640
+ "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: single clicking on the map will request information\nabout the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5641
+ "type": "boolean",
5642
+ "default": "false"
5643
+ },
5618
5644
  {
5619
5645
  "name": "subscribe",
5620
5646
  "attribute": "subscribe",
@@ -5660,7 +5686,7 @@
5660
5686
  },
5661
5687
  {
5662
5688
  "name": "pb-update-map",
5663
- "description": "When received, redraws the map to fit markers passed in with the event.\rEvent details should include an array of locations, see `pb-geolocation` event below."
5689
+ "description": "When received, redraws the map to fit markers passed in with the event.\nEvent details should include an array of locations, see `pb-geolocation` event below."
5664
5690
  },
5665
5691
  {
5666
5692
  "name": "pb-update",
@@ -5668,7 +5694,11 @@
5668
5694
  },
5669
5695
  {
5670
5696
  "name": "pb-geolocation",
5671
- "description": "When received, focuses the map on the geocoordinates passed in with the event.\rThe event details should include an object:\r```\r{\rcoordinates: {\r latitude: Number,\r longitude: Number\r},\rlabel: string - the label to show on mouseover,\rzoom: Number - fixed zoom level to zoom to,\rfitBounds: Boolean - if true, recompute current zoom level to show all markers\r}\r```"
5697
+ "description": "When received, focuses the map on the geocoordinates passed in with the event.\nThe event details should include an object:\n```\n{\ncoordinates: {\n latitude: Number,\n longitude: Number\n},\nlabel: string - the label to show on mouseover,\nzoom: Number - fixed zoom level to zoom to,\nfitBounds: Boolean - if true, recompute current zoom level to show all markers\n}\n```"
5698
+ },
5699
+ {
5700
+ "name": "pb-geocode",
5701
+ "description": "emitted if geocoding is enabled and the user searches or selects a location from the map"
5672
5702
  }
5673
5703
  ],
5674
5704
  "slots": [
@@ -9448,7 +9478,8 @@
9448
9478
  {
9449
9479
  "name": "login",
9450
9480
  "description": "Id of the pb-login element to connect to",
9451
- "type": "string"
9481
+ "type": "string",
9482
+ "deprecatedMessage": "no longer used"
9452
9483
  },
9453
9484
  {
9454
9485
  "name": "group",
@@ -9497,7 +9528,8 @@
9497
9528
  "name": "login",
9498
9529
  "attribute": "login",
9499
9530
  "description": "Id of the pb-login element to connect to",
9500
- "type": "string"
9531
+ "type": "string",
9532
+ "deprecatedMessage": "no longer used"
9501
9533
  },
9502
9534
  {
9503
9535
  "name": "group",
@@ -3,6 +3,7 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
3
3
  import { pbMixin, waitOnce } from './pb-mixin.js';
4
4
  import { translate } from "./pb-i18n.js";
5
5
  import { createConnectors } from "./authority/connectors.js";
6
+ import "./pb-restricted.js";
6
7
  import '@polymer/paper-input/paper-input';
7
8
  import '@polymer/paper-icon-button';
8
9
 
@@ -41,6 +42,15 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
41
42
  stopwords: {
42
43
  type: String
43
44
  },
45
+ /**
46
+ * A list of space- or comma-separated group names, whose members will be
47
+ * allowed to add or edit entries in the local register (if enabled).
48
+ *
49
+ * @default "tei"
50
+ */
51
+ group: {
52
+ type: String
53
+ },
44
54
  _results: {
45
55
  type: Array,
46
56
  },
@@ -55,6 +65,7 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
55
65
  this.sortByLabel = false;
56
66
  this._results = [];
57
67
  this._authorities = {};
68
+ this.group = 'tei';
58
69
  }
59
70
 
60
71
  connectedCallback() {
@@ -92,8 +103,11 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
92
103
  <iron-icon icon="icons:search" slot="prefix"></iron-icon>
93
104
  ${
94
105
  this._authorities[this.type] && this._authorities[this.type].editable ?
95
- html`<paper-icon-button icon="icons:add" @click="${this._addEntity}" title="${translate('annotations.add-entity')}" slot="suffix"></paper-icon-button>` :
96
- null
106
+ html`
107
+ <pb-restricted group="${this.group}" slot="suffix">
108
+ <paper-icon-button icon="icons:add" @click="${this._addEntity}" title="${translate('annotations.add-entity')}"></paper-icon-button>
109
+ </pb-restricted>
110
+ ` : null
97
111
  }
98
112
  </paper-input>
99
113
  <slot name="authform"></slot>
@@ -144,13 +158,16 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
144
158
 
145
159
  ${
146
160
  this._authorities[this.type] && this._authorities[this.type].editable ?
147
- html`<div class="icons">
148
- <paper-icon-button
149
- icon="editor:mode-edit"
150
- @click="${() => this._editEntity(item)}"
151
- title="${translate('annotations.edit-entity')}"
152
- ></paper-icon-button>
153
- </div>` : null
161
+ html`
162
+ <pb-restricted group="${this.group}">
163
+ <div class="icons">
164
+ <paper-icon-button
165
+ icon="editor:mode-edit"
166
+ @click="${() => this._editEntity(item)}"
167
+ title="${translate('annotations.edit-entity')}"
168
+ ></paper-icon-button>
169
+ </div>
170
+ </pb-restricted>` : null
154
171
  }
155
172
  ${item.details ? html`<div class="details" part="details">${item.details}</div>` : null}
156
173
 
@@ -260,6 +277,11 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
260
277
  flex-direction: column;
261
278
  }
262
279
 
280
+ header {
281
+ display: flex;
282
+ align-items: center;
283
+ }
284
+
263
285
  .link {
264
286
  flex-grow: 2;
265
287
  }
package/src/pb-events.js CHANGED
@@ -78,6 +78,44 @@ export class PbEvents {
78
78
  });
79
79
  document.dispatchEvent(ev);
80
80
  }
81
+
82
+ /**
83
+ * Wait for one or more TEI Publisher web components to become ready (by waiting for their `pb-ready` event).
84
+ *
85
+ * @param {HTMLElement|HTMLElement[]} targets element or array of elements to check for ready state
86
+ * @returns Promise which resolves when all components are ready
87
+ */
88
+ static ifReady(targets) {
89
+ if (!Array.isArray(targets)) {
90
+ targets = [targets];
91
+ }
92
+ // const targets = Array.from(document.querySelectorAll(selector));
93
+ return new Promise((resolve) => {
94
+ const targetCount = targets.length;
95
+ if (targetCount === 0) {
96
+ // selector did not return any targets
97
+ resolve();
98
+ return;
99
+ }
100
+ let count = targetCount;
101
+ targets.forEach((target) => {
102
+ if (target._isReady) {
103
+ count -= 1;
104
+ if (count === 0) {
105
+ resolve();
106
+ }
107
+ return;
108
+ }
109
+ const handler = target.addEventListener('pb-ready', () => {
110
+ count -= 1;
111
+ if (count === 0) {
112
+ target.removeEventListener('pb-ready', handler);
113
+ resolve();
114
+ }
115
+ });
116
+ });
117
+ });
118
+ }
81
119
  }
82
120
 
83
121
  if (!window.pbEvents) {