-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from hypermedia-app/default-iri
fix: no default node for select editors
- Loading branch information
Showing
12 changed files
with
153 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@hydrofoil/shaperone-core": patch | ||
--- | ||
|
||
Do not create a new node when the editor is a `dash:*SelectEditor` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
import { PropertyShape } from '@rdfine/shacl' | ||
import { NamedNode } from 'rdf-js' | ||
import type { Store } from '../../../state' | ||
import { FocusNode } from '../../../index' | ||
import { BaseParams } from '../../index' | ||
import { SingleEditorMatch } from '../../editors' | ||
|
||
export function addObject(store: Store) { | ||
const dispatch = store.getDispatch() | ||
return function ({ form, property, focusNode }: { focusNode: FocusNode; property: PropertyShape } & BaseParams) { | ||
const { editors, resources } = store.getState() | ||
const { editors: editorsState, resources } = store.getState() | ||
const graph = resources.get(form)?.graph | ||
if (!graph) { | ||
return | ||
} | ||
|
||
const matchedEditors = editorsState.matchSingleEditors({ shape: property }) | ||
let editors: SingleEditorMatch[] | ||
let selectedEditor: NamedNode | undefined | ||
if (property.editor?.id.termType === 'NamedNode') { | ||
selectedEditor = property.editor.id | ||
editors = [ | ||
{ term: selectedEditor, score: null, meta: editorsState.metadata.node(selectedEditor) }, | ||
...matchedEditors, | ||
] | ||
} else { | ||
editors = matchedEditors | ||
selectedEditor = editors[0]?.term | ||
} | ||
|
||
dispatch.forms.addFormField({ | ||
form, | ||
property, | ||
focusNode, | ||
matchedEditors: editors.matchSingleEditors({ shape: property }), | ||
editors, | ||
selectedEditor, | ||
}) | ||
} | ||
} |
Oops, something went wrong.