application/metaproperties/json-meta-property.js
- import React from 'react';
- import TextField from 'material-ui/TextField';
- import shallowCompare from 'react-addons-shallow-compare';
-
- class JsonMetaProperty extends React.Component {
- constructor(props) {
- super(props);
- this.displayName = 'JsonMetaProperty';
- }
-
- shouldComponentUpdate(nextProps, nextState) {
- if (nextProps.value != this.props.value) {
- return true;
- }
- if (nextProps.disabled != this.props.disabled) {
- return true;
- }
- return false;
- }
-
- rando() {
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-
- let str = [];
- for (let i=0; i<5; i++) {
- str.push(chars.charAt(Math.floor(Math.random() * chars.length)));
- }
-
- return str.join('');
- }
-
- render() {
- const name = this.props.name ? this.props.name : 'hiddenfield_' + this.rando();
- return (
- <input type="hidden" name={name} {...this.props}/>
- );
- }
- }
-
- export default JsonMetaProperty;