Many adjusts for allowing filter type options to be used on filter edition form.
This commit is contained in:
parent
9b85c8f389
commit
48865d3de4
|
@ -221,6 +221,13 @@ class Admin {
|
||||||
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filter_types = $Tainacan_Filters->fetch_filter_types();
|
||||||
|
|
||||||
|
foreach ( $filter_types as $index => $filter_type){
|
||||||
|
$class = new $filter_type;
|
||||||
|
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
||||||
|
}
|
||||||
|
|
||||||
$settings['form_hooks'] = Admin_Hooks::get_instance()->get_registered_hooks();
|
$settings['form_hooks'] = Admin_Hooks::get_instance()->get_registered_hooks();
|
||||||
|
|
||||||
$wp_post_types = get_post_types(['show_ui' => true], 'objects');
|
$wp_post_types = get_post_types(['show_ui' => true], 'objects');
|
||||||
|
|
|
@ -149,11 +149,10 @@
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
<component
|
<component
|
||||||
:errors="formErrors['filter_type_options']"
|
v-if="(editForm.filter_type_object && editForm.filter_type_object.form_component && editForm.filter_type_object.options) || editForm.edit_form == ''"
|
||||||
v-if="(editForm.filter_type_object && editForm.filter_type_object.form_component) || editForm.edit_form == ''"
|
|
||||||
:is="editForm.filter_type_object.form_component"
|
:is="editForm.filter_type_object.form_component"
|
||||||
:filter="editForm"
|
:filter="editForm"
|
||||||
v-model="editForm.filter_type_options"/>
|
v-model="editForm.filter_type_object.options"/>
|
||||||
<div
|
<div
|
||||||
v-html="editForm.edit_form"
|
v-html="editForm.edit_form"
|
||||||
v-else/>
|
v-else/>
|
||||||
|
|
|
@ -619,7 +619,7 @@
|
||||||
placement: 'auto',
|
placement: 'auto',
|
||||||
}">
|
}">
|
||||||
<a :style="{ fontWeight: 'bold', color: '#454647 !important', lineHeight: '1.5rem' }">
|
<a :style="{ fontWeight: 'bold', color: '#454647 !important', lineHeight: '1.5rem' }">
|
||||||
{{ `${$i18n.get('label_all_published_items')}` }}
|
{{ $i18n.get('label_all_published_items') }}
|
||||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${Number(collection.total_items.private) + Number(collection.total_items.publish)})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.private + repositoryTotalItems.publish })` : '' }}</span>
|
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${Number(collection.total_items.private) + Number(collection.total_items.publish)})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.private + repositoryTotalItems.publish })` : '' }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -635,7 +635,7 @@
|
||||||
<span class="icon has-text-gray">
|
<span class="icon has-text-gray">
|
||||||
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-public"/>
|
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-public"/>
|
||||||
</span>
|
</span>
|
||||||
{{ `${$i18n.get('label_publish_items')}` }}
|
{{ $i18n.get('label_publish_items') }}
|
||||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items.publish})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.publish })` : '' }}</span>
|
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items.publish})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.publish })` : '' }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -653,7 +653,7 @@
|
||||||
<span class="icon has-text-gray">
|
<span class="icon has-text-gray">
|
||||||
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-private"/>
|
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-private"/>
|
||||||
</span>
|
</span>
|
||||||
{{ `${$i18n.get('label_private_items')}` }}
|
{{ $i18n.get('label_private_items') }}
|
||||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items.private})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.private })` : '' }}</span>
|
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items.private})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.private })` : '' }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -669,7 +669,7 @@
|
||||||
<span class="icon has-text-gray">
|
<span class="icon has-text-gray">
|
||||||
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-draft"/>
|
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-draft"/>
|
||||||
</span>
|
</span>
|
||||||
{{ `${$i18n.get('label_draft_items')}` }}
|
{{ $i18n.get('label_draft_items') }}
|
||||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items.draft})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.draft })` : '' }}</span>
|
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items.draft})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.draft })` : '' }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -686,7 +686,7 @@
|
||||||
<span class="icon has-text-gray">
|
<span class="icon has-text-gray">
|
||||||
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-delete"/>
|
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-delete"/>
|
||||||
</span>
|
</span>
|
||||||
{{ `${$i18n.get('label_trash_items')}` }}
|
{{ $i18n.get('label_trash_items') }}
|
||||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items.trash})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.trash })` : '' }}</span>
|
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items.trash})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems.trash })` : '' }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -453,6 +453,8 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'instruction_click_or_drag_metadatum_create' => __( 'Click or drag and drop to create a new metadatum', 'tainacan' ),
|
'instruction_click_or_drag_metadatum_create' => __( 'Click or drag and drop to create a new metadatum', 'tainacan' ),
|
||||||
'instruction_drag_and_drop_filter_sort' => __( 'Drag and drop to change filter order', 'tainacan' ),
|
'instruction_drag_and_drop_filter_sort' => __( 'Drag and drop to change filter order', 'tainacan' ),
|
||||||
'instruction_drag_and_drop_metadatum_sort' => __( 'Drag and drop to change metadatum order', 'tainacan' ),
|
'instruction_drag_and_drop_metadatum_sort' => __( 'Drag and drop to change metadatum order', 'tainacan' ),
|
||||||
|
'instruction_select_step_options_to_show' => __( 'Select which Step values to show', 'tainacan' ),
|
||||||
|
'instruction_select_maximum_options_to_show' => __( 'Select which Maximum of options to show', 'tainacan' ),
|
||||||
|
|
||||||
// Info. Other feedback to user.
|
// Info. Other feedback to user.
|
||||||
'info_items_tab_all' => __( 'Every published item of this collection, including those visible only to editors.', 'tainacan' ),
|
'info_items_tab_all' => __( 'Every published item of this collection, including those visible only to editors.', 'tainacan' ),
|
||||||
|
|
|
@ -124,12 +124,12 @@ class Filter extends Entity {
|
||||||
function get_filter_type_object(){
|
function get_filter_type_object(){
|
||||||
$class_name = $this->get_filter_type();
|
$class_name = $this->get_filter_type();
|
||||||
|
|
||||||
if( !class_exists( $class_name ) ){
|
if (empty($class_name)) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$object_type = new $class_name();
|
$object_type = new $class_name();
|
||||||
$object_type->set_options( $this->get_filter_options() );
|
$object_type->set_options( $this->get_filter_type_options() );
|
||||||
return $object_type;
|
return $object_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ class Filter extends Entity {
|
||||||
*
|
*
|
||||||
* @return array Configurations for the filter type object
|
* @return array Configurations for the filter type object
|
||||||
*/
|
*/
|
||||||
function get_filter_options(){
|
function get_filter_type_options(){
|
||||||
return $this->get_mapped_property('filter_type_options');
|
return $this->get_mapped_property('filter_type_options');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +258,18 @@ class Filter extends Entity {
|
||||||
$this->add_error($metadatum, $message);
|
$this->add_error($metadatum, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->add_error('filter_type_options', $is_valid);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Filter type options
|
||||||
|
*
|
||||||
|
* @param [string || integer] $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function set_filter_type_options( $value ){
|
||||||
|
$this->set_mapped_property('filter_type_options', $value);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,11 +5,41 @@ use Tainacan\Metadata_Types;
|
||||||
|
|
||||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TainacanFilterType
|
||||||
|
*/
|
||||||
abstract class Filter_Type {
|
abstract class Filter_Type {
|
||||||
|
|
||||||
private $supported_types = [];
|
private $supported_types = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of options specific to this filter type. Stored in filter_type_options property of the Filter object
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
private $options = [];
|
private $options = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default values for the filter type options array
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $default_options = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the web component used by this filter type
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $component;
|
private $component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the web component used by the Form
|
||||||
|
* @var bool | string
|
||||||
|
*/
|
||||||
|
private $form_component = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The html template featuring a preview of how this metadata type componenet
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $preview_template = '';
|
private $preview_template = '';
|
||||||
protected $use_max_options = true;
|
protected $use_max_options = true;
|
||||||
|
|
||||||
|
@ -74,9 +104,11 @@ abstract class Filter_Type {
|
||||||
|
|
||||||
$attributes['className'] = get_class($this);
|
$attributes['className'] = get_class($this);
|
||||||
$attributes['component'] = $this->get_component();
|
$attributes['component'] = $this->get_component();
|
||||||
|
$attributes['options'] = $this->get_options();
|
||||||
$attributes['supported_types'] = $this->get_supported_types();
|
$attributes['supported_types'] = $this->get_supported_types();
|
||||||
$attributes['preview_template'] = $this->get_preview_template();
|
$attributes['preview_template'] = $this->get_preview_template();
|
||||||
$attributes['use_max_options'] = $this->get_use_max_options();
|
$attributes['use_max_options'] = $this->get_use_max_options();
|
||||||
|
$attributes['form_component'] = $this->get_form_component();
|
||||||
|
|
||||||
return $attributes;
|
return $attributes;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +120,10 @@ abstract class Filter_Type {
|
||||||
$this->options = ( is_array( $options ) ) ? $options : (!is_array(unserialize( $options )) ? [] : unserialize( $options ));
|
$this->options = ( is_array( $options ) ) ? $options : (!is_array(unserialize( $options )) ? [] : unserialize( $options ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function set_default_options(Array $options) {
|
||||||
|
$this->default_options = $options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the options Array
|
* Validates the options Array
|
||||||
*
|
*
|
||||||
|
@ -122,10 +158,12 @@ abstract class Filter_Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* Gets the options for this filter types including default values for options
|
||||||
|
* that were not set yet.
|
||||||
|
* @return array Filter type options
|
||||||
*/
|
*/
|
||||||
public function get_options() {
|
public function get_options() {
|
||||||
return $this->options;
|
return array_merge($this->default_options, $this->options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_use_max_options($use_max_options) {
|
public function set_use_max_options($use_max_options) {
|
||||||
|
@ -135,4 +173,38 @@ abstract class Filter_Type {
|
||||||
public function get_use_max_options() {
|
public function get_use_max_options() {
|
||||||
return $this->use_max_options;
|
return $this->use_max_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets one option from the options array.
|
||||||
|
*
|
||||||
|
* Checks if option exist or if it have a default value. Otherwise return an empty string
|
||||||
|
*
|
||||||
|
* @param string $key the desired option
|
||||||
|
* @return mixed the option value, the default value or an empty string
|
||||||
|
*/
|
||||||
|
public function get_option($key) {
|
||||||
|
$options = $this->get_options();
|
||||||
|
return isset($options[$key]) ? $options[$key] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* allow i18n from messages
|
||||||
|
*/
|
||||||
|
public function get_form_labels(){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_form_component() {
|
||||||
|
return $this->form_component;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $form_component The web component that will render the filter options form
|
||||||
|
*/
|
||||||
|
public function set_form_component($form_component){
|
||||||
|
$this->form_component = $form_component;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,54 +1,102 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- <b-select
|
<b-field :addons="false">
|
||||||
expanded
|
<label class="label is-inline">
|
||||||
:disabled="disabled"
|
{{ $i18n.getHelperTitle('tainacan-filter-numeric', 'step') }}<span> * </span>
|
||||||
:id = "id"
|
<help-button
|
||||||
:placeholder="$i18n.get('label_selectbox_init')"
|
:title="$i18n.getHelperTitle('tainacan-filter-numeric', 'step')"
|
||||||
:value="value"
|
:message="$i18n.getHelperMessage('tainacan-filter-numeric', 'step')"/>
|
||||||
:class="{'is-empty': value == undefined || value == ''}"
|
</label>
|
||||||
@blur="$emit('blur')"
|
<div
|
||||||
@input="onChecked($event)">
|
v-if="!showEditStepOptions"
|
||||||
|
class="is-flex">
|
||||||
|
<b-select
|
||||||
|
name="step_options"
|
||||||
|
v-model="step"
|
||||||
|
@input="onUpdateStep"
|
||||||
|
:placeholder="$i18n.get('instruction_select_step_options_to_show')">
|
||||||
|
<option value="0.001">0.001</option>
|
||||||
|
<option value="0.01">0.01</option>
|
||||||
|
<option value="0.1">0.1</option>
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
<option value="5">5</option>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="100">100</option>
|
||||||
|
<option value="1000">1000</option>
|
||||||
<option
|
<option
|
||||||
v-for="(option, index) in getOptions"
|
v-if="step && ![0.001,0.01,0.1,1,2,5,10,100,1000].find( (element) => element == step )"
|
||||||
:key="index"
|
:value="step">
|
||||||
:label="option"
|
{{ step }}</option>
|
||||||
:value="option"
|
</b-select>
|
||||||
border>{{ option }}</option>
|
<button
|
||||||
</b-select> -->
|
class="button is-white is-pulled-right"
|
||||||
|
:aria-label="$i18n.get('edit')"
|
||||||
|
@click.prevent="showEditStepOptions = true">
|
||||||
|
<span
|
||||||
|
v-tooltip="{
|
||||||
|
content: $i18n.get('edit'),
|
||||||
|
autoHide: true,
|
||||||
|
placement: 'bottom'
|
||||||
|
}"
|
||||||
|
class="icon">
|
||||||
|
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-edit has-text-secondary"/>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="showEditStepOptions"
|
||||||
|
class="is-flex">
|
||||||
|
<b-input
|
||||||
|
name="max_options"
|
||||||
|
v-model="step"
|
||||||
|
@input="onUpdateStep"
|
||||||
|
type="number"
|
||||||
|
step="1" />
|
||||||
|
<button
|
||||||
|
@click.prevent="showEditStepOptions = false"
|
||||||
|
class="button is-white is-pulled-right">
|
||||||
|
<span
|
||||||
|
v-tooltip="{
|
||||||
|
content: $i18n.get('close'),
|
||||||
|
autoHide: true,
|
||||||
|
placement: 'bottom'
|
||||||
|
}"
|
||||||
|
class="icon">
|
||||||
|
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-close has-text-secondary"/>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</b-field>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// props: {
|
props: {
|
||||||
// filter: {
|
filter: {
|
||||||
// type: Object
|
type: Object
|
||||||
// },
|
},
|
||||||
// options: {
|
value: [String, Number, Array],
|
||||||
// type: String
|
id: '',
|
||||||
// },
|
disabled: false,
|
||||||
// value: [String, Number, Array],
|
},
|
||||||
// id: '',
|
data() {
|
||||||
// disabled: false,
|
return {
|
||||||
// },
|
step: [Number, String],
|
||||||
// computed: {
|
showEditStepOptions: false
|
||||||
// getOptions(){
|
}
|
||||||
// if ( this.options && this.options !== '' ){
|
},
|
||||||
// return this.options.split("\n");
|
methods: {
|
||||||
// }
|
onUpdateStep(value) {
|
||||||
// else if ( this.filter && this.filter.filter.metadata_type_options.options ) {
|
this.$emit('input', value);
|
||||||
// const metadata = this.filter.filter.metadata_type_options.options;
|
},
|
||||||
// return ( metadata ) ? metadata.split("\n") : [];
|
},
|
||||||
// }
|
created() {
|
||||||
// return [];
|
if (this.value) {
|
||||||
// }
|
this.step = this.value.step ? this.value.step : 1;
|
||||||
// },
|
}
|
||||||
// methods: {
|
}
|
||||||
// onChecked(value) {
|
|
||||||
// this.$emit('input', value);
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -62,7 +62,7 @@
|
||||||
<b-numberinput
|
<b-numberinput
|
||||||
:aria-labelledby="labelId"
|
:aria-labelledby="labelId"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
step="0.01"
|
:step="step"
|
||||||
@input="emit()"
|
@input="emit()"
|
||||||
v-model="value"/>
|
v-model="value"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,6 +111,7 @@
|
||||||
filter: {
|
filter: {
|
||||||
type: Object // concentrate all attributes metadatum id and type
|
type: Object // concentrate all attributes metadatum id and type
|
||||||
},
|
},
|
||||||
|
step: [Number, String],
|
||||||
metadatum_id: [Number], // not required, but overrides the filter metadatum id if is set
|
metadatum_id: [Number], // not required, but overrides the filter metadatum id if is set
|
||||||
collection_id: [Number], // not required, but overrides the filter metadatum id if is set
|
collection_id: [Number], // not required, but overrides the filter metadatum id if is set
|
||||||
labelId: '',
|
labelId: '',
|
||||||
|
|
|
@ -12,8 +12,11 @@ class Numeric extends Filter_Type {
|
||||||
function __construct(){
|
function __construct(){
|
||||||
$this->set_supported_types(['float']);
|
$this->set_supported_types(['float']);
|
||||||
$this->set_component('tainacan-filter-numeric');
|
$this->set_component('tainacan-filter-numeric');
|
||||||
// $this->set_form_component('tainacan-filter-form-numeric');
|
$this->set_form_component('tainacan-filter-form-numeric');
|
||||||
$this->set_use_max_options(false);
|
$this->set_use_max_options(false);
|
||||||
|
$this->set_default_options([
|
||||||
|
'step' => 1
|
||||||
|
]);
|
||||||
$this->set_preview_template('
|
$this->set_preview_template('
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -66,18 +69,46 @@ class Numeric extends Filter_Type {
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function get_form_labels(){
|
||||||
|
return [
|
||||||
|
'step' => [
|
||||||
|
'title' => __( 'Step', 'tainacan' ),
|
||||||
|
'description' => __( 'The amount to be increased or decreased when clicking on filter control buttons.', 'tainacan' ),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param $filter
|
* @param $filter
|
||||||
* @return string
|
* @return string
|
||||||
* @internal param $metadatum
|
* @internal param $metadatum
|
||||||
*/
|
*/
|
||||||
public function render( $filter ){
|
public function render( $filter ){
|
||||||
$options = $this->get_option('options');
|
|
||||||
return '<tainacan-filter-custom-interval
|
return '<tainacan-filter-numeric
|
||||||
options="' . $options . '"
|
step="' . $this->get_option('step') . '"
|
||||||
name="'.$filter->get_name().'"
|
name="'.$filter->get_name().'"
|
||||||
typeRange="numeric"
|
|
||||||
collection_id="'.$filter->get_collection_id().'"
|
collection_id="'.$filter->get_collection_id().'"
|
||||||
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-custom-interval>';
|
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-custom-interval>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tainacan\Entities\Filter $filter
|
||||||
|
* @return array|bool true if is validate or array if has error
|
||||||
|
*/
|
||||||
|
public function validate_options(\Tainacan\Entities\Filter $filter) {
|
||||||
|
if ( !in_array($filter->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ( empty($this->get_option('step')) ) {
|
||||||
|
return [
|
||||||
|
'step' => __('Required step','tainacan')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -39,7 +39,7 @@ class Filters extends Repository {
|
||||||
'order' => [
|
'order' => [
|
||||||
'map' => 'menu_order',
|
'map' => 'menu_order',
|
||||||
'title' => __( 'Order', 'tainacan' ),
|
'title' => __( 'Order', 'tainacan' ),
|
||||||
'type' => 'string',
|
'type' => 'string/integer',
|
||||||
'description' => __( 'Filter order. This metadata is used if filters were manually ordered.', 'tainacan' ),
|
'description' => __( 'Filter order. This metadata is used if filters were manually ordered.', 'tainacan' ),
|
||||||
'validation' => ''
|
'validation' => ''
|
||||||
],
|
],
|
||||||
|
@ -76,14 +76,14 @@ class Filters extends Repository {
|
||||||
'color' => [
|
'color' => [
|
||||||
'map' => 'meta',
|
'map' => 'meta',
|
||||||
'title' => __( 'Color', 'tainacan' ),
|
'title' => __( 'Color', 'tainacan' ),
|
||||||
'type' => 'integer',
|
'type' => 'integer/string',
|
||||||
'description' => __( 'Filter color', 'tainacan' ),
|
'description' => __( 'Filter color', 'tainacan' ),
|
||||||
'validation' => ''
|
'validation' => ''
|
||||||
],
|
],
|
||||||
'metadatum' => [
|
'metadatum' => [
|
||||||
'map' => 'meta',
|
'map' => 'meta',
|
||||||
'title' => __( 'Metadata', 'tainacan' ),
|
'title' => __( 'Metadata', 'tainacan' ),
|
||||||
'type' => 'integer',
|
'type' => 'array/object/string',
|
||||||
'description' => __( 'Filter metadata', 'tainacan' ),
|
'description' => __( 'Filter metadata', 'tainacan' ),
|
||||||
'validation' => ''
|
'validation' => ''
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue