Init of filter modal with checkbox (issue #83)
This commit is contained in:
parent
38cbf77d65
commit
37f3501c4b
|
@ -2934,6 +2934,11 @@
|
|||
"esutils": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"dom-walk": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz",
|
||||
"integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg="
|
||||
},
|
||||
"domain-browser": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
|
||||
|
@ -3871,6 +3876,24 @@
|
|||
"pinkie-promise": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"finderjs": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/finderjs/-/finderjs-1.2.1.tgz",
|
||||
"integrity": "sha512-xzGJHGDELnut+4z44Y0gS/6QIEFIJ3LQVjOsVj8SpoMgKp4Da/TvBOxavUnPd6Ypo76HVxrZyxBaVPT7LDEHXA==",
|
||||
"requires": {
|
||||
"eventemitter3": "^2.0.3",
|
||||
"global": "^4.3.0",
|
||||
"x-is-array": "^0.1.0",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"eventemitter3": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz",
|
||||
"integrity": "sha1-teEHm1n7XhuidxwKmTvgYKWMmbo="
|
||||
}
|
||||
}
|
||||
},
|
||||
"flat-cache": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz",
|
||||
|
@ -4692,6 +4715,22 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"global": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz",
|
||||
"integrity": "sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=",
|
||||
"requires": {
|
||||
"min-document": "^2.19.0",
|
||||
"process": "~0.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"process": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz",
|
||||
"integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8="
|
||||
}
|
||||
}
|
||||
},
|
||||
"global-dirs": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz",
|
||||
|
@ -6240,6 +6279,14 @@
|
|||
"integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=",
|
||||
"dev": true
|
||||
},
|
||||
"min-document": {
|
||||
"version": "2.19.0",
|
||||
"resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz",
|
||||
"integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=",
|
||||
"requires": {
|
||||
"dom-walk": "^0.1.0"
|
||||
}
|
||||
},
|
||||
"minimalistic-assert": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
|
||||
|
@ -9989,6 +10036,11 @@
|
|||
"mkdirp": "^0.5.1"
|
||||
}
|
||||
},
|
||||
"x-is-array": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/x-is-array/-/x-is-array-0.1.0.tgz",
|
||||
"integrity": "sha1-3lIBcdR7P0FvVYfWKbidJrEtwp0="
|
||||
},
|
||||
"xregexp": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.0.0.tgz",
|
||||
|
@ -9998,8 +10050,7 @@
|
|||
"xtend": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=",
|
||||
"dev": true
|
||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
|
||||
},
|
||||
"y18n": {
|
||||
"version": "3.2.1",
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"axios": "^0.18.0",
|
||||
"buefy": "^0.6.6",
|
||||
"bulma": "^0.7.1",
|
||||
"finderjs": "^1.2.1",
|
||||
"mdi": "^2.2.43",
|
||||
"moment": "^2.22.2",
|
||||
"qs": "^6.5.2",
|
||||
|
|
|
@ -72,6 +72,57 @@
|
|||
</div>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
v-if="editForm.filter_type_object && editForm.filter_type_object.component.includes('checkbox')">
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.get('label_max_options_to_show') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('filters', 'max_options')"
|
||||
:message="$i18n.getHelperMessage('filters', 'max_options')"/>
|
||||
</label>
|
||||
|
||||
<div
|
||||
v-if="!showEditMaxOptions"
|
||||
class="is-flex">
|
||||
<b-select
|
||||
name="max_options"
|
||||
v-model="editForm.max_options"
|
||||
:placeholder="$i18n.get('instruction_select_max_options_to_show')">
|
||||
<option value="4">4</option>
|
||||
<option value="7">7</option>
|
||||
<option value="10">10</option>
|
||||
<option value="17">17</option>
|
||||
</b-select>
|
||||
<button
|
||||
class="button is-white is-pulled-right"
|
||||
:aria-label="$i18n.getFrom('items','edit_item')"
|
||||
@click.prevent="showEditMaxOptions = true">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
type="is-secondary"
|
||||
icon="pencil"/>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="showEditMaxOptions"
|
||||
class="is-flex">
|
||||
<b-input
|
||||
name="max_options"
|
||||
v-model="editForm.max_options"
|
||||
type="number"
|
||||
step="1" />
|
||||
<button
|
||||
@click.prevent="showEditMaxOptions = false"
|
||||
class="button is-white is-pulled-right">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
type="is-secondary"
|
||||
icon="close"/>
|
||||
</button>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
<component
|
||||
:errors="formErrors['filter_type_options']"
|
||||
v-if="(editForm.filter_type_object && editForm.filter_type_object.form_component) || editForm.edit_form == ''"
|
||||
|
@ -111,7 +162,8 @@ export default {
|
|||
oldForm: {},
|
||||
formErrors: {},
|
||||
formErrorMessage: '',
|
||||
closedByForm: false
|
||||
closedByForm: false,
|
||||
showEditMaxOptions: false,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -168,11 +220,12 @@ export default {
|
|||
} else {
|
||||
let formElement = document.getElementById('filterEditForm');
|
||||
let formData = new FormData(formElement);
|
||||
let formObj = {}
|
||||
let formObj = {};
|
||||
|
||||
for (let [key, value] of formData.entries())
|
||||
for (let [key, value] of formData.entries()) {
|
||||
formObj[key] = value;
|
||||
|
||||
}
|
||||
|
||||
this.updateFilter({ filterId: filter.id, index: this.index, options: formObj})
|
||||
.then(() => {
|
||||
this.editForm = {};
|
||||
|
|
|
@ -416,9 +416,9 @@
|
|||
class="button is-outlined">{{ $i18n.get('label_send_to_trash') }}</button>
|
||||
<button
|
||||
v-if="form.status == 'auto-draft'"
|
||||
@click="onDiscart()"
|
||||
@click="onDiscard()"
|
||||
type="button"
|
||||
class="button is-outlined">{{ $i18n.get('label_discart') }}</button>
|
||||
class="button is-outlined">{{ $i18n.get('label_discard') }}</button>
|
||||
<button
|
||||
@click="onSubmit('draft')"
|
||||
type="button"
|
||||
|
@ -581,7 +581,7 @@ export default {
|
|||
this.isLoading = false;
|
||||
});
|
||||
},
|
||||
onDiscart() {
|
||||
onDiscard() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
createNewItem() {
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
</span>
|
||||
<span
|
||||
v-tooltip="{
|
||||
content: $i18n.get('label_process_conpleted'),
|
||||
content: $i18n.get('label_process_completed'),
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
}"
|
||||
|
|
|
@ -1,38 +1,105 @@
|
|||
<template>
|
||||
<form action="">
|
||||
<div
|
||||
class="tainacan-modal-content"
|
||||
<div
|
||||
class="tainacan-modal-content"
|
||||
style="width: auto">
|
||||
<header class="tainacan-modal-title">
|
||||
<h2>{{ this.$i18n.get('filter') }} <em>{{ title }}</em></h2>
|
||||
<h2>{{ this.$i18n.get('filter') }} <em>{{ filter.name }}</em></h2>
|
||||
<hr>
|
||||
</header>
|
||||
<section class="tainacan-form">
|
||||
|
||||
<section
|
||||
id="filter-modal-checkbox-body"
|
||||
class="modal-card-body">
|
||||
<ul>
|
||||
<li
|
||||
v-for="(optionLevel0, index) in optionsLevel0"
|
||||
:key="index">
|
||||
<b-checkbox
|
||||
v-model="selected"
|
||||
:native-value="optionLevel0.id"
|
||||
>{{ optionLevel0.name }}
|
||||
</b-checkbox>
|
||||
</li>
|
||||
</ul>
|
||||
<pre>{{ selected }}</pre>
|
||||
</section>
|
||||
|
||||
<footer class="field is-grouped form-submit">
|
||||
<div class="control">
|
||||
<button
|
||||
class="button is-outlined"
|
||||
type="button"
|
||||
@click="$parent.close()">Close</button>
|
||||
<button
|
||||
class="button is-outlined"
|
||||
type="button"
|
||||
@click="$parent.close()">{{ $i18n.get('cancel') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-success">Login</button>
|
||||
<button
|
||||
@click="applyFilter"
|
||||
class="button is-success">{{ $i18n.get('apply') }}</button>
|
||||
</div>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'CheckboxFilterModal',
|
||||
props: {
|
||||
title: ''
|
||||
|
||||
import finder from 'finderjs/index.js';
|
||||
|
||||
export default {
|
||||
name: 'CheckboxFilterModal',
|
||||
props: {
|
||||
filter: '',
|
||||
parent: Number,
|
||||
taxonomy_id: Number,
|
||||
taxonomy: String,
|
||||
optionsLevel0: Array,
|
||||
selected: Array,
|
||||
},
|
||||
created() {
|
||||
|
||||
let container = document.getElementById('filter-modal-checkbox-body');
|
||||
|
||||
this.createFinder(container);
|
||||
},
|
||||
methods: {
|
||||
prepareDataForFinder(dataVanilla){
|
||||
return true;
|
||||
},
|
||||
getOptionChildren(){
|
||||
return true;
|
||||
},
|
||||
createFinder(container){
|
||||
let F = finder(container, {}, {});
|
||||
|
||||
console.log(F);
|
||||
},
|
||||
applyFilter(){
|
||||
this.$emit('input', {
|
||||
filter: 'checkbox',
|
||||
taxonomy: this.taxonomy,
|
||||
compare: 'IN',
|
||||
metadatum_id: this.metadatum_id,
|
||||
collection_id: this.collection_id,
|
||||
terms: this.selected
|
||||
});
|
||||
|
||||
let onlyLabels = [];
|
||||
for(let selected of this.selected) {
|
||||
let valueIndex = this.options.findIndex(option => option.id == selected );
|
||||
if (valueIndex >= 0)
|
||||
onlyLabels.push(this.options[valueIndex].name)
|
||||
}
|
||||
|
||||
this.$eventBusSearch.$emit("sendValuesToTags", {
|
||||
filterId: this.filter.id,
|
||||
value: onlyLabels
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -30,7 +30,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'terms' => __( 'Terms', 'tainacan' ),
|
||||
'mapping' => __( 'Mapping', 'tainacan' ),
|
||||
'importers' => __( 'Importers', 'tainacan' ),
|
||||
'processes' => __( 'Proceses', 'tainacan' ),
|
||||
'processes' => __( 'Processes', 'tainacan' ),
|
||||
|
||||
// Actions
|
||||
'edit' => __( 'Edit', 'tainacan' ),
|
||||
|
@ -62,6 +62,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'clear_search' => __( 'Clear search', 'tainacan' ),
|
||||
'run' => __( 'Run', 'tainacan' ),
|
||||
'edit_search' => __( 'Edit search', 'tainacan' ),
|
||||
'apply' => __( 'Apply', 'tainacan' ),
|
||||
|
||||
// Wordpress Status
|
||||
'publish' => __( 'Publish', 'tainacan' ),
|
||||
|
@ -230,7 +231,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_enabled_view_modes' => __( 'Enabled view modes', 'tainacan' ),
|
||||
'label_view_modes_available' => __( 'View modes available on theme', 'tainacan' ),
|
||||
'label_warning' => __( 'Warning', 'tainacan' ),
|
||||
'label_error' => __( 'Erro', 'tainacan' ),
|
||||
'label_error' => __( 'Error', 'tainacan' ),
|
||||
'label_thumbnails' => __( 'Thumbnails', 'tainacan' ),
|
||||
'label_table' => __( 'Table', 'tainacan' ),
|
||||
'label_cards' => __( 'Cards', 'tainacan' ),
|
||||
|
@ -253,7 +254,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_see_more' => __( 'See more', 'tainacan' ),
|
||||
'label_until' => __( 'until', 'tainacan' ),
|
||||
'label_visibility' => __( 'Visibility', 'tainacan' ),
|
||||
'label_discart' => __( 'Discart', 'tainacan' ),
|
||||
'label_discard' => __( 'Discard', 'tainacan' ),
|
||||
'label_save_as_draft' => __( 'Save as draft', 'tainacan' ),
|
||||
'label_update_draft' => __( 'Update draft', 'tainacan' ),
|
||||
'label_return_to_draft' => __( 'Return to draft', 'tainacan' ),
|
||||
|
@ -265,7 +266,8 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_queued_on' => __( 'Queued on:', 'tainacan' ),
|
||||
'label_last_processed_on' => __( 'Last processed on:', 'tainacan' ),
|
||||
'label_progress' => __( 'Progress', 'tainacan' ),
|
||||
'label_process_conpleted' => __( 'Process completed', 'tainacan' ),
|
||||
'label_process_completed' => __( 'Process completed', 'tainacan' ),
|
||||
'label_max_options_to_show' => __( 'Max options to show', 'tainacan' ),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
|
@ -296,6 +298,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'instruction_select_metadatum_type' => __( 'Select a metadatum type.', 'tainacan' ),
|
||||
'instruction_configure_new_metadatum' => __( 'Configure new metadatum.', 'tainacan' ),
|
||||
'instruction_insert_mapper_metadatum_info' => __( 'Insert the new mapper\'s metadatum info', 'tainacan' ),
|
||||
'instruction_select_max_options_to_show' => __( 'Select max options to show', 'tainacan' ),
|
||||
|
||||
// Info. Other feedback to user.
|
||||
'info_search_results' => __( 'Search Results', 'tainacan' ),
|
||||
|
|
|
@ -78,7 +78,8 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
'metacompare' => 'meta_compare',
|
||||
'hideempty' => 'hide_empty',
|
||||
'perpage' => 'posts_per_page',
|
||||
'number' => 'number',
|
||||
'number' => 'number',
|
||||
'parent' => 'parent',
|
||||
'paged' => 'paged',
|
||||
'postin' => 'post__in',
|
||||
'relation' => 'relation',
|
||||
|
|
|
@ -16,6 +16,7 @@ class Filter extends Entity {
|
|||
$order,
|
||||
$color,
|
||||
$metadatum,
|
||||
$max_options,
|
||||
$filter_type,
|
||||
$filter_type_options;
|
||||
|
||||
|
@ -82,6 +83,23 @@ class Filter extends Entity {
|
|||
return $this->get_mapped_property('color');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return max number of options to be showed
|
||||
* @return mixed|null
|
||||
*/
|
||||
function get_max_options(){
|
||||
return $this->get_mapped_property('max_options');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set max number of options to be showed
|
||||
*
|
||||
* @param $max_options
|
||||
*/
|
||||
function set_max_options($max_options){
|
||||
$this->set_mapped_property('max_options', $max_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the metadatum
|
||||
*
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
{{ option.label }}
|
||||
</b-checkbox>
|
||||
</div>
|
||||
<!-- <a
|
||||
<a
|
||||
@click="openCheckboxModal()"
|
||||
class="add-link">
|
||||
{{ $i18n.get('label_see_more') }}
|
||||
</a> -->
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tainacan as axios } from '../../../js/axios/axios';
|
||||
import { filter_type_mixin } from '../filter-types-mixin'
|
||||
// import CheckboxFilterModal from '../../../admin/components/other/checkbox-filter-modal.vue'
|
||||
import { filter_type_mixin } from '../filter-types-mixin';
|
||||
import CheckboxFilterModal from '../../../admin/components/other/checkbox-filter-modal.vue';
|
||||
|
||||
export default {
|
||||
created(){
|
||||
|
@ -146,15 +146,15 @@
|
|||
return false;
|
||||
}
|
||||
},
|
||||
// openCheckboxModal() {
|
||||
// this.$modal.open({
|
||||
// parent: this,
|
||||
// component: CheckboxFilterModal,
|
||||
// props: {
|
||||
// title: this.filter.name
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
openCheckboxModal() {
|
||||
this.$modal.open({
|
||||
parent: this,
|
||||
component: CheckboxFilterModal,
|
||||
props: {
|
||||
title: this.filter.name
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="block">
|
||||
<div
|
||||
v-for="(option,index) in getOptions(0)"
|
||||
v-for="(option, index) in getOptions(0)"
|
||||
:key="index"
|
||||
:value="index"
|
||||
class="control">
|
||||
|
@ -10,12 +10,18 @@
|
|||
v-model="selected"
|
||||
:native-value="option.id"
|
||||
>{{ option.name }}</b-checkbox>
|
||||
<div
|
||||
:style="{ paddingLeft: (option.level * 30) + 'px' }"
|
||||
v-if="option.seeMoreLink"
|
||||
@click="openCheckboxModal(option.parent)"
|
||||
v-html="option.seeMoreLink"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tainacan as axios } from '../../../js/axios/axios';
|
||||
import CheckboxFilterModal from '../../../admin/components/other/checkbox-filter-modal.vue';
|
||||
|
||||
export default {
|
||||
created(){
|
||||
|
@ -64,7 +70,8 @@
|
|||
collection: '',
|
||||
metadatum: '',
|
||||
selected: [],
|
||||
taxonomy: ''
|
||||
taxonomy: '',
|
||||
taxonomy_id: Number,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -87,7 +94,7 @@
|
|||
},
|
||||
methods: {
|
||||
getValuesTaxonomy( taxonomy ){
|
||||
return axios.get('/taxonomy/' + taxonomy + '/terms?hideempty=0&order=asc' ).then( res => {
|
||||
return axios.get(`/taxonomy/${taxonomy}/terms?hideempty=0&order=asc&childrencounts=1&parent=0&number=${this.filter.max_options}`).then( res => {
|
||||
for (let item of res.data) {
|
||||
this.taxonomy = item.taxonomy;
|
||||
this.options.push(item);
|
||||
|
@ -104,6 +111,8 @@
|
|||
axios.get('/collection/'+ this.collection +'/metadata/' + this.metadatum)
|
||||
.then( res => {
|
||||
let metadatum = res.data;
|
||||
this.taxonomy_id = metadatum.metadata_type_options.taxonomy_id;
|
||||
|
||||
promise = this.getValuesTaxonomy( metadatum.metadata_type_options.taxonomy_id );
|
||||
|
||||
promise.then( () => {
|
||||
|
@ -124,14 +133,20 @@
|
|||
if ( this.options ){
|
||||
for( let term of this.options ){
|
||||
if( term.parent == parent ){
|
||||
term['level'] = level;
|
||||
//term['level'] = level;
|
||||
result.push( term );
|
||||
const levelTerm = level + 1;
|
||||
const children = this.getOptions( term.id, levelTerm);
|
||||
result = result.concat( children );
|
||||
//const levelTerm = level + 1;
|
||||
//const children = this.getOptions( term.id, levelTerm);
|
||||
//result = result.concat( children );
|
||||
}
|
||||
}
|
||||
|
||||
if(this.filter.max_options && result.length >= this.filter.max_options){
|
||||
let seeMoreLink = `<a class="add-link"> ${ this.$i18n.get('label_see_more') } </a>`;
|
||||
result[this.filter.max_options-1].seeMoreLink = seeMoreLink;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
selectedValues(){
|
||||
|
@ -167,6 +182,21 @@
|
|||
filterId: this.filter.id,
|
||||
value: onlyLabels
|
||||
});
|
||||
},
|
||||
openCheckboxModal(parent) {
|
||||
this.$modal.open({
|
||||
parent: this,
|
||||
component: CheckboxFilterModal,
|
||||
props: {
|
||||
parent: parent,
|
||||
filter: this.filter,
|
||||
taxonomy_id: this.taxonomy_id,
|
||||
optionsLevel0: this.options,
|
||||
selected: this.selected,
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: this.collection,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,66 +25,73 @@ class Filters extends Repository {
|
|||
}
|
||||
|
||||
public function get_map() {
|
||||
return apply_filters('tainacan-get-map-'.$this->get_name(), [
|
||||
'name' => [
|
||||
'map' => 'post_title',
|
||||
'title' => __('Name', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('Name of the filter', 'tainacan'),
|
||||
'on_error' => __('The filter name should be a text value and not empty', 'tainacan'),
|
||||
'validation' => v::stringType()->notEmpty(),
|
||||
],
|
||||
'order' => [
|
||||
'map' => 'menu_order',
|
||||
'title' => __('Order', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('Filter order. This metadata is used if filters were manually ordered.', 'tainacan'),
|
||||
'validation' => ''
|
||||
],
|
||||
'description' => [
|
||||
'map' => 'post_content',
|
||||
'title' => __('Description', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('The filter description', 'tainacan'),
|
||||
'validation' => '',
|
||||
'default' => '',
|
||||
],
|
||||
'filter_type_options' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Filter type options', 'tainacan'),
|
||||
'type' => 'array/object/string',
|
||||
'items' => ['type' => 'array/string/integer/object'],
|
||||
'description'=> __('The filter type options', 'tainacan'),
|
||||
'validation' => ''
|
||||
],
|
||||
'filter_type' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Type', 'tainacan'),
|
||||
'type' => 'string',
|
||||
'description'=> __('The filter type', 'tainacan'),
|
||||
'validation' => ''
|
||||
],
|
||||
'collection_id' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Collection', 'tainacan'),
|
||||
'type' => 'integer/string',
|
||||
'description'=> __('The collection ID', 'tainacan'),
|
||||
'validation' => ''
|
||||
],
|
||||
'color' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Color', 'tainacan'),
|
||||
'type' => 'integer',
|
||||
'description'=> __('Filter color', 'tainacan'),
|
||||
'validation' => ''
|
||||
],
|
||||
'metadatum' => [
|
||||
'map' => 'meta',
|
||||
'title' => __('Metadata', 'tainacan'),
|
||||
'type' => 'integer',
|
||||
'description'=> __('Filter metadata', 'tainacan'),
|
||||
'validation' => ''
|
||||
],
|
||||
return apply_filters( 'tainacan-get-map-' . $this->get_name(), [
|
||||
'name' => [
|
||||
'map' => 'post_title',
|
||||
'title' => __( 'Name', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'Name of the filter', 'tainacan' ),
|
||||
'on_error' => __( 'The filter name should be a text value and not empty', 'tainacan' ),
|
||||
'validation' => v::stringType()->notEmpty(),
|
||||
],
|
||||
'order' => [
|
||||
'map' => 'menu_order',
|
||||
'title' => __( 'Order', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'Filter order. This metadata is used if filters were manually ordered.', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
'description' => [
|
||||
'map' => 'post_content',
|
||||
'title' => __( 'Description', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The filter description', 'tainacan' ),
|
||||
'validation' => '',
|
||||
'default' => '',
|
||||
],
|
||||
'filter_type_options' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Filter type options', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'description' => __( 'The filter type options', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
'filter_type' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Type', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The filter type', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
'collection_id' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Collection', 'tainacan' ),
|
||||
'type' => 'integer/string',
|
||||
'description' => __( 'The collection ID', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
'color' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Color', 'tainacan' ),
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Filter color', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
'metadatum' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Metadata', 'tainacan' ),
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Filter metadata', 'tainacan' ),
|
||||
'validation' => ''
|
||||
],
|
||||
'max_options' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Max of options', 'tainacan' ),
|
||||
'type' => 'integer/string',
|
||||
'description' => __( 'The max number of options to be showed in filter sidebar.', 'tainacan' ),
|
||||
'validation' => ''
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue