@pageboard/html 0.10.26 → 0.10.28

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.
@@ -2,7 +2,7 @@ exports.consent_form = {
2
2
  priority: 11,
3
3
  title: 'Consent',
4
4
  icon: '<i class="handshake icon"></i>',
5
- group: "block",
5
+ group: "block form",
6
6
  menu: 'form',
7
7
  properties: {
8
8
  transient: {
@@ -26,8 +26,41 @@ exports.consent_form = {
26
26
 
27
27
  const consents = [];
28
28
 
29
+ exports.input_radio_consent = {
30
+ title: 'Consent custom',
31
+ icon: '<i class="hand scissors icon"></i>',
32
+ menu: "form",
33
+ group: "block",
34
+ context: 'consent_form//',
35
+ properties: {
36
+ value: {
37
+ title: 'Consent',
38
+ anyOf: [{
39
+ const: 'custom',
40
+ title: 'Custom'
41
+ }, {
42
+ const: 'yes',
43
+ title: 'All'
44
+ }, {
45
+ const: 'no',
46
+ title: 'None'
47
+ }]
48
+ }
49
+ },
50
+ contents: {
51
+ id: 'label',
52
+ nodes: 'inline*'
53
+ },
54
+ html: `<div class="field">
55
+ <div class="ui radio checkbox">
56
+ <input type="radio" name="consent" value="[value]" id="for-consent-[value]" />
57
+ <label block-content="label" for="for-consent-[value]">Custom</label>
58
+ </div>
59
+ </div>`
60
+ };
61
+
29
62
  exports.input_radio_yes = {
30
- title: 'Yes',
63
+ title: 'Consent yes',
31
64
  icon: '<i class="thumbs up icon"></i>',
32
65
  menu: "form",
33
66
  group: "block",
@@ -51,7 +84,7 @@ exports.input_radio_yes = {
51
84
  };
52
85
 
53
86
  exports.input_radio_no = {
54
- title: 'No',
87
+ title: 'Consent no',
55
88
  icon: '<i class="thumbs down icon"></i>',
56
89
  menu: "form",
57
90
  group: "block",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageboard/html",
3
- "version": "0.10.26",
3
+ "version": "0.10.28",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "repository": {
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="last"] > .form[block-type="consent_form"][data-transient="true"],
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 explicit;
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
- this.explicit = forms.length > 0;
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
- window.HTMLCustomFormElement.prototype.fill.call(this, Page.storage.all());
32
- if (this.options.transient) this.classList.remove('visible');
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,15 @@ 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
+ const list = Array.from(this.constructor.explicits);
50
+ const def = consents.consent;
51
+ for (const consent of list) {
52
+ if (def != "custom") consents[consent] = def;
53
+ }
54
+ if (list.some(c => consents[c] == null)) {
55
+ // not all explicit consents have been answered
56
+ return;
57
+ }
43
58
  for (const [key, val] of Object.entries(consents)) {
44
59
  Page.storage.set(key, val);
45
60
  }
@@ -78,7 +93,7 @@ Page.ready(() => {
78
93
 
79
94
  Page.paint(state => {
80
95
  state.finish(() => {
81
- if (!HTMLCustomConsentElement.explicit) {
96
+ if (!HTMLCustomConsentElement.explicits.size) {
82
97
  state.runChain('consent');
83
98
  }
84
99
  });