Merge branch 'develop' into feature/893
This commit is contained in:
commit
ad5210db83
|
@ -20,7 +20,8 @@ class Filter extends Entity {
|
|||
$filter_type,
|
||||
$filter_type_options,
|
||||
$begin_with_filter_collapsed,
|
||||
$display_in_repository_level_lists;
|
||||
$display_in_repository_level_lists,
|
||||
$description_bellow_name;
|
||||
|
||||
static $post_type = 'tainacan-filter';
|
||||
public $enabled_for_collection = true;
|
||||
|
@ -72,9 +73,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
|
||||
|
@ -188,7 +196,15 @@ class Filter extends Entity {
|
|||
public function get_display_in_repository_level_lists() {
|
||||
return $this->get_mapped_property('display_in_repository_level_lists');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the filter description_bellow_name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_description_bellow_name() {
|
||||
return $this->get_mapped_property('description_bellow_name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the filter name
|
||||
|
@ -220,6 +236,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
|
||||
*
|
||||
|
@ -284,6 +310,16 @@ class Filter extends Entity {
|
|||
$this->enabled_for_collection = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set filter description_bellow_name
|
||||
*
|
||||
* @param [string] $value If the description will be displayed below the name instead of inside a tooltip (yes/no)
|
||||
* @return void
|
||||
*/
|
||||
function set_description_bellow_name($value) {
|
||||
$this->set_mapped_property('description_bellow_name', $value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
|
|
|
@ -110,7 +110,24 @@ 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' => '',
|
||||
],
|
||||
'description_bellow_name' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Description below name', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'Whether the filter description should be displayed below the input label instead of inside a tooltip.', 'tainacan' ),
|
||||
'on_error' => __( 'Please set the "Description below name" value as "yes" or "no"', 'tainacan' ),
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
|
||||
'enum' => [ 'yes', 'no' ],
|
||||
'default' => 'no'
|
||||
],
|
||||
] );
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,45 @@
|
|||
@focus="clearErrors('description')" />
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.getHelperTitle('filters', 'description_bellow_name')"
|
||||
:type="formErrors['description_bellow_name'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['description_bellow_name'] != undefined ? formErrors['description_bellow_name'] : ''">
|
||||
|
||||
<b-switch
|
||||
v-model="form.description_bellow_name"
|
||||
size="is-small"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
:native-value="form.description_bellow_name == 'yes' ? 'yes' : 'no'"
|
||||
name="description_bellow_name"
|
||||
@update:model-value="clearErrors('description_bellow_name')">
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('filters', 'description_bellow_name')"
|
||||
:message="$i18n.getHelperMessage('filters', 'description_bellow_name')"
|
||||
:extra-classes="isRepositoryLevel ? 'tainacan-repository-tooltip' : ''" />
|
||||
</b-switch>
|
||||
</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' : ''"
|
||||
|
@ -292,12 +331,16 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
|
||||
this.form = this.editedFilter;
|
||||
this.formErrors = this.form.formErrors != undefined ? this.form.formErrors : {};
|
||||
this.formErrorMessage = this.form.formErrors != undefined ? this.form.formErrorMessage : '';
|
||||
|
||||
this.oldForm = JSON.parse(JSON.stringify(this.originalFilter));
|
||||
|
||||
if ( this.form.metadatum == undefined && this.oldForm.metadatum != undefined )
|
||||
this.form.metadatum = this.oldForm.metadatum;
|
||||
|
||||
},
|
||||
mounted() {
|
||||
// Fills hook forms with it's real values
|
||||
|
@ -322,18 +365,22 @@ export default {
|
|||
'updateFilter'
|
||||
]),
|
||||
saveEdition(filter) {
|
||||
|
||||
this.isLoading = true;
|
||||
|
||||
if ((filter.filter_type_object && filter.filter_type_object.form_component) || filter.edit_form == '') {
|
||||
|
||||
this.isLoading = true;
|
||||
|
||||
for (let [key, value] of Object.entries(this.form)) {
|
||||
if (key === 'begin_with_filter_collapsed' || key === 'display_in_repository_level_lists')
|
||||
if (key === 'begin_with_filter_collapsed' || key === 'display_in_repository_level_lists' || key === 'description_bellow_name' )
|
||||
this.form[key] = (value == 'yes' || value == true) ? 'yes' : 'no';
|
||||
}
|
||||
if (this.form['begin_with_filter_collapsed'] === undefined)
|
||||
this.form['begin_with_filter_collapsed'] = 'no';
|
||||
if (this.form['display_in_repository_level_lists'] === undefined)
|
||||
this.form['display_in_repository_level_lists'] = 'no';
|
||||
|
||||
if (this.form['description_bellow_name'] === undefined)
|
||||
this.form['description_bellow_name'] = 'no';
|
||||
|
||||
this.updateFilter({ filterId: filter.id, index: this.index, options: this.form })
|
||||
.then(() => {
|
||||
this.form = {};
|
||||
|
@ -361,7 +408,7 @@ export default {
|
|||
let formObj = {};
|
||||
|
||||
for (let [key, value] of formData.entries()) {
|
||||
if (key === 'begin_with_filter_collapsed' || key === 'display_in_repository_level_lists')
|
||||
if (key === 'begin_with_filter_collapsed' || key === 'display_in_repository_level_lists' || key === 'description_bellow_name' )
|
||||
formObj[key] = (value == 'yes' || value == true) ? 'yes' : 'no';
|
||||
else
|
||||
formObj[key] = value;
|
||||
|
@ -370,9 +417,10 @@ export default {
|
|||
formObj['begin_with_filter_collapsed'] = 'no';
|
||||
if (formObj['display_in_repository_level_lists'] === undefined)
|
||||
formObj['display_in_repository_level_lists'] = 'no';
|
||||
if (formObj['description_bellow_name'] === undefined)
|
||||
formObj['description_bellow_name'] = 'no';
|
||||
|
||||
this.fillExtraFormData(formObj);
|
||||
this.isLoading = true;
|
||||
this.updateFilter({ filterId: filter.id, index: this.index, options: formObj })
|
||||
.then(() => {
|
||||
this.form = {};
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -19,10 +19,14 @@
|
|||
@input="resetPage()">
|
||||
<span class="check" />
|
||||
<span class="control-label">
|
||||
<span class="checkbox-label-text">{{ option.label }}</span>
|
||||
<span
|
||||
:title="option.name"
|
||||
class="checkbox-label-text">
|
||||
{{ option.label }}
|
||||
</span>
|
||||
<span
|
||||
v-if="option.total_items != undefined"
|
||||
class="has-text-gray"> {{ "(" + option.total_items + ")" }}</span>
|
||||
class="facet-item-count has-text-gray"> {{ "(" + option.total_items + ")" }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<button
|
||||
|
@ -242,12 +246,26 @@
|
|||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
width: 100%;
|
||||
align-items: baseline;
|
||||
}
|
||||
.checkbox-label-text {
|
||||
white-space: nowrap;
|
||||
white-space: wrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
line-height: 1.45em;
|
||||
break-inside: avoid;
|
||||
display: -webkit-box;
|
||||
line-clamp: 2;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.facet-item-count {
|
||||
margin-left: auto;
|
||||
}
|
||||
.b-checkbox:hover .facet-item-count,
|
||||
.b-checkbox:focus .facet-item-count {
|
||||
--tainacan-info-color: var(--tainacan-input-color);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -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)"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
{{ $i18n.get('instruction_select_second_date_to_compare' ) }}
|
||||
</option>
|
||||
<option
|
||||
v-for="option in metadata.filter(aMetadatum => aMetadatum.id != filter.metadatumId )"
|
||||
v-for="option in metadata.filter(aMetadatum => aMetadatum.id != filter.metadatum_id )"
|
||||
:key="option.id"
|
||||
:value="option.id">
|
||||
{{ option.name }}
|
||||
|
|
|
@ -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)"
|
||||
|
@ -185,10 +185,15 @@
|
|||
let dateInit = this.dateInit.getUTCFullYear() + '-' +
|
||||
('00' + (this.dateInit.getUTCMonth() + 1)).slice(-2) + '-' +
|
||||
('00' + this.dateInit.getUTCDate()).slice(-2);
|
||||
let dateEnd = this.dateEnd.getUTCFullYear() + '-' +
|
||||
('00' + (this.dateEnd.getUTCMonth() + 1)).slice(-2) + '-' +
|
||||
('00' + this.dateEnd.getUTCDate()).slice(-2);
|
||||
values = [ dateInit, dateEnd ];
|
||||
|
||||
if ( this.dateEnd !== null ) {
|
||||
let dateEnd = this.dateEnd.getUTCFullYear() + '-' +
|
||||
('00' + (this.dateEnd.getUTCMonth() + 1)).slice(-2) + '-' +
|
||||
('00' + this.dateEnd.getUTCDate()).slice(-2);
|
||||
values = [ dateInit, dateEnd ];
|
||||
} else {
|
||||
values = [ dateInit ];
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.filterTypeOptions.accept_date_interval !== 'yes' ) {
|
||||
|
|
|
@ -116,6 +116,13 @@ class Dates_Intersection_Interval_Helper {
|
|||
) {
|
||||
$filter_arguments['label'] = $filter_arguments['label'][0] . ' - ' . $filter_arguments['label'][1];
|
||||
}
|
||||
if (
|
||||
isset( $filter_arguments['filter'] ) &&
|
||||
isset( $filter_arguments['filter']['metadatum'] ) &&
|
||||
isset( $filter_arguments['filter']['metadatum']['metadatum_name'] )
|
||||
) {
|
||||
$filter_arguments['filter']['name'] = $filter_arguments['filter']['metadatum']['metadatum_name'];
|
||||
}
|
||||
if (
|
||||
isset( $filter_arguments['filter'] ) &&
|
||||
isset( $filter_arguments['filter']['filter_type_options'] ) &&
|
||||
|
|
|
@ -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); }" />
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
{{ $i18n.get('instruction_select_second_numeric_to_compare' ) }}
|
||||
</option>
|
||||
<option
|
||||
v-for="option in metadata.filter(aMetadatum => aMetadatum.id != filter.metadatumId )"
|
||||
v-for="option in metadata.filter(aMetadatum => aMetadatum.id != filter.metadatum_id )"
|
||||
:key="option.id"
|
||||
:value="option.id">
|
||||
{{ option.name }}
|
||||
|
|
|
@ -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) }" />
|
||||
|
@ -101,7 +103,7 @@
|
|||
compare: this.filterTypeOptions.first_comparator,
|
||||
metadatum_id: this.metadatumId,
|
||||
collection_id: this.collectionId,
|
||||
value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
|
||||
value: values[0]
|
||||
});
|
||||
this.$emit('input', {
|
||||
filter: 'intersection',
|
||||
|
@ -109,7 +111,8 @@
|
|||
compare: this.filterTypeOptions.second_comparator,
|
||||
metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
|
||||
collection_id: this.collectionId,
|
||||
value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
|
||||
value: values[0],
|
||||
secondary: true
|
||||
});
|
||||
} else {
|
||||
// Much more complicated logic to be implemented in the future. See #889
|
||||
|
|
|
@ -127,6 +127,13 @@ class Numerics_Intersection_Interval_Helper {
|
|||
) {
|
||||
$filter_arguments['label'] = $filter_arguments['label'][0] . ' - ' . $filter_arguments['label'][1];
|
||||
}
|
||||
if (
|
||||
isset( $filter_arguments['filter'] ) &&
|
||||
isset( $filter_arguments['filter']['metadatum'] ) &&
|
||||
isset( $filter_arguments['filter']['metadatum']['metadatum_name'] )
|
||||
) {
|
||||
$filter_arguments['filter']['name'] = $filter_arguments['filter']['metadatum']['metadatum_name'];
|
||||
}
|
||||
if (
|
||||
isset( $filter_arguments['filter'] ) &&
|
||||
isset( $filter_arguments['filter']['filter_type_options'] ) &&
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -13,17 +13,6 @@
|
|||
<template #trigger="props">
|
||||
<button
|
||||
:id="'filter-label-id-' + filter.id"
|
||||
v-tooltip="{
|
||||
delay: {
|
||||
shown: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: filter.name,
|
||||
html: false,
|
||||
autoHide: false,
|
||||
placement: 'top-start',
|
||||
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : '']
|
||||
}"
|
||||
:for="'filter-input-id-' + filter.id"
|
||||
:aria-controls="'filter-input-id-' + filter.id"
|
||||
:aria-expanded="singleCollapseOpen"
|
||||
|
@ -37,10 +26,22 @@
|
|||
}"
|
||||
class="tainacan-icon tainacan-icon-1-25em" />
|
||||
</span>
|
||||
<span class="collapse-label">{{ filter.name }}</span>
|
||||
<span
|
||||
class="collapse-label">
|
||||
{{ filter.name }}
|
||||
</span>
|
||||
<help-button
|
||||
v-if="filter.description_bellow_name !== 'yes' && filter.description"
|
||||
:title="filter.name"
|
||||
:message="filter.description" />
|
||||
</button>
|
||||
</template>
|
||||
<div :id="'filter-input-id-' + filter.id">
|
||||
<p
|
||||
v-if="filter.description_bellow_name === 'yes' && filter.description"
|
||||
class="filter-description-help-info">
|
||||
{{ filter.description }}
|
||||
</p>
|
||||
<component
|
||||
:is="filter.filter_type_object ? filter.filter_type_object.component : null"
|
||||
:filter="filter"
|
||||
|
@ -59,18 +60,6 @@
|
|||
class="collapse show disabled-filter">
|
||||
<div class="collapse-trigger">
|
||||
<button
|
||||
|
||||
v-tooltip="{
|
||||
delay: {
|
||||
shown: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: $i18n.get('instruction_click_to_load_filter'),
|
||||
html: false,
|
||||
autoHide: false,
|
||||
placement: 'top-start',
|
||||
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : '']
|
||||
}"
|
||||
:for="'filter-input-id-' + filter.id"
|
||||
:aria-controls="'filter-input-id-' + filter.id"
|
||||
class="label"
|
||||
|
@ -78,7 +67,25 @@
|
|||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-1-25em" />
|
||||
</span>
|
||||
<span class="collapse-label">{{ filter.name }}</span>
|
||||
<span
|
||||
v-tooltip="{
|
||||
delay: {
|
||||
shown: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: $i18n.get('instruction_click_to_load_filter'),
|
||||
html: false,
|
||||
autoHide: false,
|
||||
placement: 'top-start',
|
||||
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : '']
|
||||
}"
|
||||
class="collapse-label">
|
||||
{{ filter.name }}
|
||||
</span>
|
||||
<help-button
|
||||
v-if="filter.description_bellow_name !== 'yes' && filter.description"
|
||||
:title="filter.name"
|
||||
:message="filter.description" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -218,6 +225,15 @@
|
|||
outline: none;
|
||||
padding: 0 !important;
|
||||
margin: 0;
|
||||
|
||||
.tainacan-help-tooltip-trigger {
|
||||
font-size: 1.188em;
|
||||
|
||||
.icon {
|
||||
margin-right: 0px;
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,6 +243,13 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.filter-description-help-info {
|
||||
font-size: 0.75em;
|
||||
color: var(--tainacan-info-color);
|
||||
margin-top: -0.25em;
|
||||
margin-bottom: 0.75em;
|
||||
}
|
||||
|
||||
.taginput-container {
|
||||
border-radius: var(--tainacan-input-border-radius, 1px) !important;
|
||||
box-shadow: none !important;
|
||||
|
|
|
@ -20,10 +20,14 @@
|
|||
@input="resetPage">
|
||||
<span class="check" />
|
||||
<span class="control-label">
|
||||
<span class="checkbox-label-text">{{ option.label }}</span>
|
||||
<span
|
||||
:title="option.label"
|
||||
class="checkbox-label-text">
|
||||
{{ option.label }}
|
||||
</span>
|
||||
<span
|
||||
v-if="option.total_items != undefined"
|
||||
class="has-text-gray"> {{ "(" + option.total_items + ")" }}</span>
|
||||
class="facet-item-count has-text-gray"> {{ "(" + option.total_items + ")" }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<button
|
||||
|
@ -328,12 +332,27 @@
|
|||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
width: 100%;
|
||||
align-items: baseline;
|
||||
}
|
||||
.checkbox-label-text {
|
||||
white-space: nowrap;
|
||||
white-space: wrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
line-height: 1.45em;
|
||||
break-inside: avoid;
|
||||
display: -webkit-box;
|
||||
line-clamp: 2;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.facet-item-count {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.b-checkbox:hover .facet-item-count,
|
||||
.b-checkbox:focus .facet-item-count {
|
||||
--tainacan-info-color: var(--tainacan-input-color);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -30,8 +30,8 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
getHelperTooltipContent() {
|
||||
return `<h5>` + this.title + `</h5>
|
||||
<p>` + ((this.message != '' && this.message != undefined) ? this.message : this.$i18n.get('info_no_description_provided')) + `</p>`;
|
||||
return ( this.title ? ( `<p style="font-weight: bold">` + this.title + `</p>` ) : '' ) +
|
||||
`<p>` + ((this.message != '' && this.message != undefined) ? this.message : this.$i18n.get('info_no_description_provided')) + `</p>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ export default {
|
|||
|
||||
<style lang="scss">
|
||||
|
||||
.tainacan-help-tooltip-trigger>a .icon {
|
||||
.tainacan-help-tooltip-trigger > a .icon {
|
||||
i, i::before { font-size: 0.875em !important }
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,8 @@
|
|||
taxonomy: tag.taxonomy,
|
||||
metadatumName: this.getMetadatumName(tag),
|
||||
metadatumId: tag.metadatumId,
|
||||
argType: tag.argType
|
||||
argType: tag.argType,
|
||||
secondaryMetadatumId: tag.secondaryMetadatumId
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
@ -124,11 +125,12 @@
|
|||
taxonomy: tag.taxonomy,
|
||||
metadatumName: this.getMetadatumName(tag),
|
||||
metadatumId: tag.metadatumId,
|
||||
argType: tag.argType
|
||||
argType: tag.argType,
|
||||
secondaryMetadatumId: tag.secondaryMetadatumId
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return flattenTags;
|
||||
}
|
||||
},
|
||||
|
@ -168,7 +170,7 @@
|
|||
...mapGetters('search',[
|
||||
'getFilterTags'
|
||||
]),
|
||||
removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId, metadatumName, argType }) {
|
||||
removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId, metadatumName, argType, secondaryMetadatumId }) {
|
||||
this.$eventBusSearch.resetPageOnStore();
|
||||
this.$eventBusSearch.removeMetaFromFilterTag({
|
||||
filterId: filterId,
|
||||
|
@ -178,7 +180,8 @@
|
|||
taxonomy: taxonomy,
|
||||
metadatumId: metadatumId,
|
||||
metadatumName:metadatumName,
|
||||
argType: argType
|
||||
argType: argType,
|
||||
secondaryMetadatumId: secondaryMetadatumId
|
||||
});
|
||||
},
|
||||
clearAllFilters() {
|
||||
|
|
|
@ -29,7 +29,7 @@ export default {
|
|||
this.updateURLQueries();
|
||||
},
|
||||
removeMetaFromFilterTag(filterTag) {
|
||||
|
||||
|
||||
if (filterTag.singleLabel != undefined || filterTag.label != undefined) {
|
||||
|
||||
if (filterTag.argType !== 'postin') {
|
||||
|
@ -39,7 +39,8 @@ export default {
|
|||
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
|
||||
isMultiValue: filterTag.singleLabel ? false : true,
|
||||
taxonomy: filterTag.taxonomy,
|
||||
value: filterTag.value
|
||||
value: filterTag.value,
|
||||
secondaryMetadatumId: filterTag.secondaryMetadatumId
|
||||
});
|
||||
} else {
|
||||
app.config.globalProperties.$store.dispatch('search/removeMetaQuery', {
|
||||
|
@ -47,7 +48,8 @@ export default {
|
|||
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
|
||||
isMultiValue: filterTag.singleLabel ? false : true,
|
||||
metadatum_id: filterTag.metadatumId,
|
||||
value: filterTag.value
|
||||
value: filterTag.value,
|
||||
secondaryMetadatumId: filterTag.secondaryMetadatumId
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -91,13 +91,27 @@ export const removeMetaQuery = ( state, filter ) => {
|
|||
|
||||
let index = state.postquery.metaquery.findIndex( item => item.key == filter.metadatum_id);
|
||||
|
||||
if (index >= 0) {
|
||||
if ( index >= 0 ) {
|
||||
if (!filter.isMultiValue && Array.isArray(state.postquery.metaquery[index].value) && state.postquery.metaquery[index].value.length > 1) {
|
||||
let otherIndex = state.postquery.metaquery[index].value.findIndex(item => item == filter.value);
|
||||
if (otherIndex >= 0)
|
||||
if ( otherIndex >= 0 )
|
||||
state.postquery.metaquery[index].value.splice(otherIndex, 1)
|
||||
} else
|
||||
state.postquery.metaquery.splice(index, 1);
|
||||
|
||||
// Handles removing metaqueries from secondary filter metadata
|
||||
if ( filter.secondaryMetadatumId ) {
|
||||
let secondaryIndex = state.postquery.metaquery.findIndex( item => item.key == filter.secondaryMetadatumId);
|
||||
|
||||
if ( secondaryIndex >= 0 ) {
|
||||
if ( !filter.isMultiValue && Array.isArray(state.postquery.metaquery[secondaryIndex].value) && state.postquery.metaquery[secondaryIndex].value.length > 1 ) {
|
||||
let otherSecondaryIndex = state.postquery.metaquery[secondaryIndex].value.findIndex(item => item == filter.value);
|
||||
if ( otherSecondaryIndex >= 0 )
|
||||
state.postquery.metaquery[secondaryIndex].value.splice(otherSecondaryIndex, 1)
|
||||
} else
|
||||
state.postquery.metaquery.splice(secondaryIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -188,7 +202,8 @@ export const setFilterTags = ( state, filterArguments ) => {
|
|||
) ? aFilterArgument.metadatum.metadata_type_object.options.taxonomy : '',
|
||||
argType: aFilterArgument.arg_type ? aFilterArgument.arg_type : '',
|
||||
metadatumId: (aFilterArgument.filter && aFilterArgument.metadatum.metadatum_id) ? aFilterArgument.metadatum.metadatum_id : (aFilterArgument.metadatum.id || ''),
|
||||
metadatumName: (aFilterArgument.filter && aFilterArgument.filter.name) ? aFilterArgument.filter.name : (aFilterArgument.metadatum.name || '')
|
||||
metadatumName: (aFilterArgument.filter && aFilterArgument.filter.name) ? aFilterArgument.filter.name : (aFilterArgument.metadatum.name || ''),
|
||||
secondaryMetadatumId: (aFilterArgument.filter && aFilterArgument.filter.filter_type_options && aFilterArgument.filter.filter_type_options.secondary_filter_metadatum_id) ? aFilterArgument.filter.filter_type_options.secondary_filter_metadatum_id : '',
|
||||
}
|
||||
});
|
||||
state.filter_tags = filterTags;
|
||||
|
|
|
@ -32,6 +32,7 @@ import ThemeSearch from './theme.vue';
|
|||
|
||||
// Remaining imports
|
||||
import store from '../../../admin/js/store/store';
|
||||
import HelpButton from '../../../admin/components/other/help-button.vue';
|
||||
import routerTheme from './theme-search/js/theme-router.js';
|
||||
import eventBusSearch from '../../../admin/js/event-bus-search';
|
||||
import {
|
||||
|
@ -191,6 +192,7 @@ export default (element) => {
|
|||
VueItemsList.use(AxiosErrorHandlerPlugin);
|
||||
VueItemsList.use(ConsolePlugin, {visual: false});
|
||||
VueItemsList.use(AdminOptionsHelperPlugin, blockElement.dataset['options']);
|
||||
VueItemsList.component('help-button', HelpButton);
|
||||
|
||||
/* Registers Extra Vue Components passed to the window.tainacan_extra_components */
|
||||
if (typeof window.tainacan_extra_components != "undefined") {
|
||||
|
|
|
@ -7,6 +7,7 @@ import iconUrl from 'leaflet/dist/images/marker-icon.png';
|
|||
import iconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png';
|
||||
import shadowUrl from 'leaflet/dist/images/marker-shadow.png';
|
||||
|
||||
// Defines custom marker icons
|
||||
delete TainacanLeaflet.Icon.Default.prototype._getIconUrl;
|
||||
TainacanLeaflet.Icon.Default.mergeOptions({
|
||||
iconRetinaUrl: iconRetinaUrl,
|
||||
|
@ -14,6 +15,48 @@ TainacanLeaflet.Icon.Default.mergeOptions({
|
|||
shadowUrl: shadowUrl
|
||||
});
|
||||
|
||||
// Observes the visibility of the map container to resize the map when it becomes visible
|
||||
const mapObserverOptions = {
|
||||
root: null, // use the viewport
|
||||
rootMargin: '0px',
|
||||
threshold: 0.1 // 10% of the element is visible
|
||||
};
|
||||
|
||||
// The mapObserver repeats part of the initialization logic to prevent the map from looking broke
|
||||
// when it becomes visible after being hidden, for example inside section tabs
|
||||
const mapObserver = new IntersectionObserver((entries, observer) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
if (
|
||||
entry &&
|
||||
entry.target.id &&
|
||||
window.tainacan_leaflet_maps &&
|
||||
window.tainacan_leaflet_maps[entry.target.id]
|
||||
) {
|
||||
const element = entry.target;
|
||||
|
||||
const children = element.children ? element.children : [];
|
||||
if ( !children.length )
|
||||
return;
|
||||
|
||||
const coordinates = [];
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
if ( children[i].hasAttribute('data-latitude') && children[i].hasAttribute('data-longitude') )
|
||||
coordinates.push([children[i].getAttribute('data-latitude'), children[i].getAttribute('data-longitude')]);
|
||||
}
|
||||
|
||||
if ( !coordinates.length )
|
||||
return;
|
||||
|
||||
const maximum_zoom = element.hasAttribute('data-maximum_zoom') ? element.getAttribute('data-maximum_zoom') : 12;
|
||||
|
||||
window.tainacan_leaflet_maps[element.id].invalidateSize(true);
|
||||
window.tainacan_leaflet_maps[element.id].flyToBounds(coordinates, { maxZoom: maximum_zoom, animate: false });
|
||||
}
|
||||
}
|
||||
});
|
||||
}, mapObserverOptions);
|
||||
|
||||
/* Loads and instantiates map components passed to data-module="geocoordinate-item-metadatum"*/
|
||||
export default (element) => {
|
||||
if (element && element.id) {
|
||||
|
@ -54,7 +97,13 @@ export default (element) => {
|
|||
coordinates.forEach(coordinate => {
|
||||
TainacanLeaflet.marker(coordinate).addTo(tainacanMap);
|
||||
});
|
||||
|
||||
|
||||
tainacanMap.flyToBounds(coordinates, { maxZoom: maximum_zoom });
|
||||
|
||||
mapObserver.observe(element);
|
||||
|
||||
// Stores referenced to the leaflet instances to manipulate them via the window object inside the observer
|
||||
window.tainacan_leaflet_maps = typeof window.tainacan_leaflet_maps != "undefined" ? window.tainacan_leaflet_maps : {};
|
||||
window.tainacan_leaflet_maps[element.id] = tainacanMap;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue