@teipublisher/pb-components 2.26.1-next.2 → 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.
Files changed (154) 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 +4 -4
  4. package/.releaserc.json +2 -2
  5. package/CHANGELOG.md +267 -9
  6. package/Dockerfile +78 -70
  7. package/css/components.css +5 -5
  8. package/css/leaflet/images/layers.png +0 -0
  9. package/dist/demo/components.css +46 -1
  10. package/dist/demo/pb-browse-docs2.html +1 -1
  11. package/dist/demo/pb-dialog.html +3 -5
  12. package/dist/demo/pb-drawer2.html +1 -1
  13. package/dist/demo/pb-facsimile.html +2 -2
  14. package/dist/demo/pb-grid.html +19 -6
  15. package/dist/demo/pb-leaflet-map.html +1 -1
  16. package/dist/demo/pb-login.html +0 -2
  17. package/dist/demo/pb-message.html +1 -2
  18. package/dist/demo/pb-progress.html +2 -2
  19. package/dist/demo/pb-repeat.html +1 -3
  20. package/dist/demo/pb-search.html +7 -4
  21. package/dist/demo/pb-search3.html +1 -1
  22. package/dist/demo/pb-search4.html +2 -2
  23. package/dist/demo/pb-view3.html +1 -1
  24. package/dist/{iron-form-3b8dcaa7.js → iron-form-dfb3e3b1.js} +95 -95
  25. package/dist/paper-checkbox-645e1077.js +200 -0
  26. package/dist/{paper-icon-button-b1d31571.js → paper-icon-button-984162bd.js} +1 -1
  27. package/dist/{paper-checkbox-515a5284.js → paper-inky-focus-behavior-fa16796b.js} +58 -247
  28. package/dist/{paper-listbox-a3b7175c.js → paper-listbox-5f5d1cec.js} +152 -162
  29. package/dist/pb-code-editor.js +25 -20
  30. package/dist/pb-component-docs.js +68 -64
  31. package/dist/pb-components-bundle.js +1983 -2293
  32. package/dist/pb-edit-app.js +167 -107
  33. package/dist/pb-elements.json +176 -120
  34. package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
  35. package/dist/pb-leaflet-map.js +23 -23
  36. package/dist/pb-mei.js +56 -41
  37. package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
  38. package/dist/pb-odd-editor.js +1023 -782
  39. package/dist/pb-tify.js +2 -2
  40. package/dist/vaadin-element-mixin-beb74ffd.js +545 -0
  41. package/gh-pages.js +5 -3
  42. package/i18n/common/en.json +6 -0
  43. package/i18n/common/pl.json +2 -2
  44. package/lib/openseadragon.min.js +6 -6
  45. package/package.json +3 -3
  46. package/pb-elements.json +176 -120
  47. package/src/assets/components.css +5 -5
  48. package/src/authority/airtable.js +20 -21
  49. package/src/authority/anton.js +129 -129
  50. package/src/authority/custom.js +23 -21
  51. package/src/authority/geonames.js +38 -32
  52. package/src/authority/gnd.js +50 -42
  53. package/src/authority/kbga.js +137 -134
  54. package/src/authority/metagrid.js +44 -46
  55. package/src/authority/reconciliation.js +66 -67
  56. package/src/authority/registry.js +4 -4
  57. package/src/docs/pb-component-docs.js +2 -2
  58. package/src/docs/pb-component-view.js +5 -5
  59. package/src/docs/pb-components-list.js +2 -2
  60. package/src/docs/pb-demo-snippet.js +2 -2
  61. package/src/dts-client.js +299 -297
  62. package/src/dts-select-endpoint.js +90 -82
  63. package/src/parse-date-service.js +184 -135
  64. package/src/pb-ajax.js +158 -171
  65. package/src/pb-authority-lookup.js +191 -156
  66. package/src/pb-autocomplete.js +292 -280
  67. package/src/pb-blacklab-highlight.js +264 -259
  68. package/src/pb-blacklab-results.js +236 -221
  69. package/src/pb-browse-docs.js +540 -475
  70. package/src/pb-browse.js +68 -65
  71. package/src/pb-clipboard.js +79 -76
  72. package/src/pb-code-editor.js +110 -102
  73. package/src/pb-code-highlight.js +209 -204
  74. package/src/pb-codepen.js +79 -72
  75. package/src/pb-collapse.js +211 -151
  76. package/src/pb-combo-box.js +190 -190
  77. package/src/pb-components-bundle.js +1 -1
  78. package/src/pb-components.js +1 -0
  79. package/src/pb-custom-form.js +173 -153
  80. package/src/pb-dialog.js +98 -62
  81. package/src/pb-document.js +89 -90
  82. package/src/pb-download.js +212 -196
  83. package/src/pb-drawer.js +145 -148
  84. package/src/pb-edit-app.js +301 -229
  85. package/src/pb-edit-xml.js +100 -97
  86. package/src/pb-events.js +114 -107
  87. package/src/pb-facs-link.js +104 -102
  88. package/src/pb-facsimile.js +474 -410
  89. package/src/pb-formula.js +151 -153
  90. package/src/pb-geolocation.js +129 -131
  91. package/src/pb-grid-action.js +53 -56
  92. package/src/pb-grid.js +231 -228
  93. package/src/pb-highlight.js +140 -140
  94. package/src/pb-hotkeys.js +40 -42
  95. package/src/pb-i18n.js +101 -104
  96. package/src/pb-image-strip.js +84 -78
  97. package/src/pb-lang.js +142 -57
  98. package/src/pb-leaflet-map.js +488 -485
  99. package/src/pb-link.js +126 -124
  100. package/src/pb-load.js +431 -429
  101. package/src/pb-login.js +299 -244
  102. package/src/pb-manage-odds.js +352 -336
  103. package/src/pb-map-icon.js +89 -89
  104. package/src/pb-map-layer.js +85 -85
  105. package/src/pb-markdown.js +90 -99
  106. package/src/pb-media-query.js +74 -72
  107. package/src/pb-mei.js +306 -295
  108. package/src/pb-message.js +139 -97
  109. package/src/pb-mixin.js +269 -264
  110. package/src/pb-navigation.js +80 -95
  111. package/src/pb-observable.js +38 -38
  112. package/src/pb-odd-editor.js +1054 -958
  113. package/src/pb-odd-elementspec-editor.js +349 -298
  114. package/src/pb-odd-model-editor.js +1075 -909
  115. package/src/pb-odd-parameter-editor.js +200 -178
  116. package/src/pb-odd-rendition-editor.js +136 -124
  117. package/src/pb-page.js +431 -422
  118. package/src/pb-paginate.js +228 -179
  119. package/src/pb-panel.js +198 -182
  120. package/src/pb-popover-themes.js +15 -8
  121. package/src/pb-popover.js +296 -287
  122. package/src/pb-print-preview.js +127 -127
  123. package/src/pb-progress.js +51 -51
  124. package/src/pb-repeat.js +105 -104
  125. package/src/pb-restricted.js +84 -77
  126. package/src/pb-search.js +256 -228
  127. package/src/pb-select-feature.js +127 -120
  128. package/src/pb-select-odd.js +132 -124
  129. package/src/pb-select-template.js +89 -78
  130. package/src/pb-select.js +251 -227
  131. package/src/pb-split-list.js +179 -174
  132. package/src/pb-svg.js +80 -79
  133. package/src/pb-table-column.js +54 -54
  134. package/src/pb-table-grid.js +221 -203
  135. package/src/pb-tabs.js +61 -63
  136. package/src/pb-tify.js +154 -154
  137. package/src/pb-timeline.js +382 -249
  138. package/src/pb-toggle-feature.js +195 -187
  139. package/src/pb-upload.js +184 -174
  140. package/src/pb-version.js +30 -30
  141. package/src/pb-view-annotate.js +135 -98
  142. package/src/pb-view.js +1282 -1270
  143. package/src/pb-zoom.js +127 -45
  144. package/src/polymer-hack.js +1 -1
  145. package/src/search-result-service.js +256 -223
  146. package/src/seed-element.js +13 -20
  147. package/src/settings.js +4 -4
  148. package/src/theming.js +98 -91
  149. package/src/urls.js +289 -289
  150. package/src/utils.js +53 -51
  151. package/css/pb-styles.css +0 -51
  152. package/dist/vaadin-element-mixin-6e4cee3a.js +0 -527
  153. package/src/assets/pb-styles.css +0 -51
  154. package/src/pb-light-dom.js +0 -40
@@ -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
 
@@ -12,11 +12,11 @@ import '@polymer/paper-menu-button/paper-menu-button';
12
12
  import '@polymer/paper-listbox/paper-listbox';
13
13
  import '@polymer/paper-styles/color';
14
14
  import '@polymer/paper-item/paper-item';
15
- import '@polymer/iron-collapse/iron-collapse';
15
+
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
+ details.models {
100
+ --details-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
- `;
194
- }
195
-
196
- addModel(newModel) {
197
- this.models.unshift(newModel);
198
- this.requestUpdate();
199
- }
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
-
227
- }
228
-
229
-
230
- _remove(ev) {
231
- this.dispatchEvent(new CustomEvent('element-spec-removed', {
232
- composed: true, bubbles: true,
233
- detail: { target: this }
234
- }));
235
- }
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 } }));
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;
241
270
  }
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);
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;
249
315
  }
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();
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;
258
324
  }
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);
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;
274
343
  }
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);