Added a better demo displaying how our app communicates with Flamelink Schemas and displays schema details in the right order.
This commit is contained in:
parent
e427e3f702
commit
e7052dfb5b
|
@ -1,14 +1,31 @@
|
||||||
import { Component } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
|
import Grid from '@material-ui/core/Grid';
|
||||||
import flamelinkApp from '../flamelink.js';
|
import flamelinkApp from '../flamelink.js';
|
||||||
|
import Layout from './Layout';
|
||||||
class Flamelink extends Component {
|
class Flamelink extends Component {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
schemaDetails: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
// fetch the project name, once it retrieves resolve the promsie and update the state.
|
||||||
|
flamelinkApp.schemas.getFields('martenSchemaDemo', { fields: [ 'title', 'key' ] })
|
||||||
|
.then(result => this.setState({
|
||||||
|
schemaDetails: result
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
//Grabs data from text field in entry from the martenSchemaDemo
|
return(
|
||||||
flamelinkApp.content.get('martenSchemaDemo')
|
<Fragment>
|
||||||
.then(flameData => document.getElementById("flamelinkDemo").innerHTML = flameData.field_1538162314419);
|
<Layout schemaDetails = {this.state.schemaDetails}/>
|
||||||
|
</Fragment>
|
||||||
return(null);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
import React, { Component, Fragment } from 'react';
|
||||||
|
import flamelinkApp from '../flamelink.js';
|
||||||
|
|
||||||
|
class Layout extends Component {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
contentDetails: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getData(schemaData){
|
||||||
|
for (var val in this.props.schemaDetails){
|
||||||
|
this.getMoreData(this.props.schemaDetails[val]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getMoreData(moreData){
|
||||||
|
var tArray = document.createElement("H1");
|
||||||
|
var kArray = document.createElement("P");
|
||||||
|
this.getTitle(moreData.title, tArray);
|
||||||
|
this.getKey(moreData.key, kArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTitle(title, arr){
|
||||||
|
var t = document.createTextNode(title);
|
||||||
|
arr.appendChild(t);
|
||||||
|
document.getElementById("demo").appendChild(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getKey(key, arr){
|
||||||
|
var k = document.createTextNode(key);
|
||||||
|
arr.appendChild(k);
|
||||||
|
document.getElementById("demo").appendChild(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return(
|
||||||
|
<div>
|
||||||
|
<p id="demo">{this.getData(this.props)}</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Layout;
|
|
@ -2,16 +2,17 @@ import React, { Component } from 'react';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import Flamelink from '../components/Flamelink';
|
import Flamelink from '../components/Flamelink';
|
||||||
|
|
||||||
|
|
||||||
class Info extends Component {
|
class Info extends Component {
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Flamelink flamelinkApp={this.props.flamelinkApp}/>
|
|
||||||
<Typography variant='display1' align='center' gutterBottom>
|
<Typography variant='display1' align='center' gutterBottom>
|
||||||
Info
|
Info
|
||||||
</Typography>
|
</Typography>
|
||||||
<p id="flamelinkDemo"></p>
|
<Flamelink/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue