@igea/oac_frontend 1.0.35 → 1.0.43

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igea/oac_frontend",
3
- "version": "1.0.35",
3
+ "version": "1.0.43",
4
4
  "description": "Frontend service for the OAC project",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -95,3 +95,12 @@ document.getElementById('sparql-toggle').onclick = function() {
95
95
  }
96
96
  return false;
97
97
  } ;
98
+
99
+ /*
100
+ const treeValues = [
101
+ { label: "Fruit", children: ["Apple", "Orange", "Banana"] },
102
+ { label: "Vegetables", children: ["Carrot", "Lettuce"] }
103
+ ];
104
+
105
+ const widget = new TreeSelectWidget("myWidgetContainer", treeValues);
106
+ */
@@ -0,0 +1,42 @@
1
+ // TreeSelectWidget.js
2
+ class TreeSelectWidget {
3
+ constructor(containerId, values) {
4
+ this.container = document.getElementById(containerId);
5
+ this.values = values; // struttura ad albero
6
+ this.selectedValues = [];
7
+ this.render();
8
+ }
9
+
10
+ render() {
11
+ this.container.innerHTML = '';
12
+ this.values.forEach(node => {
13
+ const label = document.createElement('div');
14
+ label.textContent = node.label;
15
+ this.container.appendChild(label);
16
+
17
+ if (node.children) {
18
+ const ul = document.createElement('ul');
19
+ node.children.forEach(child => {
20
+ const li = document.createElement('li');
21
+ const checkbox = document.createElement('input');
22
+ checkbox.type = 'checkbox';
23
+ checkbox.value = child;
24
+ checkbox.addEventListener('change', e => {
25
+ if (e.target.checked) this.selectedValues.push(e.target.value);
26
+ else this.selectedValues = this.selectedValues.filter(v => v !== e.target.value);
27
+ });
28
+ li.appendChild(checkbox);
29
+ li.appendChild(document.createTextNode(child));
30
+ ul.appendChild(li);
31
+ });
32
+ this.container.appendChild(ul);
33
+ }
34
+ });
35
+ }
36
+
37
+ getValue() {
38
+ return this.selectedValues; // array dei valori selezionati
39
+ }
40
+ }
41
+
42
+ window.TreeSelectWidget = TreeSelectWidget;
@@ -40,7 +40,7 @@
40
40
  limit="1000"
41
41
  debug="true"
42
42
  ></spar-natural>
43
-
43
+
44
44
  <span class="btn btn-primary" id="sparql-toggle">Toggle SPARQL query</span>
45
45
 
46
46
  </div>
@@ -63,7 +63,7 @@
63
63
  <script src="/{{ root }}/js/lib/bootstrap.bundle.min.js"></script>
64
64
 
65
65
  <!-- YASGUI JS -->
66
- <script src="https://unpkg.com/@triply/yasgui/build/yasgui.min.js"></script>
66
+ <script src="/{{ root }}/js/lib/yasgui.min.js"></script>
67
67
 
68
68
  <!-- Sparnatural JS -->
69
69
  <script src="/{{ root }}/js/lib/sparnatural.js"></script>
@@ -74,6 +74,8 @@
74
74
  <!-- File containing example queries -->
75
75
  <script src="/{{ root }}/js/lib/sparnatural-example-queries.js"></script>
76
76
 
77
+ <script src="/{{ root }}/js/lib/sparnatural-tree-select.js"></script>
78
+
77
79
  <!-- This page custom JS -->
78
80
  <script src="/{{ root }}/js/lib/sparnatural-main.js"></script>
79
81