@teipublisher/pb-components 2.17.0 → 2.18.1
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 +20 -0
- package/dist/pb-components-bundle.js +82 -70
- package/dist/pb-elements.json +19 -4
- package/dist/pb-leaflet-map.js +5 -5
- package/package.json +1 -1
- package/pb-elements.json +19 -4
- package/src/pb-authority-lookup.js +31 -9
- package/src/pb-leaflet-map.js +37 -29
- package/src/pb-login.js +11 -0
- package/src/pb-restricted.js +41 -39
- package/src/pb-view-annotate.js +7 -4
- package/src/urls.js +6 -0
package/dist/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",
|
|
@@ -5504,7 +5517,7 @@
|
|
|
5504
5517
|
},
|
|
5505
5518
|
{
|
|
5506
5519
|
"name": "geo-coding",
|
|
5507
|
-
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible:
|
|
5520
|
+
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: clicking on the map while pressing ctrl or cmd \nwill request information about 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.",
|
|
5508
5521
|
"type": "boolean",
|
|
5509
5522
|
"default": "false"
|
|
5510
5523
|
},
|
|
@@ -5624,7 +5637,7 @@
|
|
|
5624
5637
|
{
|
|
5625
5638
|
"name": "geoCoding",
|
|
5626
5639
|
"attribute": "geo-coding",
|
|
5627
|
-
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible:
|
|
5640
|
+
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: clicking on the map while pressing ctrl or cmd \nwill request information about 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.",
|
|
5628
5641
|
"type": "boolean",
|
|
5629
5642
|
"default": "false"
|
|
5630
5643
|
},
|
|
@@ -9465,7 +9478,8 @@
|
|
|
9465
9478
|
{
|
|
9466
9479
|
"name": "login",
|
|
9467
9480
|
"description": "Id of the pb-login element to connect to",
|
|
9468
|
-
"type": "string"
|
|
9481
|
+
"type": "string",
|
|
9482
|
+
"deprecatedMessage": "no longer used"
|
|
9469
9483
|
},
|
|
9470
9484
|
{
|
|
9471
9485
|
"name": "group",
|
|
@@ -9514,7 +9528,8 @@
|
|
|
9514
9528
|
"name": "login",
|
|
9515
9529
|
"attribute": "login",
|
|
9516
9530
|
"description": "Id of the pb-login element to connect to",
|
|
9517
|
-
"type": "string"
|
|
9531
|
+
"type": "string",
|
|
9532
|
+
"deprecatedMessage": "no longer used"
|
|
9518
9533
|
},
|
|
9519
9534
|
{
|
|
9520
9535
|
"name": "group",
|
package/dist/pb-leaflet-map.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{L as
|
|
2
|
-
<link rel="Stylesheet" href="${
|
|
3
|
-
<link rel="Stylesheet" href="${
|
|
4
|
-
${this.geoCoding?o`<link rel="Stylesheet" href="${
|
|
1
|
+
import{L as t,p as e,r as i,h as o,c as s}from"./pb-mixin-d61c06b6.js";import{g as a}from"./pb-i18n-375ccc5c.js";import"./es-global-bridge-4240f389.js";const r=["type","url","label","base","show"];class n extends t{static get properties(){return{type:{type:String},url:{type:String},base:{type:Boolean},show:{type:Boolean},label:{type:String},attribution:{type:String},minZoom:{type:Number,attribute:"min-zoom"},maxZoom:{type:Number,attribute:"max-zoom"},zoomOffset:{type:Number,attribute:"zoom-offset"},opacity:{type:Number},tileSize:{type:Number},id:{type:String},accessToken:{type:String,attribute:"access-token"}}}constructor(){super(),this.type="tile",this.url=null}get options(){const t={};return Object.keys(n.properties).forEach(e=>{r.indexOf(e)<0&&this[e]&&(t[e]=this[e])}),console.log("<pb-leaflet-map-layer> Options: %o",t),t}async data(){return new Promise(t=>{fetch(this.url).then(t=>t.json()).then(e=>t(e))})}}function l(t,e){try{return t.split(/\s*,\s*/).map(t=>parseInt(t,10))}catch(e){return console.error("<pb-map-icon> Invalid size specified: "+t),null}}customElements.define("pb-map-layer",n);class c extends t{static get properties(){return{name:{type:String},iconUrl:{type:String,attribute:"icon-url"},iconSize:{type:Array,converter:l,attribute:"icon-size"},iconAnchor:{type:Array,converter:l,attribute:"icon-anchor"},shadowUrl:{type:String,attribute:"shadow-url"},shadowSize:{type:Array,converter:l,attribute:"shadow-size"},shadowAnchor:{type:Array,converter:l,attribute:"shadow-anchor"},popupAncor:{type:Array,converter:l,attribute:"popup-anchor"}}}constructor(){super(),this.name="default",this.type="image",this.iconUrl=null}get options(){const t={};return Object.keys(c.properties).forEach(e=>{this[e]&&(t[e]=this[e])}),console.log("<pb-map-icon> Options: %o",t),t}}customElements.define("pb-map-icon",c);class h extends(e(t)){static get properties(){return Object.assign(Object.assign({},super.properties),{},{latitude:{type:Number},longitude:{type:Number},zoom:{type:Number},crs:{type:String},fitMarkers:{type:Boolean,attribute:"fit-markers"},cluster:{type:Boolean},disableClusteringAt:{type:Number,attribute:"disable-clustering-at"},noScroll:{type:Boolean,attribute:"no-scroll"},accessToken:{type:String,attribute:"access-token"},toggle:{type:Boolean},imagesPath:{type:String,attribute:"images-path"},cssPath:{type:String,attribute:"css-path"},geoCoding:{type:Boolean,attribute:"geo-coding"},_map:{type:Object}})}constructor(){super(),this.latitude=51.505,this.longitude=-.09,this.zoom=15,this.crs="EPSG3857",this.accessToken="",this.imagesPath="../images/leaflet/",this.cssPath="../css/leaflet",this.toggle=!1,this.noScroll=!1,this.disabled=!0,this.cluster=!1,this.fitMarkers=!1,this.disableClusteringAt=null,this._icons={},this.geoCoding=!1}connectedCallback(){super.connectedCallback(),this._layers=this.querySelectorAll("pb-map-layer"),this._markers=this.querySelectorAll("pb-map-icon"),this.subscribeTo("pb-update-map",t=>{this._markerLayer.clearLayers(),t.detail.forEach(t=>{const e=L.marker([t.latitude,t.longitude]);t.label&&e.bindTooltip(t.label),e.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",t)}),e.bindTooltip(t.label),this.setMarkerIcon(e),this._markerLayer.addLayer(e)}),this._fitBounds()}),this.subscribeTo("pb-update",t=>{this._markerLayer.clearLayers();t.detail.root.querySelectorAll("pb-geolocation").forEach(t=>{const e=L.latLng(t.latitude,t.longitude),i=L.marker(e).addTo(this._markerLayer);t.label&&i.bindTooltip(t.label),t.popup&&i.bindPopup(t.popup),i.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",t)}),this.setMarkerIcon(i)}),this._fitBounds()}),this.subscribeTo("pb-geolocation",t=>{if(t.detail.coordinates){if(this.latitude=t.detail.coordinates.latitude,this.longitude=t.detail.coordinates.longitude,t.detail.clear&&this._markerLayer.clearLayers(),this._hasMarker(this.latitude,this.longitude))console.log("<pb-leaflet-map> Marker already added to map");else{const e=L.marker([this.latitude,this.longitude]);e.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",t.detail.element)}),t.detail.label&&e.bindTooltip(t.detail.label),t.detail.popup&&e.bindPopup(t.detail.popup),this.setMarkerIcon(e),e.addTo(this._markerLayer),t.detail.fitBounds&&this._fitBounds(),console.log("<pb-leaflet-map> added marker")}this.toggle&&(this.disabled=!1);const e=t.detail.event;this._locationChanged(this.latitude,this.longitude,t.detail.zoom,e)}})}get map(){return this._map}setMarkerIcon(t){this._icons&&this._icons.default&&t.setIcon(this._icons.default)}firstUpdated(){if(this.toggle||(this.disabled=!1),void 0!==window.L)return void this._initMap();window.ESGlobalBridge.requestAvailability();const t=i("../lib/leaflet-src.js"),e=i("../lib/leaflet.markercluster-src.js"),o=i("../lib/Control.Geocoder.min.js");window.ESGlobalBridge.instance.load("leaflet",t).then(()=>{window.ESGlobalBridge.instance.load("plugin",e).then(()=>{this.geoCoding?window.ESGlobalBridge.instance.load("geocoding",o).then(this._initMap.bind(this)):this._initMap()})})}render(){const t=i(this.cssPath);return o`
|
|
2
|
+
<link rel="Stylesheet" href="${t}/leaflet.css">
|
|
3
|
+
<link rel="Stylesheet" href="${t}/MarkerCluster.Default.css">
|
|
4
|
+
${this.geoCoding?o`<link rel="Stylesheet" href="${t}/Control.Geocoder.css">`:null}
|
|
5
5
|
<div id="map" style="height: 100%; width: 100%"></div>
|
|
6
6
|
`}static get styles(){return s`
|
|
7
7
|
:host {
|
|
@@ -22,4 +22,4 @@ import{L as e,p as t,r as i,h as o,c as s}from"./pb-mixin-d61c06b6.js";import{g
|
|
|
22
22
|
text-decoration: none;
|
|
23
23
|
cursor: pointer;
|
|
24
24
|
}
|
|
25
|
-
`}_initMap(){if(this._map)return;L.Icon.Default.imagePath=i(this.imagesPath);const
|
|
25
|
+
`}_initMap(){if(this._map)return;L.Icon.Default.imagePath=i(this.imagesPath);const t=L.CRS[this.crs]||L.CRS.EPSG3857;if(this._map=L.map(this.shadowRoot.getElementById("map"),{zoom:this.zoom,center:L.latLng(this.latitude,this.longitude),crs:t}),this._configureLayers(),this._configureMarkers(),this.cluster){const t={};this.disableClusteringAt&&(t.disableClusteringAtZoom=this.disableClusteringAt),this._markerLayer=L.markerClusterGroup(t)}else this._markerLayer=L.layerGroup();if(this._markerLayer.addTo(this._map),this.signalReady(),L.control.scale().addTo(this._map),this.toggle){let t;L.Control.CloseButton=L.Control.extend({options:{position:"topright"},onAdd:e=>(t=L.DomUtil.create("div"),t.className="close",t.innerHTML="X",L.DomEvent.on(t,"click",this._hide.bind(this)),t),onRemove:e=>{L.DomEvent.off(t,"click",this._hide.bind(this))}}),L.control.closeButton=t=>new L.Control.CloseButton(t),L.control.closeButton({position:"topright"}).addTo(this._map)}this._configureGeoCoding()}_configureGeoCoding(){if(!this.geoCoding)return;const t=L.Control.Geocoder.nominatim({geocodingQueryParams:{"accept-language":"en"}}),e=L.Control.geocoder({defaultMarkGeocode:!1,geocoder:t,placeholder:a("search.search"),suggestMinLength:3});e.on("markgeocode",t=>{const{geocode:e}=t,i={coordinates:{longitude:e.center.lng,latitude:e.center.lat},name:e.name,label:e.html,properties:e.properties};this.emitTo("pb-geocode",i)}),e.addTo(this._map),this._map.on("click",e=>{(e.originalEvent.ctrlKey||e.originalEvent.metaKey)&&(e.originalEvent.stopPropagation(),t.reverse(e.latlng,this._map.options.crs.scale(this._map.getZoom()),t=>{const i=t[0],o={coordinates:{longitude:e.latlng.lng,latitude:e.latlng.lat},name:i.name,label:i.html,properties:i.properties};this.emitTo("pb-geocode",o)}))})}_configureMarkers(){0!==this._markers.length&&(this._icons={},this._markers.forEach(t=>{t.iconUrl&&(this._icons[t.name]=L.icon(t.options))}))}_configureLayers(){if(0===this._layers.length)return void L.tileLayer("https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/{z}/{x}/{y}?access_token={accessToken}",{attribution:'© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',maxZoom:18,zoomOffset:-1,tileSize:512,accessToken:this.accessToken}).addTo(this._map);const t=L.control.layers(null,null,{collapsed:!1});this._layers.forEach(e=>{let i;switch(e.type){case"geojson":e.data().then(o=>{i=L.geoJSON([o]),this._addLayer(e,i,t)});break;default:i=L.tileLayer(e.url,e.options),this._addLayer(e,i,t)}}),this._layers.length>1&&t.addTo(this._map),this._layers=null}_addLayer(t,e,i){t.show&&e.addTo(this._map),t.label&&(t.base?i.addBaseLayer(e,t.label):i.addOverlay(e,t.label))}_fitBounds(){if(!this.fitMarkers)return;const t=L.latLngBounds();let e=0;this._markerLayer.eachLayer(i=>{t.extend(i.getLatLng()),e+=1}),0===e?this._map.fitWorld():1===e?this._map.fitBounds(t,{maxZoom:this.zoom}):this._map.fitBounds(t)}_locationChanged(t,e,i,o){if(this._map){const s=L.latLng([t,e]);this._markerLayer.eachLayer(t=>{t.getLatLng().equals(s)?(i&&!this.noScroll?(t.openTooltip(),this._map.setView(s,i)):this.cluster?this._markerLayer.zoomToShowLayer(t,()=>t.openTooltip()):(t.openTooltip(),i?this._map.setView(s,i):this._map.panTo(s)),o&&this._icons&&this._icons.active&&t.setIcon(this._icons.active)):this._icons&&this._icons.default&&t.getIcon()!==this._icons.default&&t.setIcon(this._icons.default)})}}_hasMarker(t,e){const i=L.latLng([t,e]);let o=null;return this._markerLayer.eachLayer(t=>{t instanceof L.Marker&&t.getLatLng().equals(i)&&(o=t)}),o}_hide(){this.disabled=!0}}customElements.define("pb-leaflet-map",h);export{h as PbLeafletMap};
|
package/package.json
CHANGED
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",
|
|
@@ -5504,7 +5517,7 @@
|
|
|
5504
5517
|
},
|
|
5505
5518
|
{
|
|
5506
5519
|
"name": "geo-coding",
|
|
5507
|
-
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible:
|
|
5520
|
+
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: clicking on the map while pressing ctrl or cmd \nwill request information about 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.",
|
|
5508
5521
|
"type": "boolean",
|
|
5509
5522
|
"default": "false"
|
|
5510
5523
|
},
|
|
@@ -5624,7 +5637,7 @@
|
|
|
5624
5637
|
{
|
|
5625
5638
|
"name": "geoCoding",
|
|
5626
5639
|
"attribute": "geo-coding",
|
|
5627
|
-
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible:
|
|
5640
|
+
"description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: clicking on the map while pressing ctrl or cmd \nwill request information about 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.",
|
|
5628
5641
|
"type": "boolean",
|
|
5629
5642
|
"default": "false"
|
|
5630
5643
|
},
|
|
@@ -9465,7 +9478,8 @@
|
|
|
9465
9478
|
{
|
|
9466
9479
|
"name": "login",
|
|
9467
9480
|
"description": "Id of the pb-login element to connect to",
|
|
9468
|
-
"type": "string"
|
|
9481
|
+
"type": "string",
|
|
9482
|
+
"deprecatedMessage": "no longer used"
|
|
9469
9483
|
},
|
|
9470
9484
|
{
|
|
9471
9485
|
"name": "group",
|
|
@@ -9514,7 +9528,8 @@
|
|
|
9514
9528
|
"name": "login",
|
|
9515
9529
|
"attribute": "login",
|
|
9516
9530
|
"description": "Id of the pb-login element to connect to",
|
|
9517
|
-
"type": "string"
|
|
9531
|
+
"type": "string",
|
|
9532
|
+
"deprecatedMessage": "no longer used"
|
|
9518
9533
|
},
|
|
9519
9534
|
{
|
|
9520
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
|
-
|
|
96
|
-
|
|
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
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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-leaflet-map.js
CHANGED
|
@@ -100,8 +100,8 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
100
100
|
},
|
|
101
101
|
/**
|
|
102
102
|
* Enables geocoding: an additional control will allow users to search for a place.
|
|
103
|
-
* Reverse geocoding is also possible:
|
|
104
|
-
* about the current location.
|
|
103
|
+
* Reverse geocoding is also possible: clicking on the map while pressing ctrl or cmd
|
|
104
|
+
* will request information about the current location.
|
|
105
105
|
*
|
|
106
106
|
* In both cases, a `pb-geocode` event will be emitted containing additional information
|
|
107
107
|
* about the place in the event details (see demo).
|
|
@@ -260,7 +260,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
firstUpdated() {
|
|
264
264
|
if (!this.toggle) {
|
|
265
265
|
this.disabled = false;
|
|
266
266
|
}
|
|
@@ -274,17 +274,18 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
274
274
|
const leafletPath = resolveURL('../lib/leaflet-src.js');
|
|
275
275
|
const pluginPath = resolveURL('../lib/leaflet.markercluster-src.js');
|
|
276
276
|
const geoCodingPath = resolveURL('../lib/Control.Geocoder.min.js');
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
277
|
+
window.ESGlobalBridge.instance.load("leaflet", leafletPath)
|
|
278
|
+
.then(() => {
|
|
279
|
+
window.ESGlobalBridge.instance.load("plugin", pluginPath)
|
|
280
|
+
.then(() => {
|
|
281
|
+
if (this.geoCoding) {
|
|
282
|
+
window.ESGlobalBridge.instance.load("geocoding", geoCodingPath)
|
|
283
|
+
.then(this._initMap.bind(this));
|
|
284
|
+
} else {
|
|
285
|
+
this._initMap();
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|
|
288
289
|
}
|
|
289
290
|
|
|
290
291
|
render() {
|
|
@@ -325,7 +326,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
325
326
|
return;
|
|
326
327
|
}
|
|
327
328
|
|
|
328
|
-
|
|
329
|
+
L.Icon.Default.imagePath = resolveURL(this.imagesPath);
|
|
329
330
|
|
|
330
331
|
const crs = L.CRS[this.crs] || L.CRS.EPSG3857;
|
|
331
332
|
this._map = L.map(this.shadowRoot.getElementById('map'), {
|
|
@@ -406,19 +407,22 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
406
407
|
control.addTo(this._map);
|
|
407
408
|
|
|
408
409
|
this._map.on('click', (e) => {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
410
|
+
if (e.originalEvent.ctrlKey || e.originalEvent.metaKey) {
|
|
411
|
+
e.originalEvent.stopPropagation();
|
|
412
|
+
geocoder.reverse(e.latlng, this._map.options.crs.scale(this._map.getZoom()), (results) => {
|
|
413
|
+
const geocode = results[0];
|
|
414
|
+
const options = {
|
|
415
|
+
coordinates: {
|
|
416
|
+
longitude: e.latlng.lng,
|
|
417
|
+
latitude: e.latlng.lat,
|
|
418
|
+
},
|
|
419
|
+
name: geocode.name,
|
|
420
|
+
label: geocode.html,
|
|
421
|
+
properties: geocode.properties
|
|
422
|
+
};
|
|
423
|
+
this.emitTo('pb-geocode', options);
|
|
424
|
+
});
|
|
425
|
+
}
|
|
422
426
|
});
|
|
423
427
|
}
|
|
424
428
|
|
|
@@ -516,7 +520,11 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
516
520
|
);
|
|
517
521
|
} else {
|
|
518
522
|
layer.openTooltip();
|
|
519
|
-
|
|
523
|
+
if (zoom) {
|
|
524
|
+
this._map.setView(coords, zoom);
|
|
525
|
+
} else {
|
|
526
|
+
this._map.panTo(coords);
|
|
527
|
+
}
|
|
520
528
|
}
|
|
521
529
|
if (setActive && this._icons && this._icons.active) {
|
|
522
530
|
layer.setIcon(this._icons.active);
|
package/src/pb-login.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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 { registry } from "./urls.js";
|
|
4
5
|
import '@polymer/iron-ajax';
|
|
5
6
|
import '@polymer/paper-dialog';
|
|
6
7
|
import '@polymer/paper-dialog-scrollable';
|
|
@@ -250,6 +251,15 @@ export class PbLogin extends pbMixin(LitElement) {
|
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
this.emitTo('pb-login', resp);
|
|
254
|
+
|
|
255
|
+
if (this.loggedIn) {
|
|
256
|
+
registry.currentUser = {
|
|
257
|
+
user: this.user,
|
|
258
|
+
groups: this.groups
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
registry.currentUser = null;
|
|
262
|
+
}
|
|
253
263
|
}
|
|
254
264
|
|
|
255
265
|
_handleError() {
|
|
@@ -266,6 +276,7 @@ export class PbLogin extends pbMixin(LitElement) {
|
|
|
266
276
|
this._loginDialog.open();
|
|
267
277
|
}
|
|
268
278
|
|
|
279
|
+
registry.currentUser = null;
|
|
269
280
|
this.emitTo('pb-login', resp);
|
|
270
281
|
}
|
|
271
282
|
|
package/src/pb-restricted.js
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
import { registry } from './urls.js';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {Array<String>} arr array containg string values (name of groups)
|
|
8
|
+
* @param {String} val value to check if it's in the array
|
|
9
|
+
* @returns true if the checked values is in the array
|
|
10
|
+
*/
|
|
11
|
+
function _isItemInArray(arr, val) {
|
|
12
|
+
return arr.some((arrVal) => val === arrVal);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {object} user user name returned by login function;
|
|
18
|
+
* @param {object} groups contains groups (an array) the logged user is a member of
|
|
19
|
+
* @param {string} targetGroups string containing (optionally) space separated list of target groups
|
|
20
|
+
* @returns true if user is member of one of the target groups
|
|
21
|
+
*/
|
|
22
|
+
export function isLoggedIn(user, groups, targetGroups) {
|
|
23
|
+
if (user == null) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (targetGroups) {
|
|
27
|
+
if (!groups) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const groupArray = targetGroups.split(/[\s+,]+/);
|
|
31
|
+
let exists = false;
|
|
32
|
+
groupArray.forEach(async (oneItem) => {
|
|
33
|
+
exists = _isItemInArray(groups, oneItem) || exists;
|
|
34
|
+
});
|
|
35
|
+
return exists;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
4
39
|
|
|
5
40
|
/**
|
|
6
41
|
* Show content if the user is logged in. Optionally requires the user
|
|
@@ -18,7 +53,9 @@ export class PbRestricted extends pbMixin(LitElement) {
|
|
|
18
53
|
static get properties() {
|
|
19
54
|
return {
|
|
20
55
|
...super.properties,
|
|
21
|
-
/** Id of the pb-login element to connect to
|
|
56
|
+
/** Id of the pb-login element to connect to
|
|
57
|
+
* @deprecated no longer used
|
|
58
|
+
*/
|
|
22
59
|
login: {
|
|
23
60
|
type: String
|
|
24
61
|
},
|
|
@@ -50,15 +87,10 @@ export class PbRestricted extends pbMixin(LitElement) {
|
|
|
50
87
|
this.classList.add('fallback');
|
|
51
88
|
}
|
|
52
89
|
|
|
53
|
-
const login = document.getElementById(this.login);
|
|
54
|
-
if (!login) {
|
|
55
|
-
console.error('<pb-restricted> connected pb-login element not found!');
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
90
|
this.subscribeTo('pb-login', (ev) => {
|
|
59
91
|
this.show = this._loggedIn(ev.detail.user, ev.detail.groups);
|
|
60
92
|
}, []);
|
|
61
|
-
this.show =
|
|
93
|
+
this.show = registry.currentUser && this._loggedIn(registry.currentUser.user, registry.currentUser.groups);
|
|
62
94
|
}
|
|
63
95
|
|
|
64
96
|
render() {
|
|
@@ -74,43 +106,13 @@ export class PbRestricted extends pbMixin(LitElement) {
|
|
|
74
106
|
}
|
|
75
107
|
|
|
76
108
|
:host(.fallback), :host([show]) {
|
|
77
|
-
display:
|
|
109
|
+
display: inherit;
|
|
78
110
|
}
|
|
79
111
|
`;
|
|
80
112
|
}
|
|
81
113
|
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
* @param {Array<String>} arr array containg string values (name of groups)
|
|
85
|
-
* @param {String} val value to check if it's in the array
|
|
86
|
-
* @returns true if the checked values is in the array
|
|
87
|
-
*/
|
|
88
|
-
_isItemInArray(arr, val) {
|
|
89
|
-
return arr.some((arrVal) => val === arrVal);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param {object} user user name returned by login function;
|
|
95
|
-
* @param {object} groups contains groups (an array) the logged user is a member of
|
|
96
|
-
* @returns true if user is member of one of defined groups
|
|
97
|
-
*/
|
|
98
114
|
_loggedIn(user, groups) {
|
|
99
|
-
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
if (this.group) {
|
|
103
|
-
if (!groups) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
let groupArray = this.group.split(/[\s+,]+/);
|
|
107
|
-
let exists = false;
|
|
108
|
-
groupArray.forEach(async (oneItem) => {
|
|
109
|
-
exists = this._isItemInArray(groups, oneItem) || exists;
|
|
110
|
-
});
|
|
111
|
-
return exists;
|
|
112
|
-
}
|
|
113
|
-
return true;
|
|
115
|
+
return isLoggedIn(user, groups, this.group);
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
customElements.define('pb-restricted', PbRestricted);
|
package/src/pb-view-annotate.js
CHANGED
|
@@ -556,11 +556,14 @@ class PbViewAnnotate extends PbView {
|
|
|
556
556
|
console.log('<pb-view-annotate> selection: %o', range);
|
|
557
557
|
|
|
558
558
|
if (changed) {
|
|
559
|
-
this._inHandler = true;
|
|
560
559
|
setTimeout(() => {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
560
|
+
this._inHandler = true;
|
|
561
|
+
try {
|
|
562
|
+
selection.removeAllRanges();
|
|
563
|
+
selection.addRange(range);
|
|
564
|
+
} finally {
|
|
565
|
+
this.inHandler = false;
|
|
566
|
+
}
|
|
564
567
|
}, 100);
|
|
565
568
|
}
|
|
566
569
|
this.emitTo('pb-selection-changed', { hasContent: true, range, selected: selection.toString()});
|
package/src/urls.js
CHANGED
|
@@ -69,6 +69,12 @@ class Registry {
|
|
|
69
69
|
|
|
70
70
|
this.urlIgnore = new Set();
|
|
71
71
|
this.pathParams = new Set();
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Information about the user currently logged in or null. If a user is logged in
|
|
75
|
+
* this will be an object with two properties: `user` and `groups`.
|
|
76
|
+
*/
|
|
77
|
+
this.currentUser = null;
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
configure(usePath = true, idHash = false, rootPath = '', urlPattern, ignoredParams) {
|