@teipublisher/pb-components 1.43.4 → 1.44.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 +21 -0
- package/CHANGELOG.md +14 -0
- package/dist/demo/pb-table-grid.html +16 -16
- package/dist/demo/pb-view2.html +135 -135
- package/dist/demo/redirect.html +3 -0
- package/dist/jinn-codemirror-9718e0e0.js +1 -0
- package/dist/pb-code-editor.js +1 -1
- package/dist/pb-components-bundle.js +95 -104
- package/dist/pb-edit-app.js +1 -1
- package/dist/pb-elements.json +1009 -690
- package/dist/{pb-i18n-dc551878.js → pb-i18n-3963b098.js} +1 -1
- package/dist/pb-leaflet-map.js +1 -1
- package/dist/pb-odd-editor.js +1 -1
- package/dist/{pb-message-fbc1b645.js → vaadin-element-mixin-08cf11b5.js} +21 -19
- package/gh-pages.js +23 -0
- package/i18n/common/en.json +7 -2
- package/package.json +6 -4
- package/pb-elements.json +1009 -690
- package/src/pb-ajax.js +37 -19
- package/src/pb-browse-docs.js +520 -520
- package/src/pb-browse.js +77 -0
- package/src/pb-components.js +1 -0
- package/src/pb-message.js +6 -10
- package/src/pb-mixin.js +542 -542
- package/src/pb-page.js +399 -399
- package/src/pb-split-list.js +188 -188
- package/src/pb-table-grid.js +218 -218
- package/src/pb-view.js +1366 -1366
- package/dist/jinn-codemirror-d437848a.js +0 -1
- /package/dist/{pb-mixin-f8b22e51.js → pb-mixin-88125cb2.js} +0 -0
package/src/pb-ajax.js
CHANGED
|
@@ -2,9 +2,9 @@ import { LitElement, html, css } from 'lit-element';
|
|
|
2
2
|
import '@polymer/iron-ajax';
|
|
3
3
|
import '@polymer/paper-dialog';
|
|
4
4
|
import '@polymer/paper-dialog-scrollable';
|
|
5
|
-
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
6
5
|
import { pbMixin } from './pb-mixin.js';
|
|
7
|
-
import {
|
|
6
|
+
import { get as i18n } from "./pb-i18n.js";
|
|
7
|
+
import './pb-message.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Triggers an action on the server and shows a dialog
|
|
@@ -14,7 +14,7 @@ import { translate } from "./pb-i18n.js";
|
|
|
14
14
|
* The parameters sent to the server-side script will be copied
|
|
15
15
|
* from the `pb-view` to which this component subscribes, see pb-update event.
|
|
16
16
|
*
|
|
17
|
-
* @slot - unnamed slot for link
|
|
17
|
+
* @slot - unnamed slot for link content
|
|
18
18
|
* @slot title - dialog title
|
|
19
19
|
*
|
|
20
20
|
* @fires pb-start-update - Fired before the element updates its content
|
|
@@ -51,6 +51,19 @@ export class PbAjax extends pbMixin(LitElement) {
|
|
|
51
51
|
event: {
|
|
52
52
|
type: String
|
|
53
53
|
},
|
|
54
|
+
/**
|
|
55
|
+
* If set, display a confirmation dialog with the message text given in
|
|
56
|
+
* this property. The user may cancel the action.
|
|
57
|
+
*/
|
|
58
|
+
confirm: {
|
|
59
|
+
type: String
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* Set to not show the server's response
|
|
63
|
+
*/
|
|
64
|
+
quiet: {
|
|
65
|
+
type: Boolean
|
|
66
|
+
},
|
|
54
67
|
_message: {
|
|
55
68
|
type: String
|
|
56
69
|
}
|
|
@@ -60,6 +73,8 @@ export class PbAjax extends pbMixin(LitElement) {
|
|
|
60
73
|
constructor() {
|
|
61
74
|
super();
|
|
62
75
|
this.method = 'get';
|
|
76
|
+
this.confirm = null;
|
|
77
|
+
this.quiet = false;
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
connectedCallback() {
|
|
@@ -78,22 +93,16 @@ export class PbAjax extends pbMixin(LitElement) {
|
|
|
78
93
|
with-credentials
|
|
79
94
|
@error="${this._handleError}"
|
|
80
95
|
@response="${this._handleResponse}"></iron-ajax>
|
|
81
|
-
|
|
96
|
+
<pb-message id="confirmDialog"></pb-message>
|
|
97
|
+
<slot name="title" style="display: none"></slot>
|
|
82
98
|
`;
|
|
83
99
|
}
|
|
84
100
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<div class="buttons">
|
|
91
|
-
<paper-button dialog-confirm="dialog-confirm" autofocus="autofocus">
|
|
92
|
-
${translate('dialogs.close')}
|
|
93
|
-
</paper-button>
|
|
94
|
-
</div>
|
|
95
|
-
</paper-dialog>
|
|
96
|
-
`;
|
|
101
|
+
firstUpdated() {
|
|
102
|
+
super.firstUpdated();
|
|
103
|
+
const slot = this.shadowRoot.querySelector('slot[name=title]');
|
|
104
|
+
this._dialogTitle = '';
|
|
105
|
+
slot.assignedNodes().forEach(node => {this._dialogTitle += node.innerHTML});
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
static get styles() {
|
|
@@ -109,7 +118,14 @@ export class PbAjax extends pbMixin(LitElement) {
|
|
|
109
118
|
|
|
110
119
|
_handleClick(ev) {
|
|
111
120
|
ev.preventDefault();
|
|
112
|
-
this.
|
|
121
|
+
if (this.confirm) {
|
|
122
|
+
const dialog = this.shadowRoot.getElementById('confirmDialog');
|
|
123
|
+
dialog.confirm(this._dialogTitle, i18n(this.confirm))
|
|
124
|
+
.then(() => this.trigger())
|
|
125
|
+
.catch(() => console.log('<pb-ajax> Action cancelled'));
|
|
126
|
+
} else {
|
|
127
|
+
this.trigger();
|
|
128
|
+
}
|
|
113
129
|
}
|
|
114
130
|
|
|
115
131
|
trigger() {
|
|
@@ -122,8 +138,10 @@ export class PbAjax extends pbMixin(LitElement) {
|
|
|
122
138
|
_handleResponse() {
|
|
123
139
|
const resp = this.shadowRoot.getElementById('loadContent').lastResponse;
|
|
124
140
|
this._message = resp;
|
|
125
|
-
|
|
126
|
-
|
|
141
|
+
if (!this.quiet) {
|
|
142
|
+
const dialog = this.shadowRoot.getElementById('confirmDialog');
|
|
143
|
+
dialog.show(this._dialogTitle, this._message);
|
|
144
|
+
}
|
|
127
145
|
|
|
128
146
|
this.emitTo('pb-end-update');
|
|
129
147
|
|