Browse Source

[2.5] Revert change JSON form (#2598)

* Revert change

* Revert file
pull/2616/head
Vladyslav 7 years ago
committed by GitHub
parent
commit
2a1c55f022
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      ui/src/app/components/react/json-form-ace-editor.jsx
  2. 2
      ui/src/app/components/react/json-form-array.jsx
  3. 2
      ui/src/app/components/react/json-form-fieldset.jsx
  4. 26
      ui/src/app/components/react/json-form-schema-form.jsx
  5. 3
      ui/src/app/components/react/json-form.scss

6
ui/src/app/components/react/json-form-ace-editor.jsx

@ -83,9 +83,9 @@ class ThingsboardAceEditor extends React.Component {
fixAceEditor(editor); fixAceEditor(editor);
} }
onToggleFull(groupId) { onToggleFull() {
this.setState({ isFull: !this.state.isFull }); this.setState({ isFull: !this.state.isFull });
this.props.onToggleFullscreen(groupId); this.props.onToggleFullscreen();
this.updateAceEditorSize = true; this.updateAceEditorSize = true;
} }
@ -140,7 +140,7 @@ class ThingsboardAceEditor extends React.Component {
<div className="title-panel"> <div className="title-panel">
<label>{this.props.mode}</label> <label>{this.props.mode}</label>
<FlatButton style={ styles.tidyButtonStyle } className="tidy-button" label={'Tidy'} onTouchTap={this.onTidy}/> <FlatButton style={ styles.tidyButtonStyle } className="tidy-button" label={'Tidy'} onTouchTap={this.onTidy}/>
<FlatButton style={ styles.tidyButtonStyle } className="tidy-button" label={this.state.isFull ? 'Exit fullscreen' : 'Fullscreen'} onTouchTap={() => this.onToggleFull(this.props.groupId)}/> <FlatButton style={ styles.tidyButtonStyle } className="tidy-button" label={this.state.isFull ? 'Exit fullscreen' : 'Fullscreen'} onTouchTap={this.onToggleFull}/>
</div> </div>
<AceEditor mode={this.props.mode} <AceEditor mode={this.props.mode}
height={this.state.isFull ? "100%" : "150px"} height={this.state.isFull ? "100%" : "150px"}

2
ui/src/app/components/react/json-form-array.jsx

@ -131,7 +131,7 @@ class ThingsboardArray extends React.Component {
} }
let forms = this.props.form.items.map(function(form, index){ let forms = this.props.form.items.map(function(form, index){
var copy = this.copyWithIndex(form, i); var copy = this.copyWithIndex(form, i);
return this.props.builder(copy, this.props.groupId, this.props.model, index, this.props.onChange, this.props.onColorClick, this.props.onIconClick, this.props.onToggleFullscreen, this.props.mapper, this.props.builder); return this.props.builder(copy, this.props.model, index, this.props.onChange, this.props.onColorClick, this.props.onIconClick, this.props.onToggleFullscreen, this.props.mapper, this.props.builder);
}.bind(this)); }.bind(this));
arrays.push( arrays.push(
<li key={keys[i]} className="list-group-item"> <li key={keys[i]} className="list-group-item">

2
ui/src/app/components/react/json-form-fieldset.jsx

@ -19,7 +19,7 @@ class ThingsboardFieldSet extends React.Component {
render() { render() {
let forms = this.props.form.items.map(function(form, index){ let forms = this.props.form.items.map(function(form, index){
return this.props.builder(form, this.props.groupId, this.props.model, index, this.props.onChange, this.props.onColorClick, this.props.onIconClick, this.props.onToggleFullscreen, this.props.mapper, this.props.builder); return this.props.builder(form, this.props.model, index, this.props.onChange, this.props.onColorClick, this.props.onIconClick, this.props.onToggleFullscreen, this.props.mapper, this.props.builder);
}.bind(this)); }.bind(this));
return ( return (

26
ui/src/app/components/react/json-form-schema-form.jsx

@ -40,9 +40,6 @@ class ThingsboardSchemaForm extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
groupId: null,
};
this.mapper = { this.mapper = {
'number': ThingsboardNumber, 'number': ThingsboardNumber,
@ -88,15 +85,12 @@ class ThingsboardSchemaForm extends React.Component {
this.props.onIconClick(event); this.props.onIconClick(event);
} }
onToggleFullscreen(groupId) { onToggleFullscreen() {
this.setState({
groupId: groupId
});
this.props.onToggleFullscreen(); this.props.onToggleFullscreen();
} }
builder(form, groupId, model, index, onChange, onColorClick, onIconClick, onToggleFullscreen, mapper) { builder(form, model, index, onChange, onColorClick, onIconClick, onToggleFullscreen, mapper) {
var type = form.type; var type = form.type;
let Field = this.mapper[type]; let Field = this.mapper[type];
if(!Field) { if(!Field) {
@ -109,21 +103,21 @@ class ThingsboardSchemaForm extends React.Component {
return null; return null;
} }
} }
return <Field model={model} groupId={groupId} form={form} key={index} onChange={onChange} onColorClick={onColorClick} onIconClick={onIconClick} onToggleFullscreen={onToggleFullscreen} mapper={mapper} builder={this.builder}/> return <Field model={model} form={form} key={index} onChange={onChange} onColorClick={onColorClick} onIconClick={onIconClick} onToggleFullscreen={onToggleFullscreen} mapper={mapper} builder={this.builder}/>
} }
createSchema(theForm, groupId) { createSchema(theForm) {
let merged = utils.merge(this.props.schema, theForm, this.props.ignore, this.props.option); let merged = utils.merge(this.props.schema, theForm, this.props.ignore, this.props.option);
let mapper = this.mapper; let mapper = this.mapper;
if(this.props.mapper) { if(this.props.mapper) {
mapper = _.merge(this.mapper, this.props.mapper); mapper = _.merge(this.mapper, this.props.mapper);
} }
let forms = merged.map(function(form, index) { let forms = merged.map(function(form, index) {
return this.builder(form, groupId, this.props.model, index, this.onChange, this.onColorClick, this.onIconClick, this.onToggleFullscreen, mapper); return this.builder(form, this.props.model, index, this.onChange, this.onColorClick, this.onIconClick, this.onToggleFullscreen, mapper);
}.bind(this)); }.bind(this));
let formClass = 'SchemaForm'; let formClass = 'SchemaForm';
if (this.props.isFullscreen && groupId === this.state.groupId) { if (this.props.isFullscreen) {
formClass += ' SchemaFormFullscreen'; formClass += ' SchemaFormFullscreen';
} }
@ -136,7 +130,7 @@ class ThingsboardSchemaForm extends React.Component {
if(this.props.groupInfoes&&this.props.groupInfoes.length>0){ if(this.props.groupInfoes&&this.props.groupInfoes.length>0){
let content=[]; let content=[];
for(let info of this.props.groupInfoes){ for(let info of this.props.groupInfoes){
let forms = this.createSchema(this.props.form[info.formIndex], info.formIndex); let forms = this.createSchema(this.props.form[info.formIndex]);
let item = <ThingsboardSchemaGroup key={content.length} forms={forms} info={info}></ThingsboardSchemaGroup>; let item = <ThingsboardSchemaGroup key={content.length} forms={forms} info={info}></ThingsboardSchemaGroup>;
content.push(item); content.push(item);
} }
@ -166,8 +160,8 @@ class ThingsboardSchemaGroup extends React.Component{
render() { render() {
let theCla = "pull-right fa fa-chevron-down md-toggle-icon"+(this.state.showGroup?"":" tb-toggled") let theCla = "pull-right fa fa-chevron-down md-toggle-icon"+(this.state.showGroup?"":" tb-toggled")
return (<section className="md-whiteframe-z1" style={{marginTop: '10px'}}> return (<section className="md-whiteframe-z1" style={{marginTop: '10px'}}>
<div className='SchemaGroupname md-button-toggle' onClick={this.toogleGroup.bind(this)}>{this.props.info.GroupTitle}<span className={theCla}></span></div> <div className='SchemaGroupname md-button-toggle' onClick={this.toogleGroup.bind(this)}>{this.props.info.GroupTitle}<span className={theCla}></span></div>
<div style={{padding: '20px'}} className={this.state.showGroup?"":"invisible"}>{this.props.forms}</div> <div style={{padding: '20px'}} className={this.state.showGroup?"":"invisible"}>{this.props.forms}</div>
</section>); </section>);
} }
} }

3
ui/src/app/components/react/json-form.scss

@ -24,15 +24,12 @@ $input-label-float-scale: .75 !default;
.tb-fullscreen { .tb-fullscreen {
[name="ReactSchemaForm"] { [name="ReactSchemaForm"] {
.SchemaForm { .SchemaForm {
display: none;
&.SchemaFormFullscreen { &.SchemaFormFullscreen {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
display: block;
> div:not(.fullscreen-form-field) { > div:not(.fullscreen-form-field) {
display: none !important; display: none !important;

Loading…
Cancel
Save