forked from Kenshin/simpread
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathname.jsx
More file actions
48 lines (39 loc) · 1.25 KB
/
name.jsx
File metadata and controls
48 lines (39 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
console.log( "===== simpread option common: Name =====" )
import { storage } from 'storage';
import TextField from 'textfield';
//const names = [];
export default class Name extends React.Component {
state = {
error : ""
};
changeName( event ) {
let code = 0;
const name = event.target.value.trim();
//if ( names.includes( name ) && name != this.props.name ) {
// code = -1;
// this.setState({ error : "当前值重复,请重新录入。" });
//} else
if( name == "" ) {
code = -2;
this.setState({ error : "当前输入不能为空。" });
} else {
this.setState({ error : "" });
}
this.props.changeName( name, code );
}
//componentWillMount() {
// storage.simpread.sites.forEach( site => names.push( site[1].name ) );
//}
render() {
return (
<TextField
multi={ false }
placeholder={ "必填,当前值具有唯一性。" }
floatingtext="标识"
value={ this.props.name }
errortext={ this.state.error }
onChange={ evt=>this.changeName(evt) }
/>
)
}
}