import React = require("react"); import { observer } from "mobx-react"; import "./PropertiesView.scss"; import { observable, action, computed } from "mobx"; import { Doc, Field, DocListCast } from "../../../../fields/Doc"; import { DocumentView } from "../../nodes/DocumentView"; import { ComputedField } from "../../../../fields/ScriptField"; import { EditableView } from "../../EditableView"; import { KeyValueBox } from "../../nodes/KeyValueBox"; import { Cast } from "../../../../fields/Types"; import { listSpec } from "../../../../fields/Schema"; interface PropertiesViewProps { document: Doc; //dataDoc: Doc; //docView: DocumentView; } @observer export class PropertiesView extends React.Component { @computed get expandedField() { const ids: { [key: string]: string } = {}; const doc = this.props.document; doc && Object.keys(doc).forEach(key => !(key in ids) && doc[key] !== ComputedField.undefined && (ids[key] = key)); const rows: JSX.Element[] = []; for (const key of Object.keys(ids).slice().sort()) { const contents = doc[key]; let contentElement: (JSX.Element | null)[] | JSX.Element = []; contentElement = Field.toKeyValueString(doc, key)} SetValue={(value: string) => KeyValueBox.SetField(doc, key, value, true)} />; rows.push(
{key + ":"}   {contentElement}
); } return rows; } @computed get layoutPreview() { return "layout"; } render() { return
Properties
Collection
Settings
Fields
{this.expandedField}
Layout
{this.layoutPreview}
; } }