diff --git a/src/helpers/rdf-data.js b/src/helpers/rdf-data.js new file mode 100644 index 0000000..67d24d2 --- /dev/null +++ b/src/helpers/rdf-data.js @@ -0,0 +1,31 @@ +'use strict' + + +// The default NodeShape used in FormDemo.vue +const defaultShape = `@prefix sh: . +@prefix rdf: . +@prefix rdfs: . +@prefix ex: . + +ex:DefaultShape + a sh:NodeShape, rdf:Class ; + sh:property [ + sh:name 'class' ; + sh:path rdf:type ; + sh:minCount 1 ; + sh:maxCount 1 ; + ] ; + sh:property [ + sh:name 'label' ; + sh:path rdfs:label ; + sh:maxCount 1 ; + ] .` + +// The default resource used in FormDemo.vue +const defaultData = `@prefix rdf: . +@prefix rdfs: . + + rdf:type rdf:Class ; + 'Example resource'. ` + +export { defaultShape, defaultData } \ No newline at end of file diff --git a/src/views/FormDemo.vue b/src/views/FormDemo.vue index 40fa948..07a5e2c 100644 --- a/src/views/FormDemo.vue +++ b/src/views/FormDemo.vue @@ -32,6 +32,7 @@ import { useSelectionStore } from '../stores/selection' import { Store, StreamParser, Parser, Writer } from 'n3' import { registerPlugin } from '@ulb-darmstadt/shacl-form' import { getShapeQuery4Target, getShapeQuery4Instance } from '../helpers/queries' +import { defaultShape, defaultData } from '../helpers/rdf-data' import { quadStreamToStore, quadStreamToString } from '../helpers/rdf-parse' import { Splitpanes, Pane } from 'splitpanes' // import { LeafletPlugin } from '@ulb-darmstadt/shacl-form/plugins/leaflet.js' @@ -66,29 +67,8 @@ export default { data () { return { dataModel: {}, - dataTurtle: `@prefix rdf: . -@prefix rdfs: . - - rdf:type rdf:Class ; - 'Example resource'. `, - shapeTurtle: `@prefix sh: . -@prefix rdf: . -@prefix rdfs: . -@prefix ex: . - -ex:DefaultShape - a sh:NodeShape, rdf:Class ; - sh:property [ - sh:name 'class' ; - sh:path rdf:type ; - sh:minCount 1 ; - sh:maxCount 1 ; - ] ; - sh:property [ - sh:name 'label' ; - sh:path rdfs:label ; - sh:maxCount 1 ; - ] .`, + dataTurtle: defaultData, + shapeTurtle: defaultShape, subject: rdf.namedNode(''), } }, @@ -131,24 +111,7 @@ ex:DefaultShape if (shapeData.length < 1) { console.log('Form: Use default shape') - shapeTurtle = `@prefix sh: . -@prefix rdf: . -@prefix rdfs: . -@prefix ex: . - -ex:DefaultShape - a sh:NodeShape, rdfs:Class ; - sh:property [ - sh:name 'class' ; - sh:path rdf:type ; - sh:minCount 1 ; - sh:maxCount 1 ; - ] ; - sh:property [ - sh:name 'label' ; - sh:path rdfs:label ; - sh:maxCount 1 ; - ] .` + shapeTurtle = defaultShape } else { console.log('Form: Use found shape') let data_string = ""