Fix conflits from develop

This commit is contained in:
Mateus Machado Luna 2019-10-03 15:30:59 -03:00
commit 7e787068e1
48 changed files with 931 additions and 246 deletions

View File

@ -17,7 +17,7 @@
<b-select <b-select
:loading="metadataIsLoading" :loading="metadataIsLoading"
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}" :class="{'is-field-history': bulkEditionProcedures[criterion].isDone, 'hidden-select-arrow': !!bulkEditionProcedures[criterion].metadatumID}"
:disabled="!!bulkEditionProcedures[criterion].metadatumID || metadataIsLoading" :disabled="!!bulkEditionProcedures[criterion].metadatumID || metadataIsLoading"
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last" class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
:placeholder="$i18n.get('instruction_select_a_metadatum')" :placeholder="$i18n.get('instruction_select_a_metadatum')"
@ -40,7 +40,7 @@
</b-select> </b-select>
<b-select <b-select
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}" :class="{'is-field-history': bulkEditionProcedures[criterion].isDone, 'hidden-select-arrow': !!bulkEditionProcedures[criterion].action }"
v-if="bulkEditionProcedures[criterion] && v-if="bulkEditionProcedures[criterion] &&
bulkEditionProcedures[criterion].metadatumID" bulkEditionProcedures[criterion].metadatumID"
:disabled="!!bulkEditionProcedures[criterion].action" :disabled="!!bulkEditionProcedures[criterion].action"
@ -118,7 +118,7 @@
v-else-if="bulkEditionProcedures[criterion] && v-else-if="bulkEditionProcedures[criterion] &&
bulkEditionProcedures[criterion].metadatumID == 'status'"> bulkEditionProcedures[criterion].metadatumID == 'status'">
<b-select <b-select
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}" :class="{'is-field-history': bulkEditionProcedures[criterion].isDone, 'hidden-select-arrow': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone" :disabled="bulkEditionProcedures[criterion].isDone"
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last" class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last"
:placeholder="$i18n.get('instruction_select_a_status2')" :placeholder="$i18n.get('instruction_select_a_status2')"
@ -370,10 +370,10 @@
add: this.$i18n.get('add_value'), add: this.$i18n.get('add_value'),
redefine: this.$i18n.get('set_new_value'), redefine: this.$i18n.get('set_new_value'),
remove: this.$i18n.get('remove_value'), remove: this.$i18n.get('remove_value'),
replace: this.$i18n.get('replace_value'), replace: this.$i18n.get('replace_value')
}, },
editionActionsForNotMultiple: { editionActionsForNotMultiple: {
redefine: this.$i18n.get('set_new_value'), redefine: this.$i18n.get('set_new_value')
}, },
bulkEditionProcedures: { bulkEditionProcedures: {
1: { 1: {

View File

@ -142,7 +142,9 @@
...mapActions('collection', [ ...mapActions('collection', [
'fetchCollections' 'fetchCollections'
]), ]),
updateExporterOptions(){ runExporter(){
this.runButtonLoading = true;
let formElement = document.getElementById('exporterOptionsForm'); let formElement = document.getElementById('exporterOptionsForm');
let formData = new FormData(formElement); let formData = new FormData(formElement);
@ -153,21 +155,9 @@
let exporterSessionUpdated = { let exporterSessionUpdated = {
body: { body: {
options: options, mapping_selected: this.selectedMapping,
}, send_email: this.sendEmail,
id: this.exporterSession.id, options: options
};
return this.updateExporterSession(exporterSessionUpdated)
.then(exporterSessionUpdated => this.verifyError(exporterSessionUpdated));
},
runExporter(){
this.runButtonLoading = true;
let exporterSessionUpdated = {
body: {
mapping_selected: this.selectedMapping ? this.selectedMapping : this.selectedMapping,
send_email: this.sendEmail
}, },
id: this.exporterSession.id, id: this.exporterSession.id,
}; };
@ -179,23 +169,25 @@
} }
this.updateExporterSession(exporterSessionUpdated) this.updateExporterSession(exporterSessionUpdated)
.then(exporterSessionUpdated => { .then(() => {
this.verifyError(exporterSessionUpdated);
this.updateExporterOptions().then(() => { if (!this.formErrorMessage) {
if(!this.formErrorMessage) {
this.runExporterSession(this.exporterSession.id) this.runExporterSession(this.exporterSession.id)
.then((bgp) => { .then((bgp) => {
this.runButtonLoading = false; this.runButtonLoading = false;
this.$router.push(this.$routerHelper.getProcessesPage(bgp.bg_process_id)); this.$router.push(this.$routerHelper.getProcessesPage(bgp.bg_process_id));
}) })
.catch(() => { .catch((error) => {
this.formErrorMessage = error.error_message;
this.runButtonLoading = false; this.runButtonLoading = false;
}); });
} }
});
}) })
.catch(() => this.runButtonLoading = false); .catch((error) => {
this.formErrorMessage = error.error_message;
this.runButtonLoading = false;
});
}, },
formIsValid(){ formIsValid(){
return ( return (
@ -204,15 +196,6 @@
this.exporterSession.accept_no_mapping) && this.exporterSession.accept_no_mapping) &&
!this.formErrorMessage !this.formErrorMessage
); );
},
verifyError(response){
if(response.constructor.name === 'Object' &&
(response.data && response.data.status &&
response.data.status.toString().split('')[0] != 2) || response.error_message) {
this.formErrorMessage = response.data.error_message;
} else {
this.exporterSession = response.data;
}
} }
}, },
created(){ created(){

View File

@ -704,12 +704,6 @@ export default {
// Loads Filters // Loads Filters
this.refreshFilters(); this.refreshFilters();
// On repository level we also fetch collection filters
if (this.isRepositoryLevel) {
this.fetchRepositoryCollectionFilters()
.catch(() => this.isLoadingFilters = false);
}
// Obtains collection name // Obtains collection name
if (!this.isRepositoryLevel) { if (!this.isRepositoryLevel) {

View File

@ -64,8 +64,8 @@
type="search" type="search"
:aria-label="$i18n.get('instruction_search') + ' ' + $i18n.get('terms')" :aria-label="$i18n.get('instruction_search') + ' ' + $i18n.get('terms')"
autocomplete="on" autocomplete="on"
:value="searchQuery" v-model="searchQuery"
@keyup.enter="searchQuery = $event.target.value;searchTerms(0)" @keyup.enter="searchTerms(0)"
:disabled="isEditingTerm"> :disabled="isEditingTerm">
<span <span
@click="searchTerms(0)" @click="searchTerms(0)"

View File

@ -30,11 +30,13 @@ import FilterSelectbox from '../../classes/filter-types/selectbox/Selectbox.vue'
import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomplete.vue'; import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomplete.vue';
import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue'; import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue';
import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue'; import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue';
import FilterNumericInterval from '../../classes/filter-types/numeric-interval/NumericInterval.vue';
import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue'; import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue';
import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue'; import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue';
import FormNumeric from '../../classes/filter-types/numeric/FormNumeric.vue'; import FormNumeric from '../../classes/filter-types/numeric/FormNumeric.vue';
import FormNumericInterval from '../../classes/filter-types/numeric-interval/FormNumericInterval.vue';
// import FormDate from '../../classes/filter-types/date/FormDate.vue'; // import FormDate from '../../classes/filter-types/date/FormDate.vue';
import TainacanFormItem from '../../classes/metadata-types/tainacan-form-item.vue'; import TainacanFormItem from '../../classes/metadata-types/tainacan-form-item.vue';
@ -50,6 +52,10 @@ import eventBusSearch from '../../js/event-bus-search';
import termsListBus from './terms-list-bus.js'; import termsListBus from './terms-list-bus.js';
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCapabilitiesPlugin, StatusHelperPlugin } from './utilities'; import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCapabilitiesPlugin, StatusHelperPlugin } from './utilities';
import FilterNumericListInterval from '../../classes/filter-types/numeric-list-interval/NumericListInterval.vue';
import FormNumericListInterval from '../../classes/filter-types/numeric-list-interval/FormNumericListInterval.vue';
// Configure and Register Plugins // Configure and Register Plugins
Vue.use(Buefy, { Vue.use(Buefy, {
defaultTooltipAnimated: true defaultTooltipAnimated: true
@ -89,8 +95,13 @@ Vue.component('tainacan-filter-checkbox', FilterCheckbox);
Vue.component('tainacan-filter-taginput', FilterTaginput); Vue.component('tainacan-filter-taginput', FilterTaginput);
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox); Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput); Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
Vue.component('tainacan-filter-numeric-interval', FilterNumericInterval);
Vue.component('tainacan-filter-numeric-list-interval', FilterNumericListInterval);
/* Filter Metadata Option forms */ /* Filter Metadata Option forms */
Vue.component('tainacan-filter-form-numeric', FormNumeric); Vue.component('tainacan-filter-form-numeric', FormNumeric);
Vue.component('tainacan-filter-form-numeric-interval', FormNumericInterval);
Vue.component('tainacan-filter-form-numeric-list-interval', FormNumericListInterval);
// Vue.component('tainacan-filter-form-date', FormDate); // Vue.component('tainacan-filter-form-date', FormDate);
/* Others */ /* Others */

View File

@ -12,9 +12,10 @@ import FilterSelectbox from '../../classes/filter-types/selectbox/Selectbox.vue'
import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomplete.vue'; import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomplete.vue';
import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue'; import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue';
import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue'; import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue';
import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue'; import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue';
import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue'; import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue';
import FilterNumericInterval from '../../classes/filter-types/numeric-interval/NumericInterval.vue';
import FilterNumericListInterval from '../../classes/filter-types/numeric-list-interval/NumericListInterval.vue';
import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue'; import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
import ItemsPage from '../pages/lists/items-page.vue'; import ItemsPage from '../pages/lists/items-page.vue';
@ -56,6 +57,8 @@ Vue.component('tainacan-filter-checkbox', FilterCheckbox);
Vue.component('tainacan-filter-taginput', FilterTaginput); Vue.component('tainacan-filter-taginput', FilterTaginput);
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox); Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput); Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
Vue.component('tainacan-filter-numeric-interval', FilterNumericInterval);
Vue.component('tainacan-filter-numeric-list-interval', FilterNumericListInterval);
/* Others */ /* Others */
Vue.component('items-page', ItemsPage); Vue.component('items-page', ItemsPage);

View File

@ -1066,7 +1066,7 @@
}, },
onChangeOrderBy(metadatum) { onChangeOrderBy(metadatum) {
this.$eventBusSearch.setOrderBy(metadatum); this.$eventBusSearch.setOrderBy(metadatum);
this.showItemsHiddingDueSorting(); this.showItemsHiddingDueSortingDialog();
}, },
onChangeOrder() { onChangeOrder() {
this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC'); this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC');
@ -1535,7 +1535,7 @@
} }
} }
this.showItemsHiddingDueSorting(); this.showItemsHiddingDueSortingDialog();
// Watches window resize to adjust filter's top position and compression on mobile // Watches window resize to adjust filter's top position and compression on mobile
this.adjustSearchControlHeight(); this.adjustSearchControlHeight();

View File

@ -22,7 +22,7 @@
box-shadow: none !important; box-shadow: none !important;
text-decoration: none !important; text-decoration: none !important;
} }
&[disabled] { &[disabled=disabled] {
background-color: white !important; background-color: white !important;
} }
} }

View File

@ -132,8 +132,14 @@
&:focus>option:checked, &:focus>option:hover { &:focus>option:checked, &:focus>option:hover {
background-color: $turquoise1 !important; background-color: $turquoise1 !important;
} }
&[disabled=disabled] {
border: 1px solid $gray1 !important;
} }
} }
}
.hidden-select-arrow .select::after {
color: transparent !important;
}
.dropdown { .dropdown {
width: 100%; width: 100%;
.dropdown-trigger { width: 100% } .dropdown-trigger { width: 100% }

View File

@ -133,6 +133,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'title_exporter_page' => __( 'Exporter', 'tainacan'), 'title_exporter_page' => __( 'Exporter', 'tainacan'),
// Labels (used mainly on Aria Labels and Inputs) // Labels (used mainly on Aria Labels and Inputs)
'label' => __( 'label', 'tainacan' ),
'label_clean' => __( 'Clear', 'tainacan' ), 'label_clean' => __( 'Clear', 'tainacan' ),
'label_clear_filters' => __( 'Clear filters', 'tainacan' ), 'label_clear_filters' => __( 'Clear filters', 'tainacan' ),
'label_and' => __( 'and', 'tainacan' ), 'label_and' => __( 'and', 'tainacan' ),
@ -479,11 +480,13 @@ 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_filter_activities_date' => __( 'Range of dates', 'tainacan'),
'instruction_select_a_date' => __( 'Select a date', 'tainacan' ), 'instruction_select_a_date' => __( 'Select a date', 'tainacan' ),
'instruction_select_a_month' => __( 'Select a month', 'tainacan' ), 'instruction_select_a_month' => __( 'Select a month', 'tainacan' ),
'instruction_type_value_year' => __( 'Type year value', 'tainacan' ), 'instruction_type_value_year' => __( 'Type year value', 'tainacan' ),
'instruction_select_the_amount_of_copies' => __( 'Select the amount of copies of the item that you want to create', 'tainacan'), 'instruction_select_the_amount_of_copies' => __( 'Select the amount of copies of the item that you want to create', 'tainacan'),
'instruction_filter_activities_date' => __( 'Range of dates', 'tainacan'), 'instruction_select_a_interval' => __( 'Select an interval', 'tainacan'),
// Info. Other feedback to user. // Info. Other feedback to user.
'info_items_tab_all' => __( 'Every published item, including those visible only to editors.', 'tainacan' ), 'info_items_tab_all' => __( 'Every published item, including those visible only to editors.', 'tainacan' ),
@ -659,6 +662,8 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_await_while_item_copy' => __( 'Please wait while copy is being created...', 'tainacan'), 'info_await_while_item_copy' => __( 'Please wait while copy is being created...', 'tainacan'),
'info_await_while_item_copies' => __( 'Please wait while copies are being created. This may take a while...', 'tainacan'), 'info_await_while_item_copies' => __( 'Please wait while copies are being created. This may take a while...', 'tainacan'),
'info_expose_only_displayed_metadata' => __( 'By checking this option, only metatada that are displayed on the current list will be exposed', 'tainacan' ), 'info_expose_only_displayed_metadata' => __( 'By checking this option, only metatada that are displayed on the current list will be exposed', 'tainacan' ),
'info_initial_value' => __( 'Initial value', 'tainacan' ),
'info_final_value' => __( 'Final value', 'tainacan' ),
// Tainacan Metadatum Types // Tainacan Metadatum Types
'tainacan-text' => __( 'Text', 'tainacan' ), 'tainacan-text' => __( 'Text', 'tainacan' ),
@ -681,6 +686,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'tainacan-filter-taxonomy-taginput' => __( 'Taxonomy Tag Input', 'tainacan' ), 'tainacan-filter-taxonomy-taginput' => __( 'Taxonomy Tag Input', 'tainacan' ),
'tainacan-filter-taxonomy-checkbox' => __( 'Taxonomy Check Box', 'tainacan' ), 'tainacan-filter-taxonomy-checkbox' => __( 'Taxonomy Check Box', 'tainacan' ),
'tainacan-filter-taxonomy-selectbox' => __( 'Taxonomy Select Box', 'tainacan' ), 'tainacan-filter-taxonomy-selectbox' => __( 'Taxonomy Select Box', 'tainacan' ),
'tainacan-filter-numeric-interval' => __( 'Numeric Interval', 'tainacan' ),
// Datepicker months // Datepicker months
'datepicker_month_january' => __( 'January', 'tainacan' ), 'datepicker_month_january' => __( 'January', 'tainacan' ),

View File

@ -153,7 +153,37 @@ export default {
} }
} }
} }
.metadata-alert {
display: flex;
justify-content: space-between;
align-items: center;
margin: 6px $page-side-padding;
border-radius: 3px;
padding: 4px 12px;
color: $yellow2;
background: $yellow1;
animation-name: appear;
animation-duration: 0.5s;
p {
margin: 0 auto;
}
&>div {
display: flex;
.button,
.button:hover,
.button:active,
.button:focus {
background: none;
color:$yellow2;
font-weight: bold;
border: none;
cursor: pointer;
}
}
}
.search-control { .search-control {
justify-content: flex-start !important; justify-content: flex-start !important;

View File

@ -68,7 +68,7 @@ class REST_Exporters_Controller extends REST_Controller {
], ],
'options' => [ 'options' => [
'type' => 'array/object', 'type' => 'array/object',
'description' => __( 'The importer options', 'tainacan' ), 'description' => __( 'The exporter options', 'tainacan' ),
] ]
], ],
), ),
@ -172,7 +172,7 @@ class REST_Exporters_Controller extends REST_Controller {
} }
return new \WP_REST_Response([ return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ), 'error_message' => __('Exporter Session not found', 'tainacan' ),
'session_id' => $session_id 'session_id' => $session_id
], 400); ], 400);
} }

View File

@ -46,17 +46,17 @@
export default { export default {
created(){ created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id; this.metadatum = this.filter.metadatum.metadatum_id;
const vm = this; const vm = this;
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum; let endpoint = '/collection/' + this.collection + '/metadata/' + this.metadatum;
if(this.isRepositoryLevel || this.collection == 'default'){ if (this.isRepositoryLevel || this.collection == 'default'){
in_route = '/metadata/'+ this.metadatum; in_route = '/metadata/'+ this.metadatum;
} }
axios.get(in_route) axios.get(endpoint)
.then( res => { .then( res => {
let result = res.data; let result = res.data;
if( result && result.metadata_type ){ if( result && result.metadata_type ){

View File

@ -3,12 +3,6 @@
:style="{ 'height': isLoadingOptions ? (Number(filter.max_options)*28) + 'px' : 'auto' }" :style="{ 'height': isLoadingOptions ? (Number(filter.max_options)*28) + 'px' : 'auto' }"
:class="{ 'skeleton': isLoadingOptions }" :class="{ 'skeleton': isLoadingOptions }"
class="block"> class="block">
<!-- <span
v-if="isLoadingOptions"
style="width: 100%; position: absolute;"
class="icon has-text-centered loading-icon">
<div class="control has-icons-right is-loading is-clearfix" />
</span> -->
<div <div
v-for="(option, index) in options.slice(0, filter.max_options)" v-for="(option, index) in options.slice(0, filter.max_options)"
v-if="!isLoadingOptions" v-if="!isLoadingOptions"
@ -29,15 +23,6 @@
class="has-text-gray">&nbsp;{{ "(" + option.total_items + ")" }}</span> class="has-text-gray">&nbsp;{{ "(" + option.total_items + ")" }}</span>
</span> </span>
</label> </label>
<!-- <b-checkbox
v-if="index <= filter.max_options - 1"
v-model="selected"
:native-value="option.value">
<span class="checkbox-label-text">{{ option.label }}</span>
<span
v-if="option.total_items != undefined"
class="has-text-gray">{{ "(" + option.total_items + ")" }}</span>
</b-checkbox> -->
<button <button
class="view-all-button link-style" class="view-all-button link-style"
v-if="option.showViewAllButton && index == options.slice(0, filter.max_options).length - 1" v-if="option.showViewAllButton && index == options.slice(0, filter.max_options).length - 1"
@ -60,8 +45,8 @@
export default { export default {
created(){ created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id; this.metadatum = this.filter.metadatum.metadatum_id;
let route = '/collection/' + this.collection + '/metadata/' + this.metadatum +'?nopaging=1'; let route = '/collection/' + this.collection + '/metadata/' + this.metadatum +'?nopaging=1';

View File

@ -73,16 +73,16 @@
export default { export default {
mixins: [ wpAjax, dateInter ], mixins: [ wpAjax, dateInter ],
created() { created() {
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id; this.metadatum = this.filter.metadatum.metadatum_id;
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum; let endpoint = '/collection/' + this.collection + '/metadata/' + this.metadatum;
if(this.isRepositoryLevel || this.collection == 'default'){ if (this.isRepositoryLevel || this.collection == 'default'){
in_route = '/metadata/'+ this.metadatum; in_route = '/metadata/'+ this.metadatum;
} }
axios.get(in_route) axios.get(endpoint)
.then( res => { .then( res => {
let result = res.data; let result = res.data;
if( result && result.metadata_type ){ if( result && result.metadata_type ){
@ -113,11 +113,7 @@
} }
}, },
props: { props: {
filter: { filter: Object,
type: Object // concentrate all attributes metadatum id and type
},
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
labelId: '', labelId: '',
query: Object, query: Object,
isRepositoryLevel: Boolean, isRepositoryLevel: Boolean,

View File

@ -116,16 +116,16 @@
export default { export default {
mixins: [ wpAjax, dateInter ], mixins: [ wpAjax, dateInter ],
created() { created() {
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : (typeof this.filter.metadatum.metadatum_id == 'object' ? this.filter.metadatum.metadatum_id.metadatum_id : this.filter.metadatum.metadatum_id); this.metadatum = (typeof this.filter.metadatum.metadatum_id == 'object' ? this.filter.metadatum.metadatum_id.metadatum_id : this.filter.metadatum.metadatum_id);
this.options = this.filter.filter_type_options; this.options = this.filter.filter_type_options;
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum; let endpoint = '/collection/' + this.collection + '/metadata/' + this.metadatum;
if (this.isRepositoryLevel || this.collection == 'default') if (this.isRepositoryLevel || this.collection == 'default')
in_route = '/metadata/'+ this.metadatum; in_route = '/metadata/'+ this.metadatum;
axios.get(in_route) axios.get(endpoint)
.then( res => { .then( res => {
let result = res.data; let result = res.data;
if ( result && result.metadata_type ){ if ( result && result.metadata_type ){
@ -153,11 +153,7 @@
} }
}, },
props: { props: {
filter: { filter: Object,
type: Object // concentrate all attributes metadatum id and type
},
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
labelId: '', labelId: '',
query: Object, query: Object,
isRepositoryLevel: Boolean, isRepositoryLevel: Boolean,

View File

@ -12,11 +12,7 @@ export const filter_type_mixin = {
} }
}, },
props: { props: {
filter: { filter: Object,
type: Object // concentrate all attributes metadatum id and type
},
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
id: '', id: '',
query: {} query: {}
}, },
@ -54,7 +50,7 @@ export const filter_type_mixin = {
if (isRepositoryLevel || this.filter.collection_id == 'default') if (isRepositoryLevel || this.filter.collection_id == 'default')
url = `/facets/${metadatumId}?getSelected=${getSelected}&`; url = `/facets/${metadatumId}?getSelected=${getSelected}&`;
else else
url = `/collection/${this.collection}/facets/${metadatumId}?getSelected=${getSelected}&`; url = `/collection/${this.filter.collection_id}/facets/${metadatumId}?getSelected=${getSelected}&`;
if (offset != undefined && number != undefined) { if (offset != undefined && number != undefined) {
if (!this.isUsingElasticSearch) if (!this.isUsingElasticSearch)

View File

@ -0,0 +1,103 @@
<template>
<div>
<b-field :addons="false">
<label class="label is-inline">
{{ $i18n.getHelperTitle('tainacan-filter-numeric-interval', 'step') }}<span>&nbsp;*&nbsp;</span>
<help-button
:title="$i18n.getHelperTitle('tainacan-filter-numeric-interval', 'step')"
:message="$i18n.getHelperMessage('tainacan-filter-numeric-interval', 'step')"/>
</label>
<div
v-if="!showEditStepOptions"
class="is-flex">
<b-select
name="step_options"
v-model="step"
@input="onUpdate">
<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
v-if="step && ![0.001,0.01,0.1,1,2,5,10,100,1000].find( (element) => element == step )"
:value="step">
{{ step }}</option>
</b-select>
<button
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="onUpdate"
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>
</template>
<script>
export default {
props: {
filter: {
type: Object
},
value: [String, Number, Array],
id: '',
disabled: false,
},
data() {
return {
step: [Number, String],
showEditStepOptions: false
}
},
methods: {
onUpdate() {
this.$emit('input', {
step: this.step
});
},
},
created() {
this.step = this.value && this.value.step ? this.value.step : 1;
}
}
</script>

View File

@ -0,0 +1,147 @@
<template>
<div>
<b-numberinput
:aria-labelledby="labelId"
size="is-small"
@input="validate_values()"
:step="options.step"
v-model="valueInit"/>
<p class="is-size-7 has-text-centered is-marginless">{{ $i18n.get('label_until') }}</p>
<b-numberinput
:aria-labelledby="labelId"
size="is-small"
@input="validate_values()"
:step="options.step"
v-model="valueEnd"/>
</div>
</template>
<script>
export default {
created() {
this.collectionId = this.filter.collection_id;
this.metadatumId = this.filter.metadatum.metadatum_id;
this.options = this.filter.filter_type_options;
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
},
data(){
return {
valueInit: 0,
valueEnd: 10,
isValid: false,
collectionId: '',
metadatum: '',
options: [],
}
},
props: {
filter: Object,
labelId: '',
query: Object,
isRepositoryLevel: Boolean
},
methods: {
// only validate if the first value is higher than first
validate_values: _.debounce( function (){
if ( parseFloat( this.valueInit ) > parseFloat( this.valueEnd )) {
//this.valueEnd = parseFloat( this.valueInit ) + 1;
//this.error_message();
return;
}
this.emit();
}, 600),
// message for error
error_message(){
if ( !this.isTouched ) return false;
this.$buefy.toast.open({
duration: 3000,
message: this.$i18n.get('info_error_first_value_greater'),
position: 'is-bottom',
type: 'is-danger'
})
},
cleanSearchFromTags(filterTag) {
if (filterTag.filterId == this.filter.id)
this.clearSearch();
},
clearSearch(){
this.$emit('input', {
filter: 'range',
compare: 'BETWEEN',
metadatum_id: this.metadatumId,
collection_id: this.collectionId,
value: ''
});
this.valueEnd = null;
this.valueInit = null;
},
// emit the operation for listeners
emit() {
let values = [ this.valueInit, this.valueEnd ];
let type = ! Number.isInteger( this.valueInit ) || ! Number.isInteger( this.valueEnd ) ? 'DECIMAL(20,3)' : 'NUMERIC';
this.$emit('input', {
type: type,
//filter: 'range',
compare: 'BETWEEN',
metadatum_id: this.metadatumId,
collection_id: this.collectionId,
value: values
});
if (values[0] != undefined && values[1] != undefined) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: values[0] + ' - ' + values[1]
});
}
},
selectedValues(){
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
return false;
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key == this.metadatumId );
if ( index >= 0 ){
let metaquery = this.query.metaquery[ index ];
if ( metaquery.value && metaquery.value.length > 1 ) {
this.valueInit = metaquery.value[0];
this.valueEnd = metaquery.value[1];
}
if (metaquery.value[0] != undefined && metaquery.value[1] != undefined) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.valueInit + ' - ' + this.valueEnd
});
}
} else {
return false;
}
},
},
mounted() {
this.selectedValues();
},
beforeDestroy() {
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
}
}
</script>
<style scoped>
.field {
margin-bottom: 0.125rem !important;
}
p.is-size-7 {
margin-bottom: 0.125rem !important;
}
</style>

View File

@ -0,0 +1,87 @@
<?php
namespace Tainacan\Filter_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Numeric_Interval extends Filter_Type {
function __construct(){
$this->set_supported_types(['float']);
$this->set_component('tainacan-filter-numeric-interval');
$this->set_form_component('tainacan-filter-form-numeric-interval');
$this->set_use_max_options(false);
$this->set_default_options([
'step' => 1,
'input-mode' => 'custom'
]);
$this->set_preview_template('
<div>
<div class="b-numberinput field is-grouped">
<p class="control">
<button type="button" class="button is-primary is-small">
<span class="icon is-small">
<i class="mdi mdi-minus"></i>
</span>
</button>
</p>
<div class="control is-small is-clearfix">
<input type="number" step="0.01" class="input is-small" value="6">
</div>
<p class="control">
<button type="button" class="button is-primary is-small">
<span class="icon is-small">
<i class="mdi mdi-plus"></i>
</span>
</button>
</p>
</div>
<p class="is-size-7 has-text-centered is-marginless">until</p>
<div class="b-numberinput field is-grouped">
<p class="control">
<button type="button" class="button is-primary is-small">
<span class="icon is-small">
<i class="mdi mdi-minus"></i>
</span>
</button>
</p>
<div class="control is-small is-clearfix">
<input type="number" step="0.01" class="input is-small" value="10">
</div>
<p class="control">
<button type="button" class="button is-primary is-small">
<span class="icon is-small">
<i class="mdi mdi-plus"></i>
</span>
</button>
</p>
</div>
</div>
');
}
public function get_form_labels(){
return [
'step' => [
'title' => __( 'Step', 'tainacan' ),
'description' => __( 'The amount to be increased or decreased when clicking on filter control buttons. This alo defines whether the input accepts decimal numbers.', 'tainacan' ),
],
'custom' => ['title' => __('Custom interval','tainacan')],
];
}
/**
* @param $filter
* @return string
* @internal param $metadatum
*/
public function render( $filter ){
return '<tainacan-filter-numeric-interval
name="'.$filter->get_name().'"
collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-numeric-interval>';
}
}

View File

@ -0,0 +1,139 @@
<template>
<b-field :addons="false">
<label class="label is-inline">
{{ $i18n.getHelperTitle('tainacan-filter-numeric-list-interval', 'predefined_intervals') }}<span>&nbsp;</span>
<help-button
:title="$i18n.getHelperTitle('tainacan-filter-numeric-list-interval', 'predefined_intervals')"
:message="$i18n.getHelperMessage('tainacan-filter-numeric-list-interval', 'predefined_intervals')"/>
</label>
<div v-if="intervals.length == 0" >
<br>
<a
role="button"
@click="addInterval()"
class="is-inline add-link">
<span class="icon is-small">
<i class="tainacan-icon has-text-secondary tainacan-icon-add"/>
</span>
&nbsp;{{ $i18n.get('add_value') }}
</a>
</div>
<transition-group name="filter-item">
<div
class="options-input"
v-for="(interval, index) of intervals"
:key="index">
<b-field>
<b-input
expanded="true"
:placeholder="$i18n.get('label')"
@input="onUpdate"
v-model="interval.label" />
</b-field>
<b-field>
<b-input
type="number"
:placeholder="$i18n.get('info_initial_value')"
@input="onUpdate"
v-model="interval.from" />
<b-input
type="number"
:placeholder="$i18n.get('info_final_value')"
@input="onUpdate"
v-model="interval.to" />
</b-field>
<p class="control">
<a
role="button"
@click="addInterval(index)"
class="is-inline add-link"
:title="$i18n.get('add_value')">
<span class="icon is-small">
<i class="tainacan-icon has-text-secondary tainacan-icon-add"/>
</span>
&nbsp;{{ $i18n.get('add_value') }}
</a>
</p>
<p class="control">
<a
role="button"
@click="removeInterval(index)"
class="is-inline add-link"
:title="$i18n.get('remove_value')">
<span class="icon is-small">
<i class="tainacan-icon has-text-secondary tainacan-icon-repprovedcircle"/>
</span>
&nbsp;{{ $i18n.get('remove_value') }}
</a>
</p>
</div>
</transition-group>
</b-field>
</template>
<script>
export default {
props: {
filter: {
type: Object
},
value: [String, Number, Array],
id: '',
disabled: false,
},
data() {
return {
intervals: [],
}
},
methods: {
onUpdate() {
this.$emit('input', {
intervals: this.intervals,
});
},
removeInterval(index) {
this.intervals.splice(index, 1);
},
addInterval(index) {
if (index != undefined) {
this.intervals.splice(index + 1, 0, {
label: '',
to: null,
from: null
})
} else {
this.intervals.push({
label: '',
to: null,
from: null
});
}
}
},
created() {
this.intervals = this.value && this.value.intervals ? this.value.intervals : [];
}
}
</script>
<style scoped lang="scss">
@import '../../scss/_variables.scss';
.options-input {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.field:first-child {
width: 100%;
margin-top: 1rem;
margin-bottom: -1px;
}
.field.has-addons {
margin-bottom: 0.125rem;
}
}
</style>

View File

@ -0,0 +1,137 @@
<template>
<div>
<b-select
:placeholder="$i18n.get('instruction_select_a_interval')"
@input="changeInterval"
v-model="selectedInterval">
<option
v-for="(interval, index) in options.intervals"
:value="index"
:key="index">
{{ interval.label }}
</option>
</b-select>
</div>
</template>
<script>
export default {
created() {
this.collectionId = this.filter.collection_id;
this.metadatumId = this.filter.metadatum.metadatum_id;
this.options = this.filter.filter_type_options;
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
},
data() {
return {
valueInit: 0,
valueEnd: 10,
isValid: false,
collectionId: '',
metadatum: '',
options: [],
selectedInterval: ''
}
},
props: {
filter: {
type: Object // concentrate all attributes metadatum id and type
},
labelId: '',
query: Object,
isRepositoryLevel: Boolean,
},
methods: {
cleanSearchFromTags(filterTag) {
if (filterTag.filterId == this.filter.id)
this.clearSearch();
},
changeInterval() {
if (this.selectedInterval !== '') {
this.valueInit = this.options.intervals[this.selectedInterval].from;
this.valueEnd = this.options.intervals[this.selectedInterval].to;
this.emit();
} else {
this.clearSearch();
}
},
clearSearch(){
this.$emit('input', {
filter: 'range',
compare: 'BETWEEN',
metadatum_id: this.metadatumId,
collection_id: this.collectionId,
value: ''
});
this.valueEnd = null;
this.valueInit = null;
},
// emit the operation for listeners
emit() {
let values = [ this.valueInit, this.valueEnd ];
let type = ! Number.isInteger( this.valueInit ) || ! Number.isInteger( this.valueEnd ) ? 'DECIMAL' : 'NUMERIC';
this.$emit('input', {
type: type,
compare: 'BETWEEN',
metadatum_id: this.metadatumId,
collection_id: this.collectionId,
value: values
});
if (values[0] != undefined && values[1] != undefined) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.options.intervals[this.selectedInterval].label + `(${values[0]}-${values[1]})`
//value: values[0] + ' - ' + values[1]
});
}
},
selectedValues(){
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
return false;
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key == this.metadatumId );
if ( index >= 0 ) {
let metaquery = this.query.metaquery[ index ];
if ( !metaquery.value ||
!metaquery.value.length > 1 ||
metaquery.value[0] == undefined ||
metaquery.value[1] == undefined )
return false
this.valueInit = metaquery.value[0];
this.valueEnd = metaquery.value[1];
this.selectedInterval = this.options.intervals.findIndex(
anInterval => anInterval.from == this.valueInit && anInterval.to == this.valueEnd
);
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.options.intervals[this.selectedInterval].label + `(${this.valueInit}-${this.valueEnd})`
});
} else {
return false;
}
},
},
mounted() {
this.selectedValues();
},
beforeDestroy() {
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
}
}
</script>
<style scoped>
.field {
margin-bottom: 0.125rem !important;
}
p.is-size-7 {
margin-bottom: 0.125rem !important;
}
</style>

View File

@ -0,0 +1,85 @@
<?php
namespace Tainacan\Filter_Types;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Class TainacanMetadatumType
*/
class Numeric_List_Interval extends Filter_Type {
function __construct(){
$this->set_supported_types(['float']);
$this->set_component('tainacan-filter-numeric-list-interval');
$this->set_form_component('tainacan-filter-form-numeric-list-interval');
$this->set_use_max_options(false);
$this->set_default_options([
'intervals' => []
]);
$this->set_preview_template('
<div>
<div class="b-numberinput field is-grouped">
<p class="control">
<button type="button" class="button is-primary is-small">
<span class="icon is-small">
<i class="mdi mdi-minus"></i>
</span>
</button>
</p>
<div class="control is-small is-clearfix">
<input type="number" step="0.01" class="input is-small" value="6">
</div>
<p class="control">
<button type="button" class="button is-primary is-small">
<span class="icon is-small">
<i class="mdi mdi-plus"></i>
</span>
</button>
</p>
</div>
<p class="is-size-7 has-text-centered is-marginless">until</p>
<div class="b-numberinput field is-grouped">
<p class="control">
<button type="button" class="button is-primary is-small">
<span class="icon is-small">
<i class="mdi mdi-minus"></i>
</span>
</button>
</p>
<div class="control is-small is-clearfix">
<input type="number" step="0.01" class="input is-small" value="10">
</div>
<p class="control">
<button type="button" class="button is-primary is-small">
<span class="icon is-small">
<i class="mdi mdi-plus"></i>
</span>
</button>
</p>
</div>
</div>
');
}
public function get_form_labels() {
return [
'predefined_intervals' => [
'title' => __('Predefined intervals','tainacan'),
'description' => __('Predefined intervals','tainacan')
],
];
}
/**
* @param $filter
* @return string
* @internal param $metadatum
*/
public function render( $filter ) {
return '<tainacan-filter-numeric-list-interval
name="'.$filter->get_name().'"
collection_id="'.$filter->get_collection_id().'"
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-numeric-interval>';
}
}

View File

@ -75,16 +75,16 @@
export default { export default {
mixins: [ wpAjax ], mixins: [ wpAjax ],
created() { created() {
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : (typeof this.filter.metadatum.metadatum_id == 'object' ? this.filter.metadatum.metadatum_id.metadatum_id : this.filter.metadatum.metadatum_id); this.metadatum = (typeof this.filter.metadatum.metadatum_id == 'object' ? this.filter.metadatum.metadatum_id.metadatum_id : this.filter.metadatum.metadatum_id);
this.options = this.filter.filter_type_options; this.options = this.filter.filter_type_options;
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum; let endpoint = '/collection/' + this.collection + '/metadata/' + this.metadatum;
if (this.isRepositoryLevel || this.collection == 'default') if (this.isRepositoryLevel || this.collection == 'default')
in_route = '/metadata/'+ this.metadatum; in_route = '/metadata/'+ this.metadatum;
axios.get(in_route) axios.get(endpoint)
.then( res => { .then( res => {
let result = res.data; let result = res.data;
if ( result && result.metadata_type ){ if ( result && result.metadata_type ){
@ -112,11 +112,7 @@
} }
}, },
props: { props: {
filter: { filter: Object,
type: Object // concentrate all attributes metadatum id and type
},
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
labelId: '', labelId: '',
query: Object, query: Object,
isRepositoryLevel: Boolean, isRepositoryLevel: Boolean,

View File

@ -30,17 +30,17 @@
export default { export default {
created(){ created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id; this.metadatum = this.filter.metadatum.metadatum_id;
const vm = this; const vm = this;
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum; let endpoint = '/collection/' + this.collection + '/metadata/' + this.metadatum;
if(this.isRepositoryLevel || this.collection == 'default'){ if (this.isRepositoryLevel || this.collection == 'default'){
in_route = '/metadata/'+ this.metadatum; in_route = '/metadata/'+ this.metadatum;
} }
axios.get(in_route) axios.get(endpoint)
.then( res => { .then( res => {
let result = res.data; let result = res.data;
if( result && result.metadata_type ){ if( result && result.metadata_type ){

View File

@ -49,17 +49,17 @@
export default { export default {
created(){ created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id; this.metadatum = this.filter.metadatum.metadatum_id;
const vm = this; const vm = this;
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum; let endpoint = '/collection/' + this.collection + '/metadata/' + this.metadatum;
if(this.isRepositoryLevel || this.collection == 'default'){ if (this.isRepositoryLevel || this.collection == 'default'){
in_route = '/metadata/'+ this.metadatum + '?nopaging=1'; in_route = '/metadata/'+ this.metadatum + '?nopaging=1';
} }
axios.get(in_route) axios.get(endpoint)
.then( res => { .then( res => {
let result = res.data; let result = res.data;
if( result && result.metadata_type ){ if( result && result.metadata_type ){

View File

@ -1,8 +1,6 @@
<template> <template>
<b-field <b-field
class="filter-item-forms" class="filter-item-forms">
:message="getErrorMessage"
:type="filterTypeMessage">
<b-collapse <b-collapse
class="show" class="show"
:open.sync="open" :open.sync="open"
@ -48,8 +46,6 @@
</template> </template>
<script> <script>
import { mapActions } from 'vuex';
export default { export default {
name: 'TainacanFilterItem', name: 'TainacanFilterItem',
props: { props: {
@ -61,33 +57,11 @@
data(){ data(){
return { return {
inputs: [], inputs: [],
filterTypeMessage:''
}
},
computed: {
getErrorMessage() {
let msg = '';
let errors = this.$eventBusSearch.getErrors( this.filter.id );
if ( errors) {
this.setFilterTypeMessage('is-danger');
for (let index in errors) {
msg += errors[index] + '\n';
}
} else {
this.setFilterTypeMessage('');
}
return msg;
} }
}, },
methods: { methods: {
...mapActions('search', [
'setPage'
]),
listen( inputEvent ){ listen( inputEvent ){
this.$eventBusSearch.$emit( 'input', ( inputEvent.metadatum_id ) ? inputEvent : inputEvent.detail[0] ); this.$eventBusSearch.$emit( 'input', ( inputEvent.metadatum_id ) ? inputEvent : inputEvent.detail[0] );
},
setFilterTypeMessage( message ){
this.filterTypeMessage = message;
} }
} }
} }

View File

@ -53,8 +53,8 @@
export default { export default {
created(){ created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id ; this.metadatum = this.filter.metadatum.metadatum_id ;
this.type = this.filter.metadatum.metadata_type; this.type = this.filter.metadatum.metadata_type;
this.loadOptions(); this.loadOptions();
@ -87,15 +87,9 @@
} }
}, },
props: { props: {
filter: { filter: Object,
type: Object // concentrate all attributes metadatum id and type
},
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
labelId: '', labelId: '',
query: { query: Object
type: Object // concentrate all attributes metadatum id and type
}
}, },
watch: { watch: {
selected: function(){ selected: function(){

View File

@ -41,17 +41,17 @@
export default { export default {
created(){ created(){
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id; this.collection = this.filter.collection_id;
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id ; this.metadatum = this.filter.metadatum.metadatum_id;
this.type = this.filter.metadatum.metadata_type; this.type = this.filter.metadatum.metadata_type;
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum; let endpoint = '/collection/' + this.collection + '/metadata/' + this.metadatum;
if(this.isRepositoryLevel || this.collection == 'default'){ if (this.isRepositoryLevel || this.collection == 'default'){
in_route = '/metadata/'+ this.metadatum; endpoint = '/metadata/'+ this.metadatum;
} }
axios.get(in_route) axios.get(endpoint)
.then( res => { .then( res => {
let metadatum = res.data; let metadatum = res.data;
this.selectedValues( metadatum.metadata_type_options.taxonomy_id ); this.selectedValues( metadatum.metadata_type_options.taxonomy_id );
@ -73,11 +73,7 @@
} }
}, },
props: { props: {
filter: { filter: Object,
type: Object // concentrate all attributes metadatum id and type
},
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
labelId: '', labelId: '',
query: { query: {
type: Object // concentrate all attributes metadatum id and type type: Object // concentrate all attributes metadatum id and type

View File

@ -44,12 +44,12 @@
v-for="(option, index) in metadata" v-for="(option, index) in metadata"
:key="index" :key="index"
class="field"> class="field">
<b-checkbox <b-radio
name="metadata_type_relationship[search][]" name="metadata_type_relationship[search]"
v-model="modelSearch" v-model="modelSearch"
:native-value="option.id"> :native-value="option.id">
{{ option.name }} {{ option.name }}
</b-checkbox> </b-radio>
</div> </div>
</b-field> </b-field>
@ -98,7 +98,7 @@
hasMetadata: false, hasMetadata: false,
loadingMetadata: false, loadingMetadata: false,
modelRepeated: 'yes', modelRepeated: 'yes',
modelSearch:[], modelSearch:'',
collectionType: '', collectionType: '',
collectionMessage: '' collectionMessage: ''
} }
@ -111,7 +111,7 @@
} else { } else {
this.metadata = []; this.metadata = [];
this.hasMetadata = false; this.hasMetadata = false;
this.modelSearch = []; this.modelSearch = '';
this.emitValues(); this.emitValues();
} }
@ -180,7 +180,7 @@
this.metadata = []; this.metadata = [];
for (let metadatum of metadata) { for (let metadatum of metadata) {
if (metadatum.metadata_type !== "Tainacan\\Metadata_Types\\Relationship" && metadatum.metadata_type !== "Tainacan\\Metadata_Types\\Taxonomy") { if (metadatum.metadata_type !== "Tainacan\\Metadata_Types\\Relationship") {
this.metadata.push( metadatum ); this.metadata.push( metadatum );
this.hasMetadata = true; this.hasMetadata = true;
this.checkMetadata() this.checkMetadata()
@ -207,14 +207,14 @@
}, },
checkMetadata(){ checkMetadata(){
if( this.value && this.value.search.length > 0 ){ if( this.value && this.value.search ){
this.modelSearch = this.value.search; this.modelSearch = this.value.search;
} else { } else {
try { try {
const json = JSON.parse( this.search ); const json = JSON.parse( this.search );
this.modelSearch = json; this.modelSearch = json;
} catch(e){ } catch(e){
this.modelSearch = []; this.modelSearch = '';
} }
} }
}, },

View File

@ -119,20 +119,16 @@
let query = []; let query = [];
if ( this.metadatum.metadatum.metadata_type_options && if ( this.metadatum.metadatum.metadata_type_options &&
this.metadatum.metadatum.metadata_type_options.search && this.metadatum.metadatum.metadata_type_options.search)
this.metadatum.metadatum.metadata_type_options.search.length > 0)
{ {
query['metaquery'] = []; query['metaquery'] = [];
const metaquery = query['metaquery'];
metaquery['relation'] = 'OR' query['metaquery'][0] = {
for ( let i = 0; i < this.metadatum.metadatum.metadata_type_options.search.length; i++ ){ key: this.metadatum.metadatum.metadata_type_options.search,
metaquery[i] = {
key: this.metadatum.metadatum.metadata_type_options.search[i],
value: search, value: search,
compare: 'LIKE' compare: 'LIKE'
} }
}
query['metaquery'] = metaquery;
} else { } else {
query['search'] = search; query['search'] = search;
} }

View File

@ -93,10 +93,10 @@ class Relationship extends Metadata_Type {
'collection_id' => __('The related collection is required','tainacan') 'collection_id' => __('The related collection is required','tainacan')
]; ];
} }
// empty is ok
if ( !is_array($this->get_option('search')) ) { if ( !empty($this->get_option('search')) && !is_numeric($this->get_option('search')) ) {
return [ return [
'search' => __('Search option must be an array','tainacan') 'search' => __('Search option must be a numeric Metadatum ID','tainacan')
]; ];
} }

View File

@ -141,6 +141,8 @@ $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Taginput');
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Checkbox'); $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Checkbox');
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyTaginput'); $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyTaginput');
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyCheckbox'); $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyCheckbox');
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric_Interval');
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric_List_Interval');
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();

View File

@ -112,10 +112,18 @@ class CSV extends Exporter {
$metadata = $collection->get_metadata(); $metadata = $collection->get_metadata();
foreach ($metadata as $meta) { foreach ($metadata as $meta) {
$line[] = $meta->get_name(); $meta_type = explode('\\', $meta->get_metadata_type()) ;
$meta_type = strtolower($meta_type[sizeof($meta_type)-1]);
$desc_title_meta = $meta->get_name() .
($meta->is_multiple() ? '|multiple': '') .
($meta->is_required() ? '|required': '') .
('|display_' . $meta->get_display()) .
($meta->is_collection_key() ? '|collection_key_yes' : '') .
('|' . $meta_type);
$line[] = $desc_title_meta;
} }
} }
} }

View File

@ -25,6 +25,7 @@ registerBlockType('tainacan/carousel-collections-list', {
</svg>, </svg>,
category: 'tainacan-blocks', category: 'tainacan-blocks',
keywords: [ __( 'collections', 'tainacan' ), __( 'carousel', 'tainacan' ), __( 'slider', 'tainacan' ) ], keywords: [ __( 'collections', 'tainacan' ), __( 'carousel', 'tainacan' ), __( 'slider', 'tainacan' ) ],
description: __('List collections on a Carousel, using search or collection selection.', 'tainacan'),
attributes: { attributes: {
content: { content: {
type: 'array', type: 'array',

View File

@ -19,6 +19,7 @@ registerBlockType('tainacan/collections-list', {
</svg>, </svg>,
category: 'tainacan-blocks', category: 'tainacan-blocks',
keywords: [ __( 'Tainacan', 'tainacan' ), __( 'collections', 'tainacan' ), __( 'repository', 'tainacan' ) ], keywords: [ __( 'Tainacan', 'tainacan' ), __( 'collections', 'tainacan' ), __( 'repository', 'tainacan' ) ],
description: __('Expose collections from your Tainacan repository', 'tainacan'),
attributes: { attributes: {
selectedCollectionsObject: { selectedCollectionsObject: {
type: 'array', type: 'array',

View File

@ -123,8 +123,9 @@
</button> </button>
<div <div
v-else v-else
class="spinner-container"> class="spinner-container"
{{ facets.length > 0 ? '' : $root.__('Nothing found.', 'tainacan') }} :style="{ display: facets.length > 0 ? 'none' : 'flex'}">
{{ $root.__('Nothing found.', 'tainacan') }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -25,6 +25,7 @@ registerBlockType('tainacan/facets-list', {
</svg>, </svg>,
category: 'tainacan-blocks', category: 'tainacan-blocks',
keywords: [ __( 'facets', 'tainacan' ), __( 'search', 'tainacan' ), __( 'terms', 'tainacan' ) ], keywords: [ __( 'facets', 'tainacan' ), __( 'search', 'tainacan' ), __( 'terms', 'tainacan' ) ],
description: __('List facets from a Tainacan Collection or Repository', 'tainacan'),
attributes: { attributes: {
content: { content: {
type: 'array', type: 'array',

View File

@ -25,6 +25,7 @@ registerBlockType('tainacan/carousel-items-list', {
</svg>, </svg>,
category: 'tainacan-blocks', category: 'tainacan-blocks',
keywords: [ __( 'items', 'tainacan' ), __( 'carousel', 'tainacan' ), __( 'slider', 'tainacan' ) ], keywords: [ __( 'items', 'tainacan' ), __( 'carousel', 'tainacan' ), __( 'slider', 'tainacan' ) ],
description: __('List items on a Carousel, using search or item selection.', 'tainacan'),
attributes: { attributes: {
content: { content: {
type: 'array', type: 'array',

View File

@ -25,6 +25,7 @@ registerBlockType('tainacan/dynamic-items-list', {
</svg>, </svg>,
category: 'tainacan-blocks', category: 'tainacan-blocks',
keywords: [ __( 'items', 'tainacan' ), __( 'search', 'tainacan' ), __( 'collection', 'tainacan' ) ], keywords: [ __( 'items', 'tainacan' ), __( 'search', 'tainacan' ), __( 'collection', 'tainacan' ) ],
description: __('Dynamically list items from a Tainacan items search', 'tainacan'),
attributes: { attributes: {
content: { content: {
type: 'array', type: 'array',

View File

@ -19,6 +19,7 @@ registerBlockType('tainacan/items-list', {
</svg>, </svg>,
category: 'tainacan-blocks', category: 'tainacan-blocks',
keywords: [ __( 'Tainacan', 'tainacan' ), __( 'items', 'tainacan' ), __( 'collection', 'tainacan' ) ], keywords: [ __( 'Tainacan', 'tainacan' ), __( 'items', 'tainacan' ), __( 'collection', 'tainacan' ) ],
description: __('Expose items from your Tainacan collections', 'tainacan'),
attributes: { attributes: {
selectedItemsObject: { selectedItemsObject: {
type: 'array', type: 'array',

View File

@ -28,6 +28,7 @@ registerBlockType('tainacan/search-bar', {
</svg>, </svg>,
category: 'tainacan-blocks', category: 'tainacan-blocks',
keywords: [ __( 'items', 'tainacan' ), __( 'search', 'tainacan' ), __( 'bar', 'tainacan' ) ], keywords: [ __( 'items', 'tainacan' ), __( 'search', 'tainacan' ), __( 'bar', 'tainacan' ) ],
description: __('Set up a custom search bar to redirect to an item\'s list', 'tainacan'),
attributes: { attributes: {
content: { content: {
type: 'array', type: 'array',

View File

@ -18,6 +18,7 @@ registerBlockType('tainacan/terms-list', {
</svg>, </svg>,
category: 'tainacan-blocks', category: 'tainacan-blocks',
keywords: [ __( 'Tainacan', 'tainacan' ), __( 'terms', 'tainacan' ), __( 'taxonomy', 'tainacan' ) ], keywords: [ __( 'Tainacan', 'tainacan' ), __( 'terms', 'tainacan' ), __( 'taxonomy', 'tainacan' ) ],
description: __('Expose terms from your Tainacan taxonomies', 'tainacan'),
attributes: { attributes: {
selectedTermsObject: { selectedTermsObject: {
type: 'array', type: 'array',

View File

@ -217,20 +217,6 @@ export default {
this.$store.dispatch('search/remove_fetch_only_meta', metadatum ); this.$store.dispatch('search/remove_fetch_only_meta', metadatum );
this.updateURLQueries(); this.updateURLQueries();
}, },
getErrors( filter_id ){
let error = this.errors.find( errorItem => errorItem.metadatum_id === filter_id );
return ( error ) ? error.errors : false;
},
// listener(){
// const components = this.getAllComponents();
// for (let eventElement of components){
// eventElement.addEventListener('input', (event) => {
// if( event.detail ) {
// this.add_metaquery( event.detail[0] );
// }
// });
// }
// },
setPage(page) { setPage(page) {
this.$store.dispatch('search/setPage', page); this.$store.dispatch('search/setPage', page);
this.updateURLQueries(); this.updateURLQueries();

View File

@ -26,26 +26,28 @@ export const createExporterSession = ({commit}, slug) => {
export const updateExporterSession = ({commit}, exporterSessionUpdated) => { export const updateExporterSession = ({commit}, exporterSessionUpdated) => {
return tainacan.patch(`/exporters/session/${exporterSessionUpdated.id}`, exporterSessionUpdated.body) return new Promise(( resolve, reject ) => {
tainacan.patch(`/exporters/session/${exporterSessionUpdated.id}`, exporterSessionUpdated.body)
.then(response => { .then(response => {
commit('setExporterSession'); commit('setExporterSession');
resolve( response.data );
return response;
}) })
.catch(error => { .catch(error => {
console.error(error.response.data); reject( error.response.data );
});
}); });
}; };
export const runExporterSession = ({commit}, exporterSessionID) => { export const runExporterSession = ({commit}, exporterSessionID) => {
return tainacan.post(`/exporters/session/${exporterSessionID}/run`) return new Promise(( resolve, reject ) => {
tainacan.post(`/exporters/session/${exporterSessionID}/run`)
.then(response => { .then(response => {
commit('setBackGroundProcessID', response.data); commit('setBackGroundProcessID', response.data);
resolve(response.data);
return response.data;
}) })
.catch(error => { .catch(error => {
console.error(error.response.data); reject( error.response.data );
}) })
});
}; };

View File

@ -354,7 +354,25 @@ class Migrations {
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 'default' WHERE $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 'default' WHERE
post_id IN ( post_id IN (
SELECT ID FROM $wpdb->posts WHERE post_type = 'tainacan-filter' SELECT ID FROM $wpdb->posts WHERE post_type = 'tainacan-filter'
) AND meta_key = 'collection_id' AND meta_value = 'filter_in_repository'" ); ) AND meta_key = 'collection_id' AND meta_value = 'filter_in_repository'"
);
}
static function update_relationship_metadata_search_option() {
global $wpdb;
$q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'metadata_type' AND meta_value = 'Tainacan\\\\Metadata_Types\\\\Relationship'";
$ids = $wpdb->get_col($q);
foreach ($ids as $id) {
$meta = get_post_meta($id, 'metadata_type_options', true);
if ( is_array($meta) && isset($meta['search']) && is_array($meta['search']) && isset($meta['search'][0]) && is_numeric($meta['search'][0]) ) {
$meta['search'] = $meta['search'][0];
update_post_meta($id, 'metadata_type_options', $meta);
}
}
} }

View File

@ -381,7 +381,7 @@ class Facets extends TAINACAN_UnitApiTestCase {
'metadata_type_options' => [ 'metadata_type_options' => [
'allow_new_terms' => 'yes', 'allow_new_terms' => 'yes',
'collection_id' => $collection1->get_id(), 'collection_id' => $collection1->get_id(),
'search' => [] 'search' => ''
] ]
), ),
true true

View File

@ -455,7 +455,7 @@ class Metadata extends TAINACAN_UnitTestCase {
'status' => 'publish', 'status' => 'publish',
'metadata_type_options' => [ 'metadata_type_options' => [
'collection_id' => $collection2->get_id(), 'collection_id' => $collection2->get_id(),
'search' => [$collection2->get_core_title_metadatum()->get_id()] 'search' => $collection2->get_core_title_metadatum()->get_id()
] ]
), ),
true true