Merge pull request #895 from tainacan/feature/894
Feature: Add placeholder option to most filters. #894.
This commit is contained in:
commit
5950929dfc
|
@ -72,9 +72,16 @@ class Filter extends Entity {
|
|||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function get_description(){
|
||||
function get_description() {
|
||||
return $this->get_mapped_property('description');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function get_placeholder() {
|
||||
return $this->get_mapped_property('placeholder');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the filter order type
|
||||
|
@ -220,6 +227,16 @@ class Filter extends Entity {
|
|||
$this->set_mapped_property('description', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the filter placeholder
|
||||
*
|
||||
* @param [string] $value
|
||||
* @return void
|
||||
*/
|
||||
function set_placeholder($value) {
|
||||
$this->set_mapped_property('placeholder', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the filter metadatum passing an object
|
||||
*
|
||||
|
|
|
@ -110,7 +110,14 @@ class Filters extends Repository {
|
|||
'description' => __( 'The max number of options to be showed in filter sidebar.', 'tainacan' ),
|
||||
'validation' => '',
|
||||
'default' => 4
|
||||
]
|
||||
],
|
||||
'placeholder' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Placeholder', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The filter input placeholder. This is a simple message that will appear inside textual input and may indicate to the user what kind of information is expected.', 'tainacan' ),
|
||||
'default' => '',
|
||||
],
|
||||
] );
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,24 @@
|
|||
@focus="clearErrors('description')" />
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="form.filter_type_object.use_input_placeholder"
|
||||
:addons="false"
|
||||
:type="formErrors['placeholder'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['placeholder'] != undefined ? formErrors['placeholder'] : ''">
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.getHelperTitle('filters', 'placeholder') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('filters', 'placeholder')"
|
||||
:message="$i18n.getHelperMessage('filters', 'placeholder')"
|
||||
:extra-classes="isRepositoryLevel ? 'tainacan-repository-tooltip' : ''" />
|
||||
</label>
|
||||
<b-input
|
||||
v-model="form.placeholder"
|
||||
name="placeholder"
|
||||
@focus="clearErrors('placeholder')" />
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="formErrors['status'] != undefined ? 'is-danger' : ''"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
:loading="isLoadingOptions"
|
||||
field="label"
|
||||
clearable
|
||||
:placeholder="(metadatumType === 'Tainacan\\Metadata_Types\\Relationship') ? $i18n.get('info_type_to_search_items') : $i18n.get('info_type_to_search_metadata')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : ( (metadatumType === 'Tainacan\\Metadata_Types\\Relationship') ? $i18n.get('info_type_to_search_items') : $i18n.get('info_type_to_search_metadata') )"
|
||||
check-infinite-scroll
|
||||
@update:model-value="($event) => { resetPage(); search($event); }"
|
||||
@select="onSelect"
|
||||
|
|
|
@ -12,6 +12,7 @@ class Checkbox extends Filter_Type {
|
|||
$this->set_name( __('Checkbox List', 'tainacan') );
|
||||
$this->set_supported_types(['string','long_string','item', 'control']);
|
||||
$this->set_component('tainacan-filter-checkbox');
|
||||
$this->set_use_input_placeholder(false);
|
||||
$this->set_preview_template('
|
||||
<div>
|
||||
<div>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<b-datepicker
|
||||
v-model="dateInit"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:placeholder="$i18n.get('instruction_select_a_date')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : $i18n.get('instruction_select_a_date')"
|
||||
editable
|
||||
:trap-focus="false"
|
||||
:date-formatter="(date) => dateFormatter(date)"
|
||||
|
@ -43,7 +43,7 @@
|
|||
<b-datepicker
|
||||
v-model="dateEnd"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:placeholder="$i18n.get('label_selectbox_init')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : $i18n.get('instruction_select_a_date')"
|
||||
editable
|
||||
:trap-focus="false"
|
||||
:date-formatter="(date) => dateFormatter(date)"
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
v-model="value"
|
||||
position="is-bottom-right"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:placeholder="$i18n.get('instruction_select_a_date')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : $i18n.get('instruction_select_a_date')"
|
||||
editable
|
||||
:trap-focus="false"
|
||||
:date-formatter="(date) => dateFormatter(date)"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<b-datepicker
|
||||
v-model="dateInit"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:placeholder="$i18n.get('instruction_select_a_date')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : $i18n.get('instruction_select_a_date')"
|
||||
editable
|
||||
:trap-focus="false"
|
||||
:date-formatter="(date) => dateFormatter(date)"
|
||||
|
@ -45,7 +45,7 @@
|
|||
v-if="filterTypeOptions.accept_date_interval === 'yes'"
|
||||
v-model="dateEnd"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:placeholder="$i18n.get('instruction_select_a_date')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : $i18n.get('instruction_select_a_date')"
|
||||
editable
|
||||
:trap-focus="false"
|
||||
:date-formatter="(date) => dateFormatter(date)"
|
||||
|
|
|
@ -53,8 +53,17 @@ abstract class Filter_Type {
|
|||
* @var string
|
||||
*/
|
||||
private $preview_template = '';
|
||||
|
||||
/**
|
||||
* Defines if the filter type should use the max options
|
||||
*/
|
||||
protected $use_max_options = true;
|
||||
|
||||
/**
|
||||
* Defines if the filter type should provide a placeholder for the input field
|
||||
*/
|
||||
protected $use_input_placeholder = true;
|
||||
|
||||
public function __construct(){
|
||||
add_action('register_filter_types', array(&$this, 'register_filter_type'));
|
||||
}
|
||||
|
@ -126,15 +135,16 @@ abstract class Filter_Type {
|
|||
public function _toArray(){
|
||||
$attributes = [];
|
||||
|
||||
$attributes['className'] = get_class($this);
|
||||
$attributes['name'] = $this->get_name();
|
||||
$attributes['component'] = $this->get_component();
|
||||
$attributes['script'] = $this->get_script();
|
||||
$attributes['options'] = $this->get_options();
|
||||
$attributes['supported_types'] = $this->get_supported_types();
|
||||
$attributes['preview_template'] = $this->get_preview_template();
|
||||
$attributes['use_max_options'] = $this->get_use_max_options();
|
||||
$attributes['form_component'] = $this->get_form_component();
|
||||
$attributes['className'] = get_class($this);
|
||||
$attributes['name'] = $this->get_name();
|
||||
$attributes['component'] = $this->get_component();
|
||||
$attributes['script'] = $this->get_script();
|
||||
$attributes['options'] = $this->get_options();
|
||||
$attributes['supported_types'] = $this->get_supported_types();
|
||||
$attributes['preview_template'] = $this->get_preview_template();
|
||||
$attributes['use_max_options'] = $this->get_use_max_options();
|
||||
$attributes['use_input_placeholder'] = $this->get_use_input_placeholder();
|
||||
$attributes['form_component'] = $this->get_form_component();
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
@ -208,6 +218,14 @@ abstract class Filter_Type {
|
|||
return $this->use_max_options;
|
||||
}
|
||||
|
||||
public function set_use_input_placeholder($use_input_placeholder) {
|
||||
$this->use_input_placeholder = $use_input_placeholder;
|
||||
}
|
||||
|
||||
public function get_use_input_placeholder() {
|
||||
return $this->use_input_placeholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one option from the options array.
|
||||
*
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:aria-minus-label="$i18n.get('label_decrease')"
|
||||
:aria-plus-label="$i18n.get('label_increase')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : ''"
|
||||
size="is-small"
|
||||
:step="filterTypeOptions.step"
|
||||
@update:model-value="($event) => { resetPage(); validadeValues($event) }"
|
||||
|
@ -19,6 +20,7 @@
|
|||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:aria-minus-label="$i18n.get('label_decrease')"
|
||||
:aria-plus-label="$i18n.get('label_increase')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : ''"
|
||||
size="is-small"
|
||||
:step="filterTypeOptions.step"
|
||||
@update:model-value="($event) => { resetPage(); validadeValues($event) }" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<b-select
|
||||
v-model="selectedInterval"
|
||||
expanded
|
||||
:placeholder="$i18n.get('instruction_select_a_interval')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : $i18n.get('instruction_select_a_interval')"
|
||||
@update:model-value="($event) => { resetPage; changeInterval($event) }">
|
||||
<option value="">
|
||||
{{ $i18n.get('label_selectbox_init') }}...
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:aria-minus-label="$i18n.get('label_decrease')"
|
||||
:aria-plus-label="$i18n.get('label_increase')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : ''"
|
||||
size="is-small"
|
||||
:step="Number(filterTypeOptions.step)"
|
||||
@update:model-value="($event) => { resetPage($event); emit($event); }" />
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:aria-minus-label="$i18n.get('label_decrease')"
|
||||
:aria-plus-label="$i18n.get('label_increase')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : ''"
|
||||
size="is-small"
|
||||
:step="filterTypeOptions.step"
|
||||
@update:model-value="($event) => { resetPage(); validadeValues($event) }"
|
||||
|
@ -21,6 +22,7 @@
|
|||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:aria-minus-label="$i18n.get('label_decrease')"
|
||||
:aria-plus-label="$i18n.get('label_increase')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : ''"
|
||||
size="is-small"
|
||||
:step="filterTypeOptions.step"
|
||||
@update:model-value="($event) => { resetPage(); validadeValues($event) }" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
v-if="!isLoadingOptions"
|
||||
:model-value="selected"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:placeholder="$i18n.get('label_selectbox_init')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : $i18n.get('label_selectbox_init')"
|
||||
expanded
|
||||
@update:model-value="($event) => { resetPage(); onSelect($event) }">
|
||||
<option value="">
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
attached
|
||||
:aria-close-label="$i18n.get('remove_value')"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:placeholder="getInputPlaceholder"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : getInputPlaceholder()"
|
||||
check-infinite-scroll
|
||||
@update:model-value="($event) => { resetPage(); onSelect($event) }"
|
||||
@typing="search"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
:aria-close-label="$i18n.get('remove_value')"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:class="{'has-selected': selected != undefined && selected != []}"
|
||||
:placeholder="$i18n.get('info_type_to_add_terms')"
|
||||
:placeholder="filter.placeholder ? filter.placeholder : $i18n.get('info_type_to_add_terms')"
|
||||
check-infinite-scroll
|
||||
@typing="search"
|
||||
@focus="($event) => { searchQuery = $event.target.value; performSearch(searchQuery) }"
|
||||
|
|
|
@ -12,6 +12,7 @@ class TaxonomyCheckbox extends Filter_Type {
|
|||
$this->set_name( __('Taxonomy Checkbox List', 'tainacan') );
|
||||
$this->set_supported_types(['term']);
|
||||
$this->set_component('tainacan-filter-taxonomy-checkbox');
|
||||
$this->set_use_input_placeholder(false);
|
||||
$this->set_preview_template('
|
||||
<div>
|
||||
<div>
|
||||
|
|
|
@ -98,7 +98,7 @@ export const removeMetaQuery = ( state, filter ) => {
|
|||
state.postquery.metaquery[index].value.splice(otherIndex, 1)
|
||||
} else
|
||||
state.postquery.metaquery.splice(index, 1);
|
||||
console.log(filter)
|
||||
|
||||
// Handles removing metaqueries from secondary filter metadata
|
||||
if ( filter.secondaryMetadatumId ) {
|
||||
let secondaryIndex = state.postquery.metaquery.findIndex( item => item.key == filter.secondaryMetadatumId);
|
||||
|
|
Loading…
Reference in New Issue