@@ -11,6 +11,7 @@ import '@/components/rdf-input'
1111export default class RDFForm extends WebComponent {
1212 @state ( )
1313 private accessor _parsedUrl : URL | null = null
14+
1415 @state ( )
1516 private accessor _parsedUrl2 : URL | null = null
1617
@@ -36,17 +37,6 @@ export default class RDFForm extends WebComponent {
3637 return this . _parsedUrl ? this . _parsedUrl . href : ''
3738 }
3839
39- private defaultContexts = `
40- @prefix foaf: <http://xmlns.com/foaf/0.1/>.
41- @prefix sched: <http://www.w3.org/ns/pim/schedule#>.
42- @prefix cal: <http://www.w3.org/2002/12/cal/ical#>.
43- @prefix dc: <http://purl.org/dc/elements/1.1/>.
44- @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
45- @prefix ui: <http://www.w3.org/ns/ui#>.
46- @prefix trip: <http://www.w3.org/ns/pim/trip#>.
47- @prefix vcard: <http://www.w3.org/2006/vcard/ns#>.
48- @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
49- `
5040 @property ( { type : String } )
5141 accessor whichSubject = 'me'
5242
@@ -71,12 +61,11 @@ export default class RDFForm extends WebComponent {
7161
7262 render ( ) {
7363 // TODO: detect format
74- loadDocument ( store , this . rdfTurtleFormatSource + this . defaultContexts , this . rdfName , this . rdfURI ) // load form
75- loadDocument ( store , this . subjectTurtleFormatSource + this . defaultContexts , this . subjectName , this . subjectURI ) // load data
64+ loadDocument ( store , this . rdfTurtleFormatSource , this . rdfName , this . rdfURI ) // load form
65+ loadDocument ( store , this . subjectTurtleFormatSource , this . subjectName , this . subjectURI ) // load data
7666 const document = sym ( this . rdfURI ) // rdflib NamedNode for the document
7767 const exactForm = this . whichForm // If there are more 'a ui:Form' elements in a form file
7868 const formThis = Namespace ( this . rdfURI + '#' ) ( exactForm ) // NamedNode for #this in the form
79- console . log ( 'formThis:' , formThis . value )
8069
8170 const parts = store . each ( formThis , ns . ui ( 'parts' ) , null , document )
8271 const partsBySequence = sortBySequence ( store , parts )
@@ -91,18 +80,16 @@ export default class RDFForm extends WebComponent {
9180 const typeNode = types [ 0 ]
9281 const value = typeNode ? ( ( typeNode as any ) . value || String ( typeNode ) ) : ( ( item as any ) . value || String ( item ) )
9382 const hashIndex = value . lastIndexOf ( '#' )
94- return hashIndex >= 0 ? value . slice ( hashIndex + 1 ) : value
83+ return {
84+ value : item ,
85+ fieldValue : hashIndex >= 0 ? value . slice ( hashIndex + 1 ) : value
86+ }
9587 } )
96- console . log ( 'parts:' , parts )
97- console . log ( 'partsBySequence:' , partsBySequence )
98- console . log ( 'partItems:' , partItems )
99- console . log ( 'document:' , document )
100- console . log ( 'exactForm:' , exactForm )
101- console . log ( 'uiFields:' , uiFields )
88+ const me = Namespace ( this . subjectURI + '#' ) ( this . whichSubject )
10289
10390 return html `
10491 ${ uiFields . map ( part => {
105- switch ( part ) {
92+ switch ( part . fieldValue ) {
10693 case 'PhoneField' :
10794 case 'EmailField' :
10895 case 'ColorField' :
@@ -115,8 +102,12 @@ export default class RDFForm extends WebComponent {
115102 case 'FloatField' :
116103 case 'TextField' :
117104 case 'SingleLineTextField' :
118- case 'NamedNodeURIField' :
119- return html ` < solid-ui-rdf-input .store =${ store } formSubject =${ part } .inputSubject=${ this . subjectURI } > </ solid-ui-rdf-input > `
105+ case 'NamedNodeURIField' : {
106+ const formSubject = typeof part . value === 'string'
107+ ? store . sym ( part . value )
108+ : part . value
109+ return html ` < solid-ui-rdf-input .store =${ store } .formSubject =${ formSubject } .inputSubject=${ me } > </ solid-ui-rdf-input > `
110+ }
120111 case 'MultiLineTextField' :
121112 return html `< input rdf =${ part } > </ input > `
122113 case 'BooleanField' :
0 commit comments