Skip to content

Commit e50253e

Browse files
committed
property array functionally complete
1 parent 67b93ad commit e50253e

File tree

9 files changed

+136
-192
lines changed

9 files changed

+136
-192
lines changed

src/config/layer.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,5 @@
115115
}
116116
}
117117
}
118-
},
119-
120-
"default":{
121-
"layout":{
122-
"visibility":"visible"
123-
}
124118
}
125119
}

src/view/Vfield/VfieldArray.jsx

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/view/Vfield/index.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
33

44
import Valert from '../Valert';
55
import VfieldAC from './VfieldAC';
6-
import VfieldArray from './VfieldArray';
76
import VfieldColor from './VfieldColor';
87
import VfieldFile from './VfieldFile';
98
import VfieldJSON from './VfieldJSON';
@@ -35,8 +34,6 @@ export default class Vfield extends React.Component {
3534
switch (field.type){
3635
case 'AC':
3736
return <VfieldAC type={field.type} field={field} handle={handle}/>;
38-
case 'array':
39-
return <VfieldArray type={field.type} field={field} handle={handle}/>;
4037
case 'color':
4138
return <VfieldColor type={field.type} field={field} handle={handle}/>;
4239
case 'file':

src/view/Vlayer/VlayerEditor.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ export default class VlayerEditor extends React.Component {
4747
Mlayer.setIn(layer.get('id'),key,field.value);
4848
},
4949

50+
remove:(field)=>{
51+
let key = field.name.split('.');
52+
key.forEach((k,i)=>{
53+
if (/^\d+$/.test(k)) key[i] = Number(k);
54+
});
55+
Mlayer.removeIn(layer.get('id'),key);
56+
},
57+
5058

5159
enter:(field)=>{
5260
console.log('enter:',field);
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import {List} from 'immutable';
4+
5+
import Vfield from '../../Vfield';
6+
import Valert from '../../Valert';
7+
import VpropertyInfo from '../VpropertyInfo';
8+
9+
import styleSpec from '../../../vendor/style-spec/style-spec';
10+
11+
export default class VpropertyArrayAdd extends React.Component {
12+
13+
static propTypes = {
14+
name: PropTypes.string.isRequired, // string of position . separated
15+
type: PropTypes.string.isRequired,
16+
//value: PropTypes.object,
17+
error: PropTypes.oneOfType([
18+
PropTypes.string,
19+
PropTypes.object
20+
]),
21+
focus: PropTypes.string,
22+
handle: PropTypes.object
23+
}
24+
25+
constructor(props) {
26+
super(props);
27+
const {handle, func} = this.props;
28+
29+
this.state = {
30+
open:true,
31+
value:null
32+
};
33+
34+
this.handle = {
35+
change:(field)=>{
36+
this.setState({value:field.value});
37+
},
38+
show:()=>{
39+
this.setState({show:true});
40+
},
41+
hide:()=>{
42+
this.setState({show:false});
43+
}
44+
};
45+
46+
for (let i in this.handle){
47+
this.handle[i] = this.handle[i].bind(this);
48+
}
49+
50+
}
51+
52+
render (){
53+
const {name, error, focus, type} = this.props;
54+
55+
const autoFocus = (name === focus)? true: false;
56+
57+
//console.log('spec:',spec, 'value:',value);
58+
59+
if (!this.state.show){
60+
return <div onClick={this.handle.show} className="btn btn-xs btn-light">
61+
<i className="material-icons md-14">add</i>
62+
</div>
63+
}
64+
65+
//const autoFocus = true;
66+
return <div className="position-relative add-input-pr">
67+
<Vfield field={{
68+
type:type,
69+
name:name,
70+
value:this.state.value,
71+
controlled:false,
72+
autoFocus:autoFocus
73+
}} handle={this.handle}/>
74+
75+
<div className="position-absolute add-close-pos">
76+
<button onClick={this.handle.hide} className="btn btn-light btn-sm" type="button">
77+
<i className="material-icons md-14">close</i>
78+
</button>
79+
</div>
80+
</div>
81+
}
82+
};

src/view/Vproperty/VpropertyArray/VpropertyArrayRow.jsx

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -40,64 +40,18 @@ export default class VpropertyArrayRow extends React.Component {
4040
this.setState({open:true});
4141
},
4242
remove:()=>{
43-
const pos = func.name.split('.');
44-
handle.layerRemoveIn(pos);
43+
handle.remove({name:func.name});
4544
}
4645
};
4746

4847
for (let i in this.handle){
4948
this.handle[i] = this.handle[i].bind(this);
5049
}
5150

52-
this.fieldHandle = {
53-
change:handle.change,
54-
focus:handle.focus,
55-
56-
/*
57-
58-
focusNext:(pos)=>{
59-
let nextPos = getNextPos(pos);
60-
if (!handle.layerHasIn(nextPos)) return;
61-
this.handle.focus(nextPos);
62-
},
63-
focusPrev:(pos)=>{
64-
let prevPos = getPrevPos(pos);
65-
if (!handle.layerHasIn(prevPos)) return;
66-
this.handle.focus(prevPos);
67-
},
68-
69-
enter:(f)=>{
70-
const pos = nameToPos(f.name);
71-
const nextPos = getNextPos(pos);
72-
73-
console.log('enter:',nextPos, handle.layerHasIn(nextPos));
74-
75-
if (!handle.layerHasIn(nextPos)){
76-
handle.change({
77-
name:posToName(nextPos),
78-
value:''
79-
});
80-
}
81-
handle.focus(posToName(nextPos));
82-
},
83-
backout:(f)=>{
84-
const pos = nameToPos(f.name);
85-
const prevPos = getPrevPos(pos);
86-
87-
handle.layerRemoveIn(pos);
88-
handle.focus(posToName(prevPos));
89-
}
90-
*/
91-
};
92-
93-
for (let i in this.fieldHandle){
94-
this.fieldHandle[i] = this.fieldHandle[i].bind(this);
95-
}
96-
9751
}
9852

9953
render (){
100-
const {row, error, focus} = this.props;
54+
const {row, error, focus, handle} = this.props;
10155

10256
const autoFocus = (row.name === focus)? true: false;
10357

@@ -110,7 +64,7 @@ export default class VpropertyArrayRow extends React.Component {
11064
value:row.value,
11165
controlled:false,
11266
autoFocus:autoFocus
113-
}} handle={this.fieldHandle}/>
67+
}} handle={handle}/>
11468
</div>
11569
}
11670
};

0 commit comments

Comments
 (0)