|
@@ -40,6 +40,9 @@ class ThingsboardSchemaForm extends React.Component { |
|
@@ -40,6 +40,9 @@ class ThingsboardSchemaForm extends React.Component { |
40
|
|
40
|
|
41
|
constructor(props) {
|
41
|
constructor(props) {
|
42
|
super(props);
|
42
|
super(props);
|
|
|
43
|
+ this.state = {
|
|
|
44
|
+ groupId: null,
|
|
|
45
|
+ };
|
43
|
|
46
|
|
44
|
this.mapper = {
|
47
|
this.mapper = {
|
45
|
'number': ThingsboardNumber,
|
48
|
'number': ThingsboardNumber,
|
|
@@ -71,7 +74,6 @@ class ThingsboardSchemaForm extends React.Component { |
|
@@ -71,7 +74,6 @@ class ThingsboardSchemaForm extends React.Component { |
71
|
}
|
74
|
}
|
72
|
|
75
|
|
73
|
onChange(key, val) {
|
76
|
onChange(key, val) {
|
74
|
- //console.log('SchemaForm.onChange', key, val);
|
|
|
75
|
this.props.onModelChange(key, val);
|
77
|
this.props.onModelChange(key, val);
|
76
|
if (this.hasConditions) {
|
78
|
if (this.hasConditions) {
|
77
|
this.forceUpdate();
|
79
|
this.forceUpdate();
|
|
@@ -86,12 +88,15 @@ class ThingsboardSchemaForm extends React.Component { |
|
@@ -86,12 +88,15 @@ class ThingsboardSchemaForm extends React.Component { |
86
|
this.props.onIconClick(event);
|
88
|
this.props.onIconClick(event);
|
87
|
}
|
89
|
}
|
88
|
|
90
|
|
89
|
- onToggleFullscreen() {
|
91
|
+ onToggleFullscreen(groupId) {
|
|
|
92
|
+ this.setState({
|
|
|
93
|
+ groupId: groupId
|
|
|
94
|
+ });
|
90
|
this.props.onToggleFullscreen();
|
95
|
this.props.onToggleFullscreen();
|
91
|
}
|
96
|
}
|
92
|
|
97
|
|
93
|
-
|
|
|
94
|
- builder(form, model, index, onChange, onColorClick, onIconClick, onToggleFullscreen, mapper) {
|
98
|
+
|
|
|
99
|
+ builder(form, groupId, model, index, onChange, onColorClick, onIconClick, onToggleFullscreen, mapper) {
|
95
|
var type = form.type;
|
100
|
var type = form.type;
|
96
|
let Field = this.mapper[type];
|
101
|
let Field = this.mapper[type];
|
97
|
if(!Field) {
|
102
|
if(!Field) {
|
|
@@ -104,21 +109,21 @@ class ThingsboardSchemaForm extends React.Component { |
|
@@ -104,21 +109,21 @@ class ThingsboardSchemaForm extends React.Component { |
104
|
return null;
|
109
|
return null;
|
105
|
}
|
110
|
}
|
106
|
}
|
111
|
}
|
107
|
- return <Field model={model} form={form} key={index} onChange={onChange} onColorClick={onColorClick} onIconClick={onIconClick} onToggleFullscreen={onToggleFullscreen} mapper={mapper} builder={this.builder}/>
|
112
|
+ return <Field model={model} groupId={groupId} form={form} key={index} onChange={onChange} onColorClick={onColorClick} onIconClick={onIconClick} onToggleFullscreen={onToggleFullscreen} mapper={mapper} builder={this.builder}/>
|
108
|
}
|
113
|
}
|
109
|
|
114
|
|
110
|
- createSchema(theForm) {
|
115
|
+ createSchema(theForm, groupId) {
|
111
|
let merged = utils.merge(this.props.schema, theForm, this.props.ignore, this.props.option);
|
116
|
let merged = utils.merge(this.props.schema, theForm, this.props.ignore, this.props.option);
|
112
|
let mapper = this.mapper;
|
117
|
let mapper = this.mapper;
|
113
|
if(this.props.mapper) {
|
118
|
if(this.props.mapper) {
|
114
|
mapper = _.merge(this.mapper, this.props.mapper);
|
119
|
mapper = _.merge(this.mapper, this.props.mapper);
|
115
|
}
|
120
|
}
|
116
|
let forms = merged.map(function(form, index) {
|
121
|
let forms = merged.map(function(form, index) {
|
117
|
- return this.builder(form, this.props.model, index, this.onChange, this.onColorClick, this.onIconClick, this.onToggleFullscreen, mapper);
|
122
|
+ return this.builder(form, groupId, this.props.model, index, this.onChange, this.onColorClick, this.onIconClick, this.onToggleFullscreen, mapper);
|
118
|
}.bind(this));
|
123
|
}.bind(this));
|
119
|
|
124
|
|
120
|
let formClass = 'SchemaForm';
|
125
|
let formClass = 'SchemaForm';
|
121
|
- if (this.props.isFullscreen) {
|
126
|
+ if (this.props.isFullscreen && groupId === this.state.groupId) {
|
122
|
formClass += ' SchemaFormFullscreen';
|
127
|
formClass += ' SchemaFormFullscreen';
|
123
|
}
|
128
|
}
|
124
|
|
129
|
|
|
@@ -131,7 +136,7 @@ class ThingsboardSchemaForm extends React.Component { |
|
@@ -131,7 +136,7 @@ class ThingsboardSchemaForm extends React.Component { |
131
|
if(this.props.groupInfoes&&this.props.groupInfoes.length>0){
|
136
|
if(this.props.groupInfoes&&this.props.groupInfoes.length>0){
|
132
|
let content=[];
|
137
|
let content=[];
|
133
|
for(let info of this.props.groupInfoes){
|
138
|
for(let info of this.props.groupInfoes){
|
134
|
- let forms = this.createSchema(this.props.form[info.formIndex]);
|
139
|
+ let forms = this.createSchema(this.props.form[info.formIndex], info.formIndex);
|
135
|
let item = <ThingsboardSchemaGroup key={content.length} forms={forms} info={info}></ThingsboardSchemaGroup>;
|
140
|
let item = <ThingsboardSchemaGroup key={content.length} forms={forms} info={info}></ThingsboardSchemaGroup>;
|
136
|
content.push(item);
|
141
|
content.push(item);
|
137
|
}
|
142
|
}
|
|
@@ -165,4 +170,4 @@ class ThingsboardSchemaGroup extends React.Component{ |
|
@@ -165,4 +170,4 @@ class ThingsboardSchemaGroup extends React.Component{ |
165
|
<div style={{padding: '20px'}} className={this.state.showGroup?"":"invisible"}>{this.props.forms}</div>
|
170
|
<div style={{padding: '20px'}} className={this.state.showGroup?"":"invisible"}>{this.props.forms}</div>
|
166
|
</section>);
|
171
|
</section>);
|
167
|
}
|
172
|
}
|
168
|
-} |
173
|
+} |