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-manage / grids / Columns.js

Columns.js in WP Ultimate Post Grid 4.0.1, at assets/js/admin-manage/grids/Columns.js

159 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react';
2 import he from 'he';
3
4 import TextFilter from '../general/TextFilter';
5 import Api from 'Shared/Api';
6 import Icon from 'Shared/Icon';
7 import { __wpupg } from 'Shared/Translations';
8 import CopyToClipboardIcon from 'Shared/CopyToClipboardIcon';
9
10 import '../../../css/admin/manage/grids.scss';
11
12 export default {
13 getColumns( grids ) {
14 let columns = [
15 {
16 Header: __wpupg( 'Sort:' ),
17 id: 'actions',
18 headerClassName: 'wpupg-admin-table-help-text',
19 sortable: false,
20 width: wpupg_admin.addons.premium ? 100 : 70,
21 Filter: () => (
22 <div>
23 { __wpupg( 'Filter:' ) }
24 </div>
25 ),
26 Cell: row => (
27 <div className="wpupg-admin-manage-actions">
28 <Icon
29 type="edit"
30 title={ __wpupg( 'Edit Grid' ) }
31 onClick={() => {
32 WPUPG_Modal.open('edit', { grid: row.original, saveCallback: () => grids.refreshData() });
33 }}
34 />
35 {
36 true === wpupg_admin.addons.premium
37 &&
38 <Icon
39 type="duplicate"
40 title={ __wpupg( 'Clone Grid' ) }
41 onClick={() => {
42 WPUPG_Modal.open( 'create', {
43 grid: row.original,
44 cloneGrid: true,
45 saveCallback: () => grids.refreshData(),
46 });
47 }}
48 />
49 }
50 <Icon
51 type="delete"
52 title={ __wpupg( 'Delete Grid' ) }
53 onClick={() => {
54 if( confirm( `${ __wpupg( 'Are you sure you want to delete' ) } "${row.original.name}"?` ) ) {
55 Api.grid.delete(row.original.id).then(() => grids.refreshData());
56 }
57 }}
58 />
59 </div>
60 ),
61 },{
62 Header: '#',
63 id: 'id',
64 accessor: 'id',
65 width: 65,
66 Filter: (props) => (<TextFilter {...props}/>),
67 },{
68 Header: __wpupg( 'ID' ),
69 id: 'slug',
70 accessor: 'slug',
71 width: 150,
72 Filter: (props) => (<TextFilter {...props}/>),
73 },{
74 Header: __wpupg( 'Date' ),
75 id: 'date',
76 accessor: 'date',
77 width: 150,
78 Filter: (props) => (<TextFilter {...props}/>),
79 },{
80 Header: __wpupg( 'Name' ),
81 id: 'name',
82 accessor: 'name',
83 width: 300,
84 Filter: (props) => (<TextFilter {...props}/>),
85 Cell: row => row.value ? he.decode(row.value) : null,
86 },
87 ];
88
89 if ( wpupg_admin_manage_modal.multilingual ) {
90 columns.push(
91 {
92 Header: __wpupg( 'Language' ),
93 id: 'language',
94 accessor: 'language',
95 width: 150,
96 Filter: ({ filter, onChange }) => (
97 <select
98 onChange={event => onChange(event.target.value)}
99 style={{ width: '100%', fontSize: '1em' }}
100 value={filter ? filter.value : 'all'}
101 >
102 <option value="all">{ __wpupg( 'All Languages' ) }</option>
103 {
104 Object.values(wpupg_admin_manage_modal.multilingual.languages).map((language, index) => {
105 return (
106 <option value={ language.value } key={index}>{ `${ language.value } - ${ he.decode( language.label ) }` }</option>
107 )
108 })
109 }
110 </select>
111 ),
112 Cell: row => {
113 const language = wpupg_admin_manage_modal.multilingual.languages.hasOwnProperty( row.value ) ? wpupg_admin_manage_modal.multilingual.languages[ row.value ] : false;
114
115 if ( ! language ) {
116 return (<div></div>);
117 } else {
118 return (
119 <div>{ `${ language.value } - ${ he.decode( language.label ) }` }</div>
120 )
121 }
122 },
123 }
124 );
125 }
126
127 columns.push(
128 {
129 Header: __wpupg( 'Shortcode' ),
130 id: 'shortcode',
131 accessor: 'slug',
132 width: 400,
133 sortable: false,
134 filterable: false,
135 Cell: row => {
136 let id = row.value;
137
138 if ( ! id ) {
139 id = row.original.id;
140 }
141
142 const shortcode = `[wpupg-grid-with-filters id="${ id }"]`;
143
144 return (
145 <div className="wpupg-admin-manage-shortcode-container">
146 <CopyToClipboardIcon
147 text={shortcode}
148 type="text"
149 />
150 {/* <span className="wpupg-admin-manage-shortcode">{ shortcode }</span> */}
151 </div>
152 )
153 },
154 }
155 )
156
157 return columns;
158 }
159 };