Skip to content

Commit

Permalink
update picke and picker_column code
Browse files Browse the repository at this point in the history
  • Loading branch information
ruoru committed Jan 27, 2018
1 parent f621503 commit f623fc3
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 165 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ publish.sh
pendingtest
.nyc_output
dist
build
build
yarn*
132 changes: 106 additions & 26 deletions example/pages/picker/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,93 @@
import React from 'react';
import { Popup, Picker, CityPicker, Form, FormCell, CellBody, CellHeader, Label, Input } from '../../../build/packages';
//import { Popup, Picker, CascadePicker, CityPicker, Form, FormCell, CellBody, CellHeader, Label, Input } from '../../../build/packages';
import { Popup, Picker, CascadePicker, CityPicker, Form, FormCell, CellBody, CellHeader, Label, Input } from '../../../src';
import Page from '../../component/page';
import cnCity from './cnCity';


class PickerDemo extends React.Component {

state = {
picker_show: false,
picker_value: '',
picker_group: [
{
items: [
{
label: 'Item1'
},
{
label: 'Item2 (Disabled)',
disabled: true
},
{
label: 'Item3'
},
{
label: 'Item4'
},
{
label: 'Item5'
}
]
}
[
{
label: 'A1 (Disabled)',
value: 'A1',
disable: true
},
{
label: 'A2',
value: 'A2',
},
{
label: 'A3',
value: 'A3',
},
{
label: 'A4 (Disabled)',
value: 'A4',
disable: true
},
{
label: 'A5',
value: 'A5',
},
{
label: 'A6',
value: 'A6',
},
{
label: 'A7',
value: 'A7',
}
],
[
{
label: 'B1',
value: 'B1',
},
{
label: 'B2',
value: 'B2',
},
{
label: 'B3 (Disabled)',
value: 'B3',
disable: true,
},
{
label: 'B4',
value: 'B4',
},
],
[
{
label: 'C1',
value: 'C1',
},
{
label: 'C2',
value: 'C2',
},
{
label: 'C3 (Disabled)',
value: 'C3',
disable: true,
},
{
label: 'C4',
value: 'C4',
},
],
],
picker_cascade: [
],
city_show: false,
city_value: ''
cascade_show: false,
city_value: '',
cascade_value: '',
};

hide(){
Expand Down Expand Up @@ -70,7 +126,30 @@ class PickerDemo extends React.Component {
show={this.state.city_show}
/>


<Form>
<FormCell>
<CellHeader>
<Label>Cascade</Label>
</CellHeader>
<CellBody>
<Input type="text"
value={this.state.cascade_value}
onClick={ e=> {
e.preventDefault();
this.setState({cascade_show: true})
}}
placeholder="Chose Your cascade value"
readOnly={true}
/>
</CellBody>
</FormCell>
</Form>
<CascadePicker
data={cnCity}
onCancel={e=>this.setState({cascade_show: false})}
onOk={text=>this.setState({cascade_value: text, cascade_show: false})}
show={this.state.cascade_show}
/>

<Form>
<FormCell>
Expand All @@ -93,17 +172,18 @@ class PickerDemo extends React.Component {
</Form>

<Picker
onChange={selected=>{
onOk={selected=>{
let value = ''
selected.forEach( (s, i)=> {
value = this.state.picker_group[i]['items'][s].label
value += this.state.picker_group[i][s].value
})
this.setState({
picker_value: value,
picker_show: false
})
}}
groups={this.state.picker_group}
data={this.state.picker_group}
datamap={{text: 'label'}}
show={this.state.picker_show}
onCancel={e=>this.setState({picker_show: false})}
/>
Expand Down
64 changes: 64 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"dependencies": {
"babel-runtime": "^6.18.0",
"prop-types": "^15.5.10",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"weui": "^1.1.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import Picker from './picker';

/**
* An city pick component build on top of picker
*
*/
class ConcatenationPicker extends React.Component {

class CascadePicker extends React.Component {

static propTypes = {
/**
Expand Down Expand Up @@ -112,7 +109,6 @@ class ConcatenationPicker extends React.Component {
}, ()=>cb());
}


updateGroup(item, i, groupIndex, selected, picker){
this.updateDataBySelected(selected, ()=>{
//update picker
Expand All @@ -137,15 +133,15 @@ class ConcatenationPicker extends React.Component {
return (
<Picker
show={this.props.show}
onGroupChange={this.updateGroup}
onChange={this.handleChange}
onColumnChange={this.updateGroup}
onOk={this.handleChange}
defaultSelect={this.state.selected}
groups={this.state.groups}
data={this.state.groups}
onCancel={this.props.onCancel}
lang={this.props.lang}
/>
);
}
}

export default ConcatenationPicker;
export default CascadePicker;
4 changes: 3 additions & 1 deletion src/components/picker/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Picker from './picker';
import PickerColumn from './picker_column';
import CityPicker from './city_picker';
import CascadePicker from './Cascade_picker';

export {
Picker,
PickerColumn,
CityPicker
CityPicker,
CascadePicker,
};
Loading

0 comments on commit f623fc3

Please sign in to comment.