Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(store): improve object property type
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReincarnator committed Dec 8, 2017
1 parent 2b99f8a commit 0eeb60c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/component/presentation/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export class Preview extends React.Component<PreviewProps> {
// tslint:disable-next-line:no-any
const componentProps: any = {};
pattern.getProperties().forEach(property => {
componentProps[property.getId()] = pageElement.getPropertyValue(property.getId());
componentProps[property.getId()] = this.createComponent(
pageElement.getPropertyValue(property.getId()),
property.getId()
);
});

componentProps.children = this.createComponent(pageElement.getChildren());
Expand Down
1 change: 1 addition & 0 deletions src/store/pattern/parser/typescript_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class TypeScriptParser extends PatternParser {

if (!property) {
property = new ObjectProperty(id, name, required);
// TODO: Parse properties
}

this.properties.push(property);
Expand Down
10 changes: 10 additions & 0 deletions src/store/pattern/property/object_property.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Property } from '.';

export class ObjectProperty extends Property {
private properties: Map<string, Property> = new Map();

public constructor(id: string, name: string, required: boolean) {
super(id, name, required);
}
Expand All @@ -14,6 +16,14 @@ export class ObjectProperty extends Property {
return value;
}

public getProperties(): Property[] {
return Array.from(this.properties.values());
}

public getProperty(id: string): Property | undefined {
return this.properties.get(id);
}

public getType(): string {
return 'object';
}
Expand Down

0 comments on commit 0eeb60c

Please sign in to comment.