PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.6
Yatra – Travel Booking & Tour Operator Software v3.0.2.6
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
yatra / resources / js / blocks / destination / edit.tsx

edit.tsx in Yatra – Travel Booking & Tour Operator Software 3.0.2.6, at resources/js/blocks/destination/edit.tsx

91 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { InspectorControls } from "@wordpress/block-editor";
2 import {
3 PanelBody,
4 TextControl,
5 RangeControl,
6 SelectControl,
7 ToggleControl,
8 } from "@wordpress/components";
9 import { __ } from "@wordpress/i18n";
10 import ServerSideRender from "@wordpress/server-side-render";
11
12 interface DestinationBlockAttributes {
13 order: "asc" | "desc";
14 columns: number;
15 per_page: number;
16 title: string;
17 show_pagination: boolean;
18 }
19
20 interface EditProps {
21 attributes: DestinationBlockAttributes;
22 setAttributes: (attrs: Partial<DestinationBlockAttributes>) => void;
23 }
24
25 export default function Edit({ attributes, setAttributes }: EditProps) {
26 return (
27 <>
28 <InspectorControls>
29 <PanelBody
30 title={__("Destination Settings", "yatra")}
31 initialOpen={true}
32 >
33 <TextControl
34 label={__("Title", "yatra")}
35 value={attributes.title}
36 onChange={(value: string) => setAttributes({ title: value })}
37 />
38 <SelectControl
39 label={__("Order", "yatra")}
40 value={attributes.order}
41 options={[
42 { label: __("Ascending", "yatra"), value: "asc" },
43 { label: __("Descending", "yatra"), value: "desc" },
44 ]}
45 onChange={(value: string) =>
46 setAttributes({ order: value as "asc" | "desc" })
47 }
48 />
49 <RangeControl
50 label={__("Number of Destinations", "yatra")}
51 value={attributes.per_page}
52 onChange={(value: number | undefined) =>
53 setAttributes({
54 per_page: value !== undefined && value !== null ? value : 10,
55 })
56 }
57 min={1}
58 max={50}
59 />
60 <RangeControl
61 label={__("Columns", "yatra")}
62 value={attributes.columns}
63 onChange={(value: number | undefined) =>
64 setAttributes({
65 columns: value !== undefined && value !== null ? value : 3,
66 })
67 }
68 min={1}
69 max={6}
70 />
71 <ToggleControl
72 label={__("Show pagination", "yatra")}
73 checked={attributes.show_pagination}
74 onChange={(value: boolean) =>
75 setAttributes({ show_pagination: value })
76 }
77 />
78 </PanelBody>
79 </InspectorControls>
80
81 <div className="yatra-block-editor-preview">
82 <ServerSideRender
83 block="yatra/destination"
84 attributes={attributes}
85 key={JSON.stringify(attributes)}
86 />
87 </div>
88 </>
89 );
90 }
91