-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtemplate-settings.js
More file actions
52 lines (49 loc) · 1.57 KB
/
template-settings.js
File metadata and controls
52 lines (49 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { __ } = wp.i18n; // Import __() from wp.i18n
//const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks
const el = wp.element.createElement;
const { DateTimePicker, RadioControl, SelectControl, TextControl, TextareaControl,FormToggle } = wp.components;
const { withState } = wp.compose;
const { withSelect, withDispatch } = wp.data;
import './state.js';
var TemplateTextControl = wp.compose.compose(
withDispatch( function( dispatch, props ) {
//if(props.key == 'hour')
return {
setValue: function( value ) {
dispatch( 'rsvpevent' ).setHour(value);
}
}
} ),
withSelect( function( select, props ) {
//if(props.key == 'hour')
return {
value: select( 'rsvpevent' ).getHour(),
}
} ) )( function( props ) {
return el( TextControl, {
label: props.label,
value: props.value,
onChange: props.setValue,
});
}
);
const RSVPTemplate = withState( {
week: wp.data.select('rsvpevent').getWeek(),
dow: wp.data.select('rsvpevent').getDOW(),
hour: wp.data.select('rsvpevent').getHour(),
minutes: wp.data.select('rsvpevent').getMinutes(),
end: wp.data.select('rsvpevent').getEnd(),
stop: wp.data.select('rsvpevent').getStop(),
duration: wp.data.select('rsvpevent').getDuration(),
setSked: function (value, key, index) {
if(key == hour)
wp.data.dispatch('rsvpevent').setHour(value);
}
} )( ( props ) => {
return (
<div>
<TextControl label='hour' value={props.hour} />
</div>
);
} ); //onChange={(value) => {setSked(value,'hour',0)}}
export {TemplateTextControl};// default RSVPTemplate;