PluginProbe
WP Ultimate Post Grid / 4.0.1
WP Ultimate Post Grid v4.0.1
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / assets / js / admin-modal / select / index.js

index.js in WP Ultimate Post Grid 4.0.1, at assets/js/admin-modal/select/index.js

105 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { Component, Fragment } from 'react';
2
3 import '../../../css/admin/modal/select.scss';
4
5 import { __wpupg } from 'Shared/Translations';
6 import Header from '../general/Header';
7 import Footer from '../general/Footer';
8
9 import SelectFilter from './SelectFilter';
10 import SelectGrid from './SelectGrid';
11
12 export default class Select extends Component {
13 constructor(props) {
14 super(props);
15
16 this.state = {
17 grid: false,
18 filter: false,
19 };
20 }
21
22 selectionsMade() {
23 return ( ! this.props.args.fields.grid || false !== this.state.grid )
24 && ( ! this.props.args.fields.filter || false !== this.state.filter );
25 }
26
27 render() {
28 return (
29 <Fragment>
30 <Header
31 onCloseModal={ this.props.maybeCloseModal }
32 >
33 {
34 this.props.args.title
35 ?
36 this.props.args.title
37 :
38 'WP Ultimate Post Grid'
39 }
40 </Header>
41 <div className="wpupg-admin-modal-select-container">
42 {
43 this.props.args.fields.grid
44 ?
45 <SelectGrid
46 placeholder={ __wpupg( 'Select Grid' ) }
47 value={ this.state.grid }
48 onChange={(grid) => {
49 this.setState({
50 grid,
51 filter: false,
52 });
53 }}
54 />
55 :
56 null
57 }
58 {
59 this.props.args.fields.filter
60 ?
61 <Fragment>
62 <br/>
63 <SelectFilter
64 placeholder={ __wpupg( 'Select Filter' ) }
65 grid={ this.state.grid }
66 value={ this.state.filter }
67 onChange={(filter) => {
68 this.setState({ filter });
69 }}
70 />
71 </Fragment>
72 :
73 null
74 }
75 </div>
76 <Footer
77 savingChanges={ false }
78 >
79 <button
80 className="button button-primary"
81 onClick={ () => {
82 if ( 'function' === typeof this.props.args.nextStepCallback ) {
83 this.props.args.nextStepCallback( this.state );
84 } else {
85 if ( 'function' === typeof this.props.args.insertCallback ) {
86 this.props.args.insertCallback( this.state );
87 }
88 this.props.maybeCloseModal();
89 }
90 } }
91 disabled={ ! this.selectionsMade() }
92 >
93 {
94 this.props.args.button
95 ?
96 this.props.args.button
97 :
98 __wpupg( 'Select' )
99 }
100 </button>
101 </Footer>
102 </Fragment>
103 );
104 }
105 }