@teipublisher/pb-components 1.27.1 → 1.29.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/CHANGELOG.md +33 -0
- package/dist/demo/demos.json +2 -1
- package/dist/demo/pb-view3.html +90 -0
- package/dist/pb-components-bundle.js +106 -106
- package/dist/pb-elements.json +69 -0
- package/dist/pb-odd-editor.js +23 -14
- package/i18n/common/de.json +8 -1
- package/i18n/common/en.json +11 -3
- package/package.json +1 -1
- package/pb-elements.json +69 -0
- package/src/pb-odd-editor.js +6 -2
- package/src/pb-odd-elementspec-editor.js +2 -0
- package/src/pb-odd-model-editor.js +17 -0
- package/src/pb-odd-parameter-editor.js +12 -5
- package/src/pb-table-grid.js +25 -3
- package/src/pb-view.js +38 -1
package/src/pb-odd-editor.js
CHANGED
|
@@ -832,8 +832,9 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
|
|
|
832
832
|
this.serializeAttribute('predicate', model.predicate),
|
|
833
833
|
model.type === 'model' ? this.serializeAttribute('behaviour', model.behaviour) : '',
|
|
834
834
|
this.serializeAttribute('cssClass', model.css),
|
|
835
|
-
this.serializeAttribute('useSourceRendition', model.sourcerend)
|
|
836
|
-
|
|
835
|
+
this.serializeAttribute('useSourceRendition', model.sourcerend),
|
|
836
|
+
this.serializeAttribute('pb:mode', model.mode)
|
|
837
|
+
].join('');
|
|
837
838
|
|
|
838
839
|
const desc = model.desc ? nestedIndent + '<desc>' + model.desc + '</desc>\n' : '';
|
|
839
840
|
|
|
@@ -854,6 +855,9 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
|
|
|
854
855
|
}
|
|
855
856
|
const name = this.serializeAttribute('name', parameter.name);
|
|
856
857
|
const value = this.serializeAttribute('value', parameter.value);
|
|
858
|
+
if (parameter.set) {
|
|
859
|
+
return `${indent}<pb:set-param xmlns=""${name}${value}/>\n`
|
|
860
|
+
}
|
|
857
861
|
return `${indent}<param${name}${value}/>\n`
|
|
858
862
|
}
|
|
859
863
|
|
|
@@ -171,6 +171,7 @@ export class PbOddElementspecEditor extends LitElement {
|
|
|
171
171
|
type="${model.type}"
|
|
172
172
|
output="${model.output}"
|
|
173
173
|
css="${model.css}"
|
|
174
|
+
mode="${model.mode}"
|
|
174
175
|
.model="${model}"
|
|
175
176
|
.parameters="${model.parameters}"
|
|
176
177
|
desc="${model.desc}"
|
|
@@ -203,6 +204,7 @@ export class PbOddElementspecEditor extends LitElement {
|
|
|
203
204
|
const newModel = {
|
|
204
205
|
behaviour: 'inline',
|
|
205
206
|
css: '',
|
|
207
|
+
mode: '',
|
|
206
208
|
predicate: '',
|
|
207
209
|
desc: '',
|
|
208
210
|
type: addModel.selected,
|
|
@@ -271,6 +271,9 @@ export class PbOddModelEditor extends LitElement {
|
|
|
271
271
|
return value;
|
|
272
272
|
}
|
|
273
273
|
},
|
|
274
|
+
mode: {
|
|
275
|
+
type: String
|
|
276
|
+
},
|
|
274
277
|
model: {
|
|
275
278
|
type: Object
|
|
276
279
|
},
|
|
@@ -331,6 +334,7 @@ export class PbOddModelEditor extends LitElement {
|
|
|
331
334
|
this.template = '';
|
|
332
335
|
this.output = '';
|
|
333
336
|
this.css = '';
|
|
337
|
+
this.mode = '';
|
|
334
338
|
this.model = {};
|
|
335
339
|
this.model.models = [];
|
|
336
340
|
this.parameters = [];
|
|
@@ -479,6 +483,11 @@ export class PbOddModelEditor extends LitElement {
|
|
|
479
483
|
placeholder="${translate('odd.editor.model.css-class-placeholder')}"
|
|
480
484
|
label="CSS Class"
|
|
481
485
|
@change="${this._inputCss}"></paper-input>
|
|
486
|
+
|
|
487
|
+
<paper-input id="mode" .value="${this.mode}"
|
|
488
|
+
placeholder="${translate('odd.editor.model.mode-placeholder')}"
|
|
489
|
+
label="Mode"
|
|
490
|
+
@change="${this._inputMode}"></paper-input>
|
|
482
491
|
|
|
483
492
|
<pb-code-editor id="template"
|
|
484
493
|
code="${this.template}"
|
|
@@ -501,6 +510,7 @@ export class PbOddModelEditor extends LitElement {
|
|
|
501
510
|
behaviour="${this.behaviour}"
|
|
502
511
|
name="${parameter.name}"
|
|
503
512
|
value="${parameter.value}"
|
|
513
|
+
?set="${parameter.set}"
|
|
504
514
|
endpoint="${this.endpoint}"
|
|
505
515
|
apiVersion="${this.apiVersion}"
|
|
506
516
|
@parameter-remove="${(e) => this._removeParam(e, index)}"
|
|
@@ -543,6 +553,7 @@ export class PbOddModelEditor extends LitElement {
|
|
|
543
553
|
type="${model.type}"
|
|
544
554
|
output="${model.output}"
|
|
545
555
|
css="${model.css}"
|
|
556
|
+
mode="${model.mode}"
|
|
546
557
|
.model="${model}"
|
|
547
558
|
.parameters="${model.parameters}"
|
|
548
559
|
desc="${model.desc}"
|
|
@@ -836,6 +847,11 @@ export class PbOddModelEditor extends LitElement {
|
|
|
836
847
|
this._fireModelChanged('css', this.css);
|
|
837
848
|
}
|
|
838
849
|
|
|
850
|
+
_inputMode(ev) {
|
|
851
|
+
this.mode = ev.composedPath()[0].value;
|
|
852
|
+
this._fireModelChanged('mode', this.mode);
|
|
853
|
+
}
|
|
854
|
+
|
|
839
855
|
_updateTemplate(ev) {
|
|
840
856
|
this.template = this.shadowRoot.getElementById('template').getSource();
|
|
841
857
|
this._fireModelChanged('template', this.template);
|
|
@@ -854,6 +870,7 @@ export class PbOddModelEditor extends LitElement {
|
|
|
854
870
|
_updateParam(e, index) {
|
|
855
871
|
this.parameters[index].name = e.detail.name;
|
|
856
872
|
this.parameters[index].value = e.detail.value;
|
|
873
|
+
this.parameters[index].set = e.detail.set;
|
|
857
874
|
this._fireModelChanged('parameters', this.parameters);
|
|
858
875
|
}
|
|
859
876
|
|
|
@@ -29,7 +29,7 @@ export class PbOddParameterEditor extends LitElement {
|
|
|
29
29
|
}
|
|
30
30
|
.wrapper{
|
|
31
31
|
display:grid;
|
|
32
|
-
grid-template-columns:150px auto 50px;
|
|
32
|
+
grid-template-columns:150px auto 50px 50px;
|
|
33
33
|
grid-column-gap:20px;
|
|
34
34
|
grid-row-gap:20px;
|
|
35
35
|
margin-bottom:10px;
|
|
@@ -37,8 +37,9 @@ export class PbOddParameterEditor extends LitElement {
|
|
|
37
37
|
paper-dropdown-menu{
|
|
38
38
|
align-self:start;
|
|
39
39
|
}
|
|
40
|
-
paper-icon-button{
|
|
41
|
-
align-self:center;
|
|
40
|
+
paper-icon-button, paper-checkbox {
|
|
41
|
+
align-self: center;
|
|
42
|
+
margin-top: 16px;
|
|
42
43
|
}
|
|
43
44
|
`;
|
|
44
45
|
}
|
|
@@ -56,7 +57,7 @@ export class PbOddParameterEditor extends LitElement {
|
|
|
56
57
|
code="${this.value}"
|
|
57
58
|
linter="${this.endpoint}/${cmpVersion(this.apiVersion, '1.0.0') ? 'modules/editor.xql' : 'api/lint'}"
|
|
58
59
|
apiVersion="${this.apiVersion}"></pb-code-editor>
|
|
59
|
-
|
|
60
|
+
<paper-checkbox id="set" ?checked="${this.setParam}" @change="${this._handleCodeChange}">set</paper-checkbox>
|
|
60
61
|
<paper-icon-button @click="${this._delete}" icon="delete" title="delete this parameter"></paper-icon-button>
|
|
61
62
|
</div>
|
|
62
63
|
|
|
@@ -87,6 +88,10 @@ export class PbOddParameterEditor extends LitElement {
|
|
|
87
88
|
parameters: {
|
|
88
89
|
type: Object
|
|
89
90
|
},
|
|
91
|
+
setParam: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
attribute: 'set'
|
|
94
|
+
},
|
|
90
95
|
_currentParameters: {
|
|
91
96
|
type: Array
|
|
92
97
|
},
|
|
@@ -104,6 +109,7 @@ export class PbOddParameterEditor extends LitElement {
|
|
|
104
109
|
super();
|
|
105
110
|
this.name = '';
|
|
106
111
|
this.value = '';
|
|
112
|
+
this.setParam = false;
|
|
107
113
|
this.behaviour = '';
|
|
108
114
|
this.currentParameters = [];
|
|
109
115
|
this.parameters = {
|
|
@@ -189,7 +195,8 @@ export class PbOddParameterEditor extends LitElement {
|
|
|
189
195
|
console.log('_handleCodeChange ', e);
|
|
190
196
|
this.value = this.shadowRoot.getElementById('editor').getSource();
|
|
191
197
|
this.name = this.shadowRoot.getElementById('combo').text;
|
|
192
|
-
this.
|
|
198
|
+
this.setParam = this.shadowRoot.getElementById('set').checked;
|
|
199
|
+
this.dispatchEvent(new CustomEvent('parameter-changed', { composed: true, bubbles: true, detail: { name: this.name, value: this.value, set: this.setParam } }));
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
|
package/src/pb-table-grid.js
CHANGED
|
@@ -60,6 +60,13 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
60
60
|
resizable: {
|
|
61
61
|
type: Boolean
|
|
62
62
|
},
|
|
63
|
+
perPage: {
|
|
64
|
+
type: Number,
|
|
65
|
+
attribute: 'per-page'
|
|
66
|
+
},
|
|
67
|
+
height: {
|
|
68
|
+
type: String
|
|
69
|
+
},
|
|
63
70
|
/**
|
|
64
71
|
* If specified, enable server-side search.
|
|
65
72
|
*/
|
|
@@ -79,6 +86,9 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
79
86
|
this._params = {};
|
|
80
87
|
this.resizable = false;
|
|
81
88
|
this.search = false;
|
|
89
|
+
this.perPage = 10;
|
|
90
|
+
this.height = null;
|
|
91
|
+
this.fixedHeader = false;
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
connectedCallback() {
|
|
@@ -93,6 +103,15 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
93
103
|
this._params = ev.state;
|
|
94
104
|
this._submit();
|
|
95
105
|
});
|
|
106
|
+
|
|
107
|
+
if (!this.height) {
|
|
108
|
+
const property = getComputedStyle(this).getPropertyValue('--pb-table-grid-height');
|
|
109
|
+
if (property) {
|
|
110
|
+
this.height = property;
|
|
111
|
+
} else {
|
|
112
|
+
this.height = 'auto';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
96
115
|
}
|
|
97
116
|
|
|
98
117
|
firstUpdated() {
|
|
@@ -101,11 +120,12 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
101
120
|
const pbColumns = this.querySelectorAll('pb-table-column');
|
|
102
121
|
const columns = [];
|
|
103
122
|
pbColumns.forEach((column) => columns.push(column.data()));
|
|
104
|
-
|
|
105
123
|
PbTableGrid.waitOnce('pb-page-ready', () => {
|
|
106
124
|
this._params = this.getParameters();
|
|
107
125
|
const url = this.toAbsoluteURL(this.source);
|
|
108
126
|
const config = {
|
|
127
|
+
height: this.height,
|
|
128
|
+
fixedHeader: true,
|
|
109
129
|
columns,
|
|
110
130
|
resizable: this.resizable,
|
|
111
131
|
server: {
|
|
@@ -115,6 +135,7 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
115
135
|
},
|
|
116
136
|
sort: {
|
|
117
137
|
multiColumn: false,
|
|
138
|
+
enabled: true,
|
|
118
139
|
server: {
|
|
119
140
|
url: (prev, cols) => {
|
|
120
141
|
if (!cols.length) return prev;
|
|
@@ -125,7 +146,7 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
125
146
|
},
|
|
126
147
|
pagination: {
|
|
127
148
|
enabled: true,
|
|
128
|
-
limit:
|
|
149
|
+
limit: this.perPage,
|
|
129
150
|
server: {
|
|
130
151
|
url: (prev, page, limit) => {
|
|
131
152
|
const form = this.shadowRoot.getElementById('form');
|
|
@@ -133,7 +154,7 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
133
154
|
Object.assign(this._params, form.serializeForm());
|
|
134
155
|
}
|
|
135
156
|
this._params.limit = limit;
|
|
136
|
-
this._params.start = page * limit;
|
|
157
|
+
this._params.start = page * limit + 1;
|
|
137
158
|
this.setParameters(this._params);
|
|
138
159
|
this.pushHistory('grid', this._params);
|
|
139
160
|
|
|
@@ -142,6 +163,7 @@ export class PbTableGrid extends pbMixin(LitElement) {
|
|
|
142
163
|
}
|
|
143
164
|
}
|
|
144
165
|
};
|
|
166
|
+
|
|
145
167
|
this.grid = new Grid(config);
|
|
146
168
|
this.grid.on('load', () => {
|
|
147
169
|
this.emitTo('pb-results-received', {
|
package/src/pb-view.js
CHANGED
|
@@ -272,6 +272,17 @@ export class PbView extends pbMixin(LitElement) {
|
|
|
272
272
|
type: Boolean,
|
|
273
273
|
attribute: 'disable-history'
|
|
274
274
|
},
|
|
275
|
+
/**
|
|
276
|
+
* If set to the name of an event, the content of the pb-view will not be replaced
|
|
277
|
+
* immediately upon updates. Instead, an event is emitted, which contains the new content
|
|
278
|
+
* in property `root`. An event handler intercepting the event can thus modify the content.
|
|
279
|
+
* Once it is done, it should pass the modified content to the callback function provided
|
|
280
|
+
* in the event detail under the name `render`. See the demo for an example.
|
|
281
|
+
*/
|
|
282
|
+
beforeUpdate: {
|
|
283
|
+
type: String,
|
|
284
|
+
attribute: 'before-update-event'
|
|
285
|
+
},
|
|
275
286
|
_features: {
|
|
276
287
|
type: Object
|
|
277
288
|
},
|
|
@@ -312,6 +323,7 @@ export class PbView extends pbMixin(LitElement) {
|
|
|
312
323
|
this.highlight = false;
|
|
313
324
|
this.infiniteScrollMax = 10;
|
|
314
325
|
this.disableHistory = false;
|
|
326
|
+
this.beforeUpdate = null;
|
|
315
327
|
this._features = {};
|
|
316
328
|
this._selector = new Map();
|
|
317
329
|
this._chunks = [];
|
|
@@ -496,6 +508,15 @@ export class PbView extends pbMixin(LitElement) {
|
|
|
496
508
|
|
|
497
509
|
_refresh(ev) {
|
|
498
510
|
if (ev && ev.detail) {
|
|
511
|
+
if (ev.detail.hash && !(ev.detail.id || ev.detail.path || ev.detail.odd || ev.detail.view || ev.detail.position)) {
|
|
512
|
+
// if only the scroll target has changed: scroll to the element without reloading
|
|
513
|
+
this._scrollTarget = ev.detail.hash;
|
|
514
|
+
const target = this.shadowRoot.getElementById(this._scrollTarget);
|
|
515
|
+
if (target) {
|
|
516
|
+
setTimeout(() => target.scrollIntoView());
|
|
517
|
+
}
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
499
520
|
if (ev.detail.path) {
|
|
500
521
|
const doc = this.getDocument();
|
|
501
522
|
doc.path = ev.detail.path;
|
|
@@ -641,7 +662,7 @@ export class PbView extends pbMixin(LitElement) {
|
|
|
641
662
|
if (target) {
|
|
642
663
|
setTimeout(() => {
|
|
643
664
|
target.scrollIntoView();
|
|
644
|
-
});
|
|
665
|
+
}, 100);
|
|
645
666
|
}
|
|
646
667
|
this._scrollTarget = null;
|
|
647
668
|
});
|
|
@@ -687,6 +708,22 @@ export class PbView extends pbMixin(LitElement) {
|
|
|
687
708
|
fragment.appendChild(elem);
|
|
688
709
|
elem.innerHTML = resp.content;
|
|
689
710
|
|
|
711
|
+
// if before-update-event is set, we do not replace the content immediately,
|
|
712
|
+
// but emit an event
|
|
713
|
+
if (this.beforeUpdate) {
|
|
714
|
+
this.emitTo(this.beforeUpdate, {
|
|
715
|
+
data: resp,
|
|
716
|
+
root: elem,
|
|
717
|
+
render: (content) => {
|
|
718
|
+
this._doReplaceContent(content, resp, direction);
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
} else {
|
|
722
|
+
this._doReplaceContent(elem, resp, direction);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
_doReplaceContent(elem, resp, direction) {
|
|
690
727
|
if (this.columnSeparator) {
|
|
691
728
|
this._replaceColumns(elem);
|
|
692
729
|
this._loading = false;
|