Skip to content
This repository was archived by the owner on Aug 24, 2019. It is now read-only.

Commit a591a28

Browse files
committed
fix
1 parent bd42a99 commit a591a28

File tree

6 files changed

+56
-30
lines changed

6 files changed

+56
-30
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@
194194
]
195195
}
196196
},
197-
// "pre-commit": "lint:staged",
198197
"lint-staged": {
199198
"*.{cmd,html,json,md,sh,txt,xml,yml}": [
200199
"editorconfig-tools fix",

src/actions/productsActions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ export function receiveAddProducts(data) {
5757
}
5858
}
5959

60-
export function addProducts(appName) {
60+
export function addProducts(appName, os, platform) {
6161
return (dispatch) => {
6262
dispatch(requestAddProducts());
63-
return restApi.addProducts(appName)
63+
return restApi.addProducts(appName, os, platform)
6464
.then(data => {
6565
checkResponseAuth(dispatch, data);
6666
if (_.get(data, 'status') !== "OK") {

src/components/PopAddApp/PopAddApp.js

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ class PopAddApp extends Component {
2727
errorTip: PropTypes.string,
2828
showModal: PropTypes.bool,
2929
isShowNameError: PropTypes.bool,
30-
isShowAppTypeError: PropTypes.bool,
31-
appType: PropTypes.number,
30+
isShowOSError: PropTypes.bool,
31+
isShowPlatformError: PropTypes.bool,
32+
os: PropTypes.string,
33+
platform: PropTypes.string,
3234
appName: PropTypes.string,
3335
};
3436

@@ -40,8 +42,10 @@ class PopAddApp extends Component {
4042
errorTip: '',
4143
showModal: false,
4244
isShowNameError: false,
43-
isShowAppTypeError: false,
44-
appType: 0,
45+
isShowOSError: false,
46+
isShowPlatformError: false,
47+
os: '',
48+
platform: '',
4549
appName: '',
4650
};
4751

@@ -51,12 +55,18 @@ class PopAddApp extends Component {
5155
this.setName = this.setName.bind(this);
5256
this.validateName = this.validateName.bind(this);
5357
this.setSelect = this.setSelect.bind(this);
58+
this.setPlatformSelect = this.setPlatformSelect.bind(this);
5459
this.onSubmit = this.onSubmit.bind(this);
5560
}
5661

62+
setPlatformSelect(event){
63+
let select = event.target.value;
64+
this.props.input({platform:select});
65+
}
66+
5767
setSelect(event){
58-
let select = parseInt(event.target.value);
59-
this.props.input({appType:select});
68+
let select = event.target.value;
69+
this.props.input({os:select});
6070
}
6171

6272
setName(event){
@@ -91,7 +101,7 @@ class PopAddApp extends Component {
91101
<Modal.Title>添加App</Modal.Title>
92102
</Modal.Header>
93103
<Modal.Body>
94-
<FormGroup style={{display: 'inline-block',width: '60%'}} validationState={this.props.isShowNameError ? `error` : null}>
104+
<FormGroup style={{display: 'inline-block',width: '40%'}} validationState={this.props.isShowNameError ? `error` : null}>
95105
<ControlLabel>App名字</ControlLabel>
96106
<OverlayTrigger trigger={["hover"]} placement="bottom" overlay={popoverFocus}>
97107
<FormControl
@@ -103,16 +113,29 @@ class PopAddApp extends Component {
103113
</OverlayTrigger>
104114
<FormControl.Feedback />
105115
</FormGroup>
106-
<FormGroup style={{display: 'inline-block',width: '30%',paddingLeft: 15}} validationState={this.props.isShowAppTypeError ? `error` : null}>
107-
<ControlLabel>类型</ControlLabel>
116+
<FormGroup style={{display: 'inline-block',width: '20%',paddingLeft: 15}} validationState={this.props.isShowOSError ? `error` : null}>
117+
<ControlLabel>平台</ControlLabel>
108118
<FormControl
109119
componentClass="select"
110-
value={this.props.appType}
120+
value={this.props.os}
111121
onChange={this.setSelect}
112122
>
113-
<option value="0" >请选择后缀</option>
114-
<option value="1" >-ios</option>
115-
<option value="2" >-android</option>
123+
<option value="" >选择平台</option>
124+
<option value="iOS" >iOS</option>
125+
<option value="Android" >Android</option>
126+
<option value="Windows" >Windows</option>
127+
</FormControl>
128+
</FormGroup>
129+
<FormGroup style={{display: 'inline-block',width: '20%',paddingLeft: 15}} validationState={this.props.isShowPlatformError ? `error` : null}>
130+
<ControlLabel>类型</ControlLabel>
131+
<FormControl
132+
componentClass="select"
133+
value={this.props.platform}
134+
onChange={this.setPlatformSelect}
135+
>
136+
<option value="" >选择类型</option>
137+
<option value="React-Native" >React-Native</option>
138+
<option value="Cordova" >Cordova</option>
116139
</FormControl>
117140
</FormGroup>
118141
<FormGroup validationState="error">

src/containers/PopAddAppContainer.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,9 @@ class PopAddAppContainer extends Component {
3737
close={actions.closePopAddApp}
3838
onSubmit={()=>{
3939
var appName = _.get(addProducts, 'appName');
40-
var appType = _.get(addProducts, 'appType');
41-
if (appType == 1) {
42-
appName = `${appName}-ios`;
43-
} else if (appType == 2) {
44-
appName = `${appName}-android`;
45-
}
46-
actions.addProducts(appName);
40+
var os = _.get(addProducts, 'os');
41+
var platform = _.get(addProducts, 'platform');
42+
actions.addProducts(appName, os, platform);
4743
}}
4844
/>
4945
);

src/network/RestApi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class RestApi {
5757
});
5858
}
5959

60-
addProducts(appName) {
61-
return this.post('/apps', {name:appName})
60+
addProducts(appName, os, platform) {
61+
return this.post('/apps', {name:appName, os:os, platform:platform})
6262
.then(data=>{
6363
if (data.httpCode == 200) {
6464
var rs = this.jsonDecode(data);

src/reducers/products.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export function addProducts(state = {}, action) {
5656

5757
case POP_ADD_APP_INPUT:
5858
var appName = _.get(payload, 'appName');
59-
var appType = _.get(payload, 'appType');
59+
var os = _.get(payload, 'os');
60+
var platform = _.get(payload, 'platform');
6061
if (appName !== undefined) {
6162
const REGEX = /^\w+$/;
6263
if (REGEX.test(appName)) {
@@ -65,11 +66,18 @@ export function addProducts(state = {}, action) {
6566
_.set(payload, 'isShowNameError', true);
6667
}
6768
}
68-
if (appType !== undefined) {
69-
if (_.indexOf([1, 2], parseInt(appType)) !== -1 ) {
70-
_.set(payload, 'isShowAppTypeError', false);
69+
if (os !== undefined) {
70+
if (_.indexOf(['iOS', 'Android', 'Windows'], os) !== -1 ) {
71+
_.set(payload, 'isShowOSError', false);
7172
} else {
72-
_.set(payload, 'isShowAppTypeError', true);
73+
_.set(payload, 'isShowOSError', true);
74+
}
75+
}
76+
if (platform !== undefined) {
77+
if (_.indexOf(['React-Native', 'Cordova'], platform) !== -1 ) {
78+
_.set(payload, 'isShowPlatformError', false);
79+
} else {
80+
_.set(payload, 'isShowPlatformError', true);
7381
}
7482
}
7583
return Object.assign({}, state, payload);

0 commit comments

Comments
 (0)