Skip to content

Commit

Permalink
editors for properties with sh:hasValue are now disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
s-tittel committed Jul 4, 2024
1 parent 96444f1 commit 160f794
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>&lt;shacl-form&gt; demo</title>
<link rel="stylesheet" href="./style.css">
<!-- "@ulb-darmstadt/shacl-form": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/shacl-form/dist/" -->
<!-- "@ulb-darmstadt/shacl-form": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/shacl-form@1.4.4/dist/" -->
<!-- "@ulb-darmstadt/shacl-form": "./" -->
<script type="importmap">
{
"imports": {
"@ulb-darmstadt/shacl-form/": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/[email protected].3/dist/"
"@ulb-darmstadt/shacl-form/": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/[email protected].4/dist/"
}
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createInputListEntries, findInstancesOf, findLabel, isURL } from './uti
import { ShaclPropertyTemplate } from './property-template'
import css from './styles.css'

export type Editor = HTMLElement & { value: string, type?: string, shaclDatatype?: NamedNode<string>, binaryData?: string, checked?: boolean }
export type Editor = HTMLElement & { value: string, type?: string, shaclDatatype?: NamedNode<string>, binaryData?: string, checked?: boolean, disabled?: boolean }
export type InputListEntry = { value: Term | string, label?: string }

export abstract class Theme {
Expand Down
3 changes: 3 additions & 0 deletions src/themes/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export class DefaultTheme extends Theme {
if (template?.nodeKind) {
editor.dataset.nodeKind = template.nodeKind.value
}
if (template?.hasValue) {
editor.disabled = true
}
editor.value = value?.value || template?.defaultValue?.value || ''

const labelElem = document.createElement('label')
Expand Down
3 changes: 3 additions & 0 deletions src/themes/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export class MaterialTheme extends Theme {
if (template?.nodeKind) {
editor.dataset.nodeKind = template.nodeKind.value
}
if (template?.hasValue) {
editor.disabled = true
}
editor.value = value?.value || template?.defaultValue?.value || ''

const placeholder = template?.description ? template.description.value : template?.pattern ? template.pattern : null
Expand Down

0 comments on commit 160f794

Please sign in to comment.