From 160f794917b564bd19e777b0129805c544a0033b Mon Sep 17 00:00:00 2001 From: Stephan Tittel Date: Thu, 4 Jul 2024 14:46:58 +0200 Subject: [PATCH] editors for properties with sh:hasValue are now disabled --- demo/index.html | 4 ++-- src/theme.ts | 2 +- src/themes/default.ts | 3 +++ src/themes/material.ts | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/demo/index.html b/demo/index.html index 5cf74c6..cf7e23e 100644 --- a/demo/index.html +++ b/demo/index.html @@ -6,12 +6,12 @@ <shacl-form> demo - + diff --git a/src/theme.ts b/src/theme.ts index 5d95e3c..48c67d3 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -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, binaryData?: string, checked?: boolean } +export type Editor = HTMLElement & { value: string, type?: string, shaclDatatype?: NamedNode, binaryData?: string, checked?: boolean, disabled?: boolean } export type InputListEntry = { value: Term | string, label?: string } export abstract class Theme { diff --git a/src/themes/default.ts b/src/themes/default.ts index 5bf151e..a501958 100644 --- a/src/themes/default.ts +++ b/src/themes/default.ts @@ -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') diff --git a/src/themes/material.ts b/src/themes/material.ts index e0c0af1..e3853c8 100644 --- a/src/themes/material.ts +++ b/src/themes/material.ts @@ -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