@teipublisher/pb-components 2.26.1-next.3 → 3.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/.github/workflows/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +4 -4
- package/.releaserc.json +2 -2
- package/CHANGELOG.md +262 -11
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/css/leaflet/images/layers.png +0 -0
- package/dist/demo/components.css +46 -1
- package/dist/demo/pb-browse-docs2.html +1 -1
- package/dist/demo/pb-dialog.html +3 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-facsimile.html +2 -2
- package/dist/demo/pb-grid.html +19 -6
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-login.html +0 -2
- package/dist/demo/pb-message.html +1 -2
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-search.html +7 -4
- package/dist/demo/pb-search3.html +1 -1
- package/dist/demo/pb-search4.html +2 -2
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{iron-form-3b8dcaa7.js → iron-form-dfb3e3b1.js} +95 -95
- package/dist/paper-checkbox-645e1077.js +200 -0
- package/dist/{paper-icon-button-b1d31571.js → paper-icon-button-984162bd.js} +1 -1
- package/dist/{paper-checkbox-515a5284.js → paper-inky-focus-behavior-fa16796b.js} +58 -247
- package/dist/{paper-listbox-a3b7175c.js → paper-listbox-5f5d1cec.js} +152 -162
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +68 -64
- package/dist/pb-components-bundle.js +1983 -2293
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +176 -120
- 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 +1023 -782
- package/dist/pb-tify.js +2 -2
- package/dist/vaadin-element-mixin-beb74ffd.js +545 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +6 -6
- package/package.json +3 -3
- package/pb-elements.json +176 -120
- 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 +50 -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 +158 -171
- package/src/pb-authority-lookup.js +191 -156
- 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 +211 -151
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-components.js +1 -0
- package/src/pb-custom-form.js +173 -153
- package/src/pb-dialog.js +98 -62
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +212 -196
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +100 -97
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +474 -410
- 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 +142 -57
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -429
- package/src/pb-login.js +299 -244
- package/src/pb-manage-odds.js +352 -336
- 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 +139 -97
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -95
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1054 -958
- package/src/pb-odd-elementspec-editor.js +349 -298
- package/src/pb-odd-model-editor.js +1075 -909
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -422
- package/src/pb-paginate.js +228 -179
- package/src/pb-panel.js +198 -182
- package/src/pb-popover-themes.js +15 -8
- 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 +256 -228
- 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 +382 -249
- package/src/pb-toggle-feature.js +195 -187
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +135 -98
- package/src/pb-view.js +1282 -1270
- package/src/pb-zoom.js +127 -45
- 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 +98 -91
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
- package/css/pb-styles.css +0 -51
- package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -41
package/dist/pb-odd-editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as e,N as t,j as o,k as i,l as s,A as
|
|
1
|
+
import{f as e,N as t,j as o,k as i,l as s,A as a,L as r,c as n,h as l,b as d,w as p,p as c}from"./pb-mixin-886ece32.js";import{E as h,T as u,D as m,p as b}from"./vaadin-element-mixin-beb74ffd.js";import{h as g,c as v,F as f,k as y,x as w,y as _,P as x}from"./paper-inky-focus-behavior-fa16796b.js";import{a as $}from"./paper-listbox-5f5d1cec.js";import{a as S}from"./paper-checkbox-645e1077.js";import"./paper-icon-button-984162bd.js";import"./jinn-codemirror-da0e2d1f.js";import{t as E,g as C}from"./pb-i18n-4cc00bfe.js";const k=(()=>{if("undefined"==typeof self)return!1;if("top"in self&&self!==top)try{top}catch(e){return!1}return"showOpenFilePicker"in self})();k?Promise.resolve().then((function(){return O})):Promise.resolve().then((function(){return T})),k?Promise.resolve().then((function(){return I})):Promise.resolve().then((function(){return z}));const A=k?Promise.resolve().then((function(){return j})):Promise.resolve().then((function(){return L}));async function P(...e){return(await A).default(...e)}const R=async e=>{const t=await e.getFile();return t.handle=e,t};var O={__proto__:null,default:async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((e,o)=>{t[o]={description:e.description||"Files",accept:{}},e.mimeTypes?e.mimeTypes.map(i=>{t[o].accept[i]=e.extensions||[]}):t[o].accept["*/*"]=e.extensions||[]});const o=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),i=await Promise.all(o.map(R));return e[0].multiple?i:i[0]}};function B(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(B=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var o=this.s.return;return void 0===o?Promise.resolve({value:e,done:!0}):t(o.apply(this.s,arguments))},throw:function(e){var o=this.s.return;return void 0===o?Promise.reject(e):t(o.apply(this.s,arguments))}},new B(e)}const M=async(e,t,o=e.name,i)=>{const s=[],a=[];var r,n=!1,l=!1;try{for(var d,p=function(e){var t,o,i,s=2;for("undefined"!=typeof Symbol&&(o=Symbol.asyncIterator,i=Symbol.iterator);s--;){if(o&&null!=(t=e[o]))return t.call(e);if(i&&null!=(t=e[i]))return new B(t.call(e));o="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());n=!(d=await p.next()).done;n=!1){const r=d.value,n=`${o}/${r.name}`;"file"===r.kind?a.push(r.getFile().then(t=>(t.directoryHandle=e,t.handle=r,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>n})))):"directory"!==r.kind||!t||i&&i(r)||s.push(M(r,t,n,i))}}catch(e){l=!0,r=e}finally{try{n&&null!=p.return&&await p.return()}finally{if(l)throw r}}return[...(await Promise.all(s)).flat(),...await Promise.all(a)]};var I={__proto__:null,default:async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||"read";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return(await(await t.values()).next()).done?[t]:M(t,e.recursive,void 0,e.skipDirectory)}},j={__proto__:null,default:async(e,t=[{}],o=null,i=!1,s=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const a=[];let r=null;if(e instanceof Blob&&e.type?r=e.type:e.headers&&e.headers.get("content-type")&&(r=e.headers.get("content-type")),t.forEach((e,t)=>{a[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&r&&e.mimeTypes.push(r),e.mimeTypes.map(o=>{a[t].accept[o]=e.extensions||[]})):r?a[t].accept[r]=e.extensions||[]:a[t].accept["*/*"]=e.extensions||[]}),o)try{await o.getFile()}catch(e){if(o=null,i)throw e}const n=o||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:a,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!o&&s&&s(n);const l=await n.createWritable();if("stream"in e){const t=e.stream();return await t.pipeTo(l),n}return"body"in e?(await e.body.pipeTo(l),n):(await l.write(await e),await l.close(),n)}},T={__proto__:null,default:async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,o)=>{const i=document.createElement("input");i.type="file";const s=[...e.map(e=>e.mimeTypes||[]),...e.map(e=>e.extensions||[])].join();i.multiple=e[0].multiple||!1,i.accept=s||"",i.style.display="none",document.body.append(i);const a=e=>{"function"==typeof r&&r(),t(e)},r=e[0].legacySetup&&e[0].legacySetup(a,()=>r(o),i),n=()=>{window.removeEventListener("focus",n),i.remove()};i.addEventListener("click",()=>{window.addEventListener("focus",n)}),i.addEventListener("change",()=>{window.removeEventListener("focus",n),i.remove(),a(i.multiple?Array.from(i.files):i.files[0])}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))},z={__proto__:null,default:async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,o)=>{const i=document.createElement("input");i.type="file",i.webkitdirectory=!0;const s=e=>{"function"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(s,()=>a(o),i);i.addEventListener("change",()=>{let t=Array.from(i.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter(t=>t.webkitRelativePath.split("/").every(t=>!e[0].skipDirectory({name:t,kind:"directory"})))):t=t.filter(e=>2===e.webkitRelativePath.split("/").length),s(t)}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))},L={__proto__:null,default:async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const o=document.createElement("a");let i=e;"body"in e&&(i=await async function(e,t){const o=e.getReader(),i=new ReadableStream({start:e=>async function t(){return o.read().then(({done:o,value:i})=>{if(!o)return e.enqueue(i),t();e.close()})}()}),s=new Response(i),a=await s.blob();return o.releaseLock(),new Blob([a],{type:t})}(e.body,e.headers.get("content-type"))),o.download=t.fileName||"Untitled",o.href=URL.createObjectURL(await i);const s=()=>{"function"==typeof a&&a()},a=t.legacySetup&&t.legacySetup(s,()=>a(),o);return o.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(o.href),3e4),s()}),o.click(),null}};
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
@@ -11,7 +11,7 @@ import{f as e,N as t,j as o,k as i,l as s,A as r,L as a,c as n,h as l,b as d,w a
|
|
|
11
11
|
* Code distributed by Google as part of the polymer project is also
|
|
12
12
|
* subject to an additional IP rights grant found at
|
|
13
13
|
* http://polymer.github.io/PATENTS.txt
|
|
14
|
-
*/const
|
|
14
|
+
*/const q=(e,i)=>{const s=e.startNode.parentNode,a=void 0===i?e.endNode:i.startNode,r=s.insertBefore(o(),a);s.insertBefore(o(),a);const n=new t(e.options);return n.insertAfterNode(r),n},N=(e,t)=>(e.setValue(t),e.commit(),e),F=(e,t,o)=>{const s=e.startNode.parentNode,a=o?o.startNode:e.endNode,r=t.endNode.nextSibling;r!==a&&i(s,t.startNode,r,a)},D=e=>{s(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},U=(e,t,o)=>{const i=new Map;for(let s=t;s<=o;s++)i.set(e[s],s);return i},V=new WeakMap,H=new WeakMap,W=e((e,o,i)=>{let s;return void 0===i?i=o:void 0!==o&&(s=o),o=>{if(!(o instanceof t))throw new Error("repeat can only be used in text bindings");const a=V.get(o)||[],r=H.get(o)||[],n=[],l=[],d=[];let p,c,h=0;for(const t of e)d[h]=s?s(t,h):h,l[h]=i(t,h),h++;let u=0,m=a.length-1,b=0,g=l.length-1;for(;u<=m&&b<=g;)if(null===a[u])u++;else if(null===a[m])m--;else if(r[u]===d[b])n[b]=N(a[u],l[b]),u++,b++;else if(r[m]===d[g])n[g]=N(a[m],l[g]),m--,g--;else if(r[u]===d[g])n[g]=N(a[u],l[g]),F(o,a[u],n[g+1]),u++,g--;else if(r[m]===d[b])n[b]=N(a[m],l[b]),F(o,a[m],a[u]),m--,b++;else if(void 0===p&&(p=U(d,b,g),c=U(r,u,m)),p.has(r[u]))if(p.has(r[m])){const e=c.get(d[b]),t=void 0!==e?a[e]:null;if(null===t){const e=q(o,a[u]);N(e,l[b]),n[b]=e}else n[b]=N(t,l[b]),F(o,t,a[u]),a[e]=null;b++}else D(a[m]),m--;else D(a[u]),u++;for(;b<=g;){const e=q(o,n[g+1]);N(e,l[b]),n[b++]=e}for(;u<=m;){const e=a[u++];null!==e&&D(e)}V.set(o,n),H.set(o,d)}}),K=new WeakMap,G=e(e=>t=>{const o=K.get(t);if(void 0===e&&t instanceof a){if(void 0!==o||!K.has(t)){const e=t.committer.name;t.committer.element.removeAttribute(e)}}else e!==o&&t.setValue(e);K.set(t,e)}),X=g`<dom-module id="lumo-tab" theme-for="vaadin-tab">
|
|
15
15
|
<template>
|
|
16
16
|
<style>
|
|
17
17
|
:host {
|
|
@@ -233,20 +233,20 @@ import{f as e,N as t,j as o,k as i,l as s,A as r,L as a,c as n,h as l,b as d,w a
|
|
|
233
233
|
}
|
|
234
234
|
</style>
|
|
235
235
|
</template>
|
|
236
|
-
</dom-module>`;document.head.appendChild(
|
|
236
|
+
</dom-module>`;document.head.appendChild(X.content);
|
|
237
237
|
/**
|
|
238
238
|
@license
|
|
239
239
|
Copyright (c) 2017 Vaadin Ltd.
|
|
240
240
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
241
241
|
*/
|
|
242
|
-
const
|
|
242
|
+
const Z=e=>class extends e{static get properties(){return{_hasVaadinItemMixin:{value:!0},disabled:{type:Boolean,value:!1,observer:"_disabledChanged",reflectToAttribute:!0},selected:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_selectedChanged"},_value:String}}get value(){return void 0!==this._value?this._value:this.textContent.trim()}set value(e){this._value=e}ready(){super.ready();const e=this.getAttribute("value");null!==e&&(this.value=e),this.addEventListener("focus",e=>this._setFocused(!0),!0),this.addEventListener("blur",e=>this._setFocused(!1),!0),this.addEventListener("mousedown",e=>{this._setActive(this._mousedown=!0);const t=()=>{this._setActive(this._mousedown=!1),document.removeEventListener("mouseup",t)};document.addEventListener("mouseup",t)}),this.addEventListener("keydown",e=>this._onKeydown(e)),this.addEventListener("keyup",e=>this._onKeyup(e))}disconnectedCallback(){super.disconnectedCallback(),this.hasAttribute("active")&&this._setFocused(!1)}_selectedChanged(e){this.setAttribute("aria-selected",e)}_disabledChanged(e){e?(this.selected=!1,this.setAttribute("aria-disabled","true"),this.blur()):this.removeAttribute("aria-disabled")}_setFocused(e){e?(this.setAttribute("focused",""),this._mousedown||this.setAttribute("focus-ring","")):(this.removeAttribute("focused"),this.removeAttribute("focus-ring"),this._setActive(!1))}_setActive(e){e?this.setAttribute("active",""):this.removeAttribute("active")}_onKeydown(e){/^( |SpaceBar|Enter)$/.test(e.key)&&!e.defaultPrevented&&(e.preventDefault(),this._setActive(!0))}_onKeyup(e){this.hasAttribute("active")&&(this._setActive(!1),this.click())}}
|
|
243
243
|
/**
|
|
244
244
|
@license
|
|
245
245
|
Copyright (c) 2017 Vaadin Ltd.
|
|
246
246
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
247
|
-
*/;class
|
|
247
|
+
*/;class J extends(h(u(Z(v)))){static get template(){return g`
|
|
248
248
|
<slot></slot>
|
|
249
|
-
`}static get is(){return"vaadin-tab"}static get version(){return"3.2.0"}ready(){super.ready(),this.setAttribute("role","tab")}_onKeyup(e){const t=this.hasAttribute("active");if(super._onKeyup(e),t){const e=this.querySelector("a");e&&e.click()}}}customElements.define(
|
|
249
|
+
`}static get is(){return"vaadin-tab"}static get version(){return"3.2.0"}ready(){super.ready(),this.setAttribute("role","tab")}_onKeyup(e){const t=this.hasAttribute("active");if(super._onKeyup(e),t){const e=this.querySelector("a");e&&e.click()}}}customElements.define(J.is,J);const Y=g`<dom-module id="lumo-tabs" theme-for="vaadin-tabs">
|
|
250
250
|
<template>
|
|
251
251
|
<style>
|
|
252
252
|
:host {
|
|
@@ -476,18 +476,18 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
476
476
|
}
|
|
477
477
|
</style>
|
|
478
478
|
</template>
|
|
479
|
-
</dom-module>`;document.head.appendChild(
|
|
479
|
+
</dom-module>`;document.head.appendChild(Y.content);
|
|
480
480
|
/**
|
|
481
481
|
@license
|
|
482
482
|
Copyright (c) 2017 Vaadin Ltd.
|
|
483
483
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
484
484
|
*/
|
|
485
|
-
const
|
|
485
|
+
const Q=e=>class extends e{static get properties(){return{_hasVaadinListMixin:{value:!0},selected:{type:Number,reflectToAttribute:!0,notify:!0},orientation:{type:String,reflectToAttribute:!0,value:""},items:{type:Array,readOnly:!0,notify:!0},_searchBuf:{type:String,value:""}}}static get observers(){return["_enhanceItems(items, orientation, selected, disabled)"]}ready(){super.ready(),this.addEventListener("keydown",e=>this._onKeydown(e)),this.addEventListener("click",e=>this._onClick(e)),this._observer=new f(this,e=>{this._setItems(this._filterItems(Array.from(this.children)))})}_enhanceItems(e,t,o,i){if(!i&&e){this.setAttribute("aria-orientation",t||"vertical"),this.items.forEach(e=>{t?e.setAttribute("orientation",t):e.removeAttribute("orientation"),e.updateStyles()}),this._setFocusable(o);const i=e[o];e.forEach(e=>e.selected=e===i),i&&!i.disabled&&this._scrollToItem(o)}}get focused(){return this.getRootNode().activeElement}_filterItems(e){return e.filter(e=>e._hasVaadinItemMixin)}_onClick(e){if(e.metaKey||e.shiftKey||e.ctrlKey||e.defaultPrevented)return;const t=this._filterItems(e.composedPath())[0];let o;t&&!t.disabled&&(o=this.items.indexOf(t))>=0&&(this.selected=o)}_searchKey(e,t){this._searchReset=y.debounce(this._searchReset,w.after(500),()=>this._searchBuf=""),this._searchBuf+=t.toLowerCase();const o=1,i=e=>!(e.disabled||this._isItemHidden(e))&&0===e.textContent.replace(/[^a-zA-Z0-9]/g,"").toLowerCase().indexOf(this._searchBuf);this.items.some(e=>0===e.textContent.replace(/[^a-zA-Z0-9]/g,"").toLowerCase().indexOf(this._searchBuf))||(this._searchBuf=t.toLowerCase());const s=1===this._searchBuf.length?e+1:e;return this._getAvailableIndex(s,o,i)}get _isRTL(){return!this._vertical&&"rtl"===this.getAttribute("dir")}_onKeydown(e){if(e.metaKey||e.ctrlKey)return;const t=e.key.replace(/^Arrow/,""),o=this.items.indexOf(this.focused);if(/[a-zA-Z0-9]/.test(t)&&1===t.length){const e=this._searchKey(o,t);return void(e>=0&&this._focus(e))}const i=e=>!(e.disabled||this._isItemHidden(e));let s,a;const r=this._isRTL?-1:1;this._vertical&&"Up"===t||!this._vertical&&"Left"===t?(a=-r,s=o-r):this._vertical&&"Down"===t||!this._vertical&&"Right"===t?(a=r,s=o+r):"Home"===t?(a=1,s=0):"End"===t&&(a=-1,s=this.items.length-1),s=this._getAvailableIndex(s,a,i),s>=0&&(this._focus(s),e.preventDefault())}_getAvailableIndex(e,t,o){const i=this.items.length;for(let s=0;"number"==typeof e&&s<i;s++,e+=t||1){e<0?e=i-1:e>=i&&(e=0);if(o(this.items[e]))return e}return-1}_isItemHidden(e){return"none"===getComputedStyle(e).display}_setFocusable(e){e=this._getAvailableIndex(e,1,e=>!e.disabled);const t=this.items[e]||this.items[0];this.items.forEach(e=>e.tabIndex=e===t?0:-1)}_focus(e){const t=this.items[e];this.items.forEach(e=>e.focused=e===t),this._setFocusable(e),this._scrollToItem(e),t.focus()}focus(){this._observer&&this._observer.flush();const e=this.querySelector('[tabindex="0"]')||(this.items?this.items[0]:null);e&&e.focus()}get _scrollerElement(){}_scrollToItem(e){const t=this.items[e];if(!t)return;const o=this._vertical?["top","bottom"]:this._isRTL?["right","left"]:["left","right"],i=this._scrollerElement.getBoundingClientRect(),s=(this.items[e+1]||t).getBoundingClientRect(),a=(this.items[e-1]||t).getBoundingClientRect();let r=0;!this._isRTL&&s[o[1]]>=i[o[1]]||this._isRTL&&s[o[1]]<=i[o[1]]?r=s[o[1]]-i[o[1]]:(!this._isRTL&&a[o[0]]<=i[o[0]]||this._isRTL&&a[o[0]]>=i[o[0]])&&(r=a[o[0]]-i[o[0]]),this._scroll(r)}get _vertical(){return"horizontal"!==this.orientation}_scroll(e){if(this._vertical)this._scrollerElement.scrollTop+=e;else{const t=m.detectScrollType(),o=m.getNormalizedScrollLeft(t,this.getAttribute("dir")||"ltr",this._scrollerElement)+e;m.setNormalizedScrollLeft(t,this.getAttribute("dir")||"ltr",this._scrollerElement,o)}}}
|
|
486
486
|
/**
|
|
487
487
|
@license
|
|
488
488
|
Copyright (c) 2017 Vaadin Ltd.
|
|
489
489
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
490
|
-
*/,
|
|
490
|
+
*/,ee=/Apple.* Version\/(9|10)/.test(navigator.userAgent);class te extends(h(Q(u(_([$],v))))){static get template(){return g`
|
|
491
491
|
<style>
|
|
492
492
|
:host {
|
|
493
493
|
display: flex;
|
|
@@ -573,305 +573,406 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
573
573
|
</div>
|
|
574
574
|
|
|
575
575
|
<div on-click="_scrollForward" part="forward-button"></div>
|
|
576
|
-
`}static get is(){return"vaadin-tabs"}static get version(){return"3.2.0"}static get properties(){return{orientation:{value:"horizontal",type:String},selected:{value:0,type:Number}}}static get observers(){return["_updateOverflow(items.*, vertical)"]}ready(){super.ready(),this.addEventListener("iron-resize",()=>this._updateOverflow()),this._scrollerElement.addEventListener("scroll",()=>this._updateOverflow()),this.setAttribute("role","tablist"),
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
grid-row-gap:20px;
|
|
585
|
-
margin-bottom:10px;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
.editor label {
|
|
589
|
-
margin-bottom:5px;
|
|
590
|
-
font-size: 12px;
|
|
591
|
-
font-weight: 400;
|
|
592
|
-
color: var(--paper-grey-500);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
paper-dropdown-menu{
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
paper-icon-button{
|
|
599
|
-
align-self:center;
|
|
600
|
-
}
|
|
601
|
-
`}render(){return l`
|
|
602
|
-
<div class="wrapper">
|
|
603
|
-
<paper-dropdown-menu label="Scope">
|
|
604
|
-
<paper-listbox id="scopeList" slot="dropdown-content" selected="${this.scope}" attr-for-selected="value"
|
|
605
|
-
@iron-select="${this._listchanged}">
|
|
606
|
-
${this.scopes.map(e=>l`
|
|
607
|
-
<paper-item value="${e}">${e}</paper-item>
|
|
608
|
-
`)}
|
|
609
|
-
</paper-listbox>
|
|
610
|
-
</paper-dropdown-menu>
|
|
611
|
-
<div class="editor">
|
|
612
|
-
<label>Rendition</label>
|
|
613
|
-
<jinn-codemirror
|
|
614
|
-
id="editor"
|
|
615
|
-
label="Rendition"
|
|
616
|
-
code="${this.css||""}"
|
|
617
|
-
mode="css"
|
|
618
|
-
@update="${this._handleCodeChange}"></jinn-codemirror>
|
|
619
|
-
</div>
|
|
620
|
-
<paper-icon-button @click="${this._remove}" icon="delete" title="delete this rendition"></paper-icon-button>
|
|
621
|
-
</div>
|
|
576
|
+
`}static get is(){return"vaadin-tabs"}static get version(){return"3.2.0"}static get properties(){return{orientation:{value:"horizontal",type:String},selected:{value:0,type:Number}}}static get observers(){return["_updateOverflow(items.*, vertical)"]}ready(){super.ready(),this.addEventListener("iron-resize",()=>this._updateOverflow()),this._scrollerElement.addEventListener("scroll",()=>this._updateOverflow()),this.setAttribute("role","tablist"),S(this,()=>{this._updateOverflow()})}_scrollForward(){this._scroll(-this.__direction*this._scrollOffset)}_scrollBack(){this._scroll(this.__direction*this._scrollOffset)}get _scrollOffset(){return this._vertical?this._scrollerElement.offsetHeight:this._scrollerElement.offsetWidth}get _scrollerElement(){return this.$.scroll}get __direction(){return this._vertical||"rtl"!==this.getAttribute("dir")?-1:1}_updateOverflow(){const e=this._vertical?this._scrollerElement.scrollTop:this.__getNormalizedScrollLeft(this._scrollerElement);let t=this._vertical?this._scrollerElement.scrollHeight:this._scrollerElement.scrollWidth;t-=1;let o=e>0?"start":"";o+=e+this._scrollOffset<t?" end":"",1==this.__direction&&(o=o.replace(/start|end/gi,e=>"start"===e?"end":"start")),o?this.setAttribute("overflow",o.trim()):this.removeAttribute("overflow"),this._repaintShadowNodesHack()}_repaintShadowNodesHack(){if(ee&&this.root){const e="-webkit-backface-visibility";this.root.querySelectorAll("*").forEach(t=>{t.style[e]="visible",t.style[e]=""})}}}customElements.define(te.is,te),x({_template:g`
|
|
577
|
+
<style>
|
|
578
|
+
:host {
|
|
579
|
+
display: block;
|
|
580
|
+
box-sizing: border-box;
|
|
581
|
+
position: relative;
|
|
582
|
+
|
|
583
|
+
--paper-input-container-focus-color: var(--primary-color);
|
|
622
584
|
|
|
585
|
+
--paper-icon-button: {
|
|
586
|
+
height: 24px;
|
|
587
|
+
width: 24px;
|
|
588
|
+
padding: 2px;
|
|
589
|
+
}
|
|
623
590
|
|
|
591
|
+
--paper-input-container-ms-clear: {
|
|
592
|
+
display: none;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
624
595
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
596
|
+
.input-wrapper {
|
|
597
|
+
@apply --layout-horizontal;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.input-wrapper paper-input {
|
|
601
|
+
@apply --layout-flex;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
#clear {
|
|
605
|
+
display: none;
|
|
606
|
+
line-height: 8px;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
.sr-only {
|
|
610
|
+
position: absolute;
|
|
611
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
paper-autocomplete-suggestions {
|
|
615
|
+
--suggestions-wrapper: {
|
|
616
|
+
@apply --paper-autocomplete-suggestions-wrapper;
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
--paper-item-min-height: var(--paper-autocomplete-suggestions-item-min-height, 36px);
|
|
620
|
+
}
|
|
621
|
+
</style>
|
|
622
|
+
|
|
623
|
+
<div class="input-wrapper" role="combobox" aria-haspopup="true" aria-owns="suggestionsWrapper" aria-expanded\$="[[_isSuggestionsOpened]]">
|
|
624
|
+
<!-- For accessibility, it is needed to have a label or aria-label. Label is preferred -->
|
|
625
|
+
<label for="autocompleteInput" class="sr-only">[[label]]</label>
|
|
626
|
+
|
|
627
|
+
<!-- Adding a hidden input to integrate with iron-form, if required -->
|
|
628
|
+
<input type="hidden" name\$="[[name]]" value\$="[[value]]">
|
|
629
|
+
|
|
630
|
+
<paper-input id="autocompleteInput" label="[[label]]" autocapitalize="[[autocapitalize]]" no-label-float="[[noLabelFloat]]" disabled="{{disabled}}" readonly="[[readonly]]" focused="{{focused}}" auto-validate\$="[[autoValidate]]" error-message\$="[[errorMessage]]" required\$="[[required]]" value="{{text}}" allowed-pattern="[[allowedPattern]]" pattern="[[pattern]]" always-float-label="[[alwaysFloatLabel]]" char-counter\$="[[charCounter]]" maxlength\$="[[maxlength]]" placeholder="[[placeholder]]" invalid="{{invalid}}" role="textbox" aria-autocomplete="list" aria-multiline="false" aria-activedescendant\$="[[_highlightedSuggestion.elementId]]" aria-disabled\$="[[disabled]]" aria-controls="autocompleteStatus suggestionsWrapper">
|
|
631
|
+
|
|
632
|
+
<slot name="prefix" slot="prefix"></slot>
|
|
633
|
+
<!-- TODO: remove tabindex workaround when is fixed https://github.com/PolymerElements/paper-input/issues/324 -->
|
|
634
|
+
<paper-icon-button slot="suffix" suffix="" id="clear" icon="clear" on-click="_clear" tabindex="-1"></paper-icon-button>
|
|
635
|
+
<slot name="suffix" slot="suffix"></slot>
|
|
636
|
+
</paper-input>
|
|
637
|
+
<!-- to announce current selection to screen reader -->
|
|
638
|
+
<span id="autocompleteStatus" role="status" class="sr-only">[[_highlightedSuggestion.textValue]]</span>
|
|
639
|
+
</div>
|
|
640
|
+
|
|
641
|
+
<paper-autocomplete-suggestions for="autocompleteInput" id="paperAutocompleteSuggestions" min-length="[[minLength]]" text-property="[[textProperty]]" value-property="[[valueProperty]]" selected-option="{{selectedOption}}" source="[[source]]" remote-source="[[remoteSource]]" query-fn="[[queryFn]]" event-namespace="[[eventNamespace]]" highlighted-suggestion="{{_highlightedSuggestion}}" is-open="{{_isSuggestionsOpened}}" highlight-first="[[highlightFirst]]" show-results-on-focus="[[showResultsOnFocus]]">
|
|
642
|
+
|
|
643
|
+
<slot id="templates" name="autocomplete-custom-template"></slot>
|
|
644
|
+
|
|
645
|
+
</paper-autocomplete-suggestions>
|
|
646
|
+
`,is:"paper-autocomplete",properties:{autoValidate:{type:Boolean,value:!1},invalid:{type:Boolean,notify:!0,value:!1},autocapitalize:String,errorMessage:{type:String},label:String,noLabelFloat:{type:Boolean,value:!1},alwaysFloatLabel:{type:Boolean,value:!1},placeholder:String,required:{type:Boolean,value:!1},readonly:{type:Boolean,value:!1},focused:{type:Boolean,value:!1,notify:!0},disabled:{type:Boolean,value:!1},source:{type:Array,observer:"_sourceChanged"},textProperty:{type:String,value:"text"},valueProperty:{type:String,value:"value"},value:{type:Object,notify:!0},text:{type:String,notify:!0,value:""},disableShowClear:{type:Boolean,value:!1},remoteSource:{type:Boolean,value:!1},eventNamespace:{type:String,value:"-"},minLength:{type:Number,value:1},pattern:String,allowedPattern:String,charCounter:{type:Boolean,value:!1},maxlength:{type:Number},name:String,queryFn:{type:Function},highlightFirst:{type:Boolean,value:!1},showResultsOnFocus:{type:Boolean,value:!1},_value:{value:void 0},_text:{value:void 0},_isClearButtonVisible:{type:Boolean,value:!1},_isSuggestionsOpened:{type:Boolean,value:!1},selectedOption:{type:Object,notify:!0}},observers:["_textObserver(text)"],_sourceChanged:function(e){var t=this.text;!Array.isArray(e)||0===e.length||null===t||t.length<this.minLength||this.$.autocompleteInput.focused&&this.$.paperAutocompleteSuggestions._handleSuggestions({target:{value:t}})},ready:function(){this._value=this.value,this.addEventListener("autocomplete"+this.eventNamespace+"selected",this._onAutocompleteSelected.bind(this))},_clear:function(){var e={text:this.text,value:this.value};this.value=null,this._value=null,this.text="",this._text="",this._fireEvent(e,"reset-blur"),this._hideClearButton(),this.$.autocompleteInput.focused||this.$.autocompleteInput.focus()},_fireEvent:function(e,t){var o=this._getId(),i="autocomplete"+this.eventNamespace+t;this.fire(i,{id:o,value:e[this.valueProperty]||e.value,text:e[this.textProperty]||e.text,target:this,option:e})},_textObserver:function(e){e&&e.trim()?this._showClearButton():this._hideClearButton()},_onAutocompleteSelected:function(e){var t=e.detail;this.value=t.value,this.text=t.text},_showClearButton:function(){this.disableShowClear||this._isClearButtonVisible||(this.$.clear.style.display="inline-block",this._isClearButtonVisible=!0)},_hideClearButton:function(){this._isClearButtonVisible&&(this.$.clear.style.display="none",this._isClearButtonVisible=!1)},_getId:function(){var e=this.getAttribute("id");return e||(e=this.dataset.id),e},getOption:function(){return{text:this.text,value:this.value}},setOption:function(e){this.text=e[this.textProperty]||e.text,this.value=e[this.valueProperty]||e.value,this._showClearButton()},disable:function(){this.disabled=!0},enable:function(){this.disabled=!1},suggestions:function(e){this.$.paperAutocompleteSuggestions.suggestions(e)},validate:function(){return this.$.autocompleteInput.validate()},clear:function(){this._value="",this._text="",this._clear()},reset:function(){this._clear()},hideSuggestions:function(){this._hideClearButton(),this.$.paperAutocompleteSuggestions.hideSuggestions()},onSelectHandler:function(e){this.$.paperAutocompleteSuggestions._onSelect(e)}});class oe extends r{static get styles(){return n`
|
|
647
|
+
:host {
|
|
648
|
+
display: block;
|
|
649
|
+
}
|
|
650
|
+
.wrapper {
|
|
651
|
+
display: grid;
|
|
652
|
+
grid-template-columns: 150px auto 50px;
|
|
653
|
+
grid-column-gap: 20px;
|
|
654
|
+
grid-row-gap: 20px;
|
|
655
|
+
margin-bottom: 10px;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
.editor label {
|
|
659
|
+
margin-bottom: 5px;
|
|
660
|
+
font-size: 12px;
|
|
661
|
+
font-weight: 400;
|
|
662
|
+
color: var(--paper-grey-500);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
paper-dropdown-menu {
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
paper-icon-button {
|
|
669
|
+
align-self: center;
|
|
670
|
+
}
|
|
671
|
+
`}render(){return l`
|
|
672
|
+
<div class="wrapper">
|
|
673
|
+
<paper-dropdown-menu label="Scope">
|
|
674
|
+
<paper-listbox
|
|
675
|
+
id="scopeList"
|
|
676
|
+
slot="dropdown-content"
|
|
677
|
+
selected="${this.scope}"
|
|
678
|
+
attr-for-selected="value"
|
|
679
|
+
@iron-select="${this._listchanged}"
|
|
680
|
+
>
|
|
681
|
+
${this.scopes.map(e=>l` <paper-item value="${e}">${e}</paper-item> `)}
|
|
682
|
+
</paper-listbox>
|
|
683
|
+
</paper-dropdown-menu>
|
|
684
|
+
<div class="editor">
|
|
685
|
+
<label>Rendition</label>
|
|
686
|
+
<jinn-codemirror
|
|
687
|
+
id="editor"
|
|
688
|
+
label="Rendition"
|
|
689
|
+
code="${this.css||""}"
|
|
690
|
+
mode="css"
|
|
691
|
+
@update="${this._handleCodeChange}"
|
|
692
|
+
></jinn-codemirror>
|
|
693
|
+
</div>
|
|
694
|
+
<paper-icon-button
|
|
695
|
+
@click="${this._remove}"
|
|
696
|
+
icon="delete"
|
|
697
|
+
title="delete this rendition"
|
|
698
|
+
></paper-icon-button>
|
|
699
|
+
</div>
|
|
700
|
+
|
|
701
|
+
<slot></slot>
|
|
702
|
+
`}static get properties(){return{scopes:{type:Array},css:{type:String,reflect:!0},scope:{type:String,reflect:!0},selected:{type:String}}}constructor(){super(),this.scopes=["","before","after"],this.css="",this.scope="",this.selected="",this._initialized=!1}connectedCallback(){super.connectedCallback(),this.css=this.css.trim(),this.dispatchEvent(new CustomEvent("rendition-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}firstUpdated(e){this.refreshEditor(),this._initialized=!0}refreshEditor(){console.log("refreshEditor"),this.shadowRoot.getElementById("editor")}_remove(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("remove-rendition",{}))}_handleCodeChange(){this.css=this.shadowRoot.getElementById("editor").value,this.dispatchEvent(new CustomEvent("rendition-changed",{composed:!0,bubbles:!0,detail:{name:this.name,css:this.css,scope:this.scope}}))}_listchanged(e){const t=this.shadowRoot.getElementById("scopeList");this.scope=t.selected}}customElements.define("pb-odd-rendition-editor",oe);class ie extends r{static get styles(){return n`
|
|
703
|
+
:host {
|
|
704
|
+
display: block;
|
|
705
|
+
}
|
|
706
|
+
.wrapper {
|
|
707
|
+
display: grid;
|
|
708
|
+
grid-template-columns: 150px auto 50px 50px;
|
|
709
|
+
grid-column-gap: 20px;
|
|
710
|
+
grid-row-gap: 20px;
|
|
711
|
+
margin-bottom: 10px;
|
|
712
|
+
}
|
|
713
|
+
paper-dropdown-menu {
|
|
714
|
+
align-self: start;
|
|
715
|
+
}
|
|
716
|
+
paper-icon-button,
|
|
717
|
+
paper-checkbox {
|
|
718
|
+
align-self: center;
|
|
719
|
+
margin-top: 16px;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
.editor label {
|
|
723
|
+
margin-bottom: 5px;
|
|
724
|
+
font-size: 12px;
|
|
725
|
+
font-weight: 400;
|
|
726
|
+
color: var(--paper-grey-500);
|
|
727
|
+
}
|
|
728
|
+
`}render(){return l`
|
|
729
|
+
<div class="wrapper">
|
|
730
|
+
<paper-autocomplete
|
|
731
|
+
id="combo"
|
|
732
|
+
text="${this.name}"
|
|
733
|
+
placeholder="${E("odd.editor.model.param-name-placeholder")}"
|
|
734
|
+
label="Name"
|
|
735
|
+
.source="${this._currentParameters}"
|
|
736
|
+
></paper-autocomplete>
|
|
737
|
+
|
|
738
|
+
<div class="editor">
|
|
739
|
+
<label>Parameter</label>
|
|
740
|
+
<jinn-codemirror
|
|
741
|
+
id="editor"
|
|
742
|
+
mode="xquery"
|
|
743
|
+
code="${this.value}"
|
|
744
|
+
linter="${this.endpoint}/${d(this.apiVersion,"1.0.0")?"modules/editor.xql":"api/lint"}"
|
|
745
|
+
></jinn-codemirror>
|
|
667
746
|
</div>
|
|
747
|
+
<paper-checkbox id="set" ?checked="${this.setParam}" @change="${this._handleCodeChange}"
|
|
748
|
+
>${E("odd.editor.model.set-param")}</paper-checkbox
|
|
749
|
+
>
|
|
750
|
+
<paper-icon-button
|
|
751
|
+
@click="${this._delete}"
|
|
752
|
+
icon="delete"
|
|
753
|
+
title="delete this parameter"
|
|
754
|
+
></paper-icon-button>
|
|
755
|
+
</div>
|
|
756
|
+
`}static get properties(){return{name:{type:String,reflect:!0},value:{type:String,reflect:!0},behaviour:{type:String},parameters:{type:Object},setParam:{type:Boolean,attribute:"set"},_currentParameters:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.name="",this.value="",this.setParam=!1,this.behaviour="",this.currentParameters=[],this.parameters={"":[],alternate:["default","alternate","persistent"],anchor:["content","id"],block:["content"],body:["content"],break:["content","type","label"],cell:["content"],cit:["content","source"],document:["content"],figure:["content","title"],graphic:["content","url","width","height","scale","title"],heading:["content","level"],inline:["content"],link:["content","uri","target"],list:["content","type"],listItem:["content","n"],metadata:["content"],note:["content","place","label"],omit:[],paragraph:["content"],row:["content"],section:["content"],table:["content"],text:["content"],title:["content"],webcomponent:["content","name"]},this.selected="",this.endpoint=""}connectedCallback(){super.connectedCallback(),this.value=this.value.trim(),this.dispatchEvent(new CustomEvent("parameter-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"behaviour"===e&&(this._currentParameters=this.parameters[o])}firstUpdated(e){this.selected=this.parameters[this.behaviour]||[],this.requestUpdate(),this.shadowRoot.getElementById("combo").addEventListener("focused-changed",this._handleCodeChange.bind(this)),this.shadowRoot.getElementById("editor").addEventListener("update",this._handleCodeChange.bind(this))}refreshEditor(){this.shadowRoot.getElementById("editor")}_delete(e){console.log("parameter delete ",e),e.preventDefault(),this.dispatchEvent(new CustomEvent("parameter-remove",{}))}_handleCodeChange(e){console.log("_handleCodeChange ",e),this.value=this.shadowRoot.getElementById("editor").content||"",console.log("value %s",this.value),this.name=this.shadowRoot.getElementById("combo").text,this.setParam=this.shadowRoot.getElementById("set").checked,this.dispatchEvent(new CustomEvent("parameter-changed",{composed:!0,bubbles:!0,detail:{name:this.name,value:this.value,set:this.setParam}}))}}customElements.define("pb-odd-parameter-editor",ie);class se extends r{static get styles(){return n`
|
|
757
|
+
:host {
|
|
758
|
+
display: flex;
|
|
759
|
+
flex-direction: column;
|
|
760
|
+
}
|
|
761
|
+
h1,
|
|
762
|
+
h2,
|
|
763
|
+
h3,
|
|
764
|
+
h4,
|
|
765
|
+
h5,
|
|
766
|
+
h6 {
|
|
767
|
+
font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
|
|
768
|
+
font-weight: 400 !important;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
form {
|
|
772
|
+
margin-bottom: 8px;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
paper-input,
|
|
776
|
+
paper-autocomplete {
|
|
777
|
+
margin-bottom: 16px;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
.models {
|
|
781
|
+
margin-left: 20px;
|
|
782
|
+
margin-top: 10px;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.btn,
|
|
786
|
+
.btn-group {
|
|
787
|
+
margin-top: 0;
|
|
788
|
+
margin-bottom: 0;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
header {
|
|
792
|
+
// background-color: #d1dae0;
|
|
793
|
+
background: var(--paper-grey-300);
|
|
794
|
+
margin: 0;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
header div {
|
|
798
|
+
display: flex;
|
|
799
|
+
flex-direction: row;
|
|
800
|
+
justify-content: space-between;
|
|
801
|
+
align-items: center;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
header h4 {
|
|
805
|
+
padding: 4px 8px;
|
|
806
|
+
margin: 0;
|
|
807
|
+
display: grid;
|
|
808
|
+
grid-template-columns: 40px 40% auto;
|
|
809
|
+
}
|
|
810
|
+
h4 .btn-group {
|
|
811
|
+
text-align: right;
|
|
812
|
+
display: none;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
#toggle,
|
|
816
|
+
.modelType {
|
|
817
|
+
align-self: center;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
header div.info {
|
|
821
|
+
padding: 0 16px 4px;
|
|
822
|
+
margin: 0;
|
|
823
|
+
font-size: 85%;
|
|
824
|
+
display: block;
|
|
825
|
+
margin: 0 0 0 32px;
|
|
826
|
+
}
|
|
827
|
+
header div.info * {
|
|
828
|
+
display: block;
|
|
829
|
+
line-height: 1.2;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
header .outputDisplay {
|
|
833
|
+
text-transform: uppercase;
|
|
834
|
+
}
|
|
835
|
+
header .description {
|
|
836
|
+
font-style: italic;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
header .predicate {
|
|
840
|
+
color: #ff5722;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
.predicate label,
|
|
844
|
+
.template label {
|
|
845
|
+
display: block;
|
|
846
|
+
font-size: 12px;
|
|
847
|
+
font-weight: 300;
|
|
848
|
+
color: rgb(115, 115, 115);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
.model-collapse {
|
|
852
|
+
color: #000000;
|
|
853
|
+
cursor: pointer;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
.model-collapse:hover {
|
|
857
|
+
text-decoration: none;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
.behaviour {
|
|
861
|
+
color: #ff5722;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
.behaviour:before {
|
|
865
|
+
content: ' [';
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
.behaviour:after {
|
|
869
|
+
content: ']';
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
.behaviourWrapper {
|
|
873
|
+
display: grid;
|
|
874
|
+
grid-template-columns: 140px 40px 140px auto;
|
|
875
|
+
}
|
|
876
|
+
.behaviourWrapper > * {
|
|
877
|
+
display: inline;
|
|
878
|
+
align-self: stretch;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
.group {
|
|
882
|
+
margin: 0;
|
|
883
|
+
font-size: 16px;
|
|
884
|
+
font-weight: bold;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
.group .title {
|
|
888
|
+
/*text-decoration: underline;*/
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.renditions,
|
|
892
|
+
.parameters {
|
|
893
|
+
padding-left: 16px;
|
|
894
|
+
border-left: 3px solid #e0e0e0;
|
|
895
|
+
margin-bottom: 20px;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
.renditions .group {
|
|
899
|
+
display: flex;
|
|
900
|
+
flex-direction: row;
|
|
901
|
+
justify-content: space-between;
|
|
902
|
+
align-items: center;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
.predicate .form-control {
|
|
906
|
+
width: 100%;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
.source {
|
|
910
|
+
text-decoration: none;
|
|
911
|
+
margin-bottom: 8px;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
.selectOutput {
|
|
915
|
+
margin-right: 10px;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
:host([currentselection]) > form > header {
|
|
919
|
+
@apply --shadow-elevation-4dp;
|
|
920
|
+
border-left: 3px solid var(--paper-blue-500);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
paper-menu-button paper-icon-button {
|
|
924
|
+
margin-left: -10px;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/* need to play it save for FF */
|
|
928
|
+
:host([currentselection]) > form > header > h4 > .btn-group {
|
|
929
|
+
display: inline-block;
|
|
930
|
+
}
|
|
931
|
+
details {
|
|
932
|
+
display: block;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
details summary {
|
|
936
|
+
display: none;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
.renditions {
|
|
940
|
+
margin-top: 10px;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
.details {
|
|
944
|
+
padding: 0px 50px 20px 20px;
|
|
945
|
+
background: var(--paper-grey-200);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
details:not([open]) {
|
|
949
|
+
padding: 0;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
.editor label {
|
|
953
|
+
margin-bottom: 5px;
|
|
954
|
+
font-size: 12px;
|
|
955
|
+
font-weight: 400;
|
|
956
|
+
color: var(--paper-grey-500);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
.horizontal {
|
|
960
|
+
display: flex;
|
|
961
|
+
flex-wrap: wrap;
|
|
962
|
+
justify-content: space-between;
|
|
963
|
+
}
|
|
668
964
|
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
flex-direction:column;
|
|
674
|
-
}
|
|
675
|
-
h1, h2, h3, h4, h5, h6 {
|
|
676
|
-
font-family: "Oswald", Verdana, "Helvetica", sans-serif;
|
|
677
|
-
font-weight: 400 !important;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
form {
|
|
681
|
-
margin-bottom: 8px;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
paper-input, paper-autocomplete {
|
|
685
|
-
margin-bottom: 16px;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
.models {
|
|
689
|
-
margin-left:20px;
|
|
690
|
-
margin-top:10px;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
.btn, .btn-group {
|
|
694
|
-
margin-top: 0;
|
|
695
|
-
margin-bottom: 0;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
header {
|
|
699
|
-
// background-color: #d1dae0;
|
|
700
|
-
background:var(--paper-grey-300);
|
|
701
|
-
margin:0;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
header div {
|
|
705
|
-
display: flex;
|
|
706
|
-
flex-direction: row;
|
|
707
|
-
justify-content: space-between;
|
|
708
|
-
align-items: center;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
header h4 {
|
|
712
|
-
padding: 4px 8px;
|
|
713
|
-
margin: 0;
|
|
714
|
-
display: grid;
|
|
715
|
-
grid-template-columns: 40px 40% auto;
|
|
716
|
-
}
|
|
717
|
-
h4 .btn-group{
|
|
718
|
-
text-align: right;
|
|
719
|
-
display: none;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
#toggle, .modelType{
|
|
723
|
-
align-self:center;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
header div.info {
|
|
727
|
-
padding: 0 16px 4px;
|
|
728
|
-
margin: 0;
|
|
729
|
-
font-size: 85%;
|
|
730
|
-
display: block;
|
|
731
|
-
margin:0 0 0 32px;
|
|
732
|
-
}
|
|
733
|
-
header div.info *{
|
|
734
|
-
display: block;
|
|
735
|
-
line-height: 1.2;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
header .outputDisplay{
|
|
739
|
-
text-transform: uppercase ;
|
|
740
|
-
}
|
|
741
|
-
header .description{
|
|
742
|
-
font-style: italic;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
header .predicate {
|
|
746
|
-
color: #ff5722;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
.predicate label, .template label {
|
|
750
|
-
display: block;
|
|
751
|
-
font-size: 12px;
|
|
752
|
-
font-weight: 300;
|
|
753
|
-
color: rgb(115, 115, 115);
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
.model-collapse {
|
|
757
|
-
color: #000000;
|
|
758
|
-
cursor: pointer;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
.model-collapse:hover {
|
|
762
|
-
text-decoration: none;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
.behaviour {
|
|
766
|
-
color: #ff5722;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
.behaviour:before {
|
|
770
|
-
content: ' [';
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
.behaviour:after {
|
|
774
|
-
content: ']';
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
.behaviourWrapper{
|
|
778
|
-
display:grid;
|
|
779
|
-
grid-template-columns: 140px 40px 140px auto;
|
|
780
|
-
}
|
|
781
|
-
.behaviourWrapper > *{
|
|
782
|
-
display:inline;
|
|
783
|
-
align-self:stretch;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
.group {
|
|
787
|
-
margin: 0;
|
|
788
|
-
font-size: 16px;
|
|
789
|
-
font-weight: bold;
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
.group .title {
|
|
793
|
-
/*text-decoration: underline;*/
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
.renditions, .parameters {
|
|
797
|
-
padding-left: 16px;
|
|
798
|
-
border-left: 3px solid #e0e0e0;
|
|
799
|
-
margin-bottom:20px;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
.renditions .group {
|
|
803
|
-
display: flex;
|
|
804
|
-
flex-direction: row;
|
|
805
|
-
justify-content: space-between;
|
|
806
|
-
align-items: center;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
.predicate .form-control {
|
|
810
|
-
width: 100%;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
.source {
|
|
814
|
-
text-decoration: none;
|
|
815
|
-
margin-bottom: 8px;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
.selectOutput {
|
|
819
|
-
margin-right: 10px;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
:host([currentselection]) > form > header{
|
|
823
|
-
@apply --shadow-elevation-4dp;
|
|
824
|
-
border-left:3px solid var(--paper-blue-500);
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
paper-menu-button paper-icon-button{
|
|
828
|
-
margin-left:-10px;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
/* need to play it save for FF */
|
|
832
|
-
:host([currentselection]) > form > header > h4 > .btn-group{
|
|
833
|
-
display: inline-block;
|
|
834
|
-
}
|
|
835
|
-
iron-collapse{
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
.renditions{
|
|
839
|
-
margin-top:10px;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
.details{
|
|
843
|
-
padding:0px 50px 20px 20px;
|
|
844
|
-
background:var(--paper-grey-200);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
.editor {
|
|
848
|
-
margin-bottom: 20px;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
.editor label {
|
|
852
|
-
margin-bottom:5px;
|
|
853
|
-
font-size: 12px;
|
|
854
|
-
font-weight: 400;
|
|
855
|
-
color: var(--paper-grey-500);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
.horizontal {
|
|
859
|
-
display: flex;
|
|
860
|
-
flex-wrap: wrap;
|
|
861
|
-
justify-content: space-between;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
#mode {
|
|
865
|
-
min-width: 18em;
|
|
866
|
-
}
|
|
867
|
-
`}static get properties(){return{behaviour:{type:String},predicate:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},type:{type:String,reflect:!0},template:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},output:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},css:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},mode:{type:String},model:{type:Object},models:{type:Array},parameters:{type:Array},renditions:{type:Array},desc:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},sourcerend:{type:String},show:{type:Boolean,reflect:!0},outputs:{type:Array},behaviours:{type:Array},icon:{type:String},open:{type:String},hasCustomBehaviour:{type:Boolean},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.behaviour="inline",this.predicate="",this.type="",this.template="",this.output="",this.css="",this.mode="",this.model={},this.model.models=[],this.parameters=[],this.renditions=[],this.desc="",this.sourcerend="",this.show=!1,this.outputs=["","web","print","epub","fo","latex","plain"],this.parentModel=[],this.behaviours=["alternate","anchor","block","body","break","cell","cit","document","figure","graphic","heading","inline","link","list","listItem","metadata","note","omit","paragraph","pass-through","row","section","table","text","title","webcomponent"],this.icon="expand-more",this.hasCustomBehaviour=!1}render(){let e;switch(this.output){case"web":case"epub":e="html";break;case"latex":e="tex";break;case"plain":e="default";break;case"fo":case"print":e="xml";break;default:e="html"}return l`
|
|
965
|
+
#mode {
|
|
966
|
+
min-width: 18em;
|
|
967
|
+
}
|
|
968
|
+
`}static get properties(){return{behaviour:{type:String},predicate:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},type:{type:String,reflect:!0},template:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},output:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},css:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},mode:{type:String},model:{type:Object},models:{type:Array},parameters:{type:Array},renditions:{type:Array},desc:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},sourcerend:{type:String},show:{type:Boolean,reflect:!0},outputs:{type:Array},behaviours:{type:Array},icon:{type:String},open:{type:String},hasCustomBehaviour:{type:Boolean},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.behaviour="inline",this.predicate="",this.type="",this.template="",this.output="",this.css="",this.mode="",this.model={},this.model.models=[],this.parameters=[],this.renditions=[],this.desc="",this.sourcerend="",this.show=!1,this.outputs=["","web","print","epub","fo","latex","plain"],this.parentModel=[],this.behaviours=["alternate","anchor","block","body","break","cell","cit","document","figure","graphic","heading","inline","link","list","listItem","metadata","note","omit","paragraph","pass-through","row","section","table","text","title","webcomponent"],this.icon="expand-more",this.hasCustomBehaviour=!1}render(){let e;switch(this.output){case"web":case"epub":e="html";break;case"latex":e="tex";break;case"plain":e="default";break;case"fo":case"print":e="xml";break;default:e="html"}return l`
|
|
868
969
|
<form>
|
|
869
|
-
<header>
|
|
970
|
+
<header>
|
|
870
971
|
<h4>
|
|
871
972
|
<paper-icon-button id="toggle"
|
|
872
973
|
icon="${this.icon}" @click="${this.toggle}"
|
|
873
974
|
class="model-collapse"></paper-icon-button>
|
|
874
|
-
|
|
975
|
+
|
|
875
976
|
<span class="modelType">${this.type}<span class="behaviour" ?hidden="${this._isGroupOrSequence()}">${this.behaviour}</span></span>
|
|
876
977
|
|
|
877
978
|
<span class="btn-group">
|
|
@@ -884,20 +985,27 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
884
985
|
<paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
|
|
885
986
|
|
|
886
987
|
${this._isGroupOrSequence()?l`
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
988
|
+
<paper-menu-button horizontal-align="right">
|
|
989
|
+
<paper-icon-button
|
|
990
|
+
icon="add"
|
|
991
|
+
slot="dropdown-trigger"
|
|
992
|
+
></paper-icon-button>
|
|
993
|
+
<paper-listbox
|
|
994
|
+
id="modelType"
|
|
995
|
+
slot="dropdown-content"
|
|
996
|
+
@iron-select="${this._addNested}"
|
|
997
|
+
attr-for-selected="value"
|
|
998
|
+
>
|
|
999
|
+
${"modelSequence"===this.type?l` <paper-item value="model">model</paper-item> `:""}
|
|
1000
|
+
${"modelGrp"===this.type?l`
|
|
1001
|
+
<paper-item value="modelSequence"
|
|
1002
|
+
>modelSequence</paper-item
|
|
1003
|
+
>
|
|
1004
|
+
<paper-item value="model">model</paper-item>
|
|
893
1005
|
`:""}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
`:""}
|
|
898
|
-
</paper-listbox>
|
|
899
|
-
</paper-menu-button>
|
|
900
|
-
`:""}
|
|
1006
|
+
</paper-listbox>
|
|
1007
|
+
</paper-menu-button>
|
|
1008
|
+
`:""}
|
|
901
1009
|
</span>
|
|
902
1010
|
</h4>
|
|
903
1011
|
<div class="info">
|
|
@@ -906,513 +1014,646 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
906
1014
|
<div class="predicate">${this.predicate}</div>
|
|
907
1015
|
</p>
|
|
908
1016
|
</header>
|
|
909
|
-
<
|
|
1017
|
+
<details ?open="${this.show}" class="details">
|
|
1018
|
+
<summary style="display: none;"></summary>
|
|
910
1019
|
<div class="horizontal">
|
|
911
1020
|
<paper-dropdown-menu class="selectOutput" label="Output">
|
|
912
1021
|
<paper-listbox id="output" slot="dropdown-content" attr-for-selected="value"
|
|
913
1022
|
selected="${this.output}" @iron-select="${this._selectOutput}">
|
|
914
1023
|
|
|
915
|
-
${this.outputs.map(e=>l`
|
|
916
|
-
<paper-item value="${e}">${e}</paper-item>
|
|
917
|
-
`)}
|
|
1024
|
+
${this.outputs.map(e=>l` <paper-item value="${e}">${e}</paper-item> `)}
|
|
918
1025
|
|
|
919
1026
|
</paper-listbox>
|
|
920
1027
|
</paper-dropdown-menu>
|
|
921
1028
|
<paper-input id="mode" .value="${this.mode}"
|
|
922
|
-
placeholder="${
|
|
1029
|
+
placeholder="${E("odd.editor.model.mode-placeholder")}"
|
|
923
1030
|
label="Mode"
|
|
924
1031
|
@change="${this._inputMode}"></paper-input>
|
|
925
1032
|
</div>
|
|
926
|
-
<paper-input id="desc" .value="${this.desc}" placeholder="${
|
|
1033
|
+
<paper-input id="desc" .value="${this.desc}" placeholder="${E("odd.editor.model.description-placeholder")}"
|
|
927
1034
|
label="Description" @change="${this._inputDesc}"></paper-input>
|
|
928
1035
|
|
|
929
1036
|
<div class="editor">
|
|
930
1037
|
<label>Predicate</label>
|
|
931
1038
|
<jinn-codemirror id="predicate"
|
|
932
|
-
code="${this.predicate}"
|
|
1039
|
+
code="${this.predicate}"
|
|
933
1040
|
mode="xquery"
|
|
934
1041
|
linter="${this.endpoint}/${d(this.apiVersion,"1.0.0")<0?"modules/editor.xql":"api/lint"}"
|
|
935
|
-
placeholder="${
|
|
1042
|
+
placeholder="${E("odd.editor.model.predicate-placeholder")}"
|
|
936
1043
|
@update="${this._updatePredicate}"></jinn-codemirror>
|
|
937
1044
|
</div>
|
|
938
|
-
|
|
1045
|
+
|
|
939
1046
|
${this._isModel()?l`
|
|
940
1047
|
<div>
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
<
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1048
|
+
<div class="behaviourWrapper">
|
|
1049
|
+
<paper-dropdown-menu
|
|
1050
|
+
label="behaviour"
|
|
1051
|
+
id="behaviourMenu"
|
|
1052
|
+
?disabled="${this.hasCustomBehaviour}"
|
|
1053
|
+
>
|
|
1054
|
+
<paper-listbox
|
|
1055
|
+
id="behaviour"
|
|
1056
|
+
slot="dropdown-content"
|
|
1057
|
+
attr-for-selected="value"
|
|
1058
|
+
selected="${this.behaviour}"
|
|
1059
|
+
@iron-select="${this._selectBehaviour}"
|
|
1060
|
+
>
|
|
1061
|
+
${this.behaviours.map(e=>l` <paper-item value="${e}">${e}</paper-item> `)}
|
|
1062
|
+
</paper-listbox>
|
|
1063
|
+
</paper-dropdown-menu>
|
|
1064
|
+
<span style="align-self:center;justify-self: center;">
|
|
1065
|
+
${E("odd.editor.model.link-with-or")}
|
|
1066
|
+
</span>
|
|
1067
|
+
<paper-input
|
|
1068
|
+
id="custombehaviour"
|
|
1069
|
+
label=""
|
|
1070
|
+
@input="${this._handleCustomBehaviour}"
|
|
1071
|
+
placeHolder="${E("odd.editor.model.custom-behaviour-placeholder")}"
|
|
1072
|
+
></paper-input>
|
|
1073
|
+
<span></span>
|
|
1074
|
+
</div>
|
|
1075
|
+
|
|
1076
|
+
<paper-input
|
|
1077
|
+
id="css"
|
|
1078
|
+
.value="${this.css}"
|
|
1079
|
+
placeholder="${E("odd.editor.model.css-class-placeholder")}"
|
|
1080
|
+
label="CSS Class"
|
|
1081
|
+
@change="${this._inputCss}"
|
|
1082
|
+
></paper-input>
|
|
1083
|
+
|
|
1084
|
+
<div class="editor">
|
|
1085
|
+
<label>Template</label>
|
|
1086
|
+
<jinn-codemirror
|
|
1087
|
+
id="template"
|
|
1088
|
+
code="${this.template}"
|
|
1089
|
+
mode="${e}"
|
|
1090
|
+
placeholder="${E("odd.editor.model.template-placeholder")}"
|
|
1091
|
+
@update="${this._updateTemplate}"
|
|
1092
|
+
>
|
|
1093
|
+
<div slot="toolbar">
|
|
1094
|
+
<paper-button
|
|
1095
|
+
data-mode="xml"
|
|
1096
|
+
data-command="selectElement"
|
|
1097
|
+
data-key="mod-e mod-s"
|
|
1098
|
+
title="Select element around current cursor position"
|
|
1099
|
+
><|></paper-button
|
|
1100
|
+
>
|
|
1101
|
+
<paper-button
|
|
1102
|
+
data-mode="xml"
|
|
1103
|
+
data-command="encloseWith"
|
|
1104
|
+
data-key="mod-e mod-e"
|
|
1105
|
+
title="Enclose selection in new element"
|
|
1106
|
+
><...></paper-button
|
|
1107
|
+
>
|
|
1108
|
+
<paper-button
|
|
1109
|
+
data-mode="xml"
|
|
1110
|
+
data-command="removeEnclosing"
|
|
1111
|
+
title="Remove enclosing tags"
|
|
1112
|
+
data-key="mod-e mod-r"
|
|
1113
|
+
class="sep"
|
|
1114
|
+
><X></paper-button
|
|
1115
|
+
>
|
|
1116
|
+
<paper-button
|
|
1117
|
+
data-mode="html"
|
|
1118
|
+
data-command="selectElement"
|
|
1119
|
+
data-key="mod-e mod-s"
|
|
1120
|
+
title="Select element around current cursor position"
|
|
1121
|
+
><|></paper-button
|
|
1122
|
+
>
|
|
1123
|
+
<paper-button
|
|
1124
|
+
data-mode="html"
|
|
1125
|
+
data-command="encloseWith"
|
|
1126
|
+
data-key="mod-e mod-e"
|
|
1127
|
+
title="Enclose selection in new element"
|
|
1128
|
+
><...></paper-button
|
|
1129
|
+
>
|
|
1130
|
+
<paper-button
|
|
1131
|
+
data-mode="html"
|
|
1132
|
+
data-command="removeEnclosing"
|
|
1133
|
+
title="Remove enclosing tags"
|
|
1134
|
+
data-key="mod-e mod-r"
|
|
1135
|
+
class="sep"
|
|
1136
|
+
><X></paper-button
|
|
1137
|
+
>
|
|
1138
|
+
<paper-button
|
|
1139
|
+
data-key="mod-e mod-p"
|
|
1140
|
+
data-command="snippet"
|
|
1141
|
+
data-params="[[\${_}]]"
|
|
1142
|
+
title="Insert template variable"
|
|
1143
|
+
>[[...]]</paper-button
|
|
1144
|
+
>
|
|
1145
|
+
</div>
|
|
1146
|
+
</jinn-codemirror>
|
|
1147
|
+
</div>
|
|
986
1148
|
</div>
|
|
987
|
-
|
|
1149
|
+
|
|
988
1150
|
<div class="parameters">
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1151
|
+
<div class="group">
|
|
1152
|
+
<span class="title">Parameters</span>
|
|
1153
|
+
<paper-icon-button
|
|
1154
|
+
icon="add"
|
|
1155
|
+
@click="${this._addParameter}"
|
|
1156
|
+
></paper-icon-button>
|
|
1157
|
+
</div>
|
|
1158
|
+
${W(this.parameters,e=>e.name,(e,t)=>l`
|
|
1159
|
+
<pb-odd-parameter-editor
|
|
1160
|
+
behaviour="${this.behaviour}"
|
|
1161
|
+
name="${e.name}"
|
|
1162
|
+
value="${e.value}"
|
|
1163
|
+
?set="${e.set}"
|
|
1164
|
+
endpoint="${this.endpoint}"
|
|
1165
|
+
apiVersion="${this.apiVersion}"
|
|
1166
|
+
@parameter-remove="${e=>this._removeParam(e,t)}"
|
|
1167
|
+
@parameter-changed="${e=>this._updateParam(e,t)}"
|
|
1168
|
+
></pb-odd-parameter-editor>
|
|
1169
|
+
`)}
|
|
1006
1170
|
</div>
|
|
1007
1171
|
|
|
1008
1172
|
<div class="renditions">
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
</div>
|
|
1173
|
+
<div class="group">
|
|
1174
|
+
<div>
|
|
1175
|
+
<span class="title">Renditions</span>
|
|
1176
|
+
<paper-icon-button
|
|
1177
|
+
icon="add"
|
|
1178
|
+
@click="${this._addRendition}"
|
|
1179
|
+
></paper-icon-button>
|
|
1017
1180
|
</div>
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1181
|
+
<div class="source">
|
|
1182
|
+
<paper-checkbox ?checked="${this.sourcerend}" id="sourcerend"
|
|
1183
|
+
>Use source rendition</paper-checkbox
|
|
1184
|
+
>
|
|
1185
|
+
</div>
|
|
1186
|
+
</div>
|
|
1187
|
+
|
|
1188
|
+
${W(this.renditions,e=>e.name,(e,t)=>l`
|
|
1189
|
+
<pb-odd-rendition-editor
|
|
1190
|
+
scope="${e.scope}"
|
|
1191
|
+
css="${e.css}"
|
|
1192
|
+
@remove-rendition="${e=>this._removeRendition(e,t)}"
|
|
1193
|
+
@rendition-changed="${e=>this._updateRendition(e,t)}"
|
|
1194
|
+
></pb-odd-rendition-editor>
|
|
1195
|
+
`)}
|
|
1027
1196
|
</div>
|
|
1028
|
-
|
|
1029
|
-
</
|
|
1030
|
-
|
|
1197
|
+
`:""}
|
|
1198
|
+
</details>
|
|
1199
|
+
|
|
1031
1200
|
<div class="models">
|
|
1032
|
-
${
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1201
|
+
${W(this.model.models,(e,t)=>l`
|
|
1202
|
+
<pb-odd-model-editor
|
|
1203
|
+
behaviour="${e.behaviour||"inline"}"
|
|
1204
|
+
predicate="${e.predicate}"
|
|
1205
|
+
type="${e.type}"
|
|
1206
|
+
output="${e.output}"
|
|
1207
|
+
css="${e.css}"
|
|
1208
|
+
mode="${e.mode}"
|
|
1209
|
+
.model="${e}"
|
|
1210
|
+
.parameters="${e.parameters}"
|
|
1211
|
+
desc="${e.desc}"
|
|
1212
|
+
sourcerend="${e.sourcerend}"
|
|
1213
|
+
.renditions="${e.renditions}"
|
|
1214
|
+
.template="${e.template}"
|
|
1215
|
+
.show="${e.show}"
|
|
1216
|
+
endpoint="${this.endpoint}"
|
|
1217
|
+
apiVersion="${this.apiVersion}"
|
|
1218
|
+
@model-remove="${this._removeModel}"
|
|
1219
|
+
@model-move-down="${this._moveModelDown}"
|
|
1220
|
+
@model-move-up="${this._moveModelUp}"
|
|
1221
|
+
@model-changed="${this.handleModelChanged}"
|
|
1222
|
+
@click="${e=>this.setCurrentSelection(e,t)}"
|
|
1223
|
+
hasParent
|
|
1055
1224
|
></pb-odd-model-editor>
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
</div>
|
|
1059
|
-
</form>
|
|
1225
|
+
`)}
|
|
1226
|
+
|
|
1227
|
+
</div>
|
|
1228
|
+
</form>
|
|
1060
1229
|
<pb-message id="dialog"></pb-message>
|
|
1061
|
-
`}firstUpdated(){super.firstUpdated(),this.hasCustomBehaviour=this.behaviours.indexOf(this.behaviour)<0,this.hasCustomBehaviour&&(this.shadowRoot.getElementById("custombehaviour").value=this.behaviour)}updated(e){e.has("show")&&this.show&&this.refreshEditors()}refreshEditors(){if(console.log("refreshEditors"),this._isGroupOrSequence())return console.log("asfdfa");const e=this.shadowRoot.querySelectorAll("pb-odd-model-editor");for(let t=0;t<e.length;t++)e[t].refreshEditors();const t=this.shadowRoot.querySelectorAll("pb-odd-rendition-editor");for(let e=0;e<t.length;e++)t[e].refreshEditor();const o=this.shadowRoot.querySelectorAll("pb-odd-parameter-editor");for(let e=0;e<o.length;e++)o[e].refreshEditor()}toggle(e){this.show=!this.show,this.toggleButtonIcon();const t=this.model,o=Object.assign({},t,{show:this.show});this.model=o,this.refreshEditors(),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:o}}))}toggleButtonIcon(){this.show?this.icon="expand-less":this.icon="expand-more"}_isModel(){return"model"===this.type}_isGroupOrSequence(){return"model"!==this.type}static _templateMode(e){switch(e){case"latex":return"latex";case"web":default:return"xml"}}_changeSelection(e){if(e.detail.target==this)return;e.preventDefault(),e.stopPropagation(),null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection");const t=e.detail.target;t.setAttribute("currentselection","true"),this.currentSelection=t}_requestRemoval(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("model-remove"))}_moveDown(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-down",{composed:!0,bubbles:!0,detail:{model:this}}))}_moveUp(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-up"))}_addNested(e){const t={behaviour:"inline",css:"",desc:"",predicate:"",type:e instanceof Event?e.detail.item.getAttribute("value"):e,output:"",sourcerend:!1,models:[],mode:"",parameters:[],renditions:[],template:"",show:!0},o=this.model,i=Array.from(this.model.models);i.unshift(t),this.model=Object.assign({},o,{models:i});this.shadowRoot.querySelector("#modelType").select(""),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}}))}addModel(e){"model"===e.type?(this.model.models.unshift(e),this.requestUpdate()):console.error("only models can be added to modelSequence or modelGrp")}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
.ident {
|
|
1079
|
-
display: inline-block;
|
|
1080
|
-
font-size:26px;
|
|
1081
|
-
position:relative;
|
|
1082
|
-
}
|
|
1083
|
-
.mode{
|
|
1084
|
-
font-size:10px;
|
|
1085
|
-
display:inline-block;
|
|
1086
|
-
text-transform:uppercase;
|
|
1087
|
-
border-radius:12px;
|
|
1088
|
-
color:var(--paper-grey-700);
|
|
1089
|
-
background:var(--paper-grey-300);
|
|
1090
|
-
padding:2px 6px;
|
|
1091
|
-
border:thin solid var(--paper-grey-500);
|
|
1092
|
-
margin-left:6px;
|
|
1093
|
-
position:absolute;
|
|
1094
|
-
top:8px;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
:host([currentselection]){
|
|
1098
|
-
box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14),
|
|
1099
|
-
0 1px 18px 0 rgba(0, 0, 0, 0.12),
|
|
1100
|
-
0 3px 5px -1px rgba(0, 0, 0, 0.4);
|
|
1101
|
-
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
:host([currentSelection]) > h3, :host([currentSelection]) > header{
|
|
1105
|
-
border-left:thin solid var(--paper-blue-500);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
h3{
|
|
1110
|
-
display:grid;
|
|
1111
|
-
grid-template-columns:260px auto 160px;
|
|
1112
|
-
align-items:center;
|
|
1113
|
-
}
|
|
1114
|
-
h3 .controls{
|
|
1115
|
-
text-align: right;
|
|
1116
|
-
margin-right: 10px;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
h3 .ident{
|
|
1120
|
-
align-self: center;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
paper-menu-button paper-icon-button{
|
|
1124
|
-
margin-left:-10px;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
/*todo: this does not take effect*/
|
|
1128
|
-
iron-collapse.models{
|
|
1129
|
-
--iron-collapse-transition-duration:0.4s;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
.models{
|
|
1133
|
-
padding:10px;
|
|
1134
|
-
}
|
|
1135
|
-
`}static get properties(){return{ident:{type:String},mode:{type:String},models:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.ident="",this.mode="",this.models=[],this.icon="expand-more"}render(){return l`
|
|
1136
|
-
<h3>
|
|
1137
|
-
<span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
|
|
1138
|
-
<span class="spacer"></span>
|
|
1139
|
-
|
|
1140
|
-
<span class="controls">
|
|
1141
|
-
<paper-icon-button @click="${this._remove}" icon="delete"></paper-icon-button>
|
|
1142
|
-
<paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
|
|
1143
|
-
<paper-menu-button horizontal-align="right">
|
|
1144
|
-
<paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
|
|
1145
|
-
<paper-listbox id="addModel" slot="dropdown-content" @iron-select="${this._addModel}"
|
|
1146
|
-
attr-for-selected="value">
|
|
1147
|
-
<paper-item value="model">model</paper-item>
|
|
1148
|
-
<paper-item value="modelSequence">modelSequence</paper-item>
|
|
1149
|
-
<paper-item value="modelGrp">modelGrp</paper-item>
|
|
1150
|
-
</paper-listbox>
|
|
1151
|
-
</paper-menu-button>
|
|
1230
|
+
`}firstUpdated(){super.firstUpdated(),this.hasCustomBehaviour=this.behaviours.indexOf(this.behaviour)<0,this.hasCustomBehaviour&&(this.shadowRoot.getElementById("custombehaviour").value=this.behaviour)}updated(e){e.has("show")&&this.show&&this.refreshEditors()}refreshEditors(){if(console.log("refreshEditors"),this._isGroupOrSequence())return console.log("asfdfa");const e=this.shadowRoot.querySelectorAll("pb-odd-model-editor");for(let t=0;t<e.length;t++)e[t].refreshEditors();const t=this.shadowRoot.querySelectorAll("pb-odd-rendition-editor");for(let e=0;e<t.length;e++)t[e].refreshEditor();const o=this.shadowRoot.querySelectorAll("pb-odd-parameter-editor");for(let e=0;e<o.length;e++)o[e].refreshEditor()}toggle(e){this.show=!this.show,this.toggleButtonIcon();const t=this.model,o=Object.assign(Object.assign({},t),{},{show:this.show});this.model=o,this.refreshEditors(),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:o}}))}toggleButtonIcon(){this.show?this.icon="expand-less":this.icon="expand-more"}_isModel(){return"model"===this.type}_isGroupOrSequence(){return"model"!==this.type}static _templateMode(e){switch(e){case"latex":return"latex";case"web":default:return"xml"}}_changeSelection(e){if(e.detail.target==this)return;e.preventDefault(),e.stopPropagation(),null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection");const t=e.detail.target;t.setAttribute("currentselection","true"),this.currentSelection=t}_requestRemoval(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("model-remove"))}_moveDown(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-down",{composed:!0,bubbles:!0,detail:{model:this}}))}_moveUp(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-up"))}_addNested(e){const t={behaviour:"inline",css:"",desc:"",predicate:"",type:e instanceof Event?e.detail.item.getAttribute("value"):e,output:"",sourcerend:!1,models:[],mode:"",parameters:[],renditions:[],template:"",show:!0},o=this.model,i=Array.from(this.model.models);i.unshift(t),this.model=Object.assign(Object.assign({},o),{},{models:i});this.shadowRoot.querySelector("#modelType").select(""),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}}))}addModel(e){"model"===e.type?(this.model.models.unshift(e),this.requestUpdate()):console.error("only models can be added to modelSequence or modelGrp")}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.model.delete-model-label"),C("odd.editor.model.delete-model-message")).then(()=>{const e=this.model,t=Array.from(this.model.models);t.splice(o,1),this.model=Object.assign(Object.assign({},e),{},{models:t}),this.models=t,this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:e,newModel:this.model}}))},()=>null)}_moveModelDown(e){console.log("MODEL._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(o===this.model.models.length)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o+1,0,t),this.model=Object.assign(Object.assign({},i),{},{models:s});const a=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];this._setCurrentSelection(o+1,a),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}})),this.requestUpdate()}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(0===o)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o-1,0,t),this.model=Object.assign(Object.assign({},i),{},{models:s});const a=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,a),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}}))}handleModelChanged(e){console.log("handleModelChanged ",e,this),e.stopPropagation();const t=this.model,o=this.model.models.indexOf(e.detail.oldModel),i=Array.from(this.model.models);i.splice(o,1,e.detail.newModel),this.model=Object.assign(Object.assign({},t),{},{models:i}),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:this.model}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_inputDesc(e){this.desc=e.composedPath()[0].value,this._fireModelChanged("desc",this.desc)}_selectOutput(e){this.output=e.composedPath()[0].selected,this._fireModelChanged("output",this.output)}_updatePredicate(){this.predicate=this.shadowRoot.getElementById("predicate").value,console.log("_updatePredicate ",this.predicate),this._fireModelChanged("predicate",this.predicate)}_selectBehaviour(e){this.behaviour=e.composedPath()[0].selected,this._fireModelChanged("behaviour",this.behaviour)}_inputCss(e){this.css=e.composedPath()[0].value,this._fireModelChanged("css",this.css)}_inputMode(e){this.mode=e.composedPath()[0].value,this._fireModelChanged("mode",this.mode)}_updateTemplate(e){this.template=this.shadowRoot.getElementById("template").content,this._fireModelChanged("template",this.template)}_addParameter(e){this.parameters.push({name:"",value:""}),this._fireModelChanged("parameters",this.parameters)}_updateParam(e,t){this.parameters[t].name=e.detail.name,this.parameters[t].value=e.detail.value,this.parameters[t].set=e.detail.set,this._fireModelChanged("parameters",this.parameters)}_removeParam(e,t){this.parameters.splice(t,1),this._fireModelChanged("parameters",this.parameters)}_addRendition(e){this.renditions.push({scope:"",css:""}),this._fireModelChanged("renditions",this.renditions)}_updateRendition(e,t){this.renditions[t].css=e.detail.css,this.renditions[t].scope=e.detail.scope,this._fireModelChanged("renditions",this.renditions)}_removeRendition(e,t){this.renditions.splice(t,1),this._fireModelChanged("renditions",this.renditions)}_fireModelChanged(e,t){const o=this.model;this.model=Object.assign(Object.assign({},this.model),{},{[e]:t}),console.log("model changed for %s: %o - %o",e,t,this.model),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}})),this.requestUpdate()}_copy(e){e.preventDefault(),e.stopPropagation(),console.log("odd-model.copy ",e),console.log("odd-model.copy data",this.model),this.dispatchEvent(new CustomEvent("odd-copy",{composed:!0,bubbles:!0,detail:{model:this.model}}))}_paste(e){console.log("model _paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}_handleCustomBehaviour(e){this.behaviour=e.composedPath()[0].value,this._fireModelChanged("behaviour",this.behaviour),""===this.behaviour?(this.behaviour="inline",this.hasCustomBehaviour=!1):this.hasCustomBehaviour=!0,this.requestUpdate()}}customElements.define("pb-odd-model-editor",se);class ae extends r{static get styles(){return n`
|
|
1231
|
+
:host {
|
|
1232
|
+
display: block;
|
|
1233
|
+
padding: 4px 10px;
|
|
1234
|
+
height: auto;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
h1,
|
|
1238
|
+
h2,
|
|
1239
|
+
h3,
|
|
1240
|
+
h4,
|
|
1241
|
+
h5,
|
|
1242
|
+
h6 {
|
|
1243
|
+
font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
|
|
1244
|
+
font-weight: 400 !important;
|
|
1245
|
+
}
|
|
1152
1246
|
|
|
1247
|
+
input {
|
|
1248
|
+
vertical-align: middle;
|
|
1249
|
+
}
|
|
1153
1250
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1251
|
+
.ident {
|
|
1252
|
+
display: inline-block;
|
|
1253
|
+
font-size: 26px;
|
|
1254
|
+
position: relative;
|
|
1255
|
+
}
|
|
1256
|
+
.mode {
|
|
1257
|
+
font-size: 10px;
|
|
1258
|
+
display: inline-block;
|
|
1259
|
+
text-transform: uppercase;
|
|
1260
|
+
border-radius: 12px;
|
|
1261
|
+
color: var(--paper-grey-700);
|
|
1262
|
+
background: var(--paper-grey-300);
|
|
1263
|
+
padding: 2px 6px;
|
|
1264
|
+
border: thin solid var(--paper-grey-500);
|
|
1265
|
+
margin-left: 6px;
|
|
1266
|
+
position: absolute;
|
|
1267
|
+
top: 8px;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
:host([currentselection]) {
|
|
1271
|
+
box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12),
|
|
1272
|
+
0 3px 5px -1px rgba(0, 0, 0, 0.4);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
:host([currentSelection]) > h3,
|
|
1276
|
+
:host([currentSelection]) > header {
|
|
1277
|
+
border-left: thin solid var(--paper-blue-500);
|
|
1278
|
+
}
|
|
1156
1279
|
|
|
1157
|
-
|
|
1158
|
-
|
|
1280
|
+
h3 {
|
|
1281
|
+
display: grid;
|
|
1282
|
+
grid-template-columns: 260px auto 160px;
|
|
1283
|
+
align-items: center;
|
|
1284
|
+
}
|
|
1285
|
+
h3 .controls {
|
|
1286
|
+
text-align: right;
|
|
1287
|
+
margin-right: 10px;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
h3 .ident {
|
|
1291
|
+
align-self: center;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
paper-menu-button paper-icon-button {
|
|
1295
|
+
margin-left: -10px;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/*todo: this does not take effect*/
|
|
1299
|
+
details.models {
|
|
1300
|
+
--details-transition-duration: 0.4s;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
.models {
|
|
1304
|
+
padding: 10px;
|
|
1305
|
+
}
|
|
1306
|
+
`}static get properties(){return{ident:{type:String},mode:{type:String},models:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.ident="",this.mode="",this.models=[],this.icon="expand-more"}render(){return l`
|
|
1307
|
+
<h3>
|
|
1308
|
+
<span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
|
|
1309
|
+
<span class="spacer"></span>
|
|
1310
|
+
|
|
1311
|
+
<span class="controls">
|
|
1312
|
+
<paper-icon-button @click="${this._remove}" icon="delete"></paper-icon-button>
|
|
1313
|
+
<paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
|
|
1314
|
+
<paper-menu-button horizontal-align="right">
|
|
1315
|
+
<paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
|
|
1316
|
+
<paper-listbox
|
|
1317
|
+
id="addModel"
|
|
1318
|
+
slot="dropdown-content"
|
|
1319
|
+
@iron-select="${this._addModel}"
|
|
1320
|
+
attr-for-selected="value"
|
|
1321
|
+
>
|
|
1322
|
+
<paper-item value="model">model</paper-item>
|
|
1323
|
+
<paper-item value="modelSequence">modelSequence</paper-item>
|
|
1324
|
+
<paper-item value="modelGrp">modelGrp</paper-item>
|
|
1325
|
+
</paper-listbox>
|
|
1326
|
+
</paper-menu-button>
|
|
1327
|
+
</span>
|
|
1328
|
+
</h3>
|
|
1329
|
+
|
|
1330
|
+
<div>
|
|
1331
|
+
${W(this.models,(e,t)=>l`
|
|
1159
1332
|
<pb-odd-model-editor
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
#drawer {
|
|
1201
|
-
grid-column: 1 / 1;
|
|
1202
|
-
min-width: 320px;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
#navlist {
|
|
1206
|
-
grid-column: 1 / 1;
|
|
1207
|
-
grid-row: 2 / 2;
|
|
1208
|
-
overflow: auto;
|
|
1209
|
-
height: 100%;
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
.specs {
|
|
1213
|
-
grid-column: 2 / 2;
|
|
1214
|
-
grid-row: 1 / span 2;
|
|
1215
|
-
overflow: auto;
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
section{
|
|
1219
|
-
padding:20px;
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
h3, h4 {
|
|
1223
|
-
font-family: var(--pb-heading-font-family);
|
|
1224
|
-
font-weight: var(--pb-heading-font-weight);
|
|
1225
|
-
line-height: var(--pb-heading-line-height);
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
/* ported over but not checked yet */
|
|
1229
|
-
|
|
1230
|
-
.specs {
|
|
1231
|
-
padding:6px;
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
.metadata {
|
|
1235
|
-
display: block;
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
.metadata div {
|
|
1239
|
-
padding: 0 16px 16px;
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
.metadata paper-input {
|
|
1243
|
-
margin-bottom: 10px;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
.metadata .extCssEdit {
|
|
1247
|
-
display: flex;
|
|
1248
|
-
align-items: center;
|
|
1249
|
-
padding: 0;
|
|
1250
|
-
}
|
|
1251
|
-
.metadata .extCssEdit paper-input {
|
|
1252
|
-
flex: 2;
|
|
1253
|
-
}
|
|
1254
|
-
.metadata .extCssEdit pb-edit-xml {
|
|
1255
|
-
width: 40px;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
#jump-to {
|
|
1259
|
-
margin-top: 1em;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
odd-model {
|
|
1263
|
-
border-bottom: 1px solid #E0E0E0;
|
|
1264
|
-
}
|
|
1265
|
-
odd-model h4 {
|
|
1266
|
-
margin-top: 15px;
|
|
1267
|
-
padding-top: 5px;
|
|
1268
|
-
border-top: 1px solid #E0E0E0;
|
|
1269
|
-
}
|
|
1270
|
-
.renditions {
|
|
1271
|
-
margin-top: 10px;
|
|
1272
|
-
}
|
|
1273
|
-
.icons{
|
|
1274
|
-
display:inline-block;
|
|
1275
|
-
white-space: nowrap;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
/* todo: this doesn't work - should refactor to have the complete trigger exposed here (move out of pb-collapse) */
|
|
1279
|
-
pb-collapse#meta ::slotted(.collapse-trigger){
|
|
1280
|
-
/*height:56px;*/
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
iron-collapse {
|
|
1284
|
-
--iron-collapse-transition-duration:0.8s;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
pb-message#errorMsg{
|
|
1288
|
-
background: var(--paper-red-500);
|
|
1289
|
-
color:white;
|
|
1290
|
-
}
|
|
1291
|
-
.card-content{
|
|
1292
|
-
height:100%;
|
|
1293
|
-
overflow:auto;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
paper-tab{
|
|
1297
|
-
width:100px;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
.editingView {
|
|
1301
|
-
width:100%;
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
vaadin-tabs{
|
|
1305
|
-
margin-top:10px;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
vaadin-tab{
|
|
1309
|
-
background:var(--paper-grey-200);
|
|
1310
|
-
padding:0 6px;
|
|
1311
|
-
border:thin solid var(--paper-grey-300);
|
|
1312
|
-
border-bottom:none;
|
|
1313
|
-
}
|
|
1314
|
-
vaadin-tab[selected]{
|
|
1315
|
-
background:white;
|
|
1316
|
-
border-top-right-radius:20px;
|
|
1317
|
-
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
|
|
1318
|
-
0 1px 5px 0 rgba(0, 0, 0, 0.12),
|
|
1319
|
-
0 3px 1px -2px rgba(0, 0, 0, 0.2);
|
|
1320
|
-
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
`}static get properties(){return Object.assign(Object.assign({},super.properties),{},{ident:{type:String},mode:{type:String},models:{type:Array},odd:{type:String,reflect:!0},elementSpecs:{type:Array},source:{type:String},title:{type:String},titleShort:{type:String,reflect:!0,attribute:"title-short"},description:{type:String},namespace:{type:String},rootPath:{type:String,attribute:"root-path"},loading:{type:Boolean},indentString:{type:String},outputPrefix:{type:String,attribute:"output-prefix"},outputRoot:{type:String,attribute:"output-root"},currentSelection:{type:Object},useNamespace:{type:Boolean},loggedIn:{type:Boolean},tabs:{type:Array},tabIndex:{type:Number,reflect:!0}})}constructor(){super(),this.ident="",this.mode="",this.models=()=>[],this.odd="",this.elementSpecs=[],this.source="",this.title="",this.titleShort="",this.description="",this.namespace="",this.rootPath="",this.loading=!1,this.indentString=" ",this.outputPrefix="",this.outputRoot="",this.currentSelection={},this.useNamespace=!1,this.loggedIn=!0,this.tabs=[],this.tabIndex=void 0,this.selectedNavIndex=0,this.cssFile="",this.hotkeys={save:"ctrl+shift+s,command+shift+s"},this._hasChanges=!1}render(){return l`
|
|
1324
|
-
<iron-ajax id="loadContent"
|
|
1325
|
-
handle-as="json" content-type="application/x-www-form-urlencoded"
|
|
1326
|
-
with-credentials
|
|
1327
|
-
method="GET"></iron-ajax>
|
|
1328
|
-
|
|
1329
|
-
<iron-ajax id="saveOdd"
|
|
1330
|
-
handle-as="json"
|
|
1331
|
-
with-credentials></iron-ajax>
|
|
1332
|
-
|
|
1333
|
-
<div id="layout">
|
|
1334
|
-
<div id="drawer">
|
|
1335
|
-
<slot id="slot"></slot>
|
|
1336
|
-
<h3>
|
|
1337
|
-
<span>${this.odd}</span>
|
|
1338
|
-
|
|
1339
|
-
<span class="icons">
|
|
1340
|
-
<pb-edit-xml id="editSource"><paper-icon-button icon="code" title="${$("odd.editor.odd-source")}"></paper-icon-button></pb-edit-xml>
|
|
1341
|
-
<paper-icon-button @click="${()=>this.save(!0)}" icon="icons:cloud-download" title="${$(k?"odd.editor.save-as":"odd.editor.download")}"></paper-icon-button>
|
|
1342
|
-
<paper-icon-button @click="${this._reload}" icon="refresh" title="${$("odd.editor.reload")}"></paper-icon-button>
|
|
1343
|
-
<paper-icon-button @click="${()=>this.save(!1)}" icon="save" title="${$("odd.editor.save")} ${this.display("save")}"
|
|
1344
|
-
?disabled="${!this.loggedIn}"></paper-icon-button>
|
|
1345
|
-
</span>
|
|
1346
|
-
</h3>
|
|
1347
|
-
<div id="new-element" class="input-group">
|
|
1348
|
-
<paper-input id="identNew" label="${$("odd.editor.add-element")}" always-float-label="always-float-label">
|
|
1349
|
-
<paper-icon-button slot="suffix" @click="${this.addElementSpec}" icon="add" tabindex="-1"></paper-icon-button>
|
|
1350
|
-
</paper-input>
|
|
1351
|
-
</div>
|
|
1352
|
-
|
|
1353
|
-
<div id="jump-to">
|
|
1354
|
-
<paper-autocomplete id="jumpTo" label="${$("odd.editor.jump-to")}" always-float-label="always-float-label"></paper-autocomplete>
|
|
1355
|
-
</div>
|
|
1356
|
-
|
|
1357
|
-
<h3>${$("odd.editor.specs")}</h3>
|
|
1358
|
-
</div>
|
|
1359
|
-
<div id="navlist">
|
|
1360
|
-
${H(this.elementSpecs,e=>e.ident,(e,t)=>l`
|
|
1361
|
-
<paper-item id="es_${e.ident}"
|
|
1362
|
-
index="${t}"
|
|
1363
|
-
@click="${e=>this._openElementSpec(e,t)}">${e.ident}</paper-item>
|
|
1364
|
-
`)}
|
|
1365
|
-
</div>
|
|
1366
|
-
<section class="specs" id="specs">
|
|
1367
|
-
|
|
1368
|
-
<paper-card class="metadata">
|
|
1369
|
-
<pb-collapse id="meta">
|
|
1370
|
-
<h4 slot="collapse-trigger" class="panel-title">
|
|
1371
|
-
${this._computedTitle()}
|
|
1372
|
-
</h4>
|
|
1373
|
-
<div slot="collapse-content">
|
|
1374
|
-
<paper-input id="title" name="title" value="${this.title}" label="${$("odd.editor.title")}"
|
|
1375
|
-
placeholder="[${$("odd.editor.title-placeholder")}]"
|
|
1376
|
-
@change="${this._inputTitle}"></paper-input>
|
|
1377
|
-
<paper-input id="titleShort" name="short-title" .value="${this.titleShort}" label="${$("odd.editor.title-short")}"
|
|
1378
|
-
placeholder="[${$("odd.editor.title-short-placeholder")}]"
|
|
1379
|
-
@change="${e=>this.titleShort=e.composedPath()[0].value}"></paper-input>
|
|
1380
|
-
<paper-input id="description" name="description" .value="${W(this.description)}" label="${$("odd.editor.description-label")}"
|
|
1381
|
-
placeholder="[${$("odd.editor.description-placeholder")}]"
|
|
1382
|
-
@change="${e=>this.description=e.composedPath()[0].value}"></paper-input>
|
|
1383
|
-
<paper-input id="source" name="source" ?value="${this.source}" label="${$("odd.editor.source-label")}"
|
|
1384
|
-
placeholder="[${$("odd.editor.source-placeholder")}]"
|
|
1385
|
-
@change="${e=>this.source=e.composedPath()[0].value}"></paper-input>
|
|
1386
|
-
<paper-checkbox id="useNamespace" @change="${this.setUseNamespace}">${$("odd.editor.use-namespace")}</paper-checkbox>
|
|
1387
|
-
<paper-input id="namespace" name="namespace" value="${this.namespace}" label="Namespace" ?disabled="${!this.useNamespace}"
|
|
1388
|
-
placeholder="[${$("odd.editor.namespace-placeholder")}]"
|
|
1389
|
-
@change="${e=>this.namespace=e.composedPath()[0].value}"></paper-input>
|
|
1390
|
-
<div class="extCssEdit">
|
|
1391
|
-
<paper-input name="cssFile" value="${this.cssFile}" label="External CSS File"
|
|
1392
|
-
placeholder="[External CSS file with additional class definitions]"
|
|
1393
|
-
@change="${this._cssFileChanged}"></paper-input>
|
|
1394
|
-
<pb-edit-xml id="editCSS"><paper-icon-button icon="create" title="${$("odd.editor.css-source")}"></paper-icon-button></pb-edit-xml>
|
|
1395
|
-
</div>
|
|
1396
|
-
</div>
|
|
1397
|
-
</pb-collapse>
|
|
1398
|
-
</paper-card>
|
|
1399
|
-
|
|
1400
|
-
<!-- todo: import elementspec to make it function -->
|
|
1401
|
-
|
|
1402
|
-
<div class="editingView">
|
|
1403
|
-
<vaadin-tabs id="tabs" selected="${this.tabIndex}">
|
|
1404
|
-
${H(this.tabs,e=>e.id,(e,t)=>l`
|
|
1405
|
-
<vaadin-tab name="${e}" @click="${t=>this._selectTab(t,e)}"><span style="padding-right:20px;">${e}</span><paper-icon-button icon="close" @click="${e=>this._closeTabHandler(e,t)}"></paper-icon-button></vaadin-tab>
|
|
1406
|
-
`)}
|
|
1407
|
-
</vaadin-tabs>
|
|
1408
|
-
|
|
1409
|
-
<div id="currentElement"></div>
|
|
1410
|
-
</div>
|
|
1411
|
-
</section>
|
|
1412
|
-
|
|
1413
|
-
</div>
|
|
1333
|
+
behaviour="${e.behaviour||""}"
|
|
1334
|
+
predicate="${e.predicate}"
|
|
1335
|
+
type="${e.type}"
|
|
1336
|
+
output="${e.output}"
|
|
1337
|
+
css="${e.css}"
|
|
1338
|
+
mode="${e.mode}"
|
|
1339
|
+
.model="${e}"
|
|
1340
|
+
.parameters="${e.parameters}"
|
|
1341
|
+
desc="${e.desc}"
|
|
1342
|
+
.sourcerend="${e.sourcerend}"
|
|
1343
|
+
.renditions="${e.renditions}"
|
|
1344
|
+
.template="${e.template}"
|
|
1345
|
+
.show="${e.show}"
|
|
1346
|
+
.endpoint="${this.endpoint}"
|
|
1347
|
+
.apiVersion="${this.apiVersion}"
|
|
1348
|
+
@model-remove="${this._removeModel}"
|
|
1349
|
+
@model-move-down="${this._moveModelDown}"
|
|
1350
|
+
@model-move-up="${this._moveModelUp}"
|
|
1351
|
+
@model-changed="${this.handleModelChanged}"
|
|
1352
|
+
@click="${e=>this.setCurrentSelection(e,t)}"
|
|
1353
|
+
></pb-odd-model-editor>
|
|
1354
|
+
`)}
|
|
1355
|
+
</div>
|
|
1356
|
+
<pb-message id="dialog"></pb-message>
|
|
1357
|
+
`}addModel(e){this.models.unshift(e),this.requestUpdate()}_addModel(e){console.log("ELEMENTSPEC._addModel ",e);const t=this.shadowRoot.getElementById("addModel"),o={behaviour:"inline",css:"",mode:"",predicate:"",desc:"",type:t.selected,output:"",template:"",sourcerend:!1,models:[],parameters:[],renditions:[],show:!0},i=Array.from(this.models);i.unshift(o),this.models=i,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),t.selected="",this.requestUpdate()}_remove(e){this.dispatchEvent(new CustomEvent("element-spec-removed",{composed:!0,bubbles:!0,detail:{target:this}}))}_paste(e){console.log("_paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.model.delete-model-label"),C("odd.editor.model.delete-model-message")).then(()=>{const e=Array.from(this.models);e.splice(o,1),this.models=e,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))},()=>null)}_moveModelDown(e){console.log("ELEMENTSPEC._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(o===this.models.length)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o+1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];s&&(this._setCurrentSelection(o+1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})))}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(0===o)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o-1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))}handleModelChanged(e){e.stopPropagation();const t=this.models.indexOf(e.detail.oldModel),o=Array.from(this.models);o.splice(t,1,e.detail.newModel),this.models=o,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),this.requestUpdate()}}customElements.define("pb-odd-elementspec-editor",ae);class re extends(b(c(r))){static get styles(){return n`
|
|
1358
|
+
:host {
|
|
1359
|
+
display: flex;
|
|
1360
|
+
/*margin: 30px 20px;*/
|
|
1361
|
+
margin: 0;
|
|
1362
|
+
padding: 0;
|
|
1363
|
+
height: auto;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
#layout {
|
|
1367
|
+
width: 100%;
|
|
1368
|
+
display: grid;
|
|
1369
|
+
grid-template-columns: auto 1fr;
|
|
1370
|
+
grid-template-rows: auto 1fr;
|
|
1371
|
+
}
|
|
1414
1372
|
|
|
1373
|
+
#drawer {
|
|
1374
|
+
grid-column: 1 / 1;
|
|
1375
|
+
min-width: 320px;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
#navlist {
|
|
1379
|
+
grid-column: 1 / 1;
|
|
1380
|
+
grid-row: 2 / 2;
|
|
1381
|
+
overflow: auto;
|
|
1382
|
+
height: 100%;
|
|
1383
|
+
}
|
|
1415
1384
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
`}firstUpdated(e){this.shadowRoot.getElementById("useNamespace").checked=this.useNamespace,this.jumpCtrl=this.shadowRoot.getElementById("jumpTo"),this.jumpCtrl.addEventListener("autocomplete-selected",this.jumpTo.bind(this));const t=this.querySelector("odd-selector");this.odd&&t&&(t.selected=this.odd,t.addEventListener("odd-selected",e=>{confirm("Any unsaved changes will be lost. Continue?")&&(this.odd=e.detail.odd,window.history.pushState({},"","?odd="+this.odd)),t.selected=this.odd})),this.addEventListener("current-changed",this._changeSelection),this.addEventListener("odd-copy",e=>this._copy(e)),this.addEventListener("odd-paste",e=>this._paste(e)),this.addEventListener("element-spec-removed",this.removeElementSpec.bind(this)),window.addEventListener("beforeunload",()=>"Any unsaved changes will be lost. Continue?"),this.subscribeTo("pb-login",e=>{this.loggedIn=null!=e.detail.user}),this.focus(),this.loadContent=this.shadowRoot.getElementById("loadContent"),this.rootPath=this.getAttribute("root-path"),c("pb-page-ready",()=>{this.load(),this.inited=!0}),this.registerHotkey("save",()=>this.save(!1))}setUseNamespace(){this.useNamespace=this.shadowRoot.getElementById("useNamespace").checked}async load(){if(this.loading)return;if(this.loading=!0,""===this.rootPath||""===this.odd)return;this.elementSpecs=[],document.dispatchEvent(new CustomEvent("pb-start-update"));this.shadowRoot.getElementById("editSource").setPath(this.rootPath+"/"+this.odd);const e={odd:this.odd,root:this.rootPath};this.loadContent.params=e,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`;const t=this.loadContent.generateRequest();this._hasChanges=!1,t.completes.then(e=>this.handleOdd(e))}handleOdd(e){const t=e.response;if(this.loggedIn=t.canWrite,this.source=t.source,this.title=t.title,this.titleShort=t.titleShort,this.description=t.description,this.cssFile=null==t.cssFile?"":t.cssFile,this.namespace=null!=t.namespace?t.namespace:"",this.useNamespace=null!=t.namespace,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(this.rootPath+"/"+this.cssFile)}this.elementSpecs=t.elementSpecs.map(e=>this.mapElementSpec(e)),this._updateAutoComplete(),this.requestUpdate(),this.loading=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),document.title=this.titleShort||this.title}_updateAutoComplete(){this.shadowRoot.getElementById("jumpTo").source=this.elementSpecs.map(this._specMapper)}_cssFileChanged(e){if(this.cssFile=e.composedPath()[0].value,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(this.rootPath+"/"+this.cssFile)}}_navlistActiveChanged(e,t){this.selectedNavIndex=t,this.requestUpdate()}_returnTabs(){return this.tabs}_selectTab(e,t){const o=this.elementSpecs.find(e=>e.ident===t);this._updateElementspec(o)}_openElementSpec(e,t){console.log("_openElementSpec ",e,t);const o=this.elementSpecs[t];this._updateElementspec(o);const i=o.ident;if(this.tabs.indexOf(i)>=0)return this.tabIndex=this.tabs.indexOf(i),void this.requestUpdate();this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.requestUpdate()}_updateElementspec(e){const t=this.shadowRoot.getElementById("currentElement");t.innerHTML="";const o=new se;o.addEventListener("element-spec-changed",this.handleElementSpecChanged.bind(this)),o.ident=e.ident,o.models=e.models,o.mode=e.mode,o.endpoint=this._endpoint,o.apiVersion=this._apiVersion,o.hotkeys=this.hotkeys,t.appendChild(o)}_closeTabHandler(e,t){return console.log("_closeTabHandler ",t),e.preventDefault(),e.stopPropagation(),this._closeTab(t),!1}_closeTab(e){if(this.tabs.splice(e,1),0===this.tabs.length)this.shadowRoot.getElementById("currentElement").innerHTML="",this.tabIndex=0,this.tabs=[];else if(this.tabIndex>0&&this.tabIndex>=e){this.tabIndex-=1;const e=this.tabs[this.tabIndex];this._selectTab(null,e)}}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"odd"==e&&t!==o&&this.inited&&this.load()}static get replaceCharMap(){return{'"':""","&":"&","<":"<",">":">"}}static get replaceCharRegexp(){return/"|&|<|>/g}static replaceChars(e){return re.replaceCharMap[e]}jumpTo(e){const t="#es_"+this.shadowRoot.getElementById("jumpTo").text,o=this.shadowRoot.querySelector(t);o&&(this.jumpCtrl.clear(),o.click())}_computedTitle(){return this.odd?this.title||this.titleShort||this.odd||"Loading ...":""}_copy(e){this.clipboard=e.detail.model;const t=JSON.parse(JSON.stringify(e.detail.model));this.clipboard=t}_paste(e){if(console.log("_paste ",e),console.log("_paste clipboard",this.clipboard),this.clipboard=={}||null==this.clipboard)return;const t=e.detail.target;t.addModel(this.clipboard),t.render()}_specMapper(e){return{text:e.ident,value:e.ident}}_specObserver(e){const t=this.elementSpecs.map(this._specMapper);this.jumpCtrl.source=t}mapElementSpec(e){return Object.assign({},e,{models:e.models.map(e=>this.addShowToModel(e))})}addShowToModel(e){if(e.models){const t=e.models.map(e=>this.addShowToModel(e));return Object.assign({},e,{models:t,show:!1})}return Object.assign({},e,{show:!1})}addElementSpec(e){const t=this.shadowRoot.getElementById("identNew").value;if(!t||0===t.length)return;if(this.elementSpecs.find(e=>e.ident===t)){console.log("<pb-odd-editor> element spec to be added already exists: %s",t);const e="#es_"+t,o=this.shadowRoot.querySelector(e);if(!o)return;return void o.click()}const o={action:"find",odd:this.odd,root:this.rootPath,ident:t},i={root:this.rootPath,ident:t},s=this.lessThanApiVersion("1.0.0")?o:i;this.loadContent.params=s,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.loadContent.generateRequest().completes.then(this._handleElementSpecResponse.bind(this))}_handleElementSpecResponse(e){const t=this.shadowRoot.getElementById("identNew"),o=e.response,i=t.value,s={ident:i,mode:"not-found"===o.status?"add":"change",models:o.models||[]};this.elementSpecs.unshift(s),t.value="",this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.elementSpecs.sort((e,t)=>e.ident.localeCompare(t.ident)),this.requestUpdate().then(()=>{const e=this.shadowRoot.querySelectorAll("paper-item"),t=this.elementSpecs.indexOf(s);this._updateAutoComplete(),e[t].click(),e[t].focus()})}removeElementSpec(e){const t=e.detail.target.ident;this.shadowRoot.getElementById("dialog").confirm(S("browse.delete"),S("odd.editor.delete-spec",{ident:t})).then(()=>{const e=this.elementSpecs.findIndex(e=>e.ident===t);this.elementSpecs.splice(e,1),this.requestUpdate();const o=this.shadowRoot.querySelector("vaadin-tab[selected]").getAttribute("name"),i=this.tabs.indexOf(o);this._closeTab(i)},()=>null)}serializeOdd(){const e=this.useNamespace?` ns="${this.namespace}"`:"",t=this.source?` source="${this.source}"`:"",o=this.description?` <desc>${this.description}</desc>`:"";return`<schemaSpec xmlns="http://www.tei-c.org/ns/1.0" xmlns:pb="http://teipublisher.com/1.0"${e}${t}>\n${`${this.indentString}<title>${this.title}${o}</title>\n`}${this.titleShort?`${this.indentString}<title type="short">${this.titleShort}</title>\n`:""}${this.cssFile?`${this.indentString}<rendition source="${this.cssFile}"/>\n`:""}\n${this.elementSpecs.map(e=>this.serializeElementSpec(this.indentString,e)).join("")}</schemaSpec>\n`}serializeElementSpec(e,t){const o=t.mode?` mode="${t.mode}"`:"",i=e+this.indentString,s=t.models.map(e=>this.serializeModel(i,e)).join("");return`${e}<elementSpec ident="${t.ident}"${o}>\n${s}${e}</elementSpec>\n`}serializeModel(e,t){if("model"===t.type&&!t.behaviour)return"";const o=e+this.indentString,i=[this.serializeAttribute("output",t.output),this.serializeAttribute("predicate",t.predicate),"model"===t.type?this.serializeAttribute("behaviour",t.behaviour):"",this.serializeAttribute("cssClass",t.css),this.serializeAttribute("useSourceRendition",t.sourcerend),this.serializeAttribute("pb:mode",t.mode)].join(""),s=t.desc?o+"<desc>"+t.desc+"</desc>\n":"",r=t.models.map(e=>this.serializeModel(o,e)).join(""),a=t.parameters.map(e=>this.serializeParameter(o,e)).join(""),n=t.renditions.map(e=>this.serializeRendition(o,e)).join(""),l=`${s}${r}${a}${re.serializeTemplate(o,t.template)}${n}`,d=l.length>0?`>\n${l}${e}</${t.type}`:"/";return`${e}<${t.type}${i}${d}>\n`}serializeParameter(e,t){if(!t.name)return"";const o=this.serializeAttribute("name",t.name),i=this.serializeAttribute("value",t.value);return t.set?`${e}<pb:set-param xmlns=""${o}${i}/>\n`:`${e}<param${o}${i}/>\n`}serializeRendition(e,t){return`${e}<outputRendition xml:space="preserve" ${t.scope&&"null"!==t.scope?this.serializeAttribute("scope",t.scope):""}>\n${e}${re.escape(t.css)}\n${e}</outputRendition>\n`}static serializeTemplate(e,t){return t?`${e}<pb:template xml:space="preserve" xmlns="">${t}</pb:template>\n`:""}serializeAttribute(e,t){return t?` ${e}="${re.escape(t)}"`:""}static escape(e){return e?"string"==typeof e?e.replace(re.replaceCharRegexp,re.replaceChars):e:""}save(e=!1){document.dispatchEvent(new CustomEvent("pb-start-update"));const t=this.serializeOdd();this.shadowRoot.getElementById("dialog").show(S("odd.editor.save"),S("odd.editor.saving"));const o=this.shadowRoot.getElementById("saveOdd");o.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.lessThanApiVersion("1.0.0")?(o.contentType="application/x-www-form-urlencoded",o.method="POST",o.params=null,o.body={action:"save",root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot,odd:this.odd,data:t}):(o.contentType="application/xml",o.method="PUT",o.params={root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot},o.body=t);o.generateRequest().completes.then(t=>{this.handleSaveComplete(t,e)}).catch(this.handleSaveError.bind(this))}static _renderReport(e){return e.error?`\n <div class="list-group-item-danger">\n <h4 class="list-group-item-heading">${e.file}</h4>\n <h5 class="list-group-item-heading">Compilation error on line ${e.line}:</h5>\n <pre class="list-group-item-text">${e.error}</pre>\n <pre class="list-group-item-text">${e.message}</pre>\n </div>\n `:`\n <div class="list-group-item-success">\n <p class="list-group-item-text">Generated ${e.file}</p>\n </div>\n `}handleSaveComplete(e,t=!1){const o=e.response;if("denied"===o.status)return this.shadowRoot.getElementById("dialog").set(S("odd.editor.denied"),S("odd.editor.denied-message",{odd:this.odd})),void document.dispatchEvent(new CustomEvent("pb-end-update"));let i;if(this.lessThanApiVersion("1.0.0")){i=`<div class="list-group">${o.report.map(re._renderReport).join("")}</div>`}else{i=`<div class="list-group">${o.report}</div>`}if(this.shadowRoot.getElementById("dialog").set(S("odd.editor.saved"),i),this._hasChanges=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),t){A(new Blob([o.source],{type:"application/xml"}),{fileName:this.odd,extensions:[".odd"]}).then(()=>console.log(`<pb-odd-editor> ${this.odd} exported`),()=>console.log("<pb-odd-editor> export aborted"))}}handleSaveError(e){this.shadowRoot.getElementById("dialog").set("Error",e.error),document.dispatchEvent(new CustomEvent("pb-end-update"))}_reload(){this.shadowRoot.getElementById("dialog").confirm(S("odd.editor.reload"),S("odd.editor.reload-confirm")).then(()=>{this.load(),this.tabs=[],this.tabIndex=0,this.shadowRoot.getElementById("currentElement").innerHTML=""},()=>null)}_setCurrentSelection(e){null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection"),this.currentSelection=e.target,this.currentSelection.setAttribute("currentselection","true")}_changeSelection(e){if(e.preventDefault(),e.stopPropagation(),e.detail.target===this)return;let t;this.currentSelection&&void 0!==this.currentSelection.tagName&&this.currentSelection.removeAttribute("currentselection"),t=e.detail.target?e.detail.target:e.target,t.setAttribute("currentselection","true"),this.currentSelection=t}_selectElementspec(e){this.currentElementSpec&&"PB-ODD-ELEMENTSPEC-EDITOR"===this.currentElementSpec.tagName&&this.currentElementSpec.removeAttribute("currentselection");const t=e.target;t.setAttribute("currentselection","true"),this.currentElementSpec=t}nsDisabled(){return!this.useNamespace}_handleLoadError(e){console.log("loading error occurred: ",e);const t=this.shadowRoot.getElementById("errorMsg");t.style.background="red";const o=this.shadowRoot.getElementById("loadContent").url;console.log("url ",o),t.show("Error: ","ODD file could not be loaded from "+o)}handleElementSpecChanged(e){this._hasChanges=!0;const t=this.elementSpecs.find(t=>t.ident===e.detail.ident),o=this.elementSpecs.indexOf(t),i=Object.assign({},t,{models:e.detail.models}),s=Array.from(this.elementSpecs);s.splice(o,1,i),this.elementSpecs=s}_inputTitle(e){this.title=e.composedPath()[0].value}}customElements.define("pb-odd-editor",re);export{re as PbOddEditor};
|
|
1385
|
+
.specs {
|
|
1386
|
+
grid-column: 2 / 2;
|
|
1387
|
+
grid-row: 1 / span 2;
|
|
1388
|
+
overflow: auto;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
section {
|
|
1392
|
+
padding: 20px;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
h3,
|
|
1396
|
+
h4 {
|
|
1397
|
+
font-family: var(--pb-heading-font-family);
|
|
1398
|
+
font-weight: var(--pb-heading-font-weight);
|
|
1399
|
+
line-height: var(--pb-heading-line-height);
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/* ported over but not checked yet */
|
|
1403
|
+
|
|
1404
|
+
.specs {
|
|
1405
|
+
padding: 6px;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
.metadata {
|
|
1409
|
+
display: block;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
.metadata div {
|
|
1413
|
+
padding: 0 16px 16px;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
.metadata paper-input {
|
|
1417
|
+
margin-bottom: 10px;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
.metadata .extCssEdit {
|
|
1421
|
+
display: flex;
|
|
1422
|
+
align-items: center;
|
|
1423
|
+
padding: 0;
|
|
1424
|
+
}
|
|
1425
|
+
.metadata .extCssEdit paper-input {
|
|
1426
|
+
flex: 2;
|
|
1427
|
+
}
|
|
1428
|
+
.metadata .extCssEdit pb-edit-xml {
|
|
1429
|
+
width: 40px;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
#jump-to {
|
|
1433
|
+
margin-top: 1em;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
odd-model {
|
|
1437
|
+
border-bottom: 1px solid #e0e0e0;
|
|
1438
|
+
}
|
|
1439
|
+
odd-model h4 {
|
|
1440
|
+
margin-top: 15px;
|
|
1441
|
+
padding-top: 5px;
|
|
1442
|
+
border-top: 1px solid #e0e0e0;
|
|
1443
|
+
}
|
|
1444
|
+
.renditions {
|
|
1445
|
+
margin-top: 10px;
|
|
1446
|
+
}
|
|
1447
|
+
.icons {
|
|
1448
|
+
display: inline-block;
|
|
1449
|
+
white-space: nowrap;
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
details {
|
|
1453
|
+
--details-transition-duration: 0.8s;
|
|
1454
|
+
}
|
|
1455
|
+
details[open] {
|
|
1456
|
+
padding: 0;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
pb-message#errorMsg {
|
|
1460
|
+
background: var(--paper-red-500);
|
|
1461
|
+
color: white;
|
|
1462
|
+
}
|
|
1463
|
+
.card-content {
|
|
1464
|
+
height: 100%;
|
|
1465
|
+
overflow: auto;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
paper-tab {
|
|
1469
|
+
width: 100px;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
.editingView {
|
|
1473
|
+
width: 100%;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
vaadin-tabs {
|
|
1477
|
+
margin-top: 10px;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
vaadin-tab {
|
|
1481
|
+
background: var(--paper-grey-200);
|
|
1482
|
+
padding: 0 6px;
|
|
1483
|
+
border: thin solid var(--paper-grey-300);
|
|
1484
|
+
border-bottom: none;
|
|
1485
|
+
}
|
|
1486
|
+
vaadin-tab[selected] {
|
|
1487
|
+
background: white;
|
|
1488
|
+
border-top-right-radius: 20px;
|
|
1489
|
+
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12),
|
|
1490
|
+
0 3px 1px -2px rgba(0, 0, 0, 0.2);
|
|
1491
|
+
}
|
|
1492
|
+
`}static get properties(){return Object.assign(Object.assign({},super.properties),{},{ident:{type:String},mode:{type:String},models:{type:Array},odd:{type:String,reflect:!0},elementSpecs:{type:Array},source:{type:String},title:{type:String},titleShort:{type:String,reflect:!0,attribute:"title-short"},description:{type:String},namespace:{type:String},rootPath:{type:String,attribute:"root-path"},loading:{type:Boolean},indentString:{type:String},outputPrefix:{type:String,attribute:"output-prefix"},outputRoot:{type:String,attribute:"output-root"},currentSelection:{type:Object},useNamespace:{type:Boolean},loggedIn:{type:Boolean},tabs:{type:Array},tabIndex:{type:Number,reflect:!0}})}constructor(){super(),this.ident="",this.mode="",this.models=()=>[],this.odd="",this.elementSpecs=[],this.source="",this.title="",this.titleShort="",this.description="",this.namespace="",this.rootPath="",this.loading=!1,this.indentString=" ",this.outputPrefix="",this.outputRoot="",this.currentSelection={},this.useNamespace=!1,this.loggedIn=!0,this.tabs=[],this.tabIndex=void 0,this.selectedNavIndex=0,this.cssFile="",this.hotkeys={save:"ctrl+shift+s,command+shift+s"},this._hasChanges=!1}render(){return l`
|
|
1493
|
+
<iron-ajax
|
|
1494
|
+
id="loadContent"
|
|
1495
|
+
handle-as="json"
|
|
1496
|
+
content-type="application/x-www-form-urlencoded"
|
|
1497
|
+
with-credentials
|
|
1498
|
+
method="GET"
|
|
1499
|
+
></iron-ajax>
|
|
1500
|
+
|
|
1501
|
+
<iron-ajax id="saveOdd" handle-as="json" with-credentials></iron-ajax>
|
|
1502
|
+
|
|
1503
|
+
<div id="layout">
|
|
1504
|
+
<div id="drawer">
|
|
1505
|
+
<slot id="slot"></slot>
|
|
1506
|
+
<h3>
|
|
1507
|
+
<span>${this.odd}</span>
|
|
1508
|
+
|
|
1509
|
+
<span class="icons">
|
|
1510
|
+
<pb-edit-xml id="editSource"
|
|
1511
|
+
><paper-icon-button
|
|
1512
|
+
icon="code"
|
|
1513
|
+
title="${E("odd.editor.odd-source")}"
|
|
1514
|
+
></paper-icon-button
|
|
1515
|
+
></pb-edit-xml>
|
|
1516
|
+
<paper-icon-button
|
|
1517
|
+
@click="${()=>this.save(!0)}"
|
|
1518
|
+
icon="icons:cloud-download"
|
|
1519
|
+
title="${E(k?"odd.editor.save-as":"odd.editor.download")}"
|
|
1520
|
+
></paper-icon-button>
|
|
1521
|
+
<paper-icon-button
|
|
1522
|
+
@click="${this._reload}"
|
|
1523
|
+
icon="refresh"
|
|
1524
|
+
title="${E("odd.editor.reload")}"
|
|
1525
|
+
></paper-icon-button>
|
|
1526
|
+
<paper-icon-button
|
|
1527
|
+
@click="${()=>this.save(!1)}"
|
|
1528
|
+
icon="save"
|
|
1529
|
+
title="${E("odd.editor.save")} ${this.display("save")}"
|
|
1530
|
+
?disabled="${!this.loggedIn}"
|
|
1531
|
+
></paper-icon-button>
|
|
1532
|
+
</span>
|
|
1533
|
+
</h3>
|
|
1534
|
+
<div id="new-element" class="input-group">
|
|
1535
|
+
<paper-input
|
|
1536
|
+
id="identNew"
|
|
1537
|
+
label="${E("odd.editor.add-element")}"
|
|
1538
|
+
always-float-label="always-float-label"
|
|
1539
|
+
>
|
|
1540
|
+
<paper-icon-button
|
|
1541
|
+
slot="suffix"
|
|
1542
|
+
@click="${this.addElementSpec}"
|
|
1543
|
+
icon="add"
|
|
1544
|
+
tabindex="-1"
|
|
1545
|
+
></paper-icon-button>
|
|
1546
|
+
</paper-input>
|
|
1547
|
+
</div>
|
|
1548
|
+
|
|
1549
|
+
<div id="jump-to">
|
|
1550
|
+
<paper-autocomplete
|
|
1551
|
+
id="jumpTo"
|
|
1552
|
+
label="${E("odd.editor.jump-to")}"
|
|
1553
|
+
always-float-label="always-float-label"
|
|
1554
|
+
></paper-autocomplete>
|
|
1555
|
+
</div>
|
|
1556
|
+
|
|
1557
|
+
<h3>${E("odd.editor.specs")}</h3>
|
|
1558
|
+
</div>
|
|
1559
|
+
<div id="navlist">
|
|
1560
|
+
${W(this.elementSpecs,e=>e.ident,(e,t)=>l`
|
|
1561
|
+
<paper-item
|
|
1562
|
+
id="es_${e.ident}"
|
|
1563
|
+
index="${t}"
|
|
1564
|
+
@click="${e=>this._openElementSpec(e,t)}"
|
|
1565
|
+
>${e.ident}</paper-item
|
|
1566
|
+
>
|
|
1567
|
+
`)}
|
|
1568
|
+
</div>
|
|
1569
|
+
<section class="specs" id="specs">
|
|
1570
|
+
<paper-card class="metadata">
|
|
1571
|
+
<pb-collapse id="meta">
|
|
1572
|
+
<h4 slot="collapse-trigger" class="panel-title">${this._computedTitle()}</h4>
|
|
1573
|
+
<div slot="collapse-content">
|
|
1574
|
+
<paper-input
|
|
1575
|
+
id="title"
|
|
1576
|
+
name="title"
|
|
1577
|
+
value="${this.title}"
|
|
1578
|
+
label="${E("odd.editor.title")}"
|
|
1579
|
+
placeholder="[${E("odd.editor.title-placeholder")}]"
|
|
1580
|
+
@change="${this._inputTitle}"
|
|
1581
|
+
></paper-input>
|
|
1582
|
+
<paper-input
|
|
1583
|
+
id="titleShort"
|
|
1584
|
+
name="short-title"
|
|
1585
|
+
.value="${this.titleShort}"
|
|
1586
|
+
label="${E("odd.editor.title-short")}"
|
|
1587
|
+
placeholder="[${E("odd.editor.title-short-placeholder")}]"
|
|
1588
|
+
@change="${e=>this.titleShort=e.composedPath()[0].value}"
|
|
1589
|
+
></paper-input>
|
|
1590
|
+
<paper-input
|
|
1591
|
+
id="description"
|
|
1592
|
+
name="description"
|
|
1593
|
+
.value="${G(this.description)}"
|
|
1594
|
+
label="${E("odd.editor.description-label")}"
|
|
1595
|
+
placeholder="[${E("odd.editor.description-placeholder")}]"
|
|
1596
|
+
@change="${e=>this.description=e.composedPath()[0].value}"
|
|
1597
|
+
></paper-input>
|
|
1598
|
+
<paper-input
|
|
1599
|
+
id="source"
|
|
1600
|
+
name="source"
|
|
1601
|
+
?value="${this.source}"
|
|
1602
|
+
label="${E("odd.editor.source-label")}"
|
|
1603
|
+
placeholder="[${E("odd.editor.source-placeholder")}]"
|
|
1604
|
+
@change="${e=>this.source=e.composedPath()[0].value}"
|
|
1605
|
+
></paper-input>
|
|
1606
|
+
<paper-checkbox id="useNamespace" @change="${this.setUseNamespace}"
|
|
1607
|
+
>${E("odd.editor.use-namespace")}</paper-checkbox
|
|
1608
|
+
>
|
|
1609
|
+
<paper-input
|
|
1610
|
+
id="namespace"
|
|
1611
|
+
name="namespace"
|
|
1612
|
+
value="${this.namespace}"
|
|
1613
|
+
label="Namespace"
|
|
1614
|
+
?disabled="${!this.useNamespace}"
|
|
1615
|
+
placeholder="[${E("odd.editor.namespace-placeholder")}]"
|
|
1616
|
+
@change="${e=>this.namespace=e.composedPath()[0].value}"
|
|
1617
|
+
></paper-input>
|
|
1618
|
+
<div class="extCssEdit">
|
|
1619
|
+
<paper-input
|
|
1620
|
+
name="cssFile"
|
|
1621
|
+
value="${this.cssFile}"
|
|
1622
|
+
label="External CSS File"
|
|
1623
|
+
placeholder="[External CSS file with additional class definitions]"
|
|
1624
|
+
@change="${this._cssFileChanged}"
|
|
1625
|
+
></paper-input>
|
|
1626
|
+
<pb-edit-xml id="editCSS"
|
|
1627
|
+
><paper-icon-button
|
|
1628
|
+
icon="create"
|
|
1629
|
+
title="${E("odd.editor.css-source")}"
|
|
1630
|
+
></paper-icon-button
|
|
1631
|
+
></pb-edit-xml>
|
|
1632
|
+
</div>
|
|
1633
|
+
</div>
|
|
1634
|
+
</pb-collapse>
|
|
1635
|
+
</paper-card>
|
|
1636
|
+
|
|
1637
|
+
<!-- todo: import elementspec to make it function -->
|
|
1638
|
+
|
|
1639
|
+
<div class="editingView">
|
|
1640
|
+
<vaadin-tabs id="tabs" selected="${this.tabIndex}">
|
|
1641
|
+
${W(this.tabs,e=>e.id,(e,t)=>l`
|
|
1642
|
+
<vaadin-tab name="${e}" @click="${t=>this._selectTab(t,e)}"
|
|
1643
|
+
><span style="padding-right:20px;">${e}</span
|
|
1644
|
+
><paper-icon-button
|
|
1645
|
+
icon="close"
|
|
1646
|
+
@click="${e=>this._closeTabHandler(e,t)}"
|
|
1647
|
+
></paper-icon-button
|
|
1648
|
+
></vaadin-tab>
|
|
1649
|
+
`)}
|
|
1650
|
+
</vaadin-tabs>
|
|
1651
|
+
|
|
1652
|
+
<div id="currentElement"></div>
|
|
1653
|
+
</div>
|
|
1654
|
+
</section>
|
|
1655
|
+
</div>
|
|
1656
|
+
|
|
1657
|
+
<pb-message id="dialog" hidden></pb-message>
|
|
1658
|
+
<pb-message id="errorMsg"></pb-message>
|
|
1659
|
+
`}firstUpdated(e){this.shadowRoot.getElementById("useNamespace").checked=this.useNamespace,this.jumpCtrl=this.shadowRoot.getElementById("jumpTo"),this.jumpCtrl.addEventListener("autocomplete-selected",this.jumpTo.bind(this));const t=this.querySelector("odd-selector");this.odd&&t&&(t.selected=this.odd,t.addEventListener("odd-selected",e=>{confirm("Any unsaved changes will be lost. Continue?")&&(this.odd=e.detail.odd,window.history.pushState({},"","?odd="+this.odd)),t.selected=this.odd})),this.addEventListener("current-changed",this._changeSelection),this.addEventListener("odd-copy",e=>this._copy(e)),this.addEventListener("odd-paste",e=>this._paste(e)),this.addEventListener("element-spec-removed",this.removeElementSpec.bind(this)),window.addEventListener("beforeunload",()=>"Any unsaved changes will be lost. Continue?"),this.subscribeTo("pb-login",e=>{this.loggedIn=null!=e.detail.user}),this.focus(),this.loadContent=this.shadowRoot.getElementById("loadContent"),this.rootPath=this.getAttribute("root-path"),p("pb-page-ready",()=>{this.load(),this.inited=!0}),this.registerHotkey("save",()=>this.save(!1))}setUseNamespace(){this.useNamespace=this.shadowRoot.getElementById("useNamespace").checked}async load(){if(this.loading)return;if(this.loading=!0,""===this.rootPath||""===this.odd)return;this.elementSpecs=[],document.dispatchEvent(new CustomEvent("pb-start-update"));this.shadowRoot.getElementById("editSource").setPath(`${this.rootPath}/${this.odd}`);const e={odd:this.odd,root:this.rootPath};this.loadContent.params=e,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`;const t=this.loadContent.generateRequest();this._hasChanges=!1,t.completes.then(e=>this.handleOdd(e))}handleOdd(e){const t=e.response;if(this.loggedIn=t.canWrite,this.source=t.source,this.title=t.title,this.titleShort=t.titleShort,this.description=t.description,this.cssFile=null==t.cssFile?"":t.cssFile,this.namespace=null!=t.namespace?t.namespace:"",this.useNamespace=null!=t.namespace,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(`${this.rootPath}/${this.cssFile}`)}this.elementSpecs=t.elementSpecs.map(e=>this.mapElementSpec(e)),this._updateAutoComplete(),this.requestUpdate(),this.loading=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),document.title=this.titleShort||this.title}_updateAutoComplete(){this.shadowRoot.getElementById("jumpTo").source=this.elementSpecs.map(this._specMapper)}_cssFileChanged(e){if(this.cssFile=e.composedPath()[0].value,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(`${this.rootPath}/${this.cssFile}`)}}_navlistActiveChanged(e,t){this.selectedNavIndex=t,this.requestUpdate()}_returnTabs(){return this.tabs}_selectTab(e,t){const o=this.elementSpecs.find(e=>e.ident===t);this._updateElementspec(o)}_openElementSpec(e,t){console.log("_openElementSpec ",e,t);const o=this.elementSpecs[t];this._updateElementspec(o);const{ident:i}=o;if(this.tabs.indexOf(i)>=0)return this.tabIndex=this.tabs.indexOf(i),void this.requestUpdate();this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.requestUpdate()}_updateElementspec(e){const t=this.shadowRoot.getElementById("currentElement");t.innerHTML="";const o=new ae;o.addEventListener("element-spec-changed",this.handleElementSpecChanged.bind(this)),o.ident=e.ident,o.models=e.models,o.mode=e.mode,o.endpoint=this._endpoint,o.apiVersion=this._apiVersion,o.hotkeys=this.hotkeys,t.appendChild(o)}_closeTabHandler(e,t){return console.log("_closeTabHandler ",t),e.preventDefault(),e.stopPropagation(),this._closeTab(t),!1}_closeTab(e){if(this.tabs.splice(e,1),0===this.tabs.length)this.shadowRoot.getElementById("currentElement").innerHTML="",this.tabIndex=0,this.tabs=[];else if(this.tabIndex>0&&this.tabIndex>=e){this.tabIndex-=1;const e=this.tabs[this.tabIndex];this._selectTab(null,e)}}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"odd"==e&&t!==o&&this.inited&&this.load()}static get replaceCharMap(){return{'"':""","&":"&","<":"<",">":">"}}static get replaceCharRegexp(){return/"|&|<|>/g}static replaceChars(e){return re.replaceCharMap[e]}jumpTo(e){const t="#es_"+this.shadowRoot.getElementById("jumpTo").text,o=this.shadowRoot.querySelector(t);o&&(this.jumpCtrl.clear(),o.click())}_computedTitle(){return this.odd?this.title||this.titleShort||this.odd||"Loading ...":""}_copy(e){this.clipboard=e.detail.model;const t=JSON.parse(JSON.stringify(e.detail.model));this.clipboard=t}_paste(e){if(console.log("_paste ",e),console.log("_paste clipboard",this.clipboard),this.clipboard=={}||null==this.clipboard)return;const t=e.detail.target;t.addModel(this.clipboard),t.render()}_specMapper(e){return{text:e.ident,value:e.ident}}_specObserver(e){const t=this.elementSpecs.map(this._specMapper);this.jumpCtrl.source=t}mapElementSpec(e){return Object.assign(Object.assign({},e),{},{models:e.models.map(e=>this.addShowToModel(e))})}addShowToModel(e){if(e.models){const t=e.models.map(e=>this.addShowToModel(e));return Object.assign(Object.assign({},e),{},{models:t,show:!1})}return Object.assign(Object.assign({},e),{},{show:!1})}addElementSpec(e){const t=this.shadowRoot.getElementById("identNew").value;if(!t||0===t.length)return;if(this.elementSpecs.find(e=>e.ident===t)){console.log("<pb-odd-editor> element spec to be added already exists: %s",t);const e="#es_"+t,o=this.shadowRoot.querySelector(e);if(!o)return;return void o.click()}const o={action:"find",odd:this.odd,root:this.rootPath,ident:t},i={root:this.rootPath,ident:t},s=this.lessThanApiVersion("1.0.0")?o:i;this.loadContent.params=s,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`;this.loadContent.generateRequest().completes.then(this._handleElementSpecResponse.bind(this))}_handleElementSpecResponse(e){const t=this.shadowRoot.getElementById("identNew"),o=e.response,i=t.value,s={ident:i,mode:"not-found"===o.status?"add":"change",models:o.models||[]};this.elementSpecs.unshift(s),t.value="",this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.elementSpecs.sort((e,t)=>e.ident.localeCompare(t.ident)),this.requestUpdate().then(()=>{const e=this.shadowRoot.querySelectorAll("paper-item"),t=this.elementSpecs.indexOf(s);this._updateAutoComplete(),e[t].click(),e[t].focus()})}removeElementSpec(e){const{ident:t}=e.detail.target;this.shadowRoot.getElementById("dialog").confirm(C("browse.delete"),C("odd.editor.delete-spec",{ident:t})).then(()=>{const e=this.elementSpecs.findIndex(e=>e.ident===t);this.elementSpecs.splice(e,1),this.requestUpdate();const o=this.shadowRoot.querySelector("vaadin-tab[selected]").getAttribute("name"),i=this.tabs.indexOf(o);this._closeTab(i)},()=>null)}serializeOdd(){const e=this.useNamespace?` ns="${this.namespace}"`:"",t=this.source?` source="${this.source}"`:"",o=this.description?` <desc>${this.description}</desc>`:"";return`<schemaSpec xmlns="http://www.tei-c.org/ns/1.0" xmlns:pb="http://teipublisher.com/1.0"${e}${t}>\n${`${this.indentString}<title>${this.title}${o}</title>\n`}${this.titleShort?`${this.indentString}<title type="short">${this.titleShort}</title>\n`:""}${this.cssFile?`${this.indentString}<rendition source="${this.cssFile}"/>\n`:""}\n${this.elementSpecs.map(e=>this.serializeElementSpec(this.indentString,e)).join("")}</schemaSpec>\n`}serializeElementSpec(e,t){const o=t.mode?` mode="${t.mode}"`:"",i=e+this.indentString,s=t.models.map(e=>this.serializeModel(i,e)).join("");return`${e}<elementSpec ident="${t.ident}"${o}>\n${s}${e}</elementSpec>\n`}serializeModel(e,t){if("model"===t.type&&!t.behaviour)return"";const o=e+this.indentString,i=[this.serializeAttribute("output",t.output),this.serializeAttribute("predicate",t.predicate),"model"===t.type?this.serializeAttribute("behaviour",t.behaviour):"",this.serializeAttribute("cssClass",t.css),this.serializeAttribute("useSourceRendition",t.sourcerend),this.serializeAttribute("pb:mode",t.mode)].join(""),s=t.desc?`${o}<desc>${t.desc}</desc>\n`:"",a=t.models.map(e=>this.serializeModel(o,e)).join(""),r=t.parameters.map(e=>this.serializeParameter(o,e)).join(""),n=t.renditions.map(e=>this.serializeRendition(o,e)).join(""),l=`${s}${a}${r}${re.serializeTemplate(o,t.template)}${n}`,d=l.length>0?`>\n${l}${e}</${t.type}`:"/";return`${e}<${t.type}${i}${d}>\n`}serializeParameter(e,t){if(!t.name)return"";const o=this.serializeAttribute("name",t.name),i=this.serializeAttribute("value",t.value);return t.set?`${e}<pb:set-param xmlns=""${o}${i}/>\n`:`${e}<param${o}${i}/>\n`}serializeRendition(e,t){return`${e}<outputRendition xml:space="preserve" ${t.scope&&"null"!==t.scope?this.serializeAttribute("scope",t.scope):""}>\n${e}${re.escape(t.css)}\n${e}</outputRendition>\n`}static serializeTemplate(e,t){return t?`${e}<pb:template xml:space="preserve" xmlns="">${t}</pb:template>\n`:""}serializeAttribute(e,t){return t?` ${e}="${re.escape(t)}"`:""}static escape(e){return e?"string"==typeof e?e.replace(re.replaceCharRegexp,re.replaceChars):e:""}save(e=!1){document.dispatchEvent(new CustomEvent("pb-start-update"));const t=this.serializeOdd();this.shadowRoot.getElementById("dialog").show(C("odd.editor.save"),C("odd.editor.saving"));const o=this.shadowRoot.getElementById("saveOdd");o.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.lessThanApiVersion("1.0.0")?(o.contentType="application/x-www-form-urlencoded",o.method="POST",o.params=null,o.body={action:"save",root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot,odd:this.odd,data:t}):(o.contentType="application/xml",o.method="PUT",o.params={root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot},o.body=t);o.generateRequest().completes.then(t=>{this.handleSaveComplete(t,e)}).catch(this.handleSaveError.bind(this))}static _renderReport(e){return e.error?`\n <div class="list-group-item-danger">\n <h4 class="list-group-item-heading">${e.file}</h4>\n <h5 class="list-group-item-heading">Compilation error on line ${e.line}:</h5>\n <pre class="list-group-item-text">${e.error}</pre>\n <pre class="list-group-item-text">${e.message}</pre>\n </div>\n `:`\n <div class="list-group-item-success">\n <p class="list-group-item-text">Generated ${e.file}</p>\n </div>\n `}handleSaveComplete(e,t=!1){const o=e.response;if("denied"===o.status)return this.shadowRoot.getElementById("dialog").set(C("odd.editor.denied"),C("odd.editor.denied-message",{odd:this.odd})),void document.dispatchEvent(new CustomEvent("pb-end-update"));let i;if(this.lessThanApiVersion("1.0.0")){i=`<div class="list-group">${o.report.map(re._renderReport).join("")}</div>`}else{const{report:e}=o;i=`<div class="list-group">${e}</div>`}if(this.shadowRoot.getElementById("dialog").set(C("odd.editor.saved"),i),this._hasChanges=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),t){P(new Blob([o.source],{type:"application/xml"}),{fileName:this.odd,extensions:[".odd"]}).then(()=>console.log(`<pb-odd-editor> ${this.odd} exported`),()=>console.log("<pb-odd-editor> export aborted"))}}handleSaveError(e){this.shadowRoot.getElementById("dialog").set("Error",e.error),document.dispatchEvent(new CustomEvent("pb-end-update"))}_reload(){this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.reload"),C("odd.editor.reload-confirm")).then(()=>{this.load(),this.tabs=[],this.tabIndex=0,this.shadowRoot.getElementById("currentElement").innerHTML=""},()=>null)}_setCurrentSelection(e){null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection"),this.currentSelection=e.target,this.currentSelection.setAttribute("currentselection","true")}_changeSelection(e){if(e.preventDefault(),e.stopPropagation(),e.detail.target===this)return;let t;this.currentSelection&&void 0!==this.currentSelection.tagName&&this.currentSelection.removeAttribute("currentselection"),t=e.detail.target?e.detail.target:e.target,t.setAttribute("currentselection","true"),this.currentSelection=t}_selectElementspec(e){this.currentElementSpec&&"PB-ODD-ELEMENTSPEC-EDITOR"===this.currentElementSpec.tagName&&this.currentElementSpec.removeAttribute("currentselection");const t=e.target;t.setAttribute("currentselection","true"),this.currentElementSpec=t}nsDisabled(){return!this.useNamespace}_handleLoadError(e){console.log("loading error occurred: ",e);const t=this.shadowRoot.getElementById("errorMsg");t.style.background="red";const{url:o}=this.shadowRoot.getElementById("loadContent");console.log("url ",o),t.show("Error: ","ODD file could not be loaded from "+o)}handleElementSpecChanged(e){this._hasChanges=!0;const t=this.elementSpecs.find(t=>t.ident===e.detail.ident),o=this.elementSpecs.indexOf(t),i=Object.assign(Object.assign({},t),{},{models:e.detail.models}),s=Array.from(this.elementSpecs);s.splice(o,1,i),this.elementSpecs=s}_inputTitle(e){this.title=e.composedPath()[0].value}}customElements.define("pb-odd-editor",re);export{re as PbOddEditor};
|