6 |
7 |
8 |
{props.title}
9 |
10 |
11 | {props.children}
12 |
13 | );
14 | };
15 |
16 | export default pageLayout;
--------------------------------------------------------------------------------
/src/components/layouts/panel-layout.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | const panelLayout = props => {
4 | return (
5 |
124 | {
125 | this.state.value.map((item, idx) => {
126 | return (
127 |
128 |
129 | {
130 | this.renderChildren(item, idx)
131 | }
132 |
133 |
134 | );
135 | })
136 | }
137 |
138 |
139 |
140 | );
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/src/helpers/bselect-input.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Select from 'react-select';
3 | import 'react-select/dist/react-select.css';
4 |
5 | export default class BSelectInput extends React.Component {
6 | constructor(props) {
7 | super(props);
8 |
9 | this.state = { value: props.value || {} };
10 |
11 | this.value = props.value || {};
12 |
13 | this.onSelectChange = (selectedItem) => {
14 |
15 | if (this.props.async) {
16 | //if it's in async mode get label name from mocked or selected option
17 | this.value = selectedItem || {};
18 | }
19 | else {
20 | //if it's NOT in async mode get label name from exist options
21 | this.value = selectedItem.value || selectedItem || {};
22 | }
23 |
24 | props.onChangeHandler(selectedItem);
25 | this.setState({ value: this.value });
26 | }
27 |
28 | }
29 |
30 | // fired after value props changed
31 | componentWillReceiveProps(nextProps) {
32 | this.setState({ value: nextProps.value });
33 | }
34 | // fired after state changed
35 | shouldComponentUpdate(nextProps, nextState) {
36 | return (this.props.value !== nextProps.value) && typeof nextProps.value !== 'undefined';
37 | }
38 | // fired after component render
39 | componentDidUpdate() {
40 | this.onSelectChange(this.state.value);
41 | }
42 |
43 | render() {
44 | // console.log(this.props.async);
45 | // console.log(this.props.loadOptions);
46 | return (this.props.async === true) ?
47 | (
48 |