Merge branch 'hotfix/0.13.1'

This commit is contained in:
leogermani 2019-11-06 17:58:21 -03:00
commit 84eb3ea197
46 changed files with 1027 additions and 759 deletions

View File

@ -97,8 +97,6 @@
:maxtags="1" :maxtags="1"
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}" :class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone" :disabled="bulkEditionProcedures[criterion].isDone"
:id="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component +
'-' + getMetadataByID(bulkEditionProcedures[criterion].metadatumID).slug"
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component" :is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
:metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}" :metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
class="tainacan-bulk-edition-field" class="tainacan-bulk-edition-field"
@ -152,8 +150,6 @@
:maxtags="1" :maxtags="1"
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}" :class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone || bulkEditionProcedures[criterion].isExecuting" :disabled="bulkEditionProcedures[criterion].isDone || bulkEditionProcedures[criterion].isExecuting"
:id="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component +
'-' + getMetadataByID(bulkEditionProcedures[criterion].metadatumID).slug"
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component" :is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
:metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}" :metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last" class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last"

View File

@ -182,7 +182,7 @@
</span> </span>
<br> <br>
<a <a
class="is-inline add-link" class="add-link"
:class="{'disabled': form.enable_cover_page != 'yes'}" :class="{'disabled': form.enable_cover_page != 'yes'}"
target="_blank" target="_blank"
:href="newPagePath"> :href="newPagePath">
@ -250,7 +250,7 @@
@focus="clearErrors('default_view_mode')"> @focus="clearErrors('default_view_mode')">
<option <option
v-for="(viewMode, index) of form.enabled_view_modes" v-for="(viewMode, index) of form.enabled_view_modes"
v-if="registeredViewModes[viewMode] != undefined" v-if="registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen != true"
:key="index" :key="index"
:value="viewMode">{{ registeredViewModes[viewMode].label }} :value="viewMode">{{ registeredViewModes[viewMode].label }}
</option> </option>

View File

@ -48,7 +48,7 @@
</b-select> </b-select>
<router-link <router-link
tag="a" tag="a"
class="is-inline add-link" class="add-link"
:to="{ path: $routerHelper.getNewCollectionPath(), query: { fromImporter: true }}"> :to="{ path: $routerHelper.getNewCollectionPath(), query: { fromImporter: true }}">
<span class="icon"> <span class="icon">
<i class="tainacan-icon tainacan-icon-add"/> <i class="tainacan-icon tainacan-icon-add"/>

View File

@ -132,8 +132,6 @@
:metadatum="{ metadatum: metadatum }" :metadatum="{ metadatum: metadatum }"
:value="itemMetadata[index].value" :value="itemMetadata[index].value"
@input="clearErrorMessage(metadatum.id); bulkEdit($event, metadatum)"/> @input="clearErrorMessage(metadatum.id); bulkEdit($event, metadatum)"/>
<!-- :class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone || bulkEditionProcedures[criterion].isExecuting" -->
</div> </div>
</transition> </transition>
</b-field> </b-field>

View File

@ -150,7 +150,7 @@
</b-field> </b-field>
<b-field :addons="false"> <b-field :addons="false">
<label class="label is-inline-block">{{ $i18n.get('label_options') }}</label> <label class="label is-inline-block">{{ $i18n.get('label_insert_options') }}</label>
<b-field <b-field
:type="formErrors['required'] != undefined ? 'is-danger' : ''" :type="formErrors['required'] != undefined ? 'is-danger' : ''"
:message="formErrors['required'] != undefined ? formErrors['required'] : ''"> :message="formErrors['required'] != undefined ? formErrors['required'] : ''">

View File

@ -144,7 +144,7 @@
:message="$i18n.get('info_help_parent_term')"/> :message="$i18n.get('info_help_parent_term')"/>
</label> </label>
<b-autocomplete <b-autocomplete
id="tainacan-text-cover-page" id="tainacan-add-parent-field"
:placeholder="$i18n.get('instruction_parent_term')" :placeholder="$i18n.get('instruction_parent_term')"
:data="parentTerms" :data="parentTerms"
field="name" field="name"
@ -155,7 +155,18 @@
@focus="clearErrors('parent');" @focus="clearErrors('parent');"
:disabled="!hasParent"> :disabled="!hasParent">
<template slot-scope="props"> <template slot-scope="props">
<div class="media">
<div
v-if="props.option.header_image"
class="media-left">
<img
width="28"
:src="props.option.header_image">
</div>
<div class="media-content">
{{ props.option.name }} {{ props.option.name }}
</div>
</div>
</template> </template>
<template slot="empty">{{ $i18n.get('info_no_parent_term_found') }}</template> <template slot="empty">{{ $i18n.get('info_no_parent_term_found') }}</template>
</b-autocomplete> </b-autocomplete>

View File

@ -363,28 +363,29 @@
let selected = this.selected instanceof Array ? this.selected : [this.selected]; let selected = this.selected instanceof Array ? this.selected : [this.selected];
if (this.taxonomy_id && selected.length) { if (this.taxonomy_id && selected.length) {
for (const term of selected) {
this.isSelectedTermsLoading = true; this.isSelectedTermsLoading = true;
axios.get(`/taxonomy/${this.taxonomy_id}/terms/${term}`) axios.get(`/taxonomy/${this.taxonomy_id}/terms/?${qs.stringify({ hideempty: 0, include: selected})}`)
.then((res) => { .then((res) => {
this.saveSelectedTagName(res.data.id, res.data.name); for (const term of res.data)
this.saveSelectedTagName(term.id, term.name);
this.isSelectedTermsLoading = false; this.isSelectedTermsLoading = false;
}) })
.catch((error) => { .catch((error) => {
this.$console.log(error); this.$console.log(error);
this.isSelectedTermsLoading = false; this.isSelectedTermsLoading = false;
}); });
}
} else if (this.metadatum_type === 'Tainacan\\Metadata_Types\\Relationship' && selected.length) { } else if (this.metadatum_type === 'Tainacan\\Metadata_Types\\Relationship' && selected.length) {
this.isSelectedTermsLoading = true; this.isSelectedTermsLoading = true;
for (const item of selected) { axios.get(`/items/?${qs.stringify({ fetch_only: 'title', postin: selected})}`)
axios.get('/items/' + item + '?fetch_only=title')
.then((res) => { .then((res) => {
this.saveSelectedTagName(res.data.id, res.data.title); for (const item of res.data)
this.saveSelectedTagName(item.id, item.title);
this.isSelectedTermsLoading = false; this.isSelectedTermsLoading = false;
}) })
.catch((error) => { .catch((error) => {
@ -392,7 +393,6 @@
this.isSelectedTermsLoading = false; this.isSelectedTermsLoading = false;
}); });
} }
}
}, },
saveSelectedTagName(value, label){ saveSelectedTagName(value, label){
if (!this.selectedTagsName[value]) { if (!this.selectedTagsName[value]) {

View File

@ -22,6 +22,7 @@ import Taxonomy from '../../classes/metadata-types/taxonomy/Taxonomy.vue';
import FormRelationship from '../../classes/metadata-types/relationship/FormRelationship.vue'; import FormRelationship from '../../classes/metadata-types/relationship/FormRelationship.vue';
import FormTaxonomy from '../../classes/metadata-types/taxonomy/FormTaxonomy.vue'; import FormTaxonomy from '../../classes/metadata-types/taxonomy/FormTaxonomy.vue';
import FormSelectbox from '../../classes/metadata-types/selectbox/FormSelectbox.vue'; import FormSelectbox from '../../classes/metadata-types/selectbox/FormSelectbox.vue';
import FormNumeric from '../../classes/metadata-types/numeric/FormNumeric.vue';
import FilterNumeric from '../../classes/filter-types/numeric/Numeric.vue'; import FilterNumeric from '../../classes/filter-types/numeric/Numeric.vue';
import FilterDate from '../../classes/filter-types/date/Date.vue'; import FilterDate from '../../classes/filter-types/date/Date.vue';
@ -31,12 +32,13 @@ 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 FilterNumericInterval from '../../classes/filter-types/numeric-interval/NumericInterval.vue';
import FilterDateInterval from '../../classes/filter-types/date-interval/DateInterval.vue'; import FilterDateInterval from '../../classes/filter-types/date-interval/DateInterval.vue';
import FilterNumericListInterval from '../../classes/filter-types/numeric-list-interval/NumericListInterval.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 FormFilterNumeric from '../../classes/filter-types/numeric/FormNumeric.vue';
import FormNumericInterval from '../../classes/filter-types/numeric-interval/FormNumericInterval.vue'; import FormFilterNumericInterval from '../../classes/filter-types/numeric-interval/FormNumericInterval.vue';
import FormFilterNumericListInterval from '../../classes/filter-types/numeric-list-interval/FormNumericListInterval.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';
@ -52,10 +54,6 @@ 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
@ -78,10 +76,12 @@ Vue.component('tainacan-numeric', Numeric);
Vue.component('tainacan-date', Date); Vue.component('tainacan-date', Date);
Vue.component('tainacan-relationship', Relationship); Vue.component('tainacan-relationship', Relationship);
Vue.component('tainacan-taxonomy', Taxonomy); Vue.component('tainacan-taxonomy', Taxonomy);
/* Metadata Option forms */ /* Metadata Option forms */
Vue.component('tainacan-form-relationship', FormRelationship); Vue.component('tainacan-form-relationship', FormRelationship);
Vue.component('tainacan-form-taxonomy', FormTaxonomy); Vue.component('tainacan-form-taxonomy', FormTaxonomy);
Vue.component('tainacan-form-selectbox', FormSelectbox); Vue.component('tainacan-form-selectbox', FormSelectbox);
Vue.component('tainacan-form-numeric', FormNumeric);
Vue.component('tainacan-form-item', TainacanFormItem); Vue.component('tainacan-form-item', TainacanFormItem);
Vue.component('tainacan-filter-item', TainacanFiltersList); Vue.component('tainacan-filter-item', TainacanFiltersList);
@ -99,9 +99,9 @@ Vue.component('tainacan-filter-numeric-list-interval', FilterNumericListInterval
Vue.component('tainacan-filter-date-interval', FilterDateInterval); Vue.component('tainacan-filter-date-interval', FilterDateInterval);
/* Filter Metadata Option forms */ /* Filter Metadata Option forms */
Vue.component('tainacan-filter-form-numeric', FormNumeric); Vue.component('tainacan-filter-form-numeric', FormFilterNumeric);
Vue.component('tainacan-filter-form-numeric-interval', FormNumericInterval); Vue.component('tainacan-filter-form-numeric-interval', FormFilterNumericInterval);
Vue.component('tainacan-filter-form-numeric-list-interval', FormNumericListInterval); Vue.component('tainacan-filter-form-numeric-list-interval', FormFilterNumericListInterval);
// Vue.component('tainacan-filter-form-date', FormDate); // Vue.component('tainacan-filter-form-date', FormDate);
/* Others */ /* Others */

View File

@ -26,6 +26,7 @@
border-radius: 0px; border-radius: 0px;
min-width: 6rem; min-width: 6rem;
border: none; border: none;
z-index: 99;
.dropdown-content { .dropdown-content {
padding: 0px; padding: 0px;
@ -50,6 +51,9 @@
.is-small { color: $gray4; } .is-small { color: $gray4; }
&.is-active { background-color: $turquoise2; } &.is-active { background-color: $turquoise2; }
.media {
align-items: center;
.media-left { .media-left {
margin-right: 0.5rem; margin-right: 0.5rem;
} }
@ -67,6 +71,7 @@
} }
} }
} }
}
&.is-mobile-modal { &.is-mobile-modal {
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
.dropdown-content { .dropdown-content {
@ -130,16 +135,16 @@
.tag { .tag {
background: white; background: white;
padding-right: 0; padding-right: 0;
padding-left: 0.5em; padding-left: 0.6em;
&.is-delete { &.is-delete {
color: $gray4; color: $gray4;
&::after { &::after {
height: 30% !important; height: 47% !important;
width: 1px !important; width: 1px !important;
} }
&::before { &::before {
width: 30% !important; width: 47% !important;
height: 1px !important; height: 1px !important;
} }
&:hover, &:focus { &:hover, &:focus {

View File

@ -6,12 +6,9 @@
margin-right: 0.375rem; margin-right: 0.375rem;
max-width: 100%; max-width: 100%;
overflow: hidden; overflow: hidden;
transition: all 0.2s ease;
animation-name: appear; animation-name: appear;
animation-duration: 0.2s; animation-duration: 0.3s;
&:hover, &:hover .tag {
background-color: $gray2;
}
.tag { .tag {
background-color: white; background-color: white;
@ -22,6 +19,8 @@
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
animation-name: appear;
animation-duration: 0.3s;
&.is-delete, &.is-delete,
&.is-delete:hover, &.is-delete:hover,
@ -29,12 +28,28 @@
&.is-delete:active { &.is-delete:active {
border-radius: 50px !important; border-radius: 50px !important;
border-radius: 50px !important; border-radius: 50px !important;
margin-right: 0px !important;
color: $gray4; color: $gray4;
background-color: transparent; background-color: white;
transition: border-width 0.15s linear, background-color 0.15s linear;
&:hover { &:after,
background-color: transparent; &:before {
color: $gray4; transition: transform 0.15s linear;
}
&:hover,
&:focus {
border: solid 1px $gray3 !important;
background-color: $gray2;
color: $gray5;
&:after {
transform: translateX(-50%) translateY(-50%) rotate(45deg) scale(1.15);
}
&:before {
transform: translateX(-50%) translateY(-50%) rotate(45deg) scale(1.15);
}
} }
} }
} }

View File

@ -51,6 +51,7 @@
} }
.b-numberinput { .b-numberinput {
height: 30px; height: 30px;
padding: 0 !important;
.control { .control {
margin-right: 0 !important; margin-right: 0 !important;
@ -62,6 +63,7 @@
button, button,
input { input {
height: 30px !important; height: 30px !important;
text-align: start;
} }
button.is-primary, button.is-primary,
button.is-primary:hover, button.is-primary:hover,

View File

@ -121,7 +121,7 @@ $subheader-height: 42px;
$side-menu-width: 160px; $side-menu-width: 160px;
$filter-menu-width: 16.666666667%; $filter-menu-width: 16.666666667%;
$filter-menu-width-theme: 20.833333333%; $filter-menu-width-theme: 20.833333333%;
$page-height: calc(100% - 94px); $page-height: calc(100vh - 94px);
// Overall Pages padding: // Overall Pages padding:
$page-side-padding: 4.166666667%;//82px; $page-side-padding: 4.166666667%;//82px;

View File

@ -96,8 +96,10 @@ a:hover {
text-decoration: underline; text-decoration: underline;
} }
.add-link { .add-link {
display: inline; display: inline-flex;
align-items: center;
font-size: 0.75rem; font-size: 0.75rem;
margin: 3px 0 6px 0;
&.disabled { &.disabled {
pointer-events: none; pointer-events: none;
cursor: default; cursor: default;
@ -107,6 +109,9 @@ a:hover {
color: $gray2 !important; color: $gray2 !important;
} }
} }
.tainacan-icon::before {
font-size: 0.875rem;
}
} }
// Generic page container // Generic page container

View File

@ -199,7 +199,9 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_select_taxonomy_input_type' => __( 'Input type', 'tainacan' ), 'label_select_taxonomy_input_type' => __( 'Input type', 'tainacan' ),
'label_taxonomy_allow_new_terms' => __( 'Allow new terms', 'tainacan' ), 'label_taxonomy_allow_new_terms' => __( 'Allow new terms', 'tainacan' ),
'label_selectbox_init' => __( 'Select', 'tainacan' ), 'label_selectbox_init' => __( 'Select', 'tainacan' ),
'label_options' => __( 'Insert options', 'tainacan' ), 'label_insert_options' => __( 'Insert options', 'tainacan'),
'label_available_terms' => __( 'Available terms', 'tainacan' ),
'label_some_available_terms' => __( 'Some available terms', 'tainacan' ),
'label_attachments' => __( 'Attachments', 'tainacan' ), 'label_attachments' => __( 'Attachments', 'tainacan' ),
'label_attachment' => __( 'Attachment', 'tainacan' ), 'label_attachment' => __( 'Attachment', 'tainacan' ),
'label_enabled' => __( 'Enabled', 'tainacan' ), 'label_enabled' => __( 'Enabled', 'tainacan' ),
@ -212,6 +214,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_parent_term' => __( 'Parent Term', 'tainacan' ), 'label_parent_term' => __( 'Parent Term', 'tainacan' ),
'label_children_terms' => __( 'children terms', 'tainacan' ), 'label_children_terms' => __( 'children terms', 'tainacan' ),
'label_new_term' => __( 'Create New Term', 'tainacan' ), 'label_new_term' => __( 'Create New Term', 'tainacan' ),
'label_create_and_select' => __( 'Create and Select', 'tainacan' ),
'label_new_child' => __( 'New Child', 'tainacan' ), 'label_new_child' => __( 'New Child', 'tainacan' ),
'label_taxonomy_terms' => __( 'Taxonomy Terms', 'tainacan' ), 'label_taxonomy_terms' => __( 'Taxonomy Terms', 'tainacan' ),
'label_no_parent_term' => __( 'No parent term', 'tainacan' ), 'label_no_parent_term' => __( 'No parent term', 'tainacan' ),
@ -347,6 +350,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_show_metadata' => __( 'Show metadata', 'tainacan' ), 'label_show_metadata' => __( 'Show metadata', 'tainacan' ),
'label_all_terms' => __( 'All terms', 'tainacan' ), 'label_all_terms' => __( 'All terms', 'tainacan' ),
'label_selected_terms' => __( 'Selected terms', 'tainacan' ), 'label_selected_terms' => __( 'Selected terms', 'tainacan' ),
'label_selected_term' => __( 'Selected term', 'tainacan' ),
'label_all_metadatum_values' => __( 'All metadatum values', 'tainacan' ), 'label_all_metadatum_values' => __( 'All metadatum values', 'tainacan' ),
'label_selected_metadatum_values' => __( 'Selected metadatum values', 'tainacan' ), 'label_selected_metadatum_values' => __( 'Selected metadatum values', 'tainacan' ),
'label_editing_item_number' => __( 'Editing item n.', 'tainacan' ), 'label_editing_item_number' => __( 'Editing item n.', 'tainacan' ),
@ -569,6 +573,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_showing_taxonomies' => __( 'Showing taxonomies ', 'tainacan' ), 'info_showing_taxonomies' => __( 'Showing taxonomies ', 'tainacan' ),
'info_showing_activities' => __( 'Showing activities ', 'tainacan' ), 'info_showing_activities' => __( 'Showing activities ', 'tainacan' ),
'info_showing_processes' => __( 'Showing processes ', 'tainacan' ), 'info_showing_processes' => __( 'Showing processes ', 'tainacan' ),
'info_showing_terms' => __( 'Showing terms ', 'tainacan' ),
'info_warning_remove_from_trash_first' => __( 'Remove this item from trash first' ), 'info_warning_remove_from_trash_first' => __( 'Remove this item from trash first' ),
'info_to' => __( ' to ', 'tainacan' ), 'info_to' => __( ' to ', 'tainacan' ),
'info_of' => __( ' of ', 'tainacan' ), 'info_of' => __( ' of ', 'tainacan' ),

View File

@ -493,9 +493,8 @@
.wp-block-tainacan-facets-list ul.facets-list.facets-layout-cloud li.facet-list-item a, .wp-block-tainacan-facets-list ul.facets-list.facets-layout-cloud li.facet-list-item a,
.wp-block-tainacan-facets-list ul.facets-list-edit.facets-layout-cloud li.facet-list-item a { .wp-block-tainacan-facets-list ul.facets-list-edit.facets-layout-cloud li.facet-list-item a {
color: #454647; color: #454647;
display: flex; display: inline;
align-items: center; min-height: 54px; }
height: 54px; }
.wp-block-tainacan-facets-list ul.facets-list.facets-layout-cloud li.facet-list-item img, .wp-block-tainacan-facets-list ul.facets-list.facets-layout-cloud li.facet-list-item img,
.wp-block-tainacan-facets-list ul.facets-list-edit.facets-layout-cloud li.facet-list-item img { .wp-block-tainacan-facets-list ul.facets-list-edit.facets-layout-cloud li.facet-list-item img {
height: auto; height: auto;

File diff suppressed because one or more lines are too long

View File

@ -104,7 +104,6 @@ class Log extends Entity {
return $this->get_mapped_property( 'slug' ); return $this->get_mapped_property( 'slug' );
} }
/** /**
* Return the Log description * Return the Log description
* *

View File

@ -20,7 +20,7 @@
<img <img
:alt="$i18n.get('label_thumbnail')" :alt="$i18n.get('label_thumbnail')"
width="24" width="24"
:src="`${props.option.img}`"> :src="props.option.img">
</div> </div>
<div class="media-content"> <div class="media-content">
<span class="ellipsed-text">{{ props.option.label }}</span> <span class="ellipsed-text">{{ props.option.label }}</span>
@ -149,14 +149,3 @@
} }
} }
</script> </script>
<style scoped>
#profileImage {
width: 32px;
height: 32px;
font-size: 2.1875rem;
color: #fff;
text-align: center;
line-height: 9.375rem;
margin: 20px 0;
}
</style>

View File

@ -276,13 +276,14 @@ export const dynamicFilterTypeMixin = {
sResults.push({ sResults.push({
label: item.label, label: item.label,
value: item.value, value: item.value,
img: item.thumbnail && item.thumbnail['tainacan-small'] && item.thumbnail['tainacan-small'][0] ? item.thumbnail['tainacan-small'][0] : (item.img ? item.img : ''),
total_items: item.total_items total_items: item.total_items
}); });
} else if (indexToIgnore < 0) { } else if (indexToIgnore < 0) {
opts.push({ opts.push({
label: item.label, label: item.label,
value: item.value, value: item.value,
img: (item.img ? item.img : this.thumbPlaceholderPath), img: item.thumbnail && item.thumbnail['tainacan-small'] && item.thumbnail['tainacan-small'][0] ? item.thumbnail['tainacan-small'][0] : (item.img ? item.img : ''),
total_items: item.total_items total_items: item.total_items
}); });
} }
@ -291,14 +292,14 @@ export const dynamicFilterTypeMixin = {
sResults.push({ sResults.push({
label: item.label, label: item.label,
value: item.value, value: item.value,
img: (item.img ? item.img : this.thumbPlaceholderPath), img: item.thumbnail && item.thumbnail['tainacan-small'] && item.thumbnail['tainacan-small'][0] ? item.thumbnail['tainacan-small'][0] : (item.img ? item.img : ''),
total_items: item.total_items total_items: item.total_items
}); });
} else { } else {
opts.push({ opts.push({
label: item.label, label: item.label,
value: item.value, value: item.value,
img: (item.img ? item.img : this.thumbPlaceholderPath), img: item.thumbnail && item.thumbnail['tainacan-small'] && item.thumbnail['tainacan-small'][0] ? item.thumbnail['tainacan-small'][0] : (item.img ? item.img : ''),
total_items: item.total_items total_items: item.total_items
}); });
} }

View File

@ -56,7 +56,7 @@
<a <a
role="button" role="button"
@click="addInterval(index)" @click="addInterval(index)"
class="is-inline add-link" class="add-link"
:title="$i18n.get('add_value')"> :title="$i18n.get('add_value')">
<span class="icon is-small"> <span class="icon is-small">
<i class="tainacan-icon has-text-secondary tainacan-icon-add"/> <i class="tainacan-icon has-text-secondary tainacan-icon-add"/>
@ -70,7 +70,7 @@
<a <a
role="button" role="button"
@click="removeInterval(index)" @click="removeInterval(index)"
class="is-inline add-link" class="add-link"
:title="$i18n.get('remove_value')"> :title="$i18n.get('remove_value')">
<span class="icon is-small"> <span class="icon is-small">
<i class="tainacan-icon has-text-secondary tainacan-icon-repprovedcircle"/> <i class="tainacan-icon has-text-secondary tainacan-icon-repprovedcircle"/>

View File

@ -74,9 +74,7 @@
export default { export default {
props: { props: {
filter: Object, value: [String, Number, Array]
value: [String, Number, Array],
disabled: false,
}, },
data() { data() {
return { return {

View File

@ -157,7 +157,8 @@
let params = { let params = {
'include': metadata.terms, 'include': metadata.terms,
'order': 'asc' 'order': 'asc',
'fetchonly': 0
}; };
return axios.get('/taxonomy/' + this.taxonomyId + '/terms/?' + qs.stringify(params) ) return axios.get('/taxonomy/' + this.taxonomyId + '/terms/?' + qs.stringify(params) )

View File

@ -1,18 +1,15 @@
<template> <template>
<div> <div>
<div <b-input
:class="{'has-content': dateValue !== undefined && dateValue !== ''}" :id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
class="control is-inline">
<input
:disabled="disabled" :disabled="disabled"
class="input" class="input"
:class="{'is-danger': isInvalidDate && dateValue}" :class="{'is-danger': isInvalidDate && dateValue}"
type="text" type="text"
v-mask="dateMask" v-mask="dateMask"
v-model="dateValue" v-model="dateValue"
@blur="onBlur" @input.native="onInput"
@input="onInput" :placeholder="dateFormat.toLowerCase()" />
:placeholder="dateFormat.toLowerCase()">
<p <p
v-if="isInvalidDate && dateValue" v-if="isInvalidDate && dateValue"
class="has-text-danger is-italic is-size-7">{{ $i18n.get('info_error_invalid_date') }}</p> class="has-text-danger is-italic is-size-7">{{ $i18n.get('info_error_invalid_date') }}</p>
@ -25,10 +22,7 @@
<!--<div class="field">--> <!--<div class="field">-->
<!--<b-datepicker--> <!--<b-datepicker-->
<!--:class="{'has-content': dateValue !== undefined && dateValue !== ''}"-->
<!--:id="id"-->
<!--v-model="dateValue"--> <!--v-model="dateValue"-->
<!--@blur="onBlur"-->
<!--:readonly="false"--> <!--:readonly="false"-->
<!--inline--> <!--inline-->
<!--@input="onInput($event)"--> <!--@input="onInput($event)"-->
@ -36,7 +30,6 @@
<!--</div>--> <!--</div>-->
<!--</b-collapse>--> <!--</b-collapse>-->
</div> </div>
</div>
</template> </template>
<script> <script>
@ -56,17 +49,11 @@
} }
}, },
props: { props: {
id: '', metadatum: Object,
metadatum: {
type: Object
},
value: [String, Number, Array], value: [String, Number, Array],
disabled: false, disabled: false,
}, },
methods: { methods: {
onBlur() {
this.$emit('blur');
},
onInput: _.debounce(function ($event) { onInput: _.debounce(function ($event) {
// Emty dates don't need to be validated, they remove the metadata // Emty dates don't need to be validated, they remove the metadata
if ($event.target.value != '') { if ($event.target.value != '') {
@ -89,8 +76,14 @@
} else { } else {
this.$emit('input', [null]); this.$emit('input', [null]);
} }
this.$emit('blur');
}, 300) }, 300)
} }
} }
</script> </script>
<style scoped lang="scss">
.control {
padding-left: 0 !important;
padding-right: 0 !important;
}
</style>

View File

@ -0,0 +1,99 @@
<template>
<section>
<b-field :addons="false">
<label class="label is-inline">
{{ $i18n.getHelperTitle('tainacan-numeric', 'step') }}<span>&nbsp;*&nbsp;</span>
<help-button
:title="$i18n.getHelperTitle('tainacan-numeric', 'step')"
:message="$i18n.getHelperMessage('tainacan-numeric', 'step')"/>
</label>
<div
v-if="!showEditStepOptions"
class="is-flex">
<b-select
name="step_options"
v-model="step"
@input="onUpdateStep">
<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="onUpdateStep"
type="number"
step="1" />
<button
@click.prevent="showEditStepOptions = false"
class="button is-white is-pulled-right">
<span
v-tooltip="{
content: $i18n.get('close'),
autoHide: true,
placement: 'bottom'
}"
class="icon">
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-close has-text-secondary"/>
</span>
</button>
</div>
</b-field>
</section>
</template>
<script>
export default {
props: {
value: [ String, Object, Array ]
},
data() {
return {
step: [Number, String],
showEditStepOptions: false
}
},
methods: {
onUpdateStep(value) {
this.$emit('input', { step: value });
}
},
created() {
this.step = this.value && this.value.step ? this.value.step : 0.01;
}
}
</script>
<style scoped>
section{
margin-bottom: 10px;
}
</style>

View File

@ -1,44 +1,32 @@
<template> <template>
<b-input <b-input
:disabled="disabled" :disabled="disabled"
:class="{'has-content': inputValue !== undefined && inputValue !== ''}" :id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:id="id" :value="value"
lang="en" @input="onInput($event)"
type="number" type="number"
:value="inputValue" lang="en"
step="0.01" :step="getStep"/>
@blur="onBlur"
@change="onBlur"
@input="onInput($event)"/>
</template> </template>
<script> <script>
export default { export default {
created(){
if( this.value ){
this.inputValue = this.value
}
},
data() {
return {
inputValue: ''
}
},
props: { props: {
id: '', metadatum: Object,
metadatum: {
type: Object
},
value: [String, Number, Array], value: [String, Number, Array],
disabled: false, disabled: false,
}, },
methods: { computed: {
onBlur() { getStep() {
this.$emit('blur'); if (this.metadatum && this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.step)
return this.metadatum.metadatum.metadata_type_options.step;
else
return 0.01;
}
}, },
onInput($event) { methods: {
this.inputValue = $event; onInput(value) {
this.$emit('input', this.inputValue); this.$emit('input', value);
} }
} }
} }

View File

@ -12,9 +12,10 @@ class Numeric extends Metadata_Type {
function __construct(){ function __construct(){
// call metadatum type constructor // call metadatum type constructor
parent::__construct(); parent::__construct();
$this->set_name( __('Numeric', 'tainacan') );
$this->set_primitive_type('float'); $this->set_primitive_type('float');
$this->set_component('tainacan-numeric'); $this->set_component('tainacan-numeric');
$this->set_name( __('Numeric', 'tainacan') ); $this->set_form_component('tainacan-form-numeric');
$this->set_description( __('A numeric value, integer or float', 'tainacan') ); $this->set_description( __('A numeric value, integer or float', 'tainacan') );
$this->set_preview_template(' $this->set_preview_template('
<div> <div>
@ -25,6 +26,18 @@ class Numeric extends Metadata_Type {
'); ');
} }
/**
* @inheritdoc
*/
public function get_form_labels(){
return [
'step' => [
'title' => __( 'Step', 'tainacan' ),
'description' => __( 'The amount to be increased or decreased when clicking on filter control buttons.', 'tainacan' ),
]
];
}
/** /**
* @param $itemMetadata \Tainacan\Entities\Item_Metadata_Entity The instace of the entity itemMetadata * @param $itemMetadata \Tainacan\Entities\Item_Metadata_Entity The instace of the entity itemMetadata
* @return string * @return string

View File

@ -3,17 +3,41 @@
<b-taginput <b-taginput
expanded expanded
:disabled="disabled" :disabled="disabled"
:id="id" :id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
v-model="selected" :value="selected"
size="is-small"
icon="magnify"
@input="onInput"
:data="options" :data="options"
:maxtags="maxtags != undefined ? maxtags : (metadatum.metadatum.multiple == 'yes' || allowNew === true ? 100 : 1)" :maxtags="maxtags != undefined ? maxtags : (metadatum.metadatum.multiple == 'yes' || allowNew === true ? 100 : 1)"
autocomplete autocomplete
attached attached
:loading="loading" :placeholder="$i18n.get('instruction_type_existing_term')"
:loading="isLoading"
:aria-close-label="$i18n.get('remove_value')" :aria-close-label="$i18n.get('remove_value')"
:class="{'has-selected': selected != undefined && selected != []}" :class="{'has-selected': selected != undefined && selected != []}"
field="label" field="label"
@typing="search"/> @typing="(query) => { options = []; search(query); }">
<template slot-scope="props">
<div class="media">
<div
v-if="props.option.img"
class="media-left">
<img
width="28"
:src="props.option.img">
</div>
<div class="media-content">
{{ props.option.label }}
</div>
</div>
</template>
<template
v-if="!isLoading"
slot="empty">
{{ $i18n.get('info_no_item_found') }}
</template>
</b-taginput>
</div> </div>
</template> </template>
@ -22,17 +46,20 @@
import qs from 'qs'; import qs from 'qs';
export default { export default {
created(){ created() {
let collectionId = ( this.metadatum && this.metadatum.metadatum.metadata_type_options.collection_id ) ? this.metadatum.metadatum.metadata_type_options.collection_id : this.collection_id; this.collectionId = ( this.metadatum && this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.collection_id ) ? this.metadatum.metadatum.metadata_type_options.collection_id : '';
if ( this.metadatum.value && (Array.isArray( this.metadatum.value ) ? this.metadatum.value.length > 0 : true )){ if (this.metadatum.value && (Array.isArray( this.metadatum.value ) ? this.metadatum.value.length > 0 : true )) {
let query = qs.stringify({ postin: ( Array.isArray( this.metadatum.value ) ) ? this.metadatum.value : [ this.metadatum.value ] }); let query = qs.stringify({ postin: ( Array.isArray( this.metadatum.value ) ) ? this.metadatum.value : [ this.metadatum.value ] });
query += this.metadatum.metadatum.metadata_type_options.search ? '&fetch_only_meta=' + this.metadatum.metadatum.metadata_type_options.search : ''; query += this.metadatum.metadatum.metadata_type_options.search ? '&fetch_only_meta=' + this.metadatum.metadatum.metadata_type_options.search : '';
axios.get('/collection/'+collectionId+'/items?' + query + '&nopaging=1&fetch_only=title,thumbnail') axios.get('/collection/' + this.collectionId + '/items?' + query + '&nopaging=1&fetch_only=title,thumbnail')
.then( res => { .then( res => {
if (res.data.items) { if (res.data.items) {
for (let item of res.data.items) { for (let item of res.data.items)
this.selected.push({ label: this.getItemLabel(item), value: item.id, img: item.thumbnail && item.thumbnail['tainacan-small'] && item.thumbnail['tainacan-small'][0] ? item.thumbnail['tainacan-small'][0] : '' }); this.selected.push({
} label: this.getItemLabel(item),
value: item.id,
img: item.thumbnail && item.thumbnail['tainacan-small'] && item.thumbnail['tainacan-small'][0] ? item.thumbnail['tainacan-small'][0] : ''
});
} }
}) })
.catch(error => { .catch(error => {
@ -40,100 +67,78 @@
}); });
} }
}, },
data(){ data() {
return { return {
results:'', results:'',
selected:[], selected:[],
options: [], options: [],
loading: false, isLoading: false,
collectionId: 0, collectionId: '',
inputValue: null, inputValue: null,
queryObject: {}, queryObject: {},
itemsFound: [] itemsFound: []
} }
}, },
props: { props: {
metadatum: { metadatum: Object,
type: Object
},
collection_id: {
type: Number
},
id: '',
maxtags: undefined, maxtags: undefined,
disabled: false, disabled: false,
allowNew: true, allowNew: true,
}, },
watch: {
selected( value ){
this.selected = value;
let values = [];
if( this.selected.length > 0 ){
for(let val of this.selected){
values.push( val.value );
}
}
this.onInput( values );
}
},
methods: { methods: {
setResults(option){ setResults(option){
if(!option) if(!option)
return; return;
this.results = option.value; this.results = option.value;
}, },
onInput( $event ) { onInput(newSelected) {
this.$emit('input', $event); this.selected = newSelected;
this.$emit('blur'); this.$emit('input', newSelected.map((item) => item.value));
}, },
search: _.debounce(function(query) { search: _.debounce(function(query) {
if ( this.selected.length > 0 && this.metadatum.metadatum.multiple === 'no') if ( this.selected.length > 0 && this.metadatum.metadatum.multiple === 'no')
return ''; return '';
if (query !== '') { if (query !== '') {
this.loading = true; this.isLoading = true;
this.options = [];
let metaquery = this.mountQuery( query ); axios.get('/collection/' + this.collectionId + '/items?' + this.getQueryString(query))
let collectionId = ( this.metadatum && this.metadatum.metadatum.metadata_type_options.collection_id ) ? this.metadatum.metadatum.metadata_type_options.collection_id : this.collection_id;
axios.get('/collection/'+collectionId+'/items?' + qs.stringify( metaquery ))
.then( res => { .then( res => {
this.loading = false; this.isLoading = false;
this.options = []; this.options = [];
let result = res.data;
if (result.items) { if (res.data.items) {
for (let item of result.items) { for (let item of res.data.items)
this.options.push({ label: this.getItemLabel(item), value: item.id }) this.options.push({
} label: this.getItemLabel(item),
value: item.id,
img: item.thumbnail && item.thumbnail['tainacan-small'] && item.thumbnail['tainacan-small'][0] ? item.thumbnail['tainacan-small'][0] : ''
})
} }
}) })
.catch(error => { .catch(error => {
this.$console.log(error); this.$console.log(error);
}); });
} else {
this.options = [];
} }
}, 500), }, 500),
getItemLabel(item) { getItemLabel(item) {
let label = ''; let label = '';
for (let m in item.metadata) { for (let m in item.metadata) {
if (item.metadata[m].id == this.metadatum.metadatum.metadata_type_options.search) { if (item.metadata[m].id == this.metadatum.metadatum.metadata_type_options.search)
label = item.metadata[m].value_as_string; label = item.metadata[m].value_as_string;
} }
} if (label != '' && label != item.title && item.title != '')
if (label != '' && label != item.title && item.title != '') {
label += ' (' + item.title + ')'; label += ' (' + item.title + ')';
} else if (label == '') { else if (label == '')
label = item.title; label = item.title;
}
return label; return label;
}, },
mountQuery( search ) { getQueryString( search ) {
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)
{ {
query['metaquery'] = []; query['metaquery'] = [];
@ -150,7 +155,7 @@
query['fetch_only'] = 'title,thumbnail'; query['fetch_only'] = 'title,thumbnail';
query['fetch_only_meta'] = this.metadatum.metadatum.metadata_type_options.search; query['fetch_only_meta'] = this.metadatum.metadatum.metadata_type_options.search;
return query; return qs.stringify(query);
} }
} }
} }

View File

@ -1,44 +1,33 @@
<template> <template>
<div>
<b-select <b-select
expanded expanded
:disabled="disabled" :disabled="disabled"
:id = "id" :id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:placeholder="$i18n.get('label_selectbox_init')" :placeholder="$i18n.get('label_selectbox_init')"
:value="value" :value="value"
:class="{'is-empty': value == undefined || value == ''}" @input="onSelected($event)">
@blur="$emit('blur')" <option value="">{{ $i18n.get('label_selectbox_init') }}...</option>
@input="onChecked($event)">
<option <option
v-for="(option, index) in getOptions" v-for="(option, index) in getOptions"
:key="index" :key="index"
:label="option" :label="option"
:value="option" :value="option">
border>{{ option }}</option> {{ option }}
</option>
</b-select> </b-select>
</div>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
metadatum: { metadatum: Object,
type: Object
},
options: {
type: String
},
value: [String, Number, Array], value: [String, Number, Array],
id: '',
disabled: false, disabled: false,
}, },
computed: { computed: {
getOptions(){ getOptions(){
if ( this.options && this.options !== '' ){ if (this.metadatum && this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.options ) {
return this.options.split("\n");
}
else if ( this.metadatum && this.metadatum.metadatum.metadata_type_options.options ) {
const metadata = this.metadatum.metadatum.metadata_type_options.options; const metadata = this.metadatum.metadatum.metadata_type_options.options;
return ( metadata ) ? metadata.split("\n") : []; return ( metadata ) ? metadata.split("\n") : [];
} }
@ -46,7 +35,7 @@
} }
}, },
methods: { methods: {
onChecked(value) { onSelected(value) {
this.$emit('input', value); this.$emit('input', value);
}, },
} }

View File

@ -27,8 +27,12 @@
<span <span
v-if="metadatum.metadatum.required == 'yes'" v-if="metadatum.metadatum.required == 'yes'"
class="required-metadatum-asterisk" class="required-metadatum-asterisk"
:class="metadatumTypeMessage">*</span> :class="metadatumTypeMessage">
<span class="metadata-type">({{ metadatum.metadatum.metadata_type_object.name }})</span> *
</span>
<span class="metadata-type">
({{ metadatum.metadatum.metadata_type_object.name }})
</span>
<help-button <help-button
:title="metadatum.metadatum.name" :title="metadatum.metadatum.name"
:message="metadatum.metadatum.description"/> :message="metadatum.metadatum.description"/>
@ -38,43 +42,44 @@
v-show="isCollapsed || metadatumTypeMessage == 'is-danger'" v-show="isCollapsed || metadatumTypeMessage == 'is-danger'"
v-if="isTextInputComponent( metadatum.metadatum.metadata_type_object.component )"> v-if="isTextInputComponent( metadatum.metadatum.metadata_type_object.component )">
<component <component
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:is="metadatum.metadatum.metadata_type_object.component" :is="metadatum.metadatum.metadata_type_object.component"
v-model="inputs[0]" v-model="inputs[0]"
:metadatum="metadatum" :metadatum="metadatum"
@input="emitIsChangingValue()"/> @input="changeValue()"/>
<div v-if="metadatum.metadatum.multiple == 'yes'"> <template v-if="metadatum.metadatum.multiple == 'yes'">
<div <transition-group
v-if="index > 0" name="filter-item"
v-for="(input, index) in inputs"
:key="index"
class="multiple-inputs"> class="multiple-inputs">
<template
v-for="(input, index) in inputs.slice(1)">
<component <component
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug" :key="index"
:is="metadatum.metadatum.metadata_type_object.component" :is="metadatum.metadatum.metadata_type_object.component"
v-model="inputs[index]" v-model="inputs[index]"
:metadatum="metadatum" :metadatum="metadatum"
@input="emitIsChangingValue()"/> @input="changeValue()"/>
<a <a
v-if="index > 0" v-if="index > 0"
@click="removeInput(index)" @click="removeInput(index)"
class="is-inline add-link"> class="add-link"
:key="index">
<b-icon <b-icon
icon="minus-circle" icon="minus-circle"
size="is-small" size="is-small"
type="is-secondary"/> type="is-secondary"/>
&nbsp;{{ $i18n.get('label_remove_value') }}</a> &nbsp;{{ $i18n.get('label_remove_value') }}
</div> </a>
</template>
</transition-group>
<a <a
@click="addInput" @click="addInput"
class="is-inline add-link"> class="is-block add-link">
<span class="icon is-small"> <span class="icon is-small">
<i class="tainacan-icon has-text-secondary tainacan-icon-add"/> <i class="tainacan-icon has-text-secondary tainacan-icon-add"/>
</span> </span>
&nbsp;{{ $i18n.get('label_add_value') }} &nbsp;{{ $i18n.get('label_add_value') }}
</a> </a>
</div> </template>
</div> </div>
</transition> </transition>
<transition name="filter-item"> <transition name="filter-item">
@ -82,11 +87,10 @@
v-show="isCollapsed" v-show="isCollapsed"
v-if="!isTextInputComponent( metadatum.metadatum.metadata_type_object.component )"> v-if="!isTextInputComponent( metadatum.metadatum.metadata_type_object.component )">
<component <component
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:is="metadatum.metadatum.metadata_type_object.component" :is="metadatum.metadatum.metadata_type_object.component"
v-model="inputs" v-model="inputs"
:metadatum="metadatum" :metadatum="metadatum"
@input="emitIsChangingValue()"/> @input="changeValue()"/>
</div> </div>
</transition> </transition>
</b-field> </b-field>
@ -103,8 +107,7 @@
}, },
data(){ data(){
return { return {
inputs: [], inputs: []
metadatumTypeMessage: ''
} }
}, },
computed: { computed: {
@ -113,32 +116,25 @@
let errors = eventBus.getErrors(this.metadatum.metadatum.id); let errors = eventBus.getErrors(this.metadatum.metadatum.id);
if (errors) { if (errors) {
this.setMetadatumTypeMessage('is-danger');
for (let error of errors) { for (let error of errors) {
for (let index of Object.keys(error)) { for (let index of Object.keys(error))
// this.$console.log(index);
errorMessage += error[index] + '\n'; errorMessage += error[index] + '\n';
} }
} }
} else {
this.setMetadatumTypeMessage('');
}
return errorMessage; return errorMessage;
},
metadatumTypeMessage() {
return this.getErrorMessage ? 'is-danger' : ''
} }
}, },
created(){ created() {
this.getValue(); this.createInputs();
}, },
methods: { methods: {
emitIsChangingValue() {
this.changeValue();
},
changeValue: _.debounce(function() { changeValue: _.debounce(function() {
if (this.metadatum.value != this.inputs) { if (this.inputs && this.inputs.length > 0 && this.inputs[0] && this.inputs[0].value) {
if (this.inputs.length > 0 && this.inputs[0].value) {
let terms = this.inputs.map(term => term.value) let terms = this.inputs.map(term => term.value)
if (this.metadatum.value instanceof Array){ if (this.metadatum.value instanceof Array){
@ -160,6 +156,7 @@
return; return;
} else if (this.metadatum.value instanceof Array) { } else if (this.metadatum.value instanceof Array) {
let equal = []; let equal = [];
for (let meta of this.inputs) { for (let meta of this.inputs) {
@ -173,19 +170,18 @@
return; return;
} }
eventBus.$emit('input', { item_id: this.metadatum.item.id, metadatum_id: this.metadatum.metadatum.id, values: this.inputs } ); eventBus.$emit('input', {
} itemId: this.metadatum.item.id,
}, 1000), metadatumId: this.metadatum.metadatum.id,
getValue(){ values: this.inputs ? this.inputs : ''
if (this.metadatum.value instanceof Array) { });
}, 900),
createInputs(){
if (this.metadatum.value instanceof Array)
this.inputs = this.metadatum.value.slice(0); this.inputs = this.metadatum.value.slice(0);
else
if (this.inputs.length === 0) this.metadatum.value == null || this.metadatum.value == undefined ? this.inputs = [] : this.inputs.push(this.metadatum.value);
this.inputs.push('');
} else {
this.metadatum.value == null || this.metadatum.value == undefined ? this.inputs.push('') : this.inputs.push(this.metadatum.value);
}
}, },
addInput(){ addInput(){
this.inputs.push(''); this.inputs.push('');
@ -195,12 +191,9 @@
this.inputs.splice(index, 1); this.inputs.splice(index, 1);
this.changeValue(); this.changeValue();
}, },
isTextInputComponent(component){ isTextInputComponent(component) {
let array = ['tainacan-relationship','tainacan-taxonomy']; const array = ['tainacan-relationship','tainacan-taxonomy'];
return !( array.indexOf( component ) >= 0 ); return !(array.indexOf(component) >= 0 );
},
setMetadatumTypeMessage(message){
this.metadatumTypeMessage = message;
} }
} }
} }

View File

@ -1,19 +1,19 @@
<template> <template>
<div> <div class="add-new-term">
<span v-if="!showForm"> <span v-if="!showForm">
<a <a
@click="toggleForm()" @click="toggleForm()"
class="is-inline add-link"> class="add-link">
<span class="icon is-small"> <span class="icon is-small">
<i class="tainacan-icon has-text-secondary tainacan-icon-add"/> <i class="tainacan-icon has-text-secondary tainacan-icon-add"/>
</span> </span>
&nbsp;{{ $i18n.get('label_new_term') }} &nbsp;{{ $i18n.get('label_new_term') }}
</a> </a>
</span> </span>
<transition name="appear"> <transition name="filter-item">
<section <section
v-if="showForm" v-if="showForm"
style="padding-left: 0px; margin-top: 12px; margin-bottom: -12px;"> class="add-new-term-form">
<b-field <b-field
:addons="false" :addons="false"
:type="((formErrors.name !== '' || formErrors.repeated !== '') && (formErrors.name !== undefined || formErrors.repeated !== undefined )) ? 'is-danger' : ''" :type="((formErrors.name !== '' || formErrors.repeated !== '') && (formErrors.name !== undefined || formErrors.repeated !== undefined )) ? 'is-danger' : ''"
@ -26,25 +26,11 @@
:message="$i18n.get('info_help_term_name')"/> :message="$i18n.get('info_help_term_name')"/>
</label> </label>
<b-input <b-input
:class="{'has-content': name != undefined && name != ''}" :placeholder="$i18n.get('label_term_without_name')"
v-model="name" v-model="name"
@focus="clearErrors({ name: 'name', repeated: 'repeated' })"/> @focus="clearErrors({ name: 'name', repeated: 'repeated' })"/>
</b-field> </b-field>
<!-- <b-field :label="$i18n.get('label_parent_term')">
<b-select
v-model="parent">
<option
:value="0"
selected> ---{{ $i18n.get('label_parent_term') }}--- </option>
<option
v-for="(option,index) in options"
:key="index"
:value="option.id"
v-html="setSpaces( option.level ) + option.name"/>
</b-select>
</b-field> -->
<!-- Parent -------------- --> <!-- Parent -------------- -->
<b-field <b-field
:addons="false" :addons="false"
@ -62,7 +48,7 @@
:message="$i18n.get('info_help_parent_term')"/> :message="$i18n.get('info_help_parent_term')"/>
</label> </label>
<b-autocomplete <b-autocomplete
id="tainacan-text-cover-page" id="tainacan-add-parent-field"
:placeholder="$i18n.get('instruction_parent_term')" :placeholder="$i18n.get('instruction_parent_term')"
:data="parentTerms" :data="parentTerms"
field="name" field="name"
@ -85,7 +71,7 @@
</p> </p>
</transition> </transition>
</b-field> </b-field>
<div class="field is-grouped form-submit">
<button <button
:class="{ 'is-loading': isAddingNewTerm }" :class="{ 'is-loading': isAddingNewTerm }"
class="button is-outlined" class="button is-outlined"
@ -93,14 +79,14 @@
type="button"> type="button">
{{ $i18n.get('cancel') }} {{ $i18n.get('cancel') }}
</button> </button>
<button <button
:class="{ 'is-loading': isAddingNewTerm }" :class="{ 'is-loading': isAddingNewTerm }"
class="button is-secondary" class="button is-secondary"
@click="save" @click="save"
type="button"> type="button">
{{ $i18n.get('save') }} {{ $i18n.get('label_create_and_select') }}
</button> </button>
</div>
</section> </section>
</transition> </transition>
@ -122,19 +108,15 @@
parentTermName: '', parentTermName: '',
isAddingNewTerm: false, isAddingNewTerm: false,
isFetchingParentTerms: false, isFetchingParentTerms: false,
metadatum_id: this.metadatum.metadatum.id, metadatumId: this.metadatum.metadatum.id,
itemId: this.metadatum.item.id,
formErrors: {} formErrors: {}
} }
}, },
props: { props: {
id: String,
item_id: [Number,String],
metadatum: [Number,String], metadatum: [Number,String],
taxonomy_id: [Number,String], taxonomyId: [Number,String],
value:[ Array, Boolean, Number ], value: [ Array, Boolean, Number ],
options: {
type: Array
},
componentType: '' componentType: ''
}, },
methods: { methods: {
@ -153,20 +135,11 @@
this.formErrors = {}; this.formErrors = {};
this.showForm = !this.showForm; this.showForm = !this.showForm;
}, },
setSpaces( level ){
let result = '';
let space = '&nbsp;&nbsp;'
for(let i = 0;i < level; i++)
result += space;
return result;
},
fecthParentTerms(search) { fecthParentTerms(search) {
this.isFetchingParentTerms = true; this.isFetchingParentTerms = true;
this.fetchPossibleParentTerms({ this.fetchPossibleParentTerms({
taxonomyId: this.taxonomy_id, taxonomyId: this.taxonomyId,
termId: 'new', termId: 'new',
search: search }) search: search })
.then((parentTerms) => { .then((parentTerms) => {
@ -182,21 +155,21 @@
this.clearErrors('parent'); this.clearErrors('parent');
}, },
onSelectParentTerm(selectedParentTerm) { onSelectParentTerm(selectedParentTerm) {
if (selectedParentTerm) {
this.parent = selectedParentTerm.id; this.parent = selectedParentTerm.id;
this.selectedParentTerm = selectedParentTerm;
this.parentTermName = selectedParentTerm.name; this.parentTermName = selectedParentTerm.name;
}
}, },
clearErrors(attributes) { clearErrors(attributes) {
if(attributes instanceof Object){ if (attributes instanceof Object) {
for(let attribute in attributes){ for(let attribute in attributes)
this.formErrors[attribute] = undefined; this.formErrors[attribute] = undefined;
}
} else { } else {
this.formErrors[attributes] = undefined; this.formErrors[attributes] = undefined;
} }
}, },
save(){ save() {
if( this.name.trim() === ''){ if (this.name.trim() === '') {
this.$buefy.toast.open({ this.$buefy.toast.open({
duration: 2000, duration: 2000,
message: this.$i18n.get('info_name_is_required'), message: this.$i18n.get('info_name_is_required'),
@ -206,32 +179,32 @@
} else { } else {
this.isAddingNewTerm = true; this.isAddingNewTerm = true;
axios.post(`/taxonomy/${this.taxonomy_id}/terms?hideempty=0&order=asc`, { axios.post(`/taxonomy/${this.taxonomyId}/terms?hideempty=0&order=asc`, {
name: this.name, name: this.name,
parent: this.parent parent: this.parent
}) })
.then( res => { .then(res => {
this.isAddingNewTerm = false; if (res.data && res.data.id || res.id) {
let id = res.id ? res.id : res.data.id;
if( res.data && res.data.id || res.id ){
let id = ( res.id ) ? res.id : res.data.id;
let val = this.value; let val = this.value;
if( !Array.isArray( val ) && this.metadatum.metadatum.multiple === 'no' ){ if (!Array.isArray(val) && this.metadatum.metadatum.multiple === 'no') {
axios.patch(`/item/${this.item_id}/metadata/${this.metadatum_id}`, { axios.patch(`/item/${this.itemId}/metadata/${this.metadatumId}`, {
values: id, values: id,
}).then(() => { }).then(() => {
this.$emit('newTerm', { values: id, taxonomyId: this.taxonomy_id, metadatumId: this.metadatum_id }); this.isAddingNewTerm = false;
this.$emit('newTerm', { values: id, taxonomyId: this.taxonomyId, metadatumId: this.metadatumId });
this.toggleForm(); this.toggleForm();
}) })
} else { } else {
val = ( val ) ? val : []; val = val ? val : [];
val.push( this.componentType == ('tainacan-taxonomy-checkbox' || 'tainacan-taxonomy-radio') ? id : {'label': this.name, 'value': id} ); val.push( this.componentType == ('tainacan-taxonomy-checkbox' || 'tainacan-taxonomy-radio') ? id : {'label': this.name, 'value': id} );
axios.patch(`/item/${this.item_id}/metadata/${this.metadatum_id}`, { axios.patch(`/item/${this.itemId}/metadata/${this.metadatumId}`, {
values: val, values: val,
}).then(() => { }).then(() => {
this.$emit('newTerm', { values: val, taxonomyId: this.taxonomy_id, metadatumId: this.metadatum_id }); this.isAddingNewTerm = false;
this.$emit('newTerm', { values: val, taxonomyId: this.taxonomyId, metadatumId: this.metadatumId });
this.toggleForm(); this.toggleForm();
}) })
} }
@ -256,5 +229,17 @@
} }
} }
</script> </script>
<style scoped> <style scoped>
.add-new-term {
margin-top: 15px;
margin-bottom: 25px;
font-size: 0.75rem;
}
.add-new-term-form {
padding: 14px 24px 12px 24px;
margin-top: 12px;
margin-bottom: -12px;
border: 1px solid #cbcbcb;
}
</style> </style>

View File

@ -7,53 +7,33 @@
v-model="valueComponent" v-model="valueComponent"
:allow-select-to-create="allowSelectToCreate" :allow-select-to-create="allowSelectToCreate"
:allow-new="allowNew" :allow-new="allowNew"
:terms="terms" :taxonomy-id="taxonomyId"
:taxonomy-id="taxonomy_id" :metadatum="metadatum.metadatum"/>
:options="getOptions(0)"/>
<a
class="add-new-term"
v-if="(getComponent == 'tainacan-taxonomy-checkbox' || getComponent == 'tainacan-taxonomy-radio') &&
terms.length < totalTerms"
@click="openCheckboxModal()">
{{ $i18n.get('label_view_all') }}
</a>
<add-new-term <add-new-term
class="add-new-term"
v-if="allowNew" v-if="allowNew"
:component-type="getComponent" :component-type="getComponent"
:taxonomy_id="taxonomy_id" :taxonomy-id="taxonomyId"
:metadatum="metadatum" :metadatum="metadatum"
:item_id="metadatum.item.id"
:value="valueComponent" :value="valueComponent"
:options="getOptions(0)"
@newTerm="reload"/> @newTerm="reload"/>
</div> </div>
</template> </template>
<script> <script>
import { tainacan as axios } from '../../../js/axios/axios'
import TainacanTaxonomyRadio from './TaxonomyRadio.vue' import TainacanTaxonomyRadio from './TaxonomyRadio.vue'
import TainacanTaxonomyCheckbox from './TaxonomyCheckbox.vue' import TainacanTaxonomyCheckbox from './TaxonomyCheckbox.vue'
import TainacanTaxonomyTagInput from './TaxonomyTaginput.vue' import TainacanTaxonomyTagInput from './TaxonomyTaginput.vue'
import AddNewTerm from './AddNewTerm.vue' import AddNewTerm from './AddNewTerm.vue'
import CheckboxRadioModal from '../../../admin/components/other/checkbox-radio-modal.vue'
export default { export default {
created(){ created(){
let metadata_type_options = this.metadatum.metadatum.metadata_type_options; const metadata_type_options = this.metadatum.metadatum.metadata_type_options;
this.component = ( metadata_type_options && metadata_type_options.input_type )
? this.metadatum.metadatum.metadata_type_options.input_type : this.componentAttribute;
this.collectionId = this.metadatum.metadatum.collection_id; this.taxonomyId = metadata_type_options.taxonomy_id;
this.taxonomy_id = metadata_type_options.taxonomy_id;
this.taxonomy = metadata_type_options.taxonomy; this.taxonomy = metadata_type_options.taxonomy;
if (metadata_type_options && metadata_type_options.allow_new_terms && this.metadatum.item) if (metadata_type_options && metadata_type_options.allow_new_terms && this.metadatum.item)
this.allowNew = metadata_type_options.allow_new_terms == 'yes'; this.allowNew = metadata_type_options.allow_new_terms == 'yes';
// This condition is temporary, used by bulk edition modal
if (this.component != 'tainacan-taxonomy-tag-input' || this.forcedComponentType != 'tainacan-taxonomy-tag-input')
this.getTermsFromTaxonomy();
this.getTermsId(); this.getTermsId();
}, },
components: { components: {
@ -65,32 +45,20 @@
data(){ data(){
return { return {
valueComponent: null, valueComponent: null,
component: '', taxonomyId: '',
collectionId: '',
taxonomy_id: '',
taxonomy: '', taxonomy: '',
terms:[], // object with names terms:[],
totalTerms: 0, allowNew: false
allowNew: false,
offset: 0,
termsNumber: 12
} }
}, },
watch: { watch: {
valueComponent( val ){ valueComponent( val ){
this.$emit('input', val); this.$emit('input', val);
this.$emit('blur');
} }
}, },
props: { props: {
metadatum: { metadatum: Object,
type: Object
},
componentAttribute: {
type: String
},
value: [ Number, String, Array, Object ], value: [ Number, String, Array, Object ],
id: '',
disabled: false, disabled: false,
forcedComponentType: '', forcedComponentType: '',
maxtags: '', maxtags: '',
@ -98,123 +66,36 @@
}, },
computed: { computed: {
getComponent() { getComponent() {
if (this.forcedComponentType){ if (this.forcedComponentType)
return this.forcedComponentType; return this.forcedComponentType;
} else if( this.metadatum.metadatum else if(this.metadatum.metadatum &&
&& this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.input_type ){ this.metadatum.metadatum.metadata_type_options &&
this.metadatum.metadatum.metadata_type_options.input_type
)
return this.metadatum.metadatum.metadata_type_options.input_type; return this.metadatum.metadatum.metadata_type_options.input_type;
}
} }
}, },
methods: { methods: {
openCheckboxModal(){ getTermsId() {
this.$buefy.modal.open({
parent: this,
component: CheckboxRadioModal,
props: {
isFilter: false,
parent: 0,
taxonomy_id: this.taxonomy_id,
selected: !this.valueComponent ? [] : this.valueComponent,
metadatumId: this.metadatum.metadatum.id,
taxonomy: this.taxonomy,
collectionId: this.collectionId,
isTaxonomy: true,
query: '',
metadatum: this.metadatum.metadatum,
isCheckbox: this.getComponent == 'tainacan-taxonomy-checkbox'
},
events: {
input: (selected) => {
this.valueComponent = selected;
}
},
width: 'calc(100% - 8.333333333%)',
trapFocus: true
});
},
getTermsFromTaxonomy(){
let endpoint = '/taxonomy/' + this.taxonomy_id + '/terms?hideempty=0&order=asc';
if (this.getComponent == 'tainacan-taxonomy-checkbox' || this.getComponent == 'tainacan-taxonomy-radio')
endpoint = endpoint + '&number=' + this.termsNumber + '&offset=' + this.offset;
axios.get(endpoint)
.then( res => {
if (this.getComponent == 'tainacan-taxonomy-checkbox' || this.getComponent == 'tainacan-taxonomy-radio') {
this.totalTerms = Number(res.headers['x-wp-total']);
this.offset += this.termsNumber;
}
for (let item of res.data) {
this.terms.push( item );
}
})
.catch(error => {
this.$console.log(error);
});
},
getOptions( parent, level = 0 ){ // retrieve only ids
let result = [];
if ( this.terms ){
for( let term of this.terms ){
if( term.parent == parent ){
term['level'] = level;
result.push( term );
const levelTerm = level + 1;
const children = this.getOptions( term.id, levelTerm);
result = result.concat( children );
}
}
}
return result;
},
getTermsId(){
let values = []; let values = [];
if (this.value && this.metadatum.metadatum && this.getComponent != 'tainacan-taxonomy-tag-input') {
if( this.value && this.value.length > 0){ values = this.value.map(term => term.id)
for( let term of this.value ){ this.valueComponent = (values.length >= 0 && this.metadatum.metadatum && this.metadatum.metadatum.multiple === 'no') ? values[0] : values;
if( term && term.id) } else if (this.value && this.metadatum.metadatum && this.getComponent == 'tainacan-taxonomy-tag-input') {
values.push(term.id); values = this.value.map((term) => { return { label: term.name, value: term.id } });
}
}
if( values.length > 0 && this.metadatum.metadatum && this.component != 'tainacan-taxonomy-tag-input'){
this.valueComponent = ( this.metadatum.metadatum && this.metadatum.metadatum.multiple === 'no' ) ? values[0] : values;
} else if(values.length > 0 && this.metadatum.metadatum && this.component == 'tainacan-taxonomy-tag-input') {
let values = [];
for(let term of this.value){
values.push({label: term.name, value: term.id});
}
this.valueComponent = values; this.valueComponent = values;
} }
}, },
onInput($event) { onInput($event) {
this.inputValue = $event;
this.valueComponent = $event; this.valueComponent = $event;
this.$emit('input', this.inputValue); this.$emit('input', this.valueComponent);
this.$emit('blur');
}, },
reload( $event ) { reload($event) {
if ($event.taxonomyId == this.taxonomy_id && $event.metadatumId == this.metadatum.metadatum.id) { if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.metadatum.metadatum.id) {
this.valueComponent = $event.values; this.valueComponent = $event.values;
this.terms = []; this.$emit('update-taxonomy-inputs', $event)
this.offset = 0;
this.getTermsFromTaxonomy();
this.getTermsId();
} }
} }
} }
} }
</script> </script>
<style scoped>
.add-new-term{
margin-top: 15px;
margin-bottom: 30px;
font-size: 0.75rem;
}
</style>

View File

@ -3,7 +3,7 @@
<p <p
v-if="value instanceof Array ? value.length > 0 : (value != undefined && value != '')" v-if="value instanceof Array ? value.length > 0 : (value != undefined && value != '')"
class="has-text-gray"> class="has-text-gray">
{{ $i18n.get('label_selected_terms') + ' :' }} {{ $i18n.get('label_selected_terms') + ':' }}
</p> </p>
<b-field <b-field
v-if="value instanceof Array ? value.length > 0 : (value != undefined && value != '')" v-if="value instanceof Array ? value.length > 0 : (value != undefined && value != '')"
@ -24,81 +24,118 @@
v-if="isSelectedTermsLoading" v-if="isSelectedTermsLoading"
class="control has-icons-right is-loading is-clearfix" /> class="control has-icons-right is-loading is-clearfix" />
</b-field> </b-field>
<p
style="margin-top: 10px;"
class="has-text-gray">
{{ (isShowingAllTerms ? $i18n.get('label_available_terms') : $i18n.get('label_some_available_terms')) + ':' }}
</p>
<div <div
v-for="(option, index) in options" class="metadata-taxonomy-list"
:key="index"> :id="metadatum.metadata_type_object.component + '-' + metadatum.slug">
<template v-for="(option, index) in options">
<b-checkbox <b-checkbox
:disabled="disabled"
:id="id"
:style="{ paddingLeft: (option.level * 30) + 'px' }"
:key="index" :key="index"
:disabled="disabled"
:style="{ paddingLeft: (option.level * 30) + 'px' }"
v-model="checked" v-model="checked"
@input="onChecked(option)" @input="onChecked(option)"
:native-value="option.id" :native-value="option.id"
border> border>
{{ option.name }} {{ option.name }}
</b-checkbox> </b-checkbox>
<br> <br :key="index">
</template>
</div>
<div
v-if="!isShowingAllTerms"
class="view-all">
<span>
{{
$i18n.get('info_showing_terms') + 1 +
$i18n.get('info_to') + options.length +
$i18n.get('info_of') + totalTerms + '. '
}}
</span>
<a @click="openCheckboxModal()">
{{ $i18n.get('label_view_all') + ' ' + totalTerms + '.' }}
</a>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { tainacan as axios } from '../../../js/axios/axios'; import { tainacan as axios } from '../../../js/axios/axios';
import qs from 'qs';
import CheckboxRadioModal from '../../../admin/components/other/checkbox-radio-modal.vue'
export default { export default {
created(){ created() {
if( this.value && this.value.length > 0) if (this.value && this.value.length > 0)
this.checked = this.value; this.checked = this.value;
this.getTermsFromTaxonomy();
this.$parent.$on('update-taxonomy-inputs', ($event) => {
if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.metadatum.id) {
this.offset = 0;
this.getTermsFromTaxonomy();
}
});
}, },
data(){ data() {
return { return {
checked: [], checked: [],
selectedTagsName: {}, selectedTagsName: {},
isSelectedTermsLoading: false, isSelectedTermsLoading: false,
options: [],
terms: [],
termsNumber: 12,
offset: 0,
totalTerms: 0
} }
}, },
watch: { watch: {
value( val ){ value(val){
this.checked = val; this.checked = val;
this.fetchSelectedLabels(); this.fetchSelectedLabels();
} }
}, },
props: { computed: {
options: { isShowingAllTerms() {
type: Array return this.terms.length >= this.totalTerms;
}
}, },
props: {
value: [ Number, String, Array ], value: [ Number, String, Array ],
disabled: false, disabled: false,
taxonomyId: Number taxonomyId: Number,
metadatum: Object
}, },
methods: { methods: {
onChecked() { onChecked() {
this.$emit('blur');
this.onInput(this.checked); this.onInput(this.checked);
}, },
onInput($event) { onInput($event) {
this.inputValue = $event; this.value = $event;
this.$emit('input', this.inputValue); this.$emit('input', this.value);
}, },
fetchSelectedLabels() { fetchSelectedLabels() {
if (this.value != null && this.value != undefined) { if (this.value != null && this.value != undefined) {
this.isSelectedTermsLoading = true; const selected = this.value instanceof Array ? this.value : [this.value];
let selected = this.value instanceof Array ? this.value : [this.value];
if (this.taxonomyId && selected.length > 0) { if (this.taxonomyId) {
for (const term of selected) {
if(!this.isSelectedTermsLoading){
this.isSelectedTermsLoading = true; this.isSelectedTermsLoading = true;
axios.get(`/taxonomy/${this.taxonomyId}/terms/?${qs.stringify({ hideempty: 0, include: selected })}`)
.then((res) => {
let terms = res.data;
for (let term of terms) {
if (!this.selectedTagsName[term.id])
this.$set(this.selectedTagsName, term.id, term.name);
} }
axios.get(`/taxonomy/${this.taxonomyId}/terms/${term}`)
.then((res) => {
this.saveSelectedTagName(res.data.id, res.data.name);
this.isSelectedTermsLoading = false; this.isSelectedTermsLoading = false;
}) })
.catch((error) => { .catch((error) => {
@ -106,16 +143,69 @@
this.isSelectedTermsLoading = false; this.isSelectedTermsLoading = false;
}); });
} }
} else {
this.isSelectedTermsLoading = false;
}
} }
}, },
saveSelectedTagName(value, label){ getTermsFromTaxonomy() {
if(!this.selectedTagsName[value]) { this.terms = [];
this.$set(this.selectedTagsName, `${value}`, label);
const endpoint = '/taxonomy/' + this.taxonomyId + '/terms?hideempty=0&order=asc&number=' + this.termsNumber + '&offset=' + this.offset;
axios.get(endpoint)
.then( res => {
this.totalTerms = Number(res.headers['x-wp-total']);
this.offset += this.termsNumber;
for (let item of res.data)
this.terms.push( item );
this.options = this.getOptions(0);
})
.catch(error => {
this.$console.log(error);
});
},
getOptions(parent, level = 0) { // retrieve only ids
let result = [];
if (this.terms) {
for (let term of this.terms){
if (term.parent == parent){
term['level'] = level;
result.push(term);
const levelTerm = level + 1;
const children = this.getOptions( term.id, levelTerm);
result = result.concat(children);
} }
} }
}
return result;
},
openCheckboxModal() {
this.$buefy.modal.open({
parent: this,
component: CheckboxRadioModal,
props: {
isFilter: false,
parent: 0,
taxonomy_id: this.taxonomyId,
selected: !this.value ? [] : this.value,
metadatumId: this.metadatum.id,
taxonomy: this.taxonomy,
collectionId: this.metadatum.collection_id,
isTaxonomy: true,
query: '',
metadatum: this.metadatum,
isCheckbox: true
},
events: {
input: (selected) => {
this.value = selected;
this.$emit('input', this.value);
}
},
width: 'calc(100% - 8.333333333%)',
trapFocus: true
});
}
}, },
mounted() { mounted() {
this.fetchSelectedLabels(); this.fetchSelectedLabels();
@ -123,7 +213,7 @@
} }
</script> </script>
<style> <style scoped lang="scss">
.selected-tags { .selected-tags {
margin-top: 0.75rem; margin-top: 0.75rem;
font-size: 0.75rem; font-size: 0.75rem;
@ -138,4 +228,18 @@
border-right-color: #dbdbdb !important; border-right-color: #dbdbdb !important;
border-top-color: #dbdbdb !important; border-top-color: #dbdbdb !important;
} }
.metadata-taxonomy-list {
column-count: 2;
margin: 10px;
label {
break-inside: avoid;
padding-right: 10px;
}
}
.view-all {
color: #898d8f;
margin-bottom: 20px;
font-size: 0.75rem;
}
</style> </style>

View File

@ -3,7 +3,7 @@
<p <p
v-if="value instanceof Array ? value.length > 0 : (value != undefined && value != '')" v-if="value instanceof Array ? value.length > 0 : (value != undefined && value != '')"
class="has-text-gray"> class="has-text-gray">
{{ $i18n.get('label_selected_terms') + ' :' }} {{ $i18n.get('label_selected_term') + ':' }}
</p> </p>
<b-field <b-field
v-if="value instanceof Array ? value.length > 0 : (value != undefined && value != '')" v-if="value instanceof Array ? value.length > 0 : (value != undefined && value != '')"
@ -16,7 +16,7 @@
<b-tag <b-tag
attached attached
closable closable
@close="value = ''"> @close="clearInput()">
{{ selectedTagsName[value] }} {{ selectedTagsName[value] }}
</b-tag> </b-tag>
</div> </div>
@ -24,22 +24,27 @@
v-if="isSelectedTermsLoading" v-if="isSelectedTermsLoading"
class="control has-icons-right is-loading is-clearfix" /> class="control has-icons-right is-loading is-clearfix" />
</b-field> </b-field>
<p
style="margin-top: 10px;"
class="has-text-gray">
{{ (isShowingAllTerms ? $i18n.get('label_available_terms') : $i18n.get('label_some_available_terms')) + ':' }}
</p>
<div class="metadata-taxonomy-list">
<b-radio <b-radio
:disabled="disabled" :disabled="disabled"
:id="id" :id="metadatum.metadata_type_object.component + '-' + metadatum.slug"
v-model="checked" v-model="checked"
@input="onChecked()" @input="onChecked('')"
:native-value="''" :native-value="''"
border> border>
{{ $i18n.get('clear_radio') }} {{ $i18n.get('clear_radio') }}
</b-radio> </b-radio>
<div <template
v-for="(option, index) in options" :id="metadatum.metadata_type_object.component + '-' + metadatum.slug"
:key="index"> v-for="(option, index) in options">
<b-radio <b-radio
:disabled="disabled" :disabled="disabled"
:id="id" :style="{ marginLeft: 0, paddingLeft: (option.level * 30) + 'px' }"
:style="{ paddingLeft: (option.level * 30) + 'px' }"
:key="index" :key="index"
v-model="checked" v-model="checked"
@input="onChecked(option)" @input="onChecked(option)"
@ -47,20 +52,51 @@
border> border>
{{ option.name }} {{ option.name }}
</b-radio> </b-radio>
<br> <br :key="index">
</template>
</div>
<div
v-if="!isShowingAllTerms"
class="view-all">
<span>
{{
$i18n.get('info_showing_terms') + 1 +
$i18n.get('info_to') + options.length +
$i18n.get('info_of') + totalTerms + '. '
}}
</span>
<a @click="openCheckboxModal()">
{{ $i18n.get('label_view_all') + ' ' + totalTerms + '.' }}
</a>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { tainacan as axios } from '../../../js/axios/axios'; import { tainacan as axios } from '../../../js/axios/axios';
import qs from 'qs';
import CheckboxRadioModal from '../../../admin/components/other/checkbox-radio-modal.vue'
export default { export default {
data(){ created() {
this.getTermsFromTaxonomy();
this.$parent.$on('update-taxonomy-inputs', ($event) => {
if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.metadatum.id) {
this.offset = 0;
this.getTermsFromTaxonomy();
}
});
},
data() {
return { return {
checked: ( this.value ) ? this.value : '', checked: this.value ? this.value : '',
selectedTagsName: {}, selectedTagsName: {},
isSelectedTermsLoading: false, isSelectedTermsLoading: false,
options: [],
terms: [],
termsNumber: 12,
offset: 0,
totalTerms: 0
} }
}, },
watch: { watch: {
@ -69,40 +105,47 @@
this.fetchSelectedLabels(); this.fetchSelectedLabels();
} }
}, },
props: { computed: {
options: { isShowingAllTerms() {
type: Array return this.terms.length >= this.totalTerms;
}
}, },
props: {
value: [ Number, String, Array ], value: [ Number, String, Array ],
disabled: false, disabled: false,
taxonomyId: Number taxonomyId: Number,
metadatum: Object
}, },
methods: { methods: {
clearInput() {
this.value = '';
this.onInput('');
},
onChecked() { onChecked() {
this.$emit('blur');
this.onInput(this.checked) this.onInput(this.checked)
}, },
onInput($event) { onInput($event) {
this.inputValue = $event; this.value = $event;
this.$emit('input', this.inputValue); this.$emit('input', this.value);
}, },
fetchSelectedLabels() { fetchSelectedLabels() {
if (this.value != null && this.value != undefined) { if (this.value != null && this.value != undefined) {
this.isSelectedTermsLoading = true; const selected = this.value instanceof Array ? this.value : [this.value];
let selected = this.value instanceof Array ? this.value : [this.value];
if (this.taxonomyId && selected.length > 0) { if (this.taxonomyId && selected.length > 0) {
for (const term of selected) {
if(!this.isSelectedTermsLoading){
this.isSelectedTermsLoading = true; this.isSelectedTermsLoading = true;
axios.get(`/taxonomy/${this.taxonomyId}/terms/?${qs.stringify({ hideempty: 0, include: selected })}`)
.then((res) => {
let terms = res.data;
for (let term of terms) {
if (!this.selectedTagsName[term.id])
this.$set(this.selectedTagsName, term.id, term.name);
} }
axios.get(`/taxonomy/${this.taxonomyId}/terms/${term}`)
.then((res) => {
this.saveSelectedTagName(res.data.id, res.data.name);
this.isSelectedTermsLoading = false; this.isSelectedTermsLoading = false;
}) })
.catch((error) => { .catch((error) => {
@ -110,19 +153,103 @@
this.isSelectedTermsLoading = false; this.isSelectedTermsLoading = false;
}); });
} }
} else {
this.isSelectedTermsLoading = false;
}
} }
}, },
saveSelectedTagName(value, label){ getTermsFromTaxonomy() {
if(!this.selectedTagsName[value]) { this.terms = [];
this.$set(this.selectedTagsName, `${value}`, label);
const endpoint = '/taxonomy/' + this.taxonomyId + '/terms?hideempty=0&order=asc&number=' + this.termsNumber + '&offset=' + this.offset;
axios.get(endpoint)
.then( res => {
this.totalTerms = Number(res.headers['x-wp-total']);
this.offset += this.termsNumber;
for (let item of res.data)
this.terms.push( item );
this.options = this.getOptions(0);
})
.catch(error => {
this.$console.log(error);
});
},
getOptions(parent, level = 0) { // retrieve only ids
let result = [];
if (this.terms) {
for (let term of this.terms){
if (term.parent == parent){
term['level'] = level;
result.push(term);
const levelTerm = level + 1;
const children = this.getOptions( term.id, levelTerm);
result = result.concat(children);
} }
} }
}
return result;
},
openCheckboxModal() {
this.$buefy.modal.open({
parent: this,
component: CheckboxRadioModal,
props: {
isFilter: false,
parent: 0,
taxonomy_id: this.taxonomyId,
selected: !this.value ? [] : this.value,
metadatumId: this.metadatum.id,
taxonomy: this.taxonomy,
collectionId: this.metadatum.collection_id,
isTaxonomy: true,
query: '',
metadatum: this.metadatum,
isCheckbox: false
},
events: {
input: (selected) => {
this.value = selected;
this.$emit('input', this.value);
}
},
width: 'calc(100% - 8.333333333%)',
trapFocus: true
});
}
}, },
mounted() { mounted() {
this.fetchSelectedLabels(); this.fetchSelectedLabels();
} }
} }
</script> </script>
<style lang="scss" scoped>
.selected-tags {
margin-top: 0.75rem;
font-size: 0.75rem;
position: relative;
}
.selected-tags .is-loading {
margin-left: 2rem;
margin-top: -0.4rem;
}
.selected-tags .is-loading::after {
border: 2px solid #555758 !important;
border-right-color: #dbdbdb !important;
border-top-color: #dbdbdb !important;
}
.metadata-taxonomy-list {
column-count: 2;
margin: 10px;
label {
break-inside: avoid;
padding-right: 10px;
}
}
.view-all {
color: #898d8f;
margin-bottom: 20px;
font-size: 0.75rem;
}
</style>

View File

@ -1,6 +1,7 @@
<template> <template>
<div class="block"> <div class="block">
<b-taginput <b-taginput
:id="metadatumComponentId"
:disabled="disabled" :disabled="disabled"
size="is-small" size="is-small"
icon="magnify" icon="magnify"
@ -36,16 +37,14 @@
}, },
watch: { watch: {
selected(){ selected(){
if(this.allowSelectToCreate && this.selected[0]){ if (this.allowSelectToCreate && this.selected[0]) {
this.selected[0].label.includes(`(${this.$i18n.get('select_to_create')})`); this.selected[0].label.includes(`(${this.$i18n.get('select_to_create')})`);
this.selected[0].label = this.selected[0].label.split('(')[0]; this.selected[0].label = this.selected[0].label.split('(')[0];
} }
} }
}, },
props: { props: {
options: { metadatumComponentId: '',
type: Array
},
value: [ Number, String, Array ], value: [ Number, String, Array ],
allowNew: true, allowNew: true,
taxonomyId: Number, taxonomyId: Number,
@ -54,7 +53,7 @@
maxtags: '', maxtags: '',
}, },
created(){ created(){
if(this.value && this.value.length > 0){ if (this.value && this.value.length > 0){
this.selected = this.value; this.selected = this.value;
} }
}, },
@ -85,13 +84,11 @@
}).then((res) => { }).then((res) => {
this.termList = res.terms; this.termList = res.terms;
for(let term of this.termList){ for (let term of this.termList)
this.labels.push({label: term.name, value: term.id}); this.labels.push({label: term.name, value: term.id});
}
if(this.termList.length <= 0 && this.allowSelectToCreate){ if (this.termList.length <= 0 && this.allowSelectToCreate)
this.labels.push({label: `${value} (${this.$i18n.get('select_to_create')})`, value: value}) this.labels.push({label: `${value} (${this.$i18n.get('select_to_create')})`, value: value})
}
this.isFetching = false; this.isFetching = false;
}).catch((error) => { }).catch((error) => {
@ -102,9 +99,8 @@
updateSelectedValues(){ updateSelectedValues(){
let selected = []; let selected = [];
for( let term of this.value){ for( let term of this.value)
selected.push({label: term.label, value: term.value}) selected.push({label: term.label, value: term.value})
}
this.selected = selected; this.selected = selected;
}, },
@ -117,7 +113,6 @@
results.push( term.value ); results.push( term.value );
this.$emit('input', results); this.$emit('input', results);
this.$emit('blur');
} }
}, },
emitRemove(){ emitRemove(){
@ -128,7 +123,6 @@
results.push(term.value); results.push(term.value);
this.$emit('input', results); this.$emit('input', results);
this.$emit('blur');
} }
} }
} }

View File

@ -1,21 +1,16 @@
<template> <template>
<b-input <b-input
:disabled="disabled" :disabled="disabled"
:class="{'has-content': value !== undefined && value !== ''}" :id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:id="id"
:value="value" :value="value"
@blur="$emit('blur')"
@input="onInput($event)"/> @input="onInput($event)"/>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
metadatum: { metadatum: Object,
type: Object
},
value: [String, Number, Array], value: [String, Number, Array],
id: '',
disabled: false disabled: false
}, },
methods: { methods: {

View File

@ -1,42 +1,22 @@
<template> <template>
<b-input <b-input
:disabled="disabled" :disabled="disabled"
:class="{'has-content': inputValue !== undefined && inputValue !== ''}" :id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
:id="id" :value="value"
size="is-small" @input="onInput($event)"
type="textarea" type="textarea" />
:value="inputValue"
@blur="onBlur"
@input="onInput($event)"/>
</template> </template>
<script> <script>
export default { export default {
created(){
if( this.value ){
this.inputValue = this.value
}
},
data() {
return {
inputValue: ''
}
},
props: { props: {
id: '', metadatum: Object,
metadatum: {
type: Object
},
value: [String, Number, Array], value: [String, Number, Array],
disabled: false disabled: false
}, },
methods: { methods: {
onBlur() { onInput(value) {
this.$emit('blur'); this.$emit('input', value);
},
onInput($event) {
this.inputValue = $event;
this.$emit('input', this.inputValue);
} }
} }
} }

View File

@ -283,6 +283,9 @@ class Terms extends Repository {
* @return bool|WP_Term return boolean indicating if term exists. If $return_term is true and term exists, return WP_Term object * @return bool|WP_Term return boolean indicating if term exists. If $return_term is true and term exists, return WP_Term object
*/ */
public function term_exists($searched_term, $taxonomy, $parent = null, $return_term = false) { public function term_exists($searched_term, $taxonomy, $parent = null, $return_term = false) {
if ($searched_term == "") {
return false;
}
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();

View File

@ -44,9 +44,13 @@ class CSV extends Exporter {
continue; continue;
} }
if ($meta->get_metadatum()->get_metadata_type() == 'Tainacan\Metadata_Types\Relationship') if ($meta->get_metadatum()->get_metadata_type() == 'Tainacan\Metadata_Types\Relationship') {
$line[] = $meta->get_value(); $rel = $meta->get_value();
if (is_array($rel))
$line[] = implode( $this->get_option('multivalued_delimiter'), $rel );
else else
$line[] = $rel;
} else
$line[] = $meta->get_value_as_string(); $line[] = $meta->get_value_as_string();
} }

View File

@ -404,9 +404,8 @@
// overflow: hidden; // overflow: hidden;
// text-overflow: ellipsis; // text-overflow: ellipsis;
// white-space: nowrap; // white-space: nowrap;
display: flex; display: inline;
align-items: center; min-height: 54px;
height: 54px;
} }
img { img {

View File

@ -240,7 +240,7 @@ export default {
this.termsRequestSource = axios.CancelToken.source(); this.termsRequestSource = axios.CancelToken.source();
let endpoint = '/taxonomy/' + this.taxonomyId + '/terms/?'+ qs.stringify({ include: this.selectedTerms }) + '&fetch_only=id,name,url,header_image'; let endpoint = '/taxonomy/' + this.taxonomyId + '/terms/?'+ qs.stringify({ hideempty: 0, include: this.selectedTerms }) + '&fetch_only=id,name,url,header_image';
this.tainacanAxios.get(endpoint, { cancelToken: this.termsRequestSource.token }) this.tainacanAxios.get(endpoint, { cancelToken: this.termsRequestSource.token })
.then(response => { .then(response => {

View File

@ -210,7 +210,7 @@ registerBlockType('tainacan/carousel-terms-list', {
terms = []; terms = [];
let endpoint = '/taxonomy/' + taxonomyId + '/terms/?'+ qs.stringify({ include: selectedTerms }) + '&fetch_only=id,name,url,header_image'; let endpoint = '/taxonomy/' + taxonomyId + '/terms/?'+ qs.stringify({ hideempty: 0, include: selectedTerms }) + '&fetch_only=id,name,url,header_image';
tainacan.get(endpoint, { cancelToken: itemsRequestSource.token }) tainacan.get(endpoint, { cancelToken: itemsRequestSource.token })
.then(response => { .then(response => {

View File

@ -15,51 +15,46 @@ export const eventBus = new Vue({
} }
}, },
methods : { methods : {
updateValue(data){ updateValue({ itemId, metadatumId, values}){
this.$emit('isUpdatingValue', true); this.$emit('isUpdatingValue', true);
if (data.item_id) { if (itemId) {
if (data.values.length > 0 && data.values[0].value) { if (values.length > 0 && values[0].value) {
let val = []; let onlyValues = values.map((aValueObject) => aValueObject.value);
for (let i of data.values) values = onlyValues;
val.push(i.value);
data.values = val;
} }
let values = ( Array.isArray( data.values[0] ) ) ? data.values[0] : data.values ;
this.$store.dispatch('item/updateMetadata', { this.$store.dispatch('item/updateMetadata', {
item_id: data.item_id, item_id: itemId,
metadatum_id: data.metadatum_id, metadatum_id: metadatumId,
values: values values: Array.isArray(values[0]) ? values[0] : values
}) })
.then(() => { .then(() => {
this.$emit('isUpdatingValue', false); this.$emit('isUpdatingValue', false);
let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == data.metadatum_id ); let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == metadatumId );
if ( index >= 0) if (index >= 0)
this.errors.splice( index, 1); this.errors.splice( index, 1);
}) })
.catch((error) => { .catch((error) => {
this.$emit('isUpdatingValue', false); this.$emit('isUpdatingValue', false);
let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == data.metadatum_id ); let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == metadatumId );
let messages = []; let messages = [];
for (let index in error) for (let index in error)
messages.push(error[index]); messages.push(error[index]);
if ( index >= 0) if ( index >= 0)
Vue.set( this.errors, index, { metadatum_id: data.metadatum_id, errors: messages }); Vue.set( this.errors, index, { metadatum_id: metadatumId, errors: messages });
else else
this.errors.push( { metadatum_id: data.metadatum_id, errors: messages } ); this.errors.push( { metadatum_id: metadatumId, errors: messages } );
}); });
} }
}, },
getErrors(metadatum_id) { getErrors(metadatum_id) {
let error = this.errors.find( errorItem => errorItem.metadatum_id == metadatum_id ); let error = this.errors.find(errorItem => errorItem.metadatum_id == metadatum_id);
return ( error ) ? error.errors : false return error ? error.errors : false
}, },
clearAllErrors() { clearAllErrors() {
this.errors = []; this.errors = [];

View File

@ -296,7 +296,7 @@ export const clearTerms = ({ commit }) => {
// Used only on Term Edition form, for autocomplete searhc for parents // Used only on Term Edition form, for autocomplete searhc for parents
export const fetchPossibleParentTerms = ({ commit }, { taxonomyId, termId, search } ) => { export const fetchPossibleParentTerms = ({ commit }, { taxonomyId, termId, search } ) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.tainacan.get('/taxonomy/' + taxonomyId + '/terms?searchterm=' + search + '&hierarchical=1&exclude_tree=' + termId + "&hideempty=0&offset=0&number=20") axios.tainacan.get('/taxonomy/' + taxonomyId + '/terms?searchterm=' + search + '&hierarchical=1&exclude_tree=' + termId + "&hideempty=0&offset=0&number=20&order=asc")
.then(res => { .then(res => {
let parentTerms = res.data; let parentTerms = res.data;
resolve( parentTerms ); resolve( parentTerms );

View File

@ -4,15 +4,15 @@ Tags: museums, libraries, archives, GLAM, collections, repository
Requires at least: 4.8 Requires at least: 4.8
Tested up to: 5.2.4 Tested up to: 5.2.4
Requires PHP: 5.6 Requires PHP: 5.6
Stable tag: 0.13 Stable tag: 0.13.1
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html
Tainacan is a powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. Tainacan is an open source, powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform.
== Description == == Description ==
Tainacan is a powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. [Tainacan](https://tainacan.org/) is an open source, powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform.
= Features = = Features =
@ -76,6 +76,11 @@ Upload the files to the plugins directory and activate it. You can also install
If you have Imagick installed in your server, Tainacan will be able to automatically generate a thumbnail from your PDF files. This is desired but not required. If you have Imagick installed in your server, Tainacan will be able to automatically generate a thumbnail from your PDF files. This is desired but not required.
== Find out more ==
* Visit our oficial website: [https://tainacan.org/](https://tainacan.org/)
* Check our documentation Wiki: [https://wiki.tainacan.org/](https://wiki.tainacan.org/)
== Screenshots == == Screenshots ==
1. Manage your repository 1. Manage your repository

View File

@ -2,15 +2,15 @@
/* /*
Plugin Name: Tainacan Plugin Name: Tainacan
Plugin URI: https://tainacan.org/ Plugin URI: https://tainacan.org/
Description: powerfull and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional respository platform. Description: Open source, powerfull and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional respository platform.
Author: Tainacan.org Author: Tainacan.org
Version: 0.13 Version: 0.13.1
Text Domain: tainacan Text Domain: tainacan
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/ */
const TAINACAN_VERSION = '0.13'; const TAINACAN_VERSION = '0.13.1';
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__); $TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -575,6 +575,98 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
} }
public function test_update_taxonomy_metadata() {
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'test_col',
'status' => 'publish'
),
true
);
$tax = $this->tainacan_entity_factory->create_entity(
'taxonomy',
array(
'name' => 'tax_test',
'collections' => [$collection],
'status' => 'publish'
),
true
);
$this->tainacan_entity_factory->create_entity(
'term',
array(
'taxonomy' => $tax->get_db_identifier(),
'name' => 'Rock',
'user' => 56
),
true
);
$this->tainacan_entity_factory->create_entity(
'term',
array(
'taxonomy' => $tax->get_db_identifier(),
'name' => 'Samba',
'user' => 56
),
true
);
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'tax',
'status' => 'publish',
'collection' => $collection,
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
'metadata_type_options' => [
'taxonomy_id' => $tax->get_id(),
]
),
true
);
$i1 = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'description' => 'adasdasdsa',
'collection' => $collection
),
true
);
$itemMeta1 = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum);
$itemMeta1->set_value('Rock');
$itemMeta1->validate();
$Tainacan_Item_Metadata->insert($itemMeta1);
$request = new \WP_REST_Request(
'GET',
$this->namespace . '/item/' . $i1->get_id() . '/metadata/' . $metadatum->get_id()
);
$response = $this->server->dispatch($request);
$data = $response->get_data();
$this->assertEquals(false, empty($data['value']));
$request = new \WP_REST_Request(
'PATCH',
$this->namespace . '/item/' . $i1->get_id() . '/metadata/' . $metadatum->get_id()
);
$attributes = json_encode(['values' => '']);
$request->set_body($attributes);
$response = $this->server->dispatch($request);
$data = $response->get_data();
$this->assertEquals(true, empty($data['value']));
}
} }
?> ?>