import JetEngineRepeater from "components/repeater-control.js";
import {
clone
} from '../../utils/utility';
const { __ } = wp.i18n;
const {
registerBlockType
} = wp.blocks;
const {
InspectorControls
} = wp.blockEditor;
const {
PanelColor,
IconButton,
TextControl,
TextareaControl,
SelectControl,
ToggleControl,
PanelBody,
RangeControl,
CheckboxControl,
ExternalLink,
Disabled,
G,
Path,
Circle,
Rect,
SVG,
ServerSideRender
} = wp.components;
if ( -1 !== window.JetEngineListingData.activeModules.indexOf( 'calendar' ) ) {
const GIcon = ;
const blockAttributes = window.JetEngineListingData.atts.listingCalendar;
registerBlockType( 'jet-engine/listing-calendar', {
title: __( 'Listing Calendar' ),
icon: GIcon,
category: 'layout',
attributes: blockAttributes,
className: 'jet-listing-calendar',
edit: class extends wp.element.Component {
constructor( props ) {
if ( ! props.attributes._block_id ) {
props.setAttributes( { _block_id: props.clientId } );
}
super( props );
}
render() {
const props = this.props;
const attributes = props.attributes;
const listingOptions = window.JetEngineListingData.listingOptions;
const hideOptions = window.JetEngineListingData.hideOptions;
const metaTypes = [
{
value: 'CHAR',
label: 'CHAR'
},
{
value: 'NUMERIC',
label: 'NUMERIC'
},
{
value: 'BINARY',
label: 'BINARY'
},
{
value: 'DATE',
label: 'DATE'
},
{
value: 'DATETIME',
label: 'DATETIME'
},
{
value: 'DECIMAL',
label: 'DECIMAL'
},
{
value: 'SIGNED',
label: 'SIGNED'
},
{
value: 'UNSIGNED',
label: 'UNSIGNED'
}
];
const updateItem = function( item, key, value, prop ) {
prop = prop || 'posts_query';
const query = clone( props.attributes[ prop ] );
const index = getItemIndex( item );
const currentItem = query[ getItemIndex( item, prop ) ];
if ( ! currentItem ) {
return;
}
if ( 'object' === typeof key ) {
for ( var _key in key ) {
currentItem[_key] = key[_key];
}
} else {
currentItem[ key ] = value;
}
query[ index ] = currentItem;
props.setAttributes( { [ prop ]: query } );
};
const getItemIndex = function( item, prop ) {
prop = prop || 'posts_query';
return props.attributes[ prop ].findIndex( queryItem => {
return queryItem == item;
} );
};
return [
props.isSelected && (
{
props.setAttributes( { lisitng_id: newValue } );
} }
/>
{
props.setAttributes( { group_by: newValue } );
} }
/>
{ 'meta_date' === attributes.group_by &&
{
props.setAttributes( { group_by_key: newValue } );
} }
/>
}
{
props.setAttributes( { allow_multiday: ! attributes.allow_multiday } );
} }
/>
{ 'meta_date' === attributes.group_by && attributes.allow_multiday &&
{
props.setAttributes( { end_date_key: newValue } );
} }
/>
}
{
props.setAttributes( { week_days_format: newValue } );
} }
/>
{
props.setAttributes( { custom_start_from: ! attributes.custom_start_from } );
} }
/>
{ attributes.custom_start_from &&
{
props.setAttributes( { start_from_month: newValue } );
} }
/>
}
{ attributes.custom_start_from &&
{
props.setAttributes( { start_from_year: newValue } );
} }
/>
}
{
props.setAttributes( { show_posts_nearby_months: ! attributes.show_posts_nearby_months } );
} }
/>
{
props.setAttributes( { hide_past_events: ! attributes.hide_past_events } );
} }
/>
{
props.setAttributes( { caption_layout: newValue } );
} }
/>
{
props.setAttributes({ custom_query: ! attributes.custom_query });
} }
/>
{ attributes.custom_query && {
props.setAttributes( { custom_query_id: newValue } );
}}
/> }
{
props.setAttributes({ posts_query: newData });
} }
>
{
( item ) =>
{
updateItem( item, 'type', newValue )
}}
/>
{ 'date_query' === item.type &&
{
updateItem( item, 'date_query_column', newValue )
}}
/>
{
updateItem( item, 'date_query_after', newValue )
}}
/>
{
updateItem( item, 'date_query_before', newValue )
}}
/>
}
{ 'posts_params' === item.type &&
{
updateItem( item, 'posts_in', newValue )
}}
/>
{
updateItem( item, 'posts_not_in', newValue )
}}
/>
{
updateItem( item, 'posts_parent', newValue )
}}
/>
{
updateItem( item, 'posts_status', newValue )
}}
/>
{
updateItem( item, 'posts_author', newValue )
}}
/>
{
'id' === item.posts_author &&
{
updateItem( item, 'posts_author_id', newValue )
}}
/>
}
{
updateItem( item, 'search_query', newValue )
}}
/>
}
{ 'order_offset' === item.type &&
{
updateItem( item, 'offset', newValue )
}}
/>
{
updateItem( item, 'order', newValue )
}}
/>
{
updateItem( item, 'order_by', newValue )
}}
/>
{ 'meta_value' === item.order_by &&
{
updateItem( item, 'meta_key', newValue )
}}
/>
{
updateItem( item, 'meta_type', newValue )
}}
/>
}
{ 'meta_clause' === item.order_by &&
{
updateItem( item, 'meta_clause_key', newValue )
}}
/>
}
}
{ 'tax_query' === item.type &&
{
updateItem( item, 'tax_query_taxonomy', newValue )
}}
/>
{
updateItem( item, 'tax_query_compare', newValue )
}}
/>
{
updateItem( item, 'tax_query_field', newValue )
}}
/>
{
updateItem( item, 'tax_query_terms', newValue )
}}
/>
{
updateItem( item, 'tax_query_terms_meta', newValue )
}}
/>
}
{ 'meta_query' === item.type &&
{
updateItem( item, 'meta_query_key', newValue )
}}
/>
',
label: 'Greater than',
},
{
value: '>=',
label: 'Greater or equal',
},
{
value: '<',
label: 'Less than',
},
{
value: '<=',
label: 'Equal or less',
},
{
value: 'LIKE',
label: 'LIKE',
},
{
value: 'NOT LIKE',
label: 'NOT LIKE',
},
{
value: 'IN',
label: 'IN',
},
{
value: 'NOT IN',
label: 'NOT IN',
},
{
value: 'BETWEEN',
label: 'BETWEEN',
},
{
value: 'NOT BETWEEN',
label: 'NOT BETWEEN',
},
{
value: 'EXISTS',
label: 'EXISTS',
},
{
value: 'NOT EXISTS',
label: 'NOT EXISTS',
},
{
value: 'REGEXP',
label: 'REGEXP',
},
{
value: 'NOT REGEXP',
label: 'NOT REGEXP',
},
] }
onChange={newValue => {
updateItem( item, 'meta_query_compare', newValue )
}}
/>
{ ! ['EXISTS', 'NOT EXISTS'].includes( item.meta_query_compare ) &&
{
updateItem( item, 'meta_query_val', newValue )
}}
/>
{
updateItem( item, 'meta_query_request_val', newValue )
}}
/>
}
{
updateItem( item, 'meta_query_type', newValue )
}}
/>
{
updateItem( item, 'meta_query_clause', newValue )
}}
/>
}
}
{
props.setAttributes( { meta_query_relation: newValue } );
}}
/>
{
props.setAttributes( { tax_query_relation: newValue } );
}}
/>
{
props.setAttributes( { hide_widget_if: newValue } );
} }
/>
),
];
}
},
save: props => {
return null;
}
} );
}
;
Özolgun Ticaret – Teknik Hırdavat