@pageboard/html 0.10.25 → 0.10.27
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/package.json +1 -1
- package/ui/consent.css +1 -1
- package/ui/consent.js +15 -5
package/package.json
CHANGED
package/ui/consent.css
CHANGED
|
@@ -25,7 +25,7 @@ footer [block-type="consent_form"][data-transient="true"] {
|
|
|
25
25
|
min-height:1em;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
[contenteditable] [block-focused="
|
|
28
|
+
[contenteditable] [block-focused="middle"] > .form[block-type="consent_form"][data-transient="true"],
|
|
29
29
|
.form[block-type="consent_form"][data-transient="true"][block-focused] {
|
|
30
30
|
display: block;
|
|
31
31
|
}
|
package/ui/consent.js
CHANGED
|
@@ -7,20 +7,23 @@ class HTMLCustomConsentElement extends HTMLFormElement {
|
|
|
7
7
|
dataTransient: false
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
static
|
|
10
|
+
static explicits = new Set();
|
|
11
11
|
|
|
12
12
|
static ask(consent) {
|
|
13
13
|
let tacit = true;
|
|
14
14
|
const forms = document.querySelectorAll('[block-type="consent_form"]');
|
|
15
|
-
|
|
15
|
+
const consents = Page.storage.all();
|
|
16
16
|
for (const node of forms) {
|
|
17
|
+
window.HTMLCustomFormElement.prototype.fill.call(node, consents);
|
|
17
18
|
node.classList.add('visible');
|
|
18
19
|
tacit = consent && !node.querySelector(`[name="${consent}"]`) || false;
|
|
19
20
|
}
|
|
21
|
+
if (!tacit) this.explicits.add(consent);
|
|
20
22
|
return tacit ? "yes" : null;
|
|
21
23
|
}
|
|
22
24
|
setup(state) {
|
|
23
25
|
if (this.isContentEditable) return;
|
|
26
|
+
this.constructor.explicits = new Set();
|
|
24
27
|
const view = this.ownView;
|
|
25
28
|
view.textContent = '';
|
|
26
29
|
const tmpl = this.ownTpl.prerender();
|
|
@@ -28,8 +31,11 @@ class HTMLCustomConsentElement extends HTMLFormElement {
|
|
|
28
31
|
state.chain('consent', this);
|
|
29
32
|
}
|
|
30
33
|
chainConsent(state) {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
if (this.options.transient) {
|
|
35
|
+
this.classList.remove('visible');
|
|
36
|
+
} else {
|
|
37
|
+
window.HTMLCustomFormElement.prototype.fill.call(this, Page.storage.all());
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
handleChange(e, state) {
|
|
35
41
|
if (e.type == "submit" || !this.elements.find(item => item.type == "submit")) {
|
|
@@ -40,6 +46,10 @@ class HTMLCustomConsentElement extends HTMLFormElement {
|
|
|
40
46
|
if (e.type == "submit") e.preventDefault();
|
|
41
47
|
if (this.isContentEditable) return;
|
|
42
48
|
const consents = window.HTMLCustomFormElement.prototype.read.call(this);
|
|
49
|
+
if (Array.from(this.constructor.explicits).some(c => consents[c] == null)) {
|
|
50
|
+
// not all explicit consents have been answered
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
43
53
|
for (const [key, val] of Object.entries(consents)) {
|
|
44
54
|
Page.storage.set(key, val);
|
|
45
55
|
}
|
|
@@ -78,7 +88,7 @@ Page.ready(() => {
|
|
|
78
88
|
|
|
79
89
|
Page.paint(state => {
|
|
80
90
|
state.finish(() => {
|
|
81
|
-
if (!HTMLCustomConsentElement.
|
|
91
|
+
if (!HTMLCustomConsentElement.explicits.size) {
|
|
82
92
|
state.runChain('consent');
|
|
83
93
|
}
|
|
84
94
|
});
|