@igea/oac_frontend 1.0.53 → 1.0.55

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.53",
3
+ "version": "1.0.55",
4
4
  "description": "Frontend service for the OAC project",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -85,7 +85,7 @@
85
85
  "max_files": "You can upload up to 5 files at a time",
86
86
  "max_size": "Each file must be less than 10MB",
87
87
  "select_vocabolary": "Select a vocabolary to view its items",
88
- "terms": "Terms"
88
+ "terms": "Vocabulary entries"
89
89
  }
90
90
  },
91
91
  "investigation":{
@@ -88,7 +88,7 @@
88
88
  "upload_error": "Errore durante il caricamento dei file",
89
89
  "invalid_file": "Tipo di file non valido",
90
90
  "select_vocabolary": "Seleziona un vocabolario per visualizzarne gli elementi",
91
- "terms": "Termini"
91
+ "terms": "Voci del vocabolario"
92
92
  }
93
93
  },
94
94
  "investigation": {
@@ -81,12 +81,15 @@ document.addEventListener('DOMContentLoaded', () => {
81
81
  setTimeout(async ()=>{
82
82
  _this.form = document.querySelector("shacl-form");
83
83
  const output = document.getElementById("shacl-output")
84
+
85
+ //await _this.load(this.uuid);
86
+
84
87
  _this.form.addEventListener('change', event => {
85
88
  // check if form data validates according to the SHACL shapes
86
89
  _this.validForm = event.detail?.valid;
87
90
  _this.serializedForm = _this.form.serialize();
88
91
  });
89
- await _this.load(this.uuid);
92
+
90
93
  _this.form.addEventListener("ready", () => {
91
94
  var intervalId = setInterval(() => {
92
95
  if(_this.form.shadowRoot){
@@ -97,6 +100,7 @@ document.addEventListener('DOMContentLoaded', () => {
97
100
  }
98
101
  }, 100);
99
102
  });
103
+
100
104
  })
101
105
  },
102
106
  searchByPrefixStart(rokitInput, prefix){
@@ -173,11 +177,9 @@ document.addEventListener('DOMContentLoaded', () => {
173
177
  if (rokitInput) {
174
178
  var isIndagineIdField = templateIRIOfIndagine === rokitInput.placeholder;
175
179
  if(rokitInput.value == ""){
176
- rokitInput.value = _this.generateIRI(rokitInput.placeholder);
177
- }
178
- if(isIndagineIdField){
179
- this.uuid = rokitInput.value.split("/").pop();
180
+ rokitInput.value = _this.generateIRI(rokitInput, isIndagineIdField);
180
181
  }
182
+
181
183
  rokitInput.setAttribute("disabled", "true");
182
184
  rokitInput.style.opacity = "0.6";
183
185
  rokitInput.style.pointerEvents = "none";
@@ -262,24 +264,33 @@ document.addEventListener('DOMContentLoaded', () => {
262
264
  }
263
265
  }
264
266
  },
265
- generateIRI(template, uuid){
266
- var _uuid = uuid || crypto.randomUUID();
267
- return template.replace("$uuid$", _uuid).replace("$UUID$", _uuid);
267
+ generateIRI(input, isIndagne){
268
+ var template = input.placeholder;
269
+ setTimeout((async function(){
270
+ var _uuid = crypto.randomUUID();
271
+ template = template.replace("$uuid$", _uuid).replace("$UUID$", _uuid);
272
+ for(var i=1; i<=9; i++){
273
+ var seq = "seq" + i;
274
+ var searchStr = "$" + seq + "$";
275
+ var searchStrUpp = searchStr.toUpperCase();
276
+ if(template.toLowerCase().includes(searchStr)){
277
+ var response = await fetch('/backend/ontology/counter/' + seq ).then(resp => resp.json());
278
+ if(response.success && response.data){
279
+ var counter = response.data;
280
+ template = template.replace(searchStr, counter).replace(searchStrUpp, counter);
281
+ }
282
+ }
283
+ }
284
+ input.value = template;
285
+ if(isIndagne){
286
+ this.uuid = input.value.split("/").pop();
287
+ }
288
+ }).bind(this));
268
289
  },
269
290
  async load(uuid) {
270
291
  if(uuid){
271
292
  const dataTTL = await fetch("/backend/ontology/form/" + uuid).then(resp => resp.text())
272
293
  this.form.dataset['values'] = dataTTL;
273
- /*
274
- var request = axios.get("/backend/ontology/form/" + uuid);
275
- request.then(response => {
276
- var data = response.data;
277
- this.form.dataset['values'] = data;
278
- callback()
279
- }).catch(error => {
280
- console.log(error);
281
- });
282
- */
283
294
  }
284
295
  },
285
296
 
@@ -77,6 +77,14 @@ const yasr = new Yasr(document.getElementById("yasr"), {
77
77
  defaultPlugin: "TableX",
78
78
  });
79
79
 
80
+ yasr.plugins["TableX"].config.uriHrefAdapter = function(uri) {
81
+ if(uri.startsWith("http://diagnostica/")) {
82
+ return "/frontend/investigation/form/" + uri.split("/").pop();
83
+ } else {
84
+ return uri;
85
+ }
86
+ };
87
+
80
88
  // Link query response to YASR
81
89
  yasqe.on("queryResponse", (_yasqe, response, duration) => {
82
90
  yasr.setResponse(response, duration);
@@ -132,4 +140,5 @@ document.getElementById("switch-language").onclick = function () {
132
140
 
133
141
  // Force form to re-render with new language
134
142
  sparnaturalForm.display();
135
- };
143
+ };
144
+
@@ -26,11 +26,20 @@ Yasr.registerPlugin("TableX",SparnaturalYasguiPlugins.TableX);
26
26
  Yasr.registerPlugin("Grid",SparnaturalYasguiPlugins.GridPlugin);
27
27
  delete Yasr.plugins['table'];
28
28
 
29
+
29
30
  const yasr = new Yasr(document.getElementById("yasr"), {
30
31
  pluginOrder: ["TableX", "Grid", "response"],
31
32
  defaultPlugin: "TableX"
32
33
  });
33
34
 
35
+ yasr.plugins["TableX"].config.uriHrefAdapter = function(uri) {
36
+ if(uri.startsWith("http://diagnostica/")) {
37
+ return "/frontend/investigation/form/" + uri.split("/").pop();
38
+ } else {
39
+ return uri;
40
+ }
41
+ };
42
+
34
43
  // link yasqe and yasr
35
44
  yasqe.on("queryResponse", function(_yasqe, response, duration) {
36
45
  yasr.setResponse(response, duration);
@@ -104,3 +113,5 @@ const treeValues = [
104
113
 
105
114
  const widget = new TreeSelectWidget("myWidgetContainer", treeValues);
106
115
  */
116
+
117
+
@@ -77,12 +77,21 @@
77
77
  data-editing="{{ user.role != 3 }}"
78
78
  >
79
79
 
80
+ {% if uuid %}
80
81
  <shacl-form id="shacl-form" data-collapse="open"
82
+ data-values-namespace="pref:"
81
83
  data-shapes-url="/backend/ontology/schema/ttl2"
82
- data-values-subject__="http://example.org/shapes/da4c29c4-f90e-41bf-8ac6-7714800fcc04"
83
- >
84
- </shacl-form>
85
-
84
+ data-values-url="/backend/ontology/form/{{ uuid }}"
85
+ data-shape-subject="http://example.org/shapes/E7ActivityShape"
86
+ data-values-subject="http://diagnostica/e2d49af0-6c52-4fc5-8290-936b87472adf"
87
+ ></shacl-form>
88
+ {% else %}
89
+ <shacl-form id="shacl-form" data-collapse="open"
90
+ data-values-namespace="pref:"
91
+ data-shapes-url="/backend/ontology/schema/ttl2"
92
+ ></shacl-form>
93
+ {% endif %}
94
+
86
95
  {% if user.role != 3 %}
87
96
  <!-- Buttons -->
88
97
  <div class="col-12 text-center mt-4">
@@ -31,7 +31,7 @@
31
31
  data-lang_terms="{{ t('users.vocabolaries.terms') }}"
32
32
  >
33
33
  <div><span style="font-weight:bold;">{{ t('users.vocabolaries.select_vocabolary') }}:</span></div>
34
- <select size="10" v-model="vocabolary" style="min-width:350px;">
34
+ <select size="10" v-model="vocabolary" style="min-width:500px;">
35
35
  <option v-for="item in vocabolaries" :value="item">{@ item.name @}</option>
36
36
  </select>
37
37
  <div v-if="vocabolary">