@teipublisher/pb-components 2.25.5 → 2.25.6

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.
Files changed (128) hide show
  1. package/.github/workflows/main.yml +3 -3
  2. package/.github/workflows/node.js.yml +3 -3
  3. package/.github/workflows/release.js.yml +3 -3
  4. package/CHANGELOG.md +8 -0
  5. package/Dockerfile +78 -70
  6. package/css/components.css +5 -5
  7. package/dist/demo/pb-drawer2.html +1 -1
  8. package/dist/demo/pb-leaflet-map.html +1 -1
  9. package/dist/demo/pb-repeat.html +1 -3
  10. package/dist/demo/pb-view3.html +1 -1
  11. package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
  12. package/dist/pb-code-editor.js +25 -20
  13. package/dist/pb-component-docs.js +58 -54
  14. package/dist/pb-components-bundle.js +1827 -1520
  15. package/dist/pb-edit-app.js +167 -107
  16. package/dist/pb-elements.json +54 -54
  17. package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
  18. package/dist/pb-leaflet-map.js +23 -23
  19. package/dist/pb-mei.js +56 -41
  20. package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
  21. package/dist/pb-odd-editor.js +925 -758
  22. package/dist/pb-tify.js +2 -2
  23. package/dist/{vaadin-element-mixin-859a0132.js → vaadin-element-mixin-ad07ba25.js} +88 -61
  24. package/gh-pages.js +5 -3
  25. package/package.json +2 -2
  26. package/pb-elements.json +54 -54
  27. package/src/assets/components.css +5 -5
  28. package/src/authority/airtable.js +20 -21
  29. package/src/authority/anton.js +129 -129
  30. package/src/authority/custom.js +23 -21
  31. package/src/authority/geonames.js +38 -32
  32. package/src/authority/gnd.js +47 -42
  33. package/src/authority/kbga.js +137 -134
  34. package/src/authority/metagrid.js +44 -46
  35. package/src/authority/reconciliation.js +66 -67
  36. package/src/authority/registry.js +4 -4
  37. package/src/docs/pb-component-docs.js +2 -2
  38. package/src/docs/pb-component-view.js +5 -5
  39. package/src/docs/pb-components-list.js +2 -2
  40. package/src/docs/pb-demo-snippet.js +2 -2
  41. package/src/dts-client.js +299 -297
  42. package/src/dts-select-endpoint.js +90 -82
  43. package/src/parse-date-service.js +184 -135
  44. package/src/pb-ajax.js +171 -167
  45. package/src/pb-authority-lookup.js +96 -81
  46. package/src/pb-autocomplete.js +292 -280
  47. package/src/pb-blacklab-highlight.js +264 -259
  48. package/src/pb-blacklab-results.js +236 -221
  49. package/src/pb-browse-docs.js +540 -475
  50. package/src/pb-browse.js +68 -65
  51. package/src/pb-clipboard.js +79 -76
  52. package/src/pb-code-editor.js +110 -102
  53. package/src/pb-code-highlight.js +209 -204
  54. package/src/pb-codepen.js +79 -72
  55. package/src/pb-collapse.js +149 -146
  56. package/src/pb-combo-box.js +190 -190
  57. package/src/pb-components-bundle.js +1 -1
  58. package/src/pb-custom-form.js +150 -149
  59. package/src/pb-document.js +89 -90
  60. package/src/pb-download.js +208 -195
  61. package/src/pb-drawer.js +145 -148
  62. package/src/pb-edit-app.js +301 -229
  63. package/src/pb-edit-xml.js +99 -96
  64. package/src/pb-events.js +114 -107
  65. package/src/pb-facs-link.js +104 -102
  66. package/src/pb-facsimile.js +411 -413
  67. package/src/pb-formula.js +151 -153
  68. package/src/pb-geolocation.js +129 -131
  69. package/src/pb-grid-action.js +53 -56
  70. package/src/pb-grid.js +231 -228
  71. package/src/pb-highlight.js +140 -140
  72. package/src/pb-hotkeys.js +40 -42
  73. package/src/pb-i18n.js +101 -104
  74. package/src/pb-image-strip.js +84 -78
  75. package/src/pb-lang.js +83 -70
  76. package/src/pb-leaflet-map.js +488 -485
  77. package/src/pb-link.js +126 -124
  78. package/src/pb-load.js +431 -426
  79. package/src/pb-login.js +275 -254
  80. package/src/pb-manage-odds.js +364 -318
  81. package/src/pb-map-icon.js +89 -89
  82. package/src/pb-map-layer.js +85 -85
  83. package/src/pb-markdown.js +90 -99
  84. package/src/pb-media-query.js +74 -72
  85. package/src/pb-mei.js +306 -295
  86. package/src/pb-message.js +143 -130
  87. package/src/pb-mixin.js +269 -264
  88. package/src/pb-navigation.js +80 -82
  89. package/src/pb-observable.js +38 -38
  90. package/src/pb-odd-editor.js +1056 -958
  91. package/src/pb-odd-elementspec-editor.js +348 -297
  92. package/src/pb-odd-model-editor.js +1058 -898
  93. package/src/pb-odd-parameter-editor.js +200 -178
  94. package/src/pb-odd-rendition-editor.js +136 -124
  95. package/src/pb-page.js +432 -422
  96. package/src/pb-paginate.js +202 -190
  97. package/src/pb-panel.js +191 -179
  98. package/src/pb-popover-themes.js +7 -5
  99. package/src/pb-popover.js +296 -287
  100. package/src/pb-print-preview.js +127 -127
  101. package/src/pb-progress.js +49 -49
  102. package/src/pb-repeat.js +105 -104
  103. package/src/pb-restricted.js +84 -77
  104. package/src/pb-search.js +238 -221
  105. package/src/pb-select-feature.js +127 -120
  106. package/src/pb-select-odd.js +132 -124
  107. package/src/pb-select-template.js +89 -78
  108. package/src/pb-select.js +251 -227
  109. package/src/pb-split-list.js +179 -174
  110. package/src/pb-svg.js +80 -79
  111. package/src/pb-table-column.js +54 -54
  112. package/src/pb-table-grid.js +221 -203
  113. package/src/pb-tabs.js +61 -63
  114. package/src/pb-tify.js +154 -154
  115. package/src/pb-timeline.js +271 -229
  116. package/src/pb-toggle-feature.js +198 -185
  117. package/src/pb-upload.js +184 -174
  118. package/src/pb-version.js +30 -30
  119. package/src/pb-view-annotate.js +132 -98
  120. package/src/pb-view.js +1282 -1263
  121. package/src/pb-zoom.js +40 -40
  122. package/src/polymer-hack.js +1 -1
  123. package/src/search-result-service.js +256 -223
  124. package/src/seed-element.js +13 -20
  125. package/src/settings.js +4 -4
  126. package/src/theming.js +91 -91
  127. package/src/urls.js +289 -289
  128. package/src/utils.js +53 -51
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  /* eslint-disable import/extensions */
3
- import { LitElement, html, css } from 'lit-element'
3
+ import { LitElement, html, css } from 'lit-element';
4
4
 
5
5
  import { repeat } from 'lit-html/directives/repeat';
6
6
 
@@ -16,7 +16,7 @@ import '@polymer/iron-collapse/iron-collapse';
16
16
  import './pb-message.js';
17
17
  import './pb-odd-model-editor.js';
18
18
 
19
- import { get as i18n, translate } from "./pb-i18n.js";
19
+ import { get as i18n, translate } from './pb-i18n.js';
20
20
 
21
21
  /**
22
22
  * A wrapper for the popular codemirror code editor.
@@ -26,305 +26,356 @@ import { get as i18n, translate } from "./pb-i18n.js";
26
26
  * @polymer
27
27
  */
28
28
  export class PbOddElementspecEditor extends LitElement {
29
-
30
- static get styles() {
31
- return css`
32
- :host {
33
- display: block;
34
- padding: 4px 10px;
35
- height: auto;
36
- }
37
-
38
- h1, h2, h3, h4, h5, h6 {
39
- font-family: "Oswald", Verdana, "Helvetica", sans-serif;
40
- font-weight: 400 !important;
41
- }
42
-
43
-
44
- input {
45
- vertical-align: middle;
46
- }
47
-
48
- .ident {
49
- display: inline-block;
50
- font-size:26px;
51
- position:relative;
52
- }
53
- .mode{
54
- font-size:10px;
55
- display:inline-block;
56
- text-transform:uppercase;
57
- border-radius:12px;
58
- color:var(--paper-grey-700);
59
- background:var(--paper-grey-300);
60
- padding:2px 6px;
61
- border:thin solid var(--paper-grey-500);
62
- margin-left:6px;
63
- position:absolute;
64
- top:8px;
65
- }
66
-
67
- :host([currentselection]){
68
- box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14),
69
- 0 1px 18px 0 rgba(0, 0, 0, 0.12),
70
- 0 3px 5px -1px rgba(0, 0, 0, 0.4);
71
-
72
- }
73
-
74
- :host([currentSelection]) > h3, :host([currentSelection]) > header{
75
- border-left:thin solid var(--paper-blue-500);
76
- }
77
-
78
-
79
- h3{
80
- display:grid;
81
- grid-template-columns:260px auto 160px;
82
- align-items:center;
83
- }
84
- h3 .controls{
85
- text-align: right;
86
- margin-right: 10px;
87
- }
88
-
89
- h3 .ident{
90
- align-self: center;
91
- }
92
-
93
- paper-menu-button paper-icon-button{
94
- margin-left:-10px;
95
- }
96
-
97
- /*todo: this does not take effect*/
98
- iron-collapse.models{
99
- --iron-collapse-transition-duration:0.4s;
100
- }
101
-
102
- .models{
103
- padding:10px;
104
- }
105
- `;
106
- }
107
-
108
- static get properties() {
109
- return {
110
- // identifier for this ´element-spec´
111
- ident: {
112
- type: String
113
- },
114
- /**
115
- * mode for an ´elementSpec` may be 'add', 'remove' or being undefined
116
- */
117
- mode: {
118
- type: String
119
- },
120
- /**
121
- * array of ODD `model` elements
122
- */
123
- models: {
124
- type: Array
125
- },
126
- endpoint: {
127
- type: String
128
- },
129
- apiVersion: {
130
- type: String
131
- }
132
- };
133
- }
134
-
135
- constructor() {
136
- super();
137
- this.ident = '';
138
- this.mode = '';
139
- this.models = [];
140
- this.icon = 'expand-more';
141
- }
142
-
143
- render() {
144
- return html`
145
- <h3>
146
- <span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
147
- <span class="spacer"></span>
148
-
149
- <span class="controls">
150
- <paper-icon-button @click="${this._remove}" icon="delete"></paper-icon-button>
151
- <paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
152
- <paper-menu-button horizontal-align="right">
153
- <paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
154
- <paper-listbox id="addModel" slot="dropdown-content" @iron-select="${this._addModel}"
155
- attr-for-selected="value">
156
- <paper-item value="model">model</paper-item>
157
- <paper-item value="modelSequence">modelSequence</paper-item>
158
- <paper-item value="modelGrp">modelGrp</paper-item>
159
- </paper-listbox>
160
- </paper-menu-button>
161
-
162
-
163
- </span>
164
- </h3>
165
-
166
- <div>
167
- ${repeat(this.models, (model, index) => html`
29
+ static get styles() {
30
+ return css`
31
+ :host {
32
+ display: block;
33
+ padding: 4px 10px;
34
+ height: auto;
35
+ }
36
+
37
+ h1,
38
+ h2,
39
+ h3,
40
+ h4,
41
+ h5,
42
+ h6 {
43
+ font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
44
+ font-weight: 400 !important;
45
+ }
46
+
47
+ input {
48
+ vertical-align: middle;
49
+ }
50
+
51
+ .ident {
52
+ display: inline-block;
53
+ font-size: 26px;
54
+ position: relative;
55
+ }
56
+ .mode {
57
+ font-size: 10px;
58
+ display: inline-block;
59
+ text-transform: uppercase;
60
+ border-radius: 12px;
61
+ color: var(--paper-grey-700);
62
+ background: var(--paper-grey-300);
63
+ padding: 2px 6px;
64
+ border: thin solid var(--paper-grey-500);
65
+ margin-left: 6px;
66
+ position: absolute;
67
+ top: 8px;
68
+ }
69
+
70
+ :host([currentselection]) {
71
+ box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12),
72
+ 0 3px 5px -1px rgba(0, 0, 0, 0.4);
73
+ }
74
+
75
+ :host([currentSelection]) > h3,
76
+ :host([currentSelection]) > header {
77
+ border-left: thin solid var(--paper-blue-500);
78
+ }
79
+
80
+ h3 {
81
+ display: grid;
82
+ grid-template-columns: 260px auto 160px;
83
+ align-items: center;
84
+ }
85
+ h3 .controls {
86
+ text-align: right;
87
+ margin-right: 10px;
88
+ }
89
+
90
+ h3 .ident {
91
+ align-self: center;
92
+ }
93
+
94
+ paper-menu-button paper-icon-button {
95
+ margin-left: -10px;
96
+ }
97
+
98
+ /*todo: this does not take effect*/
99
+ iron-collapse.models {
100
+ --iron-collapse-transition-duration: 0.4s;
101
+ }
102
+
103
+ .models {
104
+ padding: 10px;
105
+ }
106
+ `;
107
+ }
108
+
109
+ static get properties() {
110
+ return {
111
+ // identifier for this ´element-spec´
112
+ ident: {
113
+ type: String,
114
+ },
115
+ /**
116
+ * mode for an ´elementSpec` may be 'add', 'remove' or being undefined
117
+ */
118
+ mode: {
119
+ type: String,
120
+ },
121
+ /**
122
+ * array of ODD `model` elements
123
+ */
124
+ models: {
125
+ type: Array,
126
+ },
127
+ endpoint: {
128
+ type: String,
129
+ },
130
+ apiVersion: {
131
+ type: String,
132
+ },
133
+ };
134
+ }
135
+
136
+ constructor() {
137
+ super();
138
+ this.ident = '';
139
+ this.mode = '';
140
+ this.models = [];
141
+ this.icon = 'expand-more';
142
+ }
143
+
144
+ render() {
145
+ return html`
146
+ <h3>
147
+ <span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
148
+ <span class="spacer"></span>
149
+
150
+ <span class="controls">
151
+ <paper-icon-button @click="${this._remove}" icon="delete"></paper-icon-button>
152
+ <paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
153
+ <paper-menu-button horizontal-align="right">
154
+ <paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
155
+ <paper-listbox
156
+ id="addModel"
157
+ slot="dropdown-content"
158
+ @iron-select="${this._addModel}"
159
+ attr-for-selected="value"
160
+ >
161
+ <paper-item value="model">model</paper-item>
162
+ <paper-item value="modelSequence">modelSequence</paper-item>
163
+ <paper-item value="modelGrp">modelGrp</paper-item>
164
+ </paper-listbox>
165
+ </paper-menu-button>
166
+ </span>
167
+ </h3>
168
+
169
+ <div>
170
+ ${repeat(
171
+ this.models,
172
+ (model, index) => html`
168
173
  <pb-odd-model-editor
169
- behaviour="${model.behaviour || ''}"
170
- predicate="${model.predicate}"
171
- type="${model.type}"
172
- output="${model.output}"
173
- css="${model.css}"
174
- mode="${model.mode}"
175
- .model="${model}"
176
- .parameters="${model.parameters}"
177
- desc="${model.desc}"
178
- .sourcerend="${model.sourcerend}"
179
- .renditions="${model.renditions}"
180
- .template="${model.template}"
181
- .show="${model.show}"
182
- .endpoint="${this.endpoint}"
183
- .apiVersion="${this.apiVersion}"
184
- @model-remove="${this._removeModel}"
185
- @model-move-down="${this._moveModelDown}"
186
- @model-move-up="${this._moveModelUp}"
187
- @model-changed="${this.handleModelChanged}"
188
- @click="${(e) => this.setCurrentSelection(e, index)}"
189
- ></pb-odd-model-editor>
190
- `)}
191
- </div>
192
- <pb-message id="dialog"></pb-message>
193
- `;
174
+ behaviour="${model.behaviour || ''}"
175
+ predicate="${model.predicate}"
176
+ type="${model.type}"
177
+ output="${model.output}"
178
+ css="${model.css}"
179
+ mode="${model.mode}"
180
+ .model="${model}"
181
+ .parameters="${model.parameters}"
182
+ desc="${model.desc}"
183
+ .sourcerend="${model.sourcerend}"
184
+ .renditions="${model.renditions}"
185
+ .template="${model.template}"
186
+ .show="${model.show}"
187
+ .endpoint="${this.endpoint}"
188
+ .apiVersion="${this.apiVersion}"
189
+ @model-remove="${this._removeModel}"
190
+ @model-move-down="${this._moveModelDown}"
191
+ @model-move-up="${this._moveModelUp}"
192
+ @model-changed="${this.handleModelChanged}"
193
+ @click="${e => this.setCurrentSelection(e, index)}"
194
+ ></pb-odd-model-editor>
195
+ `,
196
+ )}
197
+ </div>
198
+ <pb-message id="dialog"></pb-message>
199
+ `;
200
+ }
201
+
202
+ addModel(newModel) {
203
+ this.models.unshift(newModel);
204
+ this.requestUpdate();
205
+ }
206
+
207
+ _addModel(e) {
208
+ console.log('ELEMENTSPEC._addModel ', e);
209
+ const addModel = this.shadowRoot.getElementById('addModel');
210
+ const newModel = {
211
+ behaviour: 'inline',
212
+ css: '',
213
+ mode: '',
214
+ predicate: '',
215
+ desc: '',
216
+ type: addModel.selected,
217
+ output: '',
218
+ template: '',
219
+ sourcerend: false,
220
+ models: [],
221
+ parameters: [],
222
+ renditions: [],
223
+ show: true,
224
+ };
225
+
226
+ const models = Array.from(this.models);
227
+ models.unshift(newModel);
228
+ this.models = models;
229
+ this.dispatchEvent(
230
+ new CustomEvent('element-spec-changed', {
231
+ composed: true,
232
+ bubbles: true,
233
+ detail: { action: 'models', ident: this.ident, models: this.models },
234
+ }),
235
+ );
236
+ addModel.selected = '';
237
+ this.requestUpdate();
238
+ }
239
+
240
+ _remove(ev) {
241
+ this.dispatchEvent(
242
+ new CustomEvent('element-spec-removed', {
243
+ composed: true,
244
+ bubbles: true,
245
+ detail: { target: this },
246
+ }),
247
+ );
248
+ }
249
+
250
+ _paste(ev) {
251
+ console.log('_paste ', ev);
252
+ // const editor = document.querySelector('pb-odd-editor');
253
+ this.dispatchEvent(
254
+ new CustomEvent('odd-paste', { composed: true, bubbles: true, detail: { target: this } }),
255
+ );
256
+ }
257
+
258
+ setCurrentSelection(e, index) {
259
+ e.preventDefault();
260
+ e.stopPropagation();
261
+
262
+ // prevent event if model is already the current one
263
+ this._setCurrentSelection(index, e.target);
264
+ }
265
+
266
+ _setCurrentSelection(index, target) {
267
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index];
268
+ if (!targetModel) {
269
+ return;
194
270
  }
195
-
196
- addModel(newModel) {
197
- this.models.unshift(newModel);
198
- this.requestUpdate();
271
+ if (targetModel.hasAttribute('currentselection')) return;
272
+
273
+ this.dispatchEvent(
274
+ new CustomEvent('current-changed', { composed: true, bubbles: true, detail: { target } }),
275
+ );
276
+ this.requestUpdate();
277
+ }
278
+
279
+ _removeModel(ev) {
280
+ console.log('_removeModel ', ev);
281
+ ev.stopPropagation();
282
+ const { model } = ev.target;
283
+ const index = this.models.indexOf(model);
284
+
285
+ this.shadowRoot
286
+ .getElementById('dialog')
287
+ .confirm(
288
+ i18n('odd.editor.model.delete-model-label'),
289
+ i18n('odd.editor.model.delete-model-message'),
290
+ )
291
+ .then(
292
+ () => {
293
+ const models = Array.from(this.models);
294
+ models.splice(index, 1);
295
+ this.models = models;
296
+ this.dispatchEvent(
297
+ new CustomEvent('element-spec-changed', {
298
+ composed: true,
299
+ bubbles: true,
300
+ detail: { action: 'models', ident: this.ident, models: this.models },
301
+ }),
302
+ );
303
+ },
304
+ () => null,
305
+ );
306
+ }
307
+
308
+ _moveModelDown(ev) {
309
+ console.log('ELEMENTSPEC._moveModelDown ', ev);
310
+ ev.stopPropagation();
311
+ const { model } = ev.target;
312
+ const index = this.models.indexOf(model);
313
+ if (index === this.models.length) {
314
+ return;
199
315
  }
200
-
201
- _addModel(e) {
202
- console.log('ELEMENTSPEC._addModel ', e);
203
- const addModel = this.shadowRoot.getElementById('addModel');
204
- const newModel = {
205
- behaviour: 'inline',
206
- css: '',
207
- mode: '',
208
- predicate: '',
209
- desc: '',
210
- type: addModel.selected,
211
- output: '',
212
- template: '',
213
- sourcerend: false,
214
- models: [],
215
- parameters: [],
216
- renditions: [],
217
- show: true
218
- };
219
-
220
- const models = Array.from(this.models);
221
- models.unshift(newModel);
222
- this.models = models;
223
- this.dispatchEvent(new CustomEvent('element-spec-changed', { composed: true, bubbles: true, detail: { action: "models", ident: this.ident, models: this.models } }));
224
- addModel.selected = "";
225
- this.requestUpdate();
226
-
316
+ const models = Array.from(this.models);
317
+ models.splice(index, 1);
318
+ models.splice(index + 1, 0, model);
319
+ this.models = models;
320
+
321
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index + 1];
322
+ if (!targetModel) {
323
+ return;
227
324
  }
228
-
229
-
230
- _remove(ev) {
231
- this.dispatchEvent(new CustomEvent('element-spec-removed', {
232
- composed: true, bubbles: true,
233
- detail: { target: this }
234
- }));
325
+ this._setCurrentSelection(index + 1, targetModel);
326
+
327
+ this.dispatchEvent(
328
+ new CustomEvent('element-spec-changed', {
329
+ composed: true,
330
+ bubbles: true,
331
+ detail: { action: 'models', ident: this.ident, models: this.models },
332
+ }),
333
+ );
334
+ // this.requestUpdate();
335
+ }
336
+
337
+ _moveModelUp(ev) {
338
+ ev.stopPropagation();
339
+ const { model } = ev.target;
340
+ const index = this.models.indexOf(model);
341
+ if (index === 0) {
342
+ return;
235
343
  }
236
-
237
- _paste(ev) {
238
- console.log('_paste ', ev);
239
- // const editor = document.querySelector('pb-odd-editor');
240
- this.dispatchEvent(new CustomEvent('odd-paste', { composed: true, bubbles: true, detail: { target: this } }));
241
- }
242
-
243
- setCurrentSelection(e, index) {
244
- e.preventDefault();
245
- e.stopPropagation();
246
-
247
- //prevent event if model is already the current one
248
- this._setCurrentSelection(index, e.target);
249
- }
250
-
251
- _setCurrentSelection(index, target) {
252
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index];
253
- if (!targetModel) { return; }
254
- if (targetModel.hasAttribute('currentselection')) return;
255
-
256
- this.dispatchEvent(new CustomEvent('current-changed', { composed: true, bubbles: true, detail: { target: target } }));
257
- this.requestUpdate();
258
- }
259
-
260
- _removeModel(ev) {
261
- console.log('_removeModel ', ev);
262
- ev.stopPropagation();
263
- const { model } = ev.target;
264
- const index = this.models.indexOf(model)
265
-
266
- this.shadowRoot.getElementById('dialog')
267
- .confirm(i18n('odd.editor.model.delete-model-label'), i18n('odd.editor.model.delete-model-message'))
268
- .then(() => {
269
- const models = Array.from(this.models);
270
- models.splice(index, 1);
271
- this.models = models;
272
- this.dispatchEvent(new CustomEvent('element-spec-changed', { composed: true, bubbles: true, detail: { action: "models", ident: this.ident, models: this.models } }));
273
- }, () => null);
274
- }
275
-
276
- _moveModelDown(ev) {
277
- console.log('ELEMENTSPEC._moveModelDown ', ev);
278
- ev.stopPropagation();
279
- const { model } = ev.target;
280
- const index = this.models.indexOf(model)
281
- if (index === this.models.length) {
282
- return;
283
- }
284
- const models = Array.from(this.models);
285
- models.splice(index, 1);
286
- models.splice(index + 1, 0, model);
287
- this.models = models;
288
-
289
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index + 1];
290
- if (!targetModel) { return; }
291
- this._setCurrentSelection(index + 1, targetModel);
292
-
293
- this.dispatchEvent(new CustomEvent('element-spec-changed', { composed: true, bubbles: true, detail: { action: "models", ident: this.ident, models: this.models } }));
294
- // this.requestUpdate();
295
- }
296
-
297
- _moveModelUp(ev) {
298
- ev.stopPropagation();
299
- const { model } = ev.target;
300
- const index = this.models.indexOf(model)
301
- if (index === 0) {
302
- return;
303
- }
304
- const models = Array.from(this.models);
305
- // remove element from models
306
- models.splice(index, 1);
307
- // add element to new index
308
- models.splice(index - 1, 0, model);
309
- this.models = models;
310
-
311
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index - 1];
312
- this._setCurrentSelection(index - 1, targetModel);
313
-
314
- this.dispatchEvent(new CustomEvent('element-spec-changed', { composed: true, bubbles: true, detail: { action: "models", ident: this.ident, models: this.models } }));
315
- // this.requestUpdate();
316
- }
317
-
318
- handleModelChanged(ev) {
319
- // console.log('ELEMENTSPEC.handleModelChanged ', ev.detail);
320
- ev.stopPropagation();
321
- const index = this.models.indexOf(ev.detail.oldModel);
322
- const models = Array.from(this.models);
323
- models.splice(index, 1, ev.detail.newModel);
324
- this.models = models;
325
- this.dispatchEvent(new CustomEvent('element-spec-changed', { composed: true, bubbles: true, detail: { action: "models", ident: this.ident, models: this.models } }));
326
- this.requestUpdate();
327
- }
328
-
344
+ const models = Array.from(this.models);
345
+ // remove element from models
346
+ models.splice(index, 1);
347
+ // add element to new index
348
+ models.splice(index - 1, 0, model);
349
+ this.models = models;
350
+
351
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index - 1];
352
+ this._setCurrentSelection(index - 1, targetModel);
353
+
354
+ this.dispatchEvent(
355
+ new CustomEvent('element-spec-changed', {
356
+ composed: true,
357
+ bubbles: true,
358
+ detail: { action: 'models', ident: this.ident, models: this.models },
359
+ }),
360
+ );
361
+ // this.requestUpdate();
362
+ }
363
+
364
+ handleModelChanged(ev) {
365
+ // console.log('ELEMENTSPEC.handleModelChanged ', ev.detail);
366
+ ev.stopPropagation();
367
+ const index = this.models.indexOf(ev.detail.oldModel);
368
+ const models = Array.from(this.models);
369
+ models.splice(index, 1, ev.detail.newModel);
370
+ this.models = models;
371
+ this.dispatchEvent(
372
+ new CustomEvent('element-spec-changed', {
373
+ composed: true,
374
+ bubbles: true,
375
+ detail: { action: 'models', ident: this.ident, models: this.models },
376
+ }),
377
+ );
378
+ this.requestUpdate();
379
+ }
329
380
  }
330
381
  customElements.define('pb-odd-elementspec-editor', PbOddElementspecEditor);