@ulb-darmstadt/shacl-form 1.6.6 → 1.7.0
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/dist/form-bootstrap.js +1 -1
- package/dist/form-default.js +1 -1
- package/dist/form-material.js +1 -1
- package/dist/form.d.ts +1 -1
- package/package.json +1 -1
- package/src/form.ts +7 -6
- package/src/property.ts +5 -4
package/dist/form.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class ShaclForm extends HTMLElement {
|
|
|
19
19
|
setTheme(theme: Theme): void;
|
|
20
20
|
setSharedShapesGraph(graph: Store): void;
|
|
21
21
|
setClassInstanceProvider(provider: ClassInstanceProvider): void;
|
|
22
|
-
validate(ignoreEmptyValues?: boolean): Promise<
|
|
22
|
+
validate(ignoreEmptyValues?: boolean): Promise<any>;
|
|
23
23
|
private createValidationErrorDisplay;
|
|
24
24
|
private findRootShaclShapeSubject;
|
|
25
25
|
}
|
package/package.json
CHANGED
package/src/form.ts
CHANGED
|
@@ -25,8 +25,8 @@ export class ShaclForm extends HTMLElement {
|
|
|
25
25
|
this.form.addEventListener('change', ev => {
|
|
26
26
|
ev.stopPropagation()
|
|
27
27
|
if (this.config.editMode) {
|
|
28
|
-
this.validate(true).then(
|
|
29
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, cancelable: false, composed: true, detail: { 'valid':
|
|
28
|
+
this.validate(true).then(report => {
|
|
29
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, cancelable: false, composed: true, detail: { 'valid': report.conforms, 'report': report } }))
|
|
30
30
|
}).catch(e => { console.warn(e) })
|
|
31
31
|
}
|
|
32
32
|
})
|
|
@@ -82,8 +82,8 @@ export class ShaclForm extends HTMLElement {
|
|
|
82
82
|
// let browser check form validity first
|
|
83
83
|
if (this.form.reportValidity()) {
|
|
84
84
|
// now validate data graph
|
|
85
|
-
this.validate().then(
|
|
86
|
-
if (
|
|
85
|
+
this.validate().then(report => {
|
|
86
|
+
if (report?.conforms) {
|
|
87
87
|
// form and data graph are valid, so fire submit event
|
|
88
88
|
this.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }))
|
|
89
89
|
} else {
|
|
@@ -140,7 +140,8 @@ export class ShaclForm extends HTMLElement {
|
|
|
140
140
|
this.initialize()
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
/* Returns the validation report */
|
|
144
|
+
public async validate(ignoreEmptyValues = false): Promise<any> {
|
|
144
145
|
for (const elem of this.form.querySelectorAll(':scope .validation-error')) {
|
|
145
146
|
elem.remove()
|
|
146
147
|
}
|
|
@@ -201,7 +202,7 @@ export class ShaclForm extends HTMLElement {
|
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
|
-
return report
|
|
205
|
+
return report
|
|
205
206
|
} catch(e) {
|
|
206
207
|
console.error(e)
|
|
207
208
|
return false
|
package/src/property.ts
CHANGED
|
@@ -126,10 +126,11 @@ export class ShaclProperty extends HTMLElement {
|
|
|
126
126
|
const shapeSubject = instance.firstChild.toRDF(graph)
|
|
127
127
|
graph.addQuad(subject, pathNode, shapeSubject, this.template.config.valuesGraph)
|
|
128
128
|
} else {
|
|
129
|
-
const editor
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
for (const editor of instance.querySelectorAll<Editor>(':scope > .editor')) {
|
|
130
|
+
const value = toRDF(editor)
|
|
131
|
+
if (value) {
|
|
132
|
+
graph.addQuad(subject, pathNode, value, this.template.config.valuesGraph)
|
|
133
|
+
}
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
}
|