Merge branch 'hotfix/0.21.3'

This commit is contained in:
vnmedeiros 2024-05-15 10:04:11 -03:00
commit 21702a5de3
19 changed files with 108 additions and 72 deletions

View File

@ -185,6 +185,8 @@
.wp-block-tainacan-facets-list ul.facets-list-edit li.facet-list-item {
display: flex;
align-items: flex-start; }
.wp-block-tainacan-facets-list ul.facets-list-edit li.facet-list-item a {
pointer-events: none; }
.wp-block-tainacan-facets-list ul.facets-list-edit li.facet-list-item button {
position: absolute !important;
background-color: rgba(255, 255, 255, 0.75);

File diff suppressed because one or more lines are too long

View File

@ -197,7 +197,12 @@ class CSV extends Importer {
? explode( $this->get_option('multivalued_delimiter'), $valueToInsert)
: [$valueToInsert];
if(!is_array($header)) {
$this->add_error_log('the compound metadata specification is invalid');
continue;
}
$key = key($header);
$returnValue = [];
foreach($valueToInsert as $index => $metadatumValue) {
$childrenHeaders = str_getcsv($compoundHeaders[$key], $this->get_option('delimiter'), $this->get_option('enclosure'));
@ -206,7 +211,7 @@ class CSV extends Importer {
str_getcsv($metadatumValue, $this->get_option('delimiter'), $this->get_option('enclosure'));
if ( sizeof($childrenHeaders) != sizeof($childrenValue) ) {
$this->add_error_log('Mismatch count headers childrens and row columns. file value:' . $metadatumValue);
$this->add_error_log('Mismatch count headers childrens and row columns in compound metadata. file value:' . $metadatumValue);
return false;
}
$tmp = [];

View File

@ -274,9 +274,10 @@
$this->debug('locking process: ' . $this->identifier);
$this->start_time = time(); // Set start time of current process.
$max_execution_time = ini_get('max_execution_time');
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : ( empty($max_execution_time) ? 60 : ($max_execution_time * 1.5) ); // 1 minute
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) && !empty($this->queue_lock_time) ) ? $this->queue_lock_time : ( empty($max_execution_time) ? 60 : ($max_execution_time * 1.5) ); // 1 minute
$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
$this->process_lock_in_time = microtime();
$this->debug('locking duration: ' . $lock_duration);
if(!$this->is_process_running())
set_site_transient( $this->identifier . '_process_lock', $this->process_lock_in_time, $lock_duration );
}

View File

@ -4,7 +4,7 @@ Tags: museums, archives, GLAM, collections, repository
Requires at least: 5.9
Tested up to: 6.5
Requires PHP: 7.0
Stable tag: 0.21.2
Stable tag: 0.21.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

@ -5,17 +5,17 @@ Plugin URI: https://tainacan.org/
Description: Open source, powerful 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 repository platform.
Author: Tainacan.org
Author URI: https://tainacan.org/
Version: 0.21.2
Version: 0.21.3
Requires at least: 5.9
Tested up to: 6.5
Requires PHP: 7.0
Stable tag: 0.21.2
Stable tag: 0.21.3
Text Domain: tainacan
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
const TAINACAN_VERSION = '0.21.2';
const TAINACAN_VERSION = '0.21.3';
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -108,7 +108,7 @@
v-for="(collectionMetadatum, metadatumIndex) of collectionNonChildMetadata"
:key="metadatumIndex"
:value="collectionMetadatum.id"
:disabled="checkIfMetadatumIsAvailable(collectionMetadatum.id)">
:disabled="checkIfMetadatumIsAvailable(collectionMetadatum.id) || ( checkIfMetadatumIsCompound(collectionMetadatum) && sourceMetadatum.indexOf('compound|(') < 0 )">
<span class="metadatum-name">
{{ collectionMetadatum.name }}
</span>
@ -139,7 +139,7 @@
v-for="(collectionMetadatum, metadatumIndex) of collectionNonChildMetadata"
:key="metadatumIndex"
:value="collectionMetadatum.id"
:disabled="!checkIfMetadatumIsCompound(collectionMetadatum) || checkIfMetadatumIsAvailable(collectionMetadatum.id)">
:disabled="!checkIfMetadatumIsCompound(collectionMetadatum) || checkIfMetadatumIsAvailable(collectionMetadatum.id) || typeof sourceMetadatum != 'object' || !Object.entries(sourceMetadatum)[0]">
<span class="metadatum-name">
{{ collectionMetadatum.name }}
</span>

View File

@ -108,7 +108,7 @@
{{ status == 'draft' ? $i18n.get('label_update_draft') : $i18n.get('label_change_to_draft') }}
</b-dropdown-item>
<b-dropdown-item
v-if="currentUserCanPublish && !$adminOptions.hideItemEditionStatusPublishOption"
v-if="currentUserCanPublish"
:class="{ 'is-forced-last-option': status == 'private' }"
aria-role="listitem"
@click="$emit(

View File

@ -260,7 +260,7 @@
<!-- The Metadata list, inside each metadata section -->
<template v-if="metadataSection.metadata_object_list && Array.isArray(metadataSection.metadata_object_list)">
<sortable
:list="metadataSection.metadata_object_list"
:list="metadataSection.metadata_object_list.filter((metadatum) => metadatum != undefined && metadatum.parent == 0)"
item-key="id"
class="active-metadata-area"
:options="{
@ -284,7 +284,6 @@
@remove="handleChange($event, sectionIndex)">
<template #item="{ element: metadatum, index }">
<div
v-if="metadatum != undefined && metadatum.parent == 0"
v-show="(metadataNameFilterString == '' || filterByMetadatumName(metadatum)) && filterByMetadatumType(metadatum)"
:key="metadatum.id"
:data-metadatum-id="metadatum.id"
@ -461,22 +460,22 @@
v-if="isCollapseOpen(metadatum.id) && openedMetadatumId !== metadatum.id"
:metadatum="metadatum" />
</transition>
<!-- Child metadata list, inside each compound metadata -->
<child-metadata-list
v-if="metadatum.metadata_type_object && metadatum.metadata_type_object.component == 'tainacan-compound'"
:parent="metadatum"
:metadata-name-filter-string="metadataNameFilterString"
:metadata-type-filter-options="metadataTypeFilterOptions"
:has-some-metadata-type-filter-applied="hasSomeMetadataTypeFilterApplied"
:is-parent-multiple="metadatum.multiple == 'yes'"
:is-repository-level="false"
:collapse-all="collapseAll"
:section-id="metadataSection.id + ''" />
</div>
<!-- Child metadata list, inside each compound metadata -->
<child-metadata-list
v-if="metadatum.metadata_type_object && metadatum.metadata_type_object.component == 'tainacan-compound'"
:parent="metadatum"
:metadata-name-filter-string="metadataNameFilterString"
:metadata-type-filter-options="metadataTypeFilterOptions"
:has-some-metadata-type-filter-applied="hasSomeMetadataTypeFilterApplied"
:is-parent-multiple="metadatum.multiple == 'yes'"
:is-repository-level="false"
:collapse-all="collapseAll"
:section-id="metadataSection.id + ''" />
<!-- Metadata edition form, for each metadata -->
<b-modal
v-if="openedMetadatumId == metadatum.id"
:model-value="openedMetadatumId == metadatum.id"
trap-focus
aria-modal
@ -492,8 +491,8 @@
@on-edition-finished="onEditionFinished()"
@on-edition-canceled="onEditionCanceled()" />
</b-modal>
</template>
</sortable><!-- End of .active-metadata-area -->
</template>
@ -679,7 +678,6 @@ export default {
handleChange($event, sectionIndex) {
switch ( $event.type ) {
case 'add':
if ( !$event.from.classList.contains('active-metadata-area') ) {
this.addNewMetadatum(this.getMetadatumTypes()[$event.oldIndex], $event.newIndex, sectionIndex);
$event.to.removeChild($event.item)

View File

@ -141,8 +141,10 @@ class Control extends Metadata_Type {
* @return string The HTML representation of the value, containing one or multiple items names, linked to the item page
*/
public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$control_metadatum = $this->get_option('control_metadatum');
if (in_array($control_metadatum, ['document_type', 'collection_id', 'has_thumbnail']))
return $this->get_control_metadatum_value($value, $control_metadatum, 'html');
@ -176,8 +178,30 @@ class Control extends Metadata_Type {
$value = $item_metadata->get_value();
$control_metadatum = $this->get_option('control_metadatum');
if (in_array($control_metadatum, ['document_type', 'collection_id', 'has_thumbnail']))
return $this->get_control_metadatum_value($value, $control_metadatum, 'string');
return $this->get_control_metadatum_value($value, $control_metadatum, 'string');
$return = '';
if ( $item_metadata->is_multiple() ) {
$total = sizeof($value);
$count = 0;
$prefix = $item_metadata->get_multivalue_prefix();
$suffix = $item_metadata->get_multivalue_suffix();
$separator = $item_metadata->get_multivalue_separator();
foreach ($value as $v) {
$return .= $prefix;
$return .= (string) $v;
$return .= $suffix;
$count ++;
if ($count < $total)
$return .= $separator;
}
} else {
$return = (string) $value;
}
return $return;
}
private function get_document_as_html( $value ) {

View File

@ -11,7 +11,7 @@
:disabled="disabled"
size="is-small"
icon="magnify"
:model-value="selected"
:model-value="JSON.parse(JSON.stringify(selected))"
:data="options"
:maxtags="maxtags != undefined ? maxtags : (itemMetadatum.metadatum.multiple == 'yes' || allowNew === true ? (maxMultipleValues !== undefined ? maxMultipleValues : null) : '1')"
autocomplete
@ -51,6 +51,9 @@
<div v-html="props.option.valuesAsHtml" />
</div>
</template>
<template #tag="props">
{{ (props.tag && props.tag.label) ? props.tag.label : '' }}
</template>
<template
v-if="!isLoading"
#empty>

View File

@ -6,7 +6,7 @@
:disabled="disabled"
size="is-small"
icon="account"
:model-value="selected"
:model-value="JSON.parse(JSON.stringify(selected))"
:data="options"
:maxtags="maxtags != undefined ? maxtags : (itemMetadatum.metadatum.multiple == 'yes' || allowNew === true ? (maxMultipleValues !== undefined ? maxMultipleValues : null) : '1')"
autocomplete
@ -30,17 +30,20 @@
<template #default="props">
<div class="media">
<div
v-if="props.option.avatar_urls && props.option.avatar_urls['24']"
v-if="props.option.img"
class="media-left">
<img
width="24"
:src="props.option.avatar_urls['24']">
:src="props.option.img">
</div>
<div class="media-content">
{{ props.option.name }}
</div>
</div>
</template>
<template #tag="props">
{{ (props.tag && props.tag.name) ? props.tag.name : '' }}
</template>
<template
v-if="!isLoading"
#empty>
@ -98,7 +101,7 @@ export default {
]),
onInput(newSelected) {
this.selected = newSelected;
this.$emit('update:value', newSelected.map((user) => user.id || user.value));
this.$emit('update:value', this.selected.map((user) => user.id || user.value));
},
onBlur() {
this.$emit('blur');
@ -109,17 +112,14 @@ export default {
this.isLoading = true;
let query = qs.stringify({ include: this.itemMetadatum.value });
let endpoint = '/users/';
wpApi.get(endpoint + '?' + query)
.then((res) => {
for (let user of res.data) {
this.selected.push({
name: user.name,
value: user.id,
img: user.avatar_urls && user.avatar_urls['24'] ? user.avatar_urls['24'] : ''
}) ;
}
this.selected = res.data.map((user) => ({
name: user.name,
value: user.id,
img: user.avatar_urls && user.avatar_urls['24'] ? user.avatar_urls['24'] : ''
}));
this.isLoading = false;
})
.catch(() => this.isLoading = false );

View File

@ -38,7 +38,8 @@
v-for="(statusOption, index) of availableStatus"
:key="index"
v-model="selectedStatus"
:native-value="statusOption.slug">
:native-value="statusOption.slug"
:disabled="(statusOption.slug === 'private' || statusOption.slug === 'publish') && !currentUserCanPublish">
<span class="icon has-text-gray">
<i
class="tainacan-icon tainacan-icon-18px"

View File

@ -136,7 +136,7 @@ export default (element) => {
app.use(FloatingVue, {
popperTriggers: ['hover', 'touch'],
themes: {
'taianacan-tooltip': {
'tainacan-tooltip': {
'$extend': 'tooltip',
triggers: ['hover', 'focus', 'touch'],
autoHide: true,

View File

@ -294,16 +294,12 @@ export default {
margin-left: 1.5em;
padding-right: 1em;
min-height: 330px;
.active-metadata-area {
margin-left: 0.5rem;
}
}
.active-metadatum-item,
.active-metadata-sections-item {
background-color: var(--tainacan-white);
padding: 0.7em 0.9em;
padding: 0;
margin: 0px 4px;
min-height: 2.8571em;
display: block;
@ -316,7 +312,7 @@ export default {
}
.handle {
padding-right: 6em;
padding: 0.7em 6.9em 0.7em 0.9em;
white-space: nowrap;
display: flex;
}
@ -410,12 +406,10 @@ export default {
}
}
}
&:not(.not-sortable-item):hover {
.sorting-buttons {
opacity: 1.0;
visibility: visible;
left: -2em
}
&:not(.not-sortable-item) .handle:hover >.sorting-buttons {
opacity: 1.0;
visibility: visible;
left: -2em
}
&.is-compact-item .metadatum-name {
@ -453,8 +447,8 @@ export default {
.active-filter-item:hover.not-sortable-item .icon-level-identifier .tainacan-icon::before {
color: var(--tainacan-gray3) !important;
}
.active-metadatum-item:hover:not(.not-sortable-item),
.active-metadata-sections-item:hover:not(.not-sortable-item) {
.active-metadatum-item:not(.not-sortable-item) .handle:hover,
.active-metadata-sections-item:hover:not(.not-sortable-item) .handle:hover {
background-color: var(--tainacan-turquoise1);
border-color: var(--tainacan-turquoise1);
@ -487,8 +481,8 @@ export default {
&::before { background-color: var(--tainacan-blue5); }
}
&.active-metadatum-item:hover:not(.not-sortable-item),
&.active-metadata-sections-item:hover:not(.not-sortable-item) {
&.active-metadatum-item:not(.not-sortable-item) .handle:hover,
&.active-metadata-sections-item:not(.not-sortable-item) .handle:hover {
background-color: var(--tainacan-blue1);
border-color: var(--tainacan-blue1);
@ -496,7 +490,7 @@ export default {
color: var(--tainacan-blue5) !important;
}
}
.sorting-buttons button {
& > .sorting-buttons button {
background: var(--tainacan-blue1);
&:hover {
color: var(--tainacan-blue5);

View File

@ -261,14 +261,14 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
if (isMetadatumTypeTaxonomy(metadatumType)) {
for (let facet of response.data.values) {
facetsObject.push(Object.assign({
term_url: facet.entity && facet.entity.url ? facet.entity.url : tainacan_blocks.site_url + '/' + collectionSlug + '/#/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value,
url: tainacan_blocks.site_url + '/' + collectionSlug + '/#/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value
term_url: facet.entity && facet.entity.url ? facet.entity.url : tainacan_blocks.site_url + '/' + collectionSlug + '/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value,
url: tainacan_blocks.site_url + '/' + collectionSlug + '/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value
}, facet));
}
} else {
for (let facet of response.data.values) {
facetsObject.push(Object.assign({
url: tainacan_blocks.site_url + '/' + collectionSlug + '/#/?metaquery[0][key]=' + metadatumId + '&metaquery[0][value]=' + facet.value
url: tainacan_blocks.site_url + '/' + collectionSlug + '/?metaquery[0][key]=' + metadatumId + '&metaquery[0][value]=' + facet.value
}, facet));
}
}
@ -344,8 +344,8 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
for (let facet of response.data.values) {
childFacets.push(Object.assign({
term_url: facet.entity && facet.entity.url ? facet.entity.url : tainacan_blocks.site_url + '/' + collectionSlug + '/#/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value,
url: tainacan_blocks.site_url + '/' + collectionSlug + '/#/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value
term_url: facet.entity && facet.entity.url ? facet.entity.url : tainacan_blocks.site_url + '/' + collectionSlug + '/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value,
url: tainacan_blocks.site_url + '/' + collectionSlug + '/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value
}, facet));
}

View File

@ -226,6 +226,10 @@
display: flex;
align-items: flex-start;
a {
pointer-events: none;
}
button {
position: absolute !important;
background-color: rgba(255, 255, 255, 0.75);

View File

@ -33,6 +33,7 @@
<ul
v-if="layout !== 'list'"
:style="{
listStyle: 'none',
gridGap: layout == 'grid' ? (gridMargin + 'px') : 'inherit',
marginTop: showSearchBar ? '1.5em' : '4px'
}"
@ -50,6 +51,7 @@
<ul
v-else
:style="{
listStyle: 'none',
marginTop: showSearchBar ? '1.5em' : '4px'
}"
class="facets-list"
@ -73,6 +75,7 @@
<ul
v-if="facets.length > 0 && layout != 'list'"
:style="{
listStyle: 'none',
gridGap: layout == 'grid' ? (gridMargin + 'px') : 'inherit',
marginTop: showSearchBar ? '1.5em' : '0px'
}"
@ -102,6 +105,7 @@
<ul
v-if="facets.length > 0 && layout == 'list'"
:style="{
listStyle: 'none',
marginTop: showSearchBar ? '1.5em' : '0px'
}"
class="facets-list"
@ -321,14 +325,14 @@ export default {
if (this.isMetadatumTypeTaxonomy) {
for (let facet of response.data.values) {
this.facets.push(Object.assign({
term_url: facet.entity && facet.entity.url ? facet.entity.url : this.tainacanSiteUrl + '/' + this.collectionSlug + '/#/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value,
url: this.tainacanSiteUrl + '/' + this.collectionSlug + '/#/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value
term_url: facet.entity && facet.entity.url ? facet.entity.url : this.tainacanSiteUrl + '/' + this.collectionSlug + '/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value,
url: this.tainacanSiteUrl + '/' + this.collectionSlug + '/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value
}, facet));
}
} else {
for (let facet of response.data.values) {
this.facets.push(Object.assign({
url: this.tainacanSiteUrl + '/' + this.collectionSlug + '/#/?metaquery[0][key]=' + this.metadatumId + '&metaquery[0][value]=' + facet.value
url: this.tainacanSiteUrl + '/' + this.collectionSlug + '/?metaquery[0][key]=' + this.metadatumId + '&metaquery[0][value]=' + facet.value
}, facet));
}
}
@ -387,8 +391,8 @@ export default {
for (let facet of response.data.values) {
childFacets.push(Object.assign({
term_url: facet.entity && facet.entity.url ? facet.entity.url : this.tainacanSiteUrl + '/' + this.collectionSlug + '/#/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value,
url: this.tainacanSiteUrl + '/' + this.collectionSlug + '/#/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value
term_url: facet.entity && facet.entity.url ? facet.entity.url : this.tainacanSiteUrl + '/' + this.collectionSlug + '/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value,
url: this.tainacanSiteUrl + '/' + this.collectionSlug + '/?taxquery[0][compare]=IN&taxquery[0][taxonomy]=' + facet.taxonomy + '&taxquery[0][terms][0]=' + facet.value
}, facet));
}

View File

@ -31,7 +31,7 @@ export default (element) => {
VueRoles.use(FloatingVue, {
popperTriggers: ['hover'],
themes: {
'taianacan-tooltip': {
'tainacan-tooltip': {
$extend: 'tooltip',
triggers: ['hover', 'focus', 'touch'],
html: true,