This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #57 from endeavourhealth-discovery/dynamic-editor
Dynamic editor
- Loading branch information
Showing
21 changed files
with
473 additions
and
258 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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import DefaultPredicateNames from "./modules/DefaultPredicateNames"; | ||
import EntityTypes from "./modules/EntityTypes"; | ||
import FilterDefaults from "./modules/FilterDefaults"; | ||
import GraphExcludePredicates from "./modules/GraphExcludePredicates"; | ||
import TextDefinitionExcludePredicates from "./modules/TextDefinitionExcludePredicates"; | ||
import XmlSchemaDatatypes from "./modules/XmlSchemaDatatypes"; | ||
|
||
export { DefaultPredicateNames, FilterDefaults, GraphExcludePredicates, TextDefinitionExcludePredicates, XmlSchemaDatatypes }; | ||
export { DefaultPredicateNames, EntityTypes, FilterDefaults, GraphExcludePredicates, TextDefinitionExcludePredicates, XmlSchemaDatatypes }; |
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,8 @@ | ||
import { IM } from "../../vocabulary/IM"; | ||
import { SHACL } from "../../vocabulary/SHACL"; | ||
import { RDFS } from "../../vocabulary/RDFS"; | ||
import { RDF } from "../../vocabulary/RDF"; | ||
|
||
const ENTITY_TYPES = [IM.CONCEPT, IM.VALUE_SET, IM.CONCEPT_SET, SHACL.NODESHAPE, IM.DATAMODEL_PROPERTY, IM.QUERY, RDFS.CLASS, RDF.PROPERTY, IM.FOLDER]; | ||
|
||
export default [...ENTITY_TYPES]; |
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,9 +1,10 @@ | ||
import { BuilderType } from "./modules/BuilderType"; | ||
import { ComponentType } from "./modules/ComponentType"; | ||
import { ECLComponent } from "./modules/ECLComponent"; | ||
import { EditorMode } from "./modules/EditorMode"; | ||
import { PasswordStrength } from "./modules/PasswordStrength"; | ||
import { QueryComponentType } from "./modules/QueryComponentType"; | ||
import { SortBy } from "./modules/SortBy"; | ||
import { SortDirection } from "./modules/SortDirection"; | ||
|
||
export { BuilderType, ComponentType, ECLComponent, PasswordStrength, QueryComponentType, SortBy, SortDirection }; | ||
export { BuilderType, ComponentType, ECLComponent, EditorMode, PasswordStrength, QueryComponentType, SortBy, SortDirection }; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export enum EditorMode { | ||
EDIT = "edit", | ||
CREATE = "create", | ||
MAP = "map", | ||
QUERY = "query" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ComponentType } from "../../enums/Enums"; | ||
import { PropertyShape, TTIriRef } from "../../interfaces/Interfaces"; | ||
import { IM } from "../../vocabulary/IM"; | ||
|
||
export function processArguments(property: PropertyShape, valueVariableMap?: Map<string, any>) { | ||
const result = new Map<string, any>(); | ||
property.argument.forEach(arg => { | ||
let key = ""; | ||
let value: any; | ||
if (arg.parameter === "this" && !arg.valueIri) key = property.path["@id"]; | ||
else key = arg.parameter; | ||
if (arg.valueIri) value = arg.valueIri["@id"]; | ||
else if (arg.valueVariable) { | ||
if (!valueVariableMap) throw new Error("missing valueVariableMap while processing arguments with a valueProperty"); | ||
if (property.builderChild && valueVariableMap && valueVariableMap.has(arg.valueVariable + property.order)) { | ||
value = valueVariableMap.get(arg.valueVariable + property.order); | ||
} else { | ||
value = valueVariableMap.get(arg.valueVariable); | ||
} | ||
} else if (arg.valueText) value = arg.valueText; | ||
result.set(key, value); | ||
}); | ||
return result; | ||
} | ||
|
||
function processComponentType(type: TTIriRef): any { | ||
switch (type["@id"]) { | ||
case IM.TEXT_DISPLAY_COMPONENT: | ||
return ComponentType.TEXT_DISPLAY; | ||
case IM.TEXT_INPUT_COMPONENT: | ||
return ComponentType.TEXT_INPUT; | ||
case IM.HTML_INPUT_COMPONENT: | ||
return ComponentType.HTML_INPUT; | ||
case IM.ARRAY_BUILDER_COMPONENT: | ||
return ComponentType.ARRAY_BUILDER; | ||
case IM.ENTITY_SEARCH_COMPONENT: | ||
return ComponentType.ENTITY_SEARCH; | ||
case IM.ENTITY_COMBOBOX_COMPONENT: | ||
return ComponentType.ENTITY_COMBOBOX; | ||
case IM.ENTITY_DROPDOWN_COMPONENT: | ||
return ComponentType.ENTITY_DROPDOWN; | ||
case IM.ENTITY_AUTO_COMPLETE_COMPONENT: | ||
return ComponentType.ENTITY_AUTO_COMPLETE; | ||
default: | ||
throw new Error("Invalid component type encountered in shape group" + type["@id"]); | ||
} | ||
} | ||
|
||
export default { processArguments, processComponentType }; |
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,12 +1,16 @@ | ||
import { EditorMode } from "../../enums/Enums"; | ||
import { BuilderType } from "../../enums/modules/BuilderType"; | ||
import { ComponentType } from "../../enums/modules/ComponentType"; | ||
import { PropertyGroup } from "./PropertyGroup"; | ||
import { PropertyShape } from "./PropertyShape"; | ||
|
||
export interface ComponentDetails { | ||
id: string; | ||
value: any; | ||
position: number; | ||
type: ComponentType; | ||
json: any; | ||
builderType: BuilderType; | ||
showButtons?: { minus: boolean; plus: boolean }; | ||
shape: PropertyShape | PropertyGroup; | ||
mode: EditorMode; | ||
} |
Oops, something went wrong.