Skip to content

Commit 11feb89

Browse files
committed
1 parent e94706d commit 11feb89

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const PREFIX_RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
77
export const PREFIX_RDFS = 'http://www.w3.org/2000/01/rdf-schema#'
88
export const PREFIX_SKOS = 'http://www.w3.org/2004/02/skos/core#'
99
export const PREFIX_OWL = 'http://www.w3.org/2002/07/owl#'
10+
export const PREFIX_OA = 'http://www.w3.org/ns/oa#'
1011

1112
export const SHAPES_GRAPH = DataFactory.namedNode('shapes')
1213
export const OWL_IMPORTS = DataFactory.namedNode(PREFIX_OWL + 'imports')

src/property-template.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { Literal, NamedNode, BlankNode, Quad, DataFactory } from 'n3'
22
import { Term } from '@rdfjs/types'
3-
import { PREFIX_DASH, PREFIX_RDF, PREFIX_SHACL, SHACL_PREDICATE_CLASS, SHACL_PREDICATE_TARGET_CLASS, SHAPES_GRAPH } from './constants'
3+
import { PREFIX_DASH, PREFIX_OA, PREFIX_RDF, PREFIX_SHACL, SHACL_PREDICATE_CLASS, SHACL_PREDICATE_TARGET_CLASS, SHAPES_GRAPH } from './constants'
44
import { Config } from './config'
55
import { findLabel, removePrefixes } from './util'
66

77
const mappers: Record<string, (template: ShaclPropertyTemplate, term: Term) => void> = {
88
[`${PREFIX_SHACL}name`]: (template, term) => { const literal = term as Literal; if (!template.name || literal.language === template.config.attributes.language) { template.name = literal } },
9-
[`${PREFIX_SHACL}cssClass`]: (template, term) => { template.cssClass = term.value },
109
[`${PREFIX_SHACL}description`]: (template, term) => { const literal = term as Literal; if (!template.description || literal.language === template.config.attributes.language) { template.description = literal } },
1110
[`${PREFIX_SHACL}path`]: (template, term) => { template.path = term.value },
1211
[`${PREFIX_SHACL}node`]: (template, term) => { template.node = term as NamedNode },
@@ -23,6 +22,7 @@ const mappers: Record<string, (template: ShaclPropertyTemplate, term: Term) => v
2322
[`${PREFIX_SHACL}pattern`]: (template, term) => { template.pattern = term.value },
2423
[`${PREFIX_SHACL}order`]: (template, term) => { template.order = parseInt(term.value) },
2524
[`${PREFIX_DASH}singleLine`]: (template, term) => { template.singleLine = term.value === 'true' },
25+
[`${PREFIX_OA}styleClass`]: (template, term) => { template.cssClass = term.value },
2626
[`${PREFIX_SHACL}and`]: (template, term) => { template.shaclAnd = term.value },
2727
[`${PREFIX_SHACL}in`]: (template, term) => { template.shaclIn = term.value },
2828
// sh:datatype might be undefined, but sh:languageIn defined. this is undesired. the spec says, that strings without a lang tag are not valid if sh:languageIn is set. but the shacl validator accepts these as valid. to prevent this, we just set the datatype here to 'langString'.
@@ -51,7 +51,6 @@ export class ShaclPropertyTemplate {
5151
label = ''
5252
nodeId: NamedNode | BlankNode
5353
name: Literal | undefined
54-
cssClass: string | undefined
5554
description: Literal | undefined
5655
path: string | undefined
5756
node: NamedNode | undefined
@@ -65,6 +64,7 @@ export class ShaclPropertyTemplate {
6564
minExclusive: number | undefined
6665
maxExclusive: number | undefined
6766
singleLine: boolean | undefined
67+
cssClass: string | undefined
6868
defaultValue: Term | undefined
6969
pattern: string | undefined
7070
order: number | undefined

src/property.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ export class ShaclProperty extends HTMLElement {
2222
if (this.template.order !== undefined) {
2323
this.style.order = `${this.template.order}`
2424
}
25+
if (this.template.cssClass) {
26+
this.classList.add(this.template.cssClass)
27+
}
2528

2629
if (config.editMode) {
2730
this.addButton = document.createElement('a')
2831
this.addButton.innerText = this.template.label
2932
this.addButton.title = 'Add ' + this.template.label
3033
this.addButton.classList.add('control-button', 'add-button')
31-
if (this.template.cssClass)
32-
this.addButton.classList.add(this.template.cssClass);
3334
this.addButton.addEventListener('click', _ => {
3435
const instance = this.addPropertyInstance()
3536
instance.classList.add('fadeIn')

0 commit comments

Comments
 (0)