Merge branch 'develop' into feature/783

This commit is contained in:
mateuswetah 2023-10-19 09:53:38 -03:00
commit 4724cddeae
37 changed files with 1402 additions and 415 deletions

View File

@ -132,7 +132,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
public function prepare_item_for_response( $item, $request ) {
$item_arr = $item->_toArray(true, true);
if($request['context'] === 'edit'){
if ($request['context'] === 'edit') {
$item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete();
}

View File

@ -191,7 +191,7 @@ class Private_Files {
$upload_dir = wp_get_upload_dir();
$base_upload_url = preg_replace('/^https?:\/\//', '', $upload_dir['baseurl']);
$requested_uri = ($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
$requested_uri = ($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
if ( strpos($requested_uri, $base_upload_url) === false ) {
// Not uploads
@ -228,7 +228,7 @@ class Private_Files {
if ( !$existing_file && \file_exists( $prefixed_both ) ) {
$existing_file = $prefixed_both;
}
echo "-----------> $file <br> $prefixed_file <br> $prefixed_collection $prefixed_both: $existing_file";
if ($existing_file) {
$item = \Tainacan\Repositories\Items::get_instance()->fetch( (int) $item_id, (int) $collection_id );

View File

@ -41,7 +41,17 @@ class Collection extends Entity {
$submission_anonymous_user,
$submission_default_status,
$submission_use_recaptcha,
$disabled_mappers;
$disabled_mappers,
$item_enabled_document_types,
$item_document_label,
$item_thumbnail_label,
$item_enable_thubmnail,
$item_attachment_label,
$item_enable_attachments,
$item_enable_metadata_focus_mode,
$item_enable_metadata_required_filter,
$item_enable_metadata_searchbar,
$item_enable_metadata_collapses;
/**
* {@inheritDoc}
@ -608,8 +618,6 @@ class Collection extends Entity {
/**
* Get the default metadata section properties.
*
* @param [string] $value
*
* @return void
*/
function get_default_metadata_section_properties( ) {
@ -625,6 +633,97 @@ class Collection extends Entity {
return $this->get_mapped_property( 'disabled_mappers' );
}
/**
* Get the enabled document types for this collection.
*
* @return array The enabled document types.
*/
function get_item_enabled_document_types() {
return $this->get_mapped_property('item_enabled_document_types');
}
/**
* Get the label for the section in this collection.
*
* @return string The label for the section.
*/
function get_item_document_label() {
return $this->get_mapped_property('item_document_label');
}
/**
* Get the label for the thumbnail section in this collection.
*
* @return string The label for the thumbnail section.
*/
function get_item_thumbnail_label() {
return $this->get_mapped_property('item_thumbnail_label');
}
/**
* Check if thumbnail are enabled for this collection.
*
* @return string 'yes' if thumbnail are enabled, 'no' otherwise.
*/
function get_item_enable_thumbnail() {
return $this->get_mapped_property('item_enable_thumbnail');
}
/**
* Get the plural label for the attachment section in this collection.
*
* @return string The plural label for the attachment section.
*/
function get_item_attachment_label() {
return $this->get_mapped_property('item_attachment_label');
}
/**
* Check if attachments are enabled for this collection.
*
* @return string 'yes' if attachments are enabled, 'no' otherwise.
*/
function get_item_enable_attachments() {
return $this->get_mapped_property('item_enable_attachments');
}
/**
* Check if metadata focus mode is enabled for this collection.
*
* @return string 'yes' if metadata focus mode is enabled, 'no' otherwise.
*/
function get_item_enable_metadata_focus_mode() {
return $this->get_mapped_property('item_enable_metadata_focus_mode');
}
/**
* Check if metadata required filter is enabled for this collection.
*
* @return string 'yes' if metadata required filter is enabled, 'no' otherwise.
*/
function get_item_enable_metadata_required_filter() {
return $this->get_mapped_property('item_enable_metadata_required_filter');
}
/**
* Check if metadata search bar is enabled for this collection.
*
* @return string 'yes' if metadata search bar is enabled, 'no' otherwise.
*/
function get_item_enable_metadata_searchbar() {
return $this->get_mapped_property('item_enable_metadata_searchbar');
}
/**
* Check if metadata collapses are enabled for this collection.
*
* @return bool True if metadata collapses are enabled, 'no' otherwise.
*/
function get_item_enable_metadata_collapses() {
return $this->get_mapped_property('item_enable_metadata_collapses');
}
// Setters
/**
* Set the collection name
*
@ -760,7 +859,7 @@ class Collection extends Entity {
* @return void
*/
function set_metadata_section_order( $value ) {
if( !empty($value) ) {
if( !empty( $value ) ) {
$metadata_order = array( );
foreach($value as $section) {
$metadata_order = array_merge($metadata_order, $section['metadata_order']);
@ -907,6 +1006,105 @@ class Collection extends Entity {
function set_disabled_mappers($value) {
return $this->set_mapped_property( 'disabled_mappers', $value);
}
/* Set the enabled document types for this collection.
*
* @param array $value The enabled document types.
* @return void
*/
function set_item_enabled_document_types( $value ) {
$this->set_mapped_property('item_enabled_document_types', $value);
}
/**
* Set the label for the document section in this collection.
*
* @param string $value The label for the document section.
* @return void
*/
function set_item_document_label( $value ) {
$this->set_mapped_property('item_document_label', $value);
}
/**
* Set the label for the thumbnail section in this collection.
*
* @param string $value The label for the thumbnail section.
* @return void
*/
function set_item_thumbnail_label( $value ) {
$this->set_mapped_property('item_thumbnail_label', $value);
}
/**
* Enable or disable thumbnail for this collection.
*
* @param string $value 'yes' to enable thumbnail, 'no' to disable.
* @return void
*/
function set_item_enable_thumbnail( $value ) {
$this->set_mapped_property('item_enable_thumbnail', $value);
}
/**
* Set the plural label for the attachment section in this collection.
*
* @param string $value The plural label for the attachment section.
* @return void
*/
function set_item_attachment_label( $value ) {
$this->set_mapped_property('item_attachment_label', $value);
}
/**
* Enable or disable attachments for this collection.
*
* @param string $value 'yes' to enable attachments, 'no' to disable.
* @return void
*/
function set_item_enable_attachments( $value ) {
$this->set_mapped_property('item_enable_attachments', $value);
}
/**
* Enable or disable metadata focus mode for this collection.
*
* @param string $value 'yes' to enable metadata focus mode, 'no' to disable.
* @return void
*/
function set_item_enable_metadata_focus_mode( $value ) {
$this->set_mapped_property('item_enable_metadata_focus_mode', $value);
}
/**
* Enable or disable metadata required filter for this collection.
*
* @param string $value 'yes' to enable metadata required filter, 'no' to disable.
* @return void
*/
function set_item_enable_metadata_required_filter( $value ) {
$this->set_mapped_property('item_enable_metadata_required_filter', $value);
}
/**
* Enable or disable metadata search bar for this collection.
*
* @param string $value 'yes' to enable metadata search bar, 'no' to disable.
* @return void
*/
function set_item_enable_metadata_searchbar( $value ) {
$this->set_mapped_property('item_enable_metadata_searchbar', $value);
}
/**
* Enable or disable metadata collapses for this collection.
*
* @param string $value 'yes' to enable metadata collapses, 'no' to disable.
* @return void
*/
function set_item_enable_metadata_collapses( $value ) {
$this->set_mapped_property('item_enable_metadata_collapses', $value);
}
/**
* Validate Collection

View File

@ -338,6 +338,131 @@ class Collections extends Repository {
'items' => [ 'type' => 'string' ],
'default' => [],
],
'item_enabled_document_types' => [
'map' => 'meta',
'title' => __( 'Enabled document types', 'tainacan' ),
'type' => 'object',
'description' => __( 'The document types that are available in the item edition form.', 'tainacan' ),
'items' => [
'type' => 'object',
'properties' => [
'enabled' => [
'description' => __( 'Whether the document type is enabled or not.', 'tainacan' ),
'type' => 'string',
'enum' => [ 'yes', 'no' ],
],
'label' => [
'description' => __( 'The label that will represent the document type.', 'tainacan' ),
'type' => 'string',
],
'icon' => [
'description' => __( 'The slug of the icon that will represent the document type.', 'tainacan' ),
'type' => 'string',
],
]
],
'default' => [
'attachment' => [
'enabled' => 'yes',
'label' => __( 'File', 'tainacan' ),
'icon' => 'attachments'
],
'url' => [
'enabled' => 'yes',
'label' => __('URL', 'tainacan' ),
'icon' => 'url'
],
'text' => [
'enabled' => 'yes',
'label' => __('Text', 'tainacan' ),
'icon' => 'text'
]
]
],
'item_document_label' => [
'map' => 'meta',
'title' => __( 'Main document label', 'tainacan' ),
'type' => 'string',
'description' => __( 'The label for the main document section in the item edition form', 'tainacan' ),
'default' => __( 'Document', 'tainacan' ),
//'validation' => v::stringType(),
],
'item_thumbnail_label' => [
'map' => 'meta',
'title' => __( 'Thumbnail label', 'tainacan' ),
'type' => 'string',
'description' => __( 'The label for the thumbnail section in the item edition form', 'tainacan' ),
'default' => __( 'Thumbnail', 'tainacan' ),
//'validation' => v::stringType(),
],
'item_enable_thumbnail' => [
'map' => 'meta',
'title' => __( 'Item thumbnail', 'tainacan' ),
'type' => 'string',
'description' => __( 'If enabled, each item can have a thumbnail customized instead of the one automatically generated based on the item document.', 'tainacan' ),
'default' => 'yes',
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
'enum' => [ 'yes', 'no' ],
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
],
'item_attachment_label' => [
'map' => 'meta',
'title' => __( 'Attachments plural label', 'tainacan' ),
'type' => 'string',
'description' => __( 'The plural label for the attachments section in the item edition form', 'tainacan' ),
'default' => __( 'Attachments', 'tainacan' ),
//'validation' => v::stringType(),
],
'item_enable_attachments' => [
'map' => 'meta',
'title' => __( 'Item attachments', 'tainacan' ),
'type' => 'string',
'description' => __( 'If enabled, each item can have a set of files attached to it, complementary to the item document.', 'tainacan' ),
'default' => 'yes',
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
'enum' => [ 'yes', 'no' ],
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
],
'item_enable_metadata_focus_mode' => [
'map' => 'meta',
'title' => __( 'Metadata focus mode', 'tainacan' ),
'type' => 'string',
'description' => __( 'If enabled, a button can start a special navigation mode, that focus one metadatum per time in the item edition form.', 'tainacan' ),
'default' => 'yes',
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
'enum' => [ 'yes', 'no' ],
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
],
'item_enable_metadata_required_filter' => [
'map' => 'meta',
'title' => __( 'Metadata required filter', 'tainacan' ),
'type' => 'string',
'description' => __( 'If enabled, a switch can be toggled to display only required metadata in the item edition form.', 'tainacan' ),
'default' => 'yes',
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
'enum' => [ 'yes', 'no' ],
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
],
'item_enable_metadata_searchbar' => [
'map' => 'meta',
'title' => __( 'Metadata search bar', 'tainacan' ),
'type' => 'string',
'description' => __( 'If enabled, a search bar can be used for filtering the list of metadata in the item edition form.', 'tainacan' ),
'default' => 'yes',
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
'enum' => [ 'yes', 'no' ],
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
],
'item_enable_metadata_collapses' => [
'map' => 'meta',
'title' => __( 'Metadata collapses', 'tainacan' ),
'type' => 'string',
'description' => __( 'If enabled, each metadata in the item form will be wrapped in a collapsable component.', 'tainacan' ),
'default' => 'yes',
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
'enum' => [ 'yes', 'no' ],
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
]
] );
}

View File

@ -103,7 +103,7 @@ class Items extends Repository {
'map' => 'meta',
'title' => __( 'Document', 'tainacan' ),
'type' => 'string',
'description' => __( 'The document itself. An ID in case of attachment, an URL in case of link or a text in the case of text.', 'tainacan' ),
'description' => __( 'The item main content. May be a file attached, an URL or a text depending on the type of the document.', 'tainacan' ),
'on_error' => __( 'Invalid document', 'tainacan' ),
'default' => ''
],

View File

@ -8,7 +8,7 @@
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-attachments"/>
</span>
{{ $i18n.get('label_attachments') }}&nbsp;
{{ collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments') }}&nbsp;
<span
v-if="totalAttachments"
class="has-text-gray has-text-weight-normal"
@ -17,7 +17,7 @@
</span>
</label>
<help-button
:title="$i18n.get('label_attachments')"
:title="collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments')"
:message="$i18n.get('info_edit_attachments')"/>
<button
style="float: right; font-size: 0.875em; margin: 2px 5px;"
@ -28,7 +28,7 @@
<span class="icon">
<i class="tainacan-icon tainacan-icon-edit"/>
</span>
{{ $i18n.get('label_add_or_update_attachments') }}
{{ $i18n.getWithVariables('label_add_or_update_%s', [ collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments') ]) }}
</button>
</div>
<div
@ -38,6 +38,7 @@
<attachments-list
:item="item"
:form="form"
:collection="collection"
:is-editable="true"
:should-load-attachments="shouldLoadAttachments"
@onDeleteAttachment="($event) => $emit('onDeleteAttachment', $event)"/>
@ -55,6 +56,7 @@ export default {
props: {
item: Object,
form: Object,
collection: Object,
totalAttachments: Number,
isLoading: Boolean,
shouldLoadAttachments: Boolean

View File

@ -1,21 +1,17 @@
<template>
<div>
<div
v-if="!$adminOptions.hideItemEditionDocument"
class="section-label">
<div v-if="!$adminOptions.hideItemEditionDocument && ( !$adminOptions.hideItemEditionDocumentFileInput && !$adminOptions.hideItemEditionDocumentTextInput && !$adminOptions.hideItemEditionDocumentUrlInput )">
<div class="section-label">
<label>
<span class="icon has-text-gray4">
<i :class="'tainacan-icon tainacan-icon-' + ( (!form.document_type || form.document_type == 'empty' ) ? 'item' : (form.document_type == 'attachment' ? 'attachments' : form.document_type))"/>
</span>
{{ form.document != undefined && form.document != null && form.document != '' ? $i18n.get('label_document') : $i18n.get('label_document_empty') }}
{{ collection && collection.item_document_label ? collection.item_document_label : ( (form.document != undefined && form.document != null && form.document != '') ? $i18n.get('label_document') : $i18n.get('label_document_empty') ) }}
</label>
<help-button
:title="$i18n.getHelperTitle('items', 'document')"
:title="collection && collection.item_document_label ? collection.item_document_label : $i18n.getHelperTitle('items', 'document')"
:message="$i18n.getHelperMessage('items', 'document')"/>
</div>
<div
v-if="!$adminOptions.hideItemEditionDocument"
class="section-box document-field">
<div class="section-box document-field">
<div
v-if="form.document != undefined && form.document != null &&
form.document_type != undefined && form.document_type != null &&
@ -63,7 +59,7 @@
<ul
v-else
class="document-field-placeholder">
<li v-if="!$adminOptions.hideItemEditionDocumentFileInput">
<li v-if="!$adminOptions.hideItemEditionDocumentFileInput && (collection && collection.item_enabled_document_types && collection.item_enabled_document_types['attachment'] && collection.item_enabled_document_types['attachment']['enabled'] === 'yes')">
<button
type="button"
@click.prevent="($event) => $emit('onSetFileDocument', $event)">
@ -73,7 +69,7 @@
</button>
<p>{{ $i18n.get('label_file') }}</p>
</li>
<li v-if="!$adminOptions.hideItemEditionDocumentTextInput">
<li v-if="!$adminOptions.hideItemEditionDocumentTextInput && (collection && collection.item_enabled_document_types && collection.item_enabled_document_types['text'] && collection.item_enabled_document_types['text']['enabled'] === 'yes')">
<button
type="button"
@click.prevent="$emit('onSetTextDocument')">
@ -83,7 +79,7 @@
</button>
<p>{{ $i18n.get('label_text') }}</p>
</li>
<li v-if="!$adminOptions.hideItemEditionDocumentUrlInput">
<li v-if="!$adminOptions.hideItemEditionDocumentUrlInput && (collection && collection.item_enabled_document_types && collection.item_enabled_document_types['url'] && collection.item_enabled_document_types['url']['enabled'] === 'yes')">
<button
type="button"
@click.prevent="$emit('onSetURLDocument')">
@ -102,7 +98,8 @@
export default {
props: {
item: Object,
form: Object
form: Object,
collection: Object
}
}
</script>

View File

@ -142,19 +142,19 @@
<span>{{ $i18n.get('label_all_metadata') }}</span>
</button>
<button
v-if="!$adminOptions.hideItemEditionDocument"
v-if="shouldDisplayItemEditionDocument || shouldDisplayItemEditionThumbnail"
@click="activeTab = 'document'; isMobileSubheaderOpen = false;">
<span><i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-item" /></span>
<span>{{ $i18n.get('label_document_and_thumbnail') }}</span>
</button>
<button
v-if="!$adminOptions.hideItemEditionAttachments"
v-if="shouldDisplayItemEditionAttachments"
@click="activeTab = 'attachments'; isMobileSubheaderOpen = false;">
<span><i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-attachments" /></span>
<span>{{ $i18n.get('label_all_attachments') }}</span>
</button>
<button
v-if="!$adminOptions.hideItemEditionRequiredOnlySwitch"
v-if="!$adminOptions.hideItemEditionRequiredOnlySwitch && (collection && collection.item_enable_metadata_required_filter === 'yes')"
@click="showOnlyRequiredMetadata = true; isMobileSubheaderOpen = false;">
<span><i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-metadata" /></span>
<span>{{ $i18n.get('label_only_required_metadata') }}</span>
@ -177,8 +177,8 @@
<div
class="column main-column"
:class="
(( (!$adminOptions.hideItemEditionDocument || !$adminOptions.hideItemEditionThumbnail) && !$adminOptions.itemEditionDocumentInsideTabs) ||
(!$adminOptions.hideItemEditionAttachments && !$adminOptions.itemEditionAttachmentsInsideTabs)) ? 'is-7' : 'is-12'">
(( (shouldDisplayItemEditionDocument || shouldDisplayItemEditionThumbnail) && !$adminOptions.itemEditionDocumentInsideTabs) ||
(shouldDisplayItemEditionAttachments && !$adminOptions.itemEditionAttachmentsInsideTabs)) ? 'is-7' : 'is-12'">
<!-- Hook for extra Form options -->
<template v-if="hasBeginRightForm">
@ -287,7 +287,7 @@
class="header-item metadata-navigation"
:style="$adminOptions.hideItemEditionCollapses ? 'padding-left: 0.35em !important;' : ''">
<b-button
v-if="!$adminOptions.hideItemEditionFocusMode && !isMetadataNavigation && !showOnlyRequiredMetadata && !metadataNameFilterString"
v-if="!$adminOptions.hideItemEditionFocusMode && (collection && collection.item_enable_metadata_focus_mode === 'yes') && !isMetadataNavigation && !showOnlyRequiredMetadata && !metadataNameFilterString"
@click="isMetadataNavigation = true; setMetadatumFocus({ index: 0, scrollIntoView: true });"
class="collapse-all has-text-secondary"
size="is-small">
@ -340,7 +340,7 @@
</span>
<b-switch
v-if="!isMetadataNavigation && !$adminOptions.hideItemEditionRequiredOnlySwitch && itemMetadata && itemMetadata.length > 3"
v-if="!isMetadataNavigation && !$adminOptions.hideItemEditionRequiredOnlySwitch && (collection && collection.item_enable_metadata_required_filter === 'yes') && itemMetadata && itemMetadata.length > 3"
id="tainacan-switch-required-metadata"
:style="'font-size: 0.625em;' + (isMobileScreen ? 'margin-right: 2rem;' : '')"
size="is-small"
@ -349,7 +349,7 @@
</b-switch>
<b-field
v-if="!isMetadataNavigation && itemMetadata && itemMetadata.length > 5"
v-if="!isMetadataNavigation && (collection && collection.item_enable_metadata_searchbar === 'yes') && itemMetadata && itemMetadata.length > 5"
class="header-item metadata-name-search">
<b-input
v-if="!isMobileScreen || openMetadataNameFilter"
@ -433,7 +433,7 @@
:item-metadatum="itemMetadatum"
:metadata-name-filter-string="metadataNameFilterString"
:is-collapsed="metadataCollapses[index]"
:hide-collapses="$adminOptions.hideItemEditionCollapses || isMetadataNavigation"
:hide-collapses="$adminOptions.hideItemEditionCollapses || isMetadataNavigation || (collection && collection.item_enable_metadata_collapses === 'no')"
:hide-metadata-types="hideMetadataTypes"
:hide-help-buttons="false"
:help-info-bellow-label="false"
@ -495,6 +495,7 @@
<item-document-edition-form
:item="item"
:form="form"
:collection="collection"
@onSetDocument="setDocument"
@onRemoveDocument="removeDocument"
@onSetFileDocument="setFileDocument"
@ -503,6 +504,7 @@
<item-thumbnail-edition-form
:item="item"
:form="form"
:collection="collection"
:is-loading="isLoading"
@onDeleteThumbnail="deleteThumbnail"
@onUpdateThumbnailAlt="($event) => onUpdateThumbnailAlt($event)"
@ -511,7 +513,7 @@
<!-- Attachments on mobile modal -->
<div
v-if="activeTab === 'attachments' && $adminOptions.itemEditionAttachmentsInsideTabs"
v-if="activeTab === 'attachments' && shouldDisplayItemEditionAttachments && $adminOptions.itemEditionAttachmentsInsideTabs"
class="tab-item"
role="tabpanel"
aria-labelledby="attachments-tab-label"
@ -519,6 +521,7 @@
<item-attachments-edition-form
:item="item"
:form="form"
:collection="collection"
:is-loading="isLoading"
:total-attachments="totalAttachments"
:should-load-attachments="shouldLoadAttachments"
@ -532,8 +535,8 @@
</div>
<div
v-if="( (!$adminOptions.hideItemEditionDocument || !$adminOptions.hideItemEditionThumbnail) && !$adminOptions.itemEditionDocumentInsideTabs) ||
(!$adminOptions.hideItemEditionAttachments && !$adminOptions.itemEditionAttachmentsInsideTabs)"
v-if="( (shouldDisplayItemEditionDocument || shouldDisplayItemEditionThumbnail) && !$adminOptions.itemEditionDocumentInsideTabs) ||
(shouldDisplayItemEditionAttachments && !$adminOptions.itemEditionAttachmentsInsideTabs)"
class="column is-5">
<div
@ -550,33 +553,37 @@
<!-- Document -------------------------------- -->
<item-document-edition-form
v-if="!$adminOptions.itemEditionDocumentInsideTabs"
v-if="shouldDisplayItemEditionDocument && !$adminOptions.itemEditionDocumentInsideTabs"
:item="item"
:form="form"
:collection="collection"
@onSetDocument="setDocument"
@onRemoveDocument="removeDocument"
@onSetFileDocument="setFileDocument"
@onSetTextDocument="setTextDocument"
@onSetURLDocument="setURLDocument" />
<hr>
<hr v-if="shouldDisplayItemEditionDocument && shouldDisplayItemEditionThumbnail">
<!-- Thumbnail -------------------------------- -->
<item-thumbnail-edition-form
v-if="!$adminOptions.itemEditionDocumentInsideTabs"
v-if="shouldDisplayItemEditionThumbnail && !$adminOptions.itemEditionDocumentInsideTabs"
:item="item"
:form="form"
:collection="collection"
:is-loading="isLoading"
@onDeleteThumbnail="deleteThumbnail"
@onUpdateThumbnailAlt="($event) => onUpdateThumbnailAlt($event)"
@openThumbnailMediaFrame="thumbnailMediaFrame.openFrame($event)" />
<hr v-if="!$adminOptions.itemEditionAttachmentsInsideTabs || hasEndLeftForm">
<hr v-if="(shouldDisplayItemEditionAttachments && !$adminOptions.itemEditionAttachmentsInsideTabs) || hasEndLeftForm">
<!-- Attachments -->
<item-attachments-edition-form
v-if="!$adminOptions.itemEditionAttachmentsInsideTabs"
v-if="shouldDisplayItemEditionAttachments && !$adminOptions.itemEditionAttachmentsInsideTabs"
:item="item"
:form="form"
:collection="collection"
:is-loading="isLoading"
:total-attachments="totalAttachments"
:should-load-attachments="shouldLoadAttachments"
@ -874,18 +881,18 @@ export default {
name: this.$i18n.get('metadata'),
total: this.itemMetadata.length
}];
if ( this.$adminOptions.itemEditionDocumentInsideTabs && (!this.$adminOptions.hideItemEditionDocument || !this.$adminOptions.hideItemEditionThumbnail) ) {
if ( this.$adminOptions.itemEditionDocumentInsideTabs && (this.shouldDisplayItemEditionDocument || this.shouldDisplayItemEditionThumbnail) ) {
pageTabs.push({
slug: 'document',
icon: 'item',
name: this.$i18n.get('label_document')
name: this.collection && this.collection.item_document_label ? this.collection.item_document_label : this.$i18n.get('label_document')
});
}
if ( this.$adminOptions.itemEditionAttachmentsInsideTabs && !this.$adminOptions.hideItemEditionAttachments ) {
if ( this.$adminOptions.itemEditionAttachmentsInsideTabs && this.shouldDisplayItemEditionAttachments ) {
pageTabs.push({
slug: 'attachments',
icon: 'attachments',
name: this.$i18n.get('label_attachments'),
name: this.collection && this.collection.item_attachment_label ? this.collection.item_attachment_label : this.$i18n.get('label_attachments'),
total: this.totalAttachments
});
}
@ -903,6 +910,21 @@ export default {
if (!this.isMetadataNavigation || !this.itemMetadata[this.focusedMetadatum])
return false;
return this.itemMetadata[this.focusedMetadatum].metadatum && this.itemMetadata[this.focusedMetadatum].metadatum.metadata_type === 'Tainacan\\Metadata_Types\\Compound';
},
shouldDisplayItemEditionDocument() {
return !this.$adminOptions.hideItemEditionDocument &&
( this.collection && this.collection.item_enabled_document_types && (
( this.collection.item_enabled_document_types['attachment'] && this.collection.item_enabled_document_types['attachment']['enabled'] === 'yes' ) ||
( this.collection.item_enabled_document_types['text'] && this.collection.item_enabled_document_types['text']['enabled'] === 'yes' ) ||
( this.collection.item_enabled_document_types['url'] && this.collection.item_enabled_document_types['url']['enabled'] === 'yes' )
)
);
},
shouldDisplayItemEditionThumbnail() {
return !this.$adminOptions.hideItemEditionThumbnail && (this.collection && this.collection.item_enable_thumbnail === 'yes');
},
shouldDisplayItemEditionAttachments() {
return !this.$adminOptions.hideItemEditionAttachments && (this.collection && this.collection.item_enable_attachments === 'yes');
}
},
watch: {

View File

@ -7,10 +7,10 @@
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-image"/>
</span>
{{ $i18n.get('label_thumbnail') }}
{{ collection && collection.item_thumbnail_label ? collection.item_thumbnail_label : $i18n.get('label_thumbnail') }}
</label>
<help-button
:title="$i18n.getHelperTitle('items', '_thumbnail_id')"
:title="collection && collection.item_thumbnail_label ? collection.item_thumbnail_label: $i18n.getHelperTitle('items', '_thumbnail_id')"
:message="$i18n.getHelperMessage('items', '_thumbnail_id')"/>
</div>
@ -104,6 +104,7 @@ export default {
},
props: {
item: Object,
collection: Object,
form: Object
},
methods: {

View File

@ -436,6 +436,18 @@
height: 1px;
background-color: var(--tainacan-gray2);
margin-left: 42px;
transition: background-color 0.2s ease, height 0.2s ease;
}
&:hover {
.icon,
strong {
color: var(--tainacan-secondary);
}
hr {
background-color: var(--tainacan-primary);
height: 2px;
}
}
}

View File

@ -610,6 +610,18 @@
height: 1px;
background-color: var(--tainacan-gray2);
margin-left: 42px;
transition: background-color 0.2s ease, height 0.2s ease;
}
&:hover {
.icon,
strong {
color: var(--tainacan-secondary);
}
hr {
background-color: var(--tainacan-primary);
height: 2px;
}
}
}

View File

@ -233,7 +233,9 @@
originalForm: Object,
taxonomyId: '',
isHierarchical: Boolean,
isTermInsertionFlow: false
isTermInsertionFlow: false,
metadatumId: [String, Number],
itemId: [String, Number]
},
data() {
return {
@ -308,7 +310,9 @@
this.isLoading = true;
this.sendChildTerm({
taxonomyId: this.taxonomyId,
term: data
term: data,
metadatumId: this.metadatumId,
itemId: this.itemId
})
.then((term) => {
this.$emit('onEditionFinished', {term: term, hasChangedParent: this.hasChangedParent, initialParent: this.initialParentId });
@ -342,7 +346,9 @@
this.isLoading = true;
this.updateTerm({
taxonomyId: this.taxonomyId,
term: data
term: data,
metadatumId: this.metadatumId,
itemId: this.itemId
})
.then((term) => {
this.formErrors = {};

View File

@ -18,7 +18,7 @@
<span
v-if="form.document == attachment.id"
class="file-attachment-document-tag">
{{ $i18n.get('label_document') }}
{{ collection && collection.item_document_label ? collection.item_document_label : $i18n.get('label_document') }}
</span>
<file-item
:show-name="true"
@ -52,7 +52,7 @@
<i class="tainacan-icon tainacan-icon-30px tainacan-icon-attachments"/>
</span>
</p>
<p>{{ $i18n.get('info_no_attachments_on_item_yet') }}</p>
<p>{{ $i18n.getWithVariables('info_no_%s_on_item_yet', [ collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments') ]) }}</p>
</div>
</section>
</div>
@ -63,7 +63,7 @@
v-if="attachments.length > 0">
<div class="shown-items">
{{
$i18n.get('info_showing_attachments') + ' ' +
$i18n.getWithVariables('info_showing_%s', [ collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments') ]) + ' ' +
(attachmentsPerPage * (attachmentsPage - 1) + 1) +
$i18n.get('info_to') +
getLastAttachmentsNumber() +
@ -99,6 +99,7 @@
props: {
item: Object,
form: Object,
collection: Object,
shouldLoadAttachments: Boolean,
isEditable: Boolean,
},

View File

@ -277,7 +277,7 @@
popperClass: ['tainacan-tooltip', 'tooltip']
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-openurl"/>
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</li>

View File

@ -349,6 +349,24 @@
class="tainacan-icon tainacan-icon-1-25em"/>
</span>
</a>
<a
id="button-open-external"
:aria-label="$i18n.getFrom('collections','view_item')"
@click.stop=""
target="_blank"
:href="collection.url">
<span
v-tooltip="{
content: $i18n.get('label_view_collection_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip'],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
</td>
</tr>

View File

@ -303,6 +303,25 @@
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
</a>
<a
v-if="!isOnTrash"
id="button-open-external"
:aria-label="$i18n.getFrom('items','view_item')"
@click.stop=""
target="_blank"
:href="item.url">
<span
v-tooltip="{
content: $i18n.get('label_item_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : ''],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
</div>
@ -448,6 +467,25 @@
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
</a>
<a
v-if="!isOnTrash"
id="button-open-external"
:aria-label="$i18n.getFrom('items','view_item')"
@click.stop=""
target="_blank"
:href="item.url">
<span
v-tooltip="{
content: $i18n.get('label_item_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : ''],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
</div>
</li>
@ -579,6 +617,25 @@
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
</a>
<a
v-if="!isOnTrash"
id="button-open-external"
:aria-label="$i18n.getFrom('items','view_item')"
@click.stop=""
target="_blank"
:href="item.url">
<span
v-tooltip="{
content: $i18n.get('label_item_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : ''],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
<!-- Remaining metadata -->
@ -802,6 +859,25 @@
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
</a>
<a
v-if="!isOnTrash"
id="button-open-external"
:aria-label="$i18n.getFrom('items','view_item')"
@click.stop=""
target="_blank"
:href="item.url">
<span
v-tooltip="{
content: $i18n.get('label_item_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : ''],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
<!-- Remaining metadata -->
@ -1147,7 +1223,26 @@
<i
:class="{ 'tainacan-icon-delete': !isOnTrash, 'tainacan-icon-deleteforever': isOnTrash }"
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
</span>
</a>
<a
v-if="!isOnTrash"
id="button-open-external"
:aria-label="$i18n.getFrom('items','view_item')"
@click.stop=""
target="_blank"
:href="item.url">
<span
v-tooltip="{
content: $i18n.get('label_item_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : ''],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
</td>
@ -1304,6 +1399,25 @@
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
</a>
<a
v-if="!isOnTrash"
id="button-open-external"
:aria-label="$i18n.getFrom('items','view_item')"
@click.stop=""
target="_blank"
:href="item.url">
<span
v-tooltip="{
content: $i18n.get('label_item_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : ''],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
<!-- Remaining metadata -->
@ -1779,6 +1893,25 @@
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
</a>
<a
v-if="!isOnTrash"
id="button-open-external"
:aria-label="$i18n.getFrom('items','view_item')"
@click.stop=""
target="_blank"
:href="item.url">
<span
v-tooltip="{
content: $i18n.get('label_item_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : ''],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
<!-- Remaining metadata -->

View File

@ -235,6 +235,25 @@
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
</a>
<a
v-if="!isOnTrash"
id="button-open-external"
:aria-label="$i18n.getFrom('taxonomies','view_item')"
@click.stop=""
target="_blank"
:href="themeTaxonomiesURL + taxonomy.slug">
<span
v-tooltip="{
content: $i18n.get('label_taxonomy_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip'],
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
</td>
</tr>
@ -263,7 +282,8 @@
selected: [],
allOnPageSelected: false,
isSelecting: false,
adminUrl: tainacan_plugin.admin_url
adminUrl: tainacan_plugin.admin_url,
themeTaxonomiesURL: tainacan_plugin.theme_taxonomy_list_url
}
},
computed: {

View File

@ -136,9 +136,23 @@
placement: 'bottom'
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-delete"/>
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-delete"/>
</span>
</button>
<a
target="_blank"
:href="term.url">
<span
v-tooltip="{
content: $i18n.get('label_term_page_on_website'),
autoHide: true,
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip'],
placement: 'bottom'
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
</a>
</div>
</label>
<button

View File

@ -119,6 +119,21 @@
:message="$i18n.getHelperMessage('tainacan-relationship', 'accept_draft_items')"/>
</b-field>
<b-field
:addons="false"
:label="$i18n.getHelperTitle('tainacan-relationship', 'accept_only_items_authored_by_current_user')">
&nbsp;
<b-switch
size="is-small"
v-model="modelAcceptOnlyItemsAuthoredByCurrentUser"
@input="emitValues()"
true-value="yes"
false-value="no" />
<help-button
:title="$i18n.getHelperTitle('tainacan-relationship', 'accept_only_items_authored_by_current_user')"
:message="$i18n.getHelperMessage('tainacan-relationship', 'accept_only_items_authored_by_current_user')"/>
</b-field>
</section>
</template>
@ -148,6 +163,7 @@
collectionMessage: '',
displayRelatedItemMetadata: [],
modelAcceptDraftItems: 'no',
modelAcceptOnlyItemsAuthoredByCurrentUser: 'no',
isMetaqueryRelationshipEnabled: tainacan_plugin && tainacan_plugin.tainacan_enable_relationship_metaquery == true ? tainacan_plugin.tainacan_enable_relationship_metaquery : false
}
},
@ -172,6 +188,7 @@
this.modelSearch = '';
this.modelDisplayInRelatedItems = 'no';
this.modelAcceptDraftItems = 'no';
this.modelAcceptOnlyItemsAuthoredByCurrentUser = 'no';
this.emitValues();
}
},
@ -193,6 +210,7 @@
this.displayRelatedItemMetadata = this.value && this.value.display_related_item_metadata && Array.isArray(this.value.display_related_item_metadata) ? this.value.display_related_item_metadata : [];
this.modelDisplayInRelatedItems = this.value && this.value.display_in_related_items ? this.value.display_in_related_items : 'no';
this.modelAcceptDraftItems = this.value && this.value.accept_draft_items ? this.value.accept_draft_items : 'no';
this.modelAcceptOnlyItemsAuthoredByCurrentUser = this.value && this.value.accept_only_items_authored_by_current_user ? this.value.accept_only_items_authored_by_current_user : 'no';
},
methods: {
setErrorsAttributes( type, message ){
@ -283,7 +301,8 @@
search: this.modelSearch,
display_in_related_items: this.modelDisplayInRelatedItems,
display_related_item_metadata: this.displayRelatedItemMetadata,
accept_draft_items: this.modelAcceptDraftItems
accept_draft_items: this.modelAcceptDraftItems,
accept_only_items_authored_by_current_user: this.modelAcceptOnlyItemsAuthoredByCurrentUser
});
}
}

View File

@ -56,7 +56,7 @@
<template
v-if="!isLoading"
slot="empty">
{{ $i18n.get('info_no_item_found') }}
{{ isAcceptingOnlyItemsAuthoredByCurrentUser ? $i18n.get('info_no_item_authored_by_you_found') : $i18n.get('info_no_item_found') }}
</template>
<template
v-if="currentUserCanEditItems && (!$adminOptions.itemEditionMode || $adminOptions.allowItemEditionModalInsideModal)"
@ -209,6 +209,12 @@
this.itemMetadatum.metadatum &&
this.itemMetadatum.metadatum.metadata_type_options &&
this.itemMetadatum.metadatum.metadata_type_options.accept_draft_items === 'yes';
},
isAcceptingOnlyItemsAuthoredByCurrentUser() {
return this.itemMetadatum &&
this.itemMetadatum.metadatum &&
this.itemMetadatum.metadatum.metadata_type_options &&
this.itemMetadatum.metadatum.metadata_type_options.accept_only_items_authored_by_current_user === 'yes';
}
},
watch: {
@ -230,7 +236,8 @@
query['order'] = 'asc';
query['fetch_only'] = 'title,document_mimetype,thumbnail';
query['fetch_only_meta'] = this.isDisplayingRelatedItemMetadata ? (this.itemMetadatum.metadatum.metadata_type_options.display_related_item_metadata.filter(metadatumId => metadatumId !== 'thumbnail') + '') : (this.itemMetadatum.metadatum.metadata_type_options.search ? this.itemMetadatum.metadatum.metadata_type_options.search : '');
if (this.isAcceptingDraftItems)
if ( this.isAcceptingDraftItems )
query['status'] = ['publish','private','draft'];
axios.get('/collection/' + this.collectionId + '/items?' + qs.stringify(query) )
@ -397,6 +404,9 @@
if (this.isAcceptingDraftItems)
query['status'] = ['publish','private','draft'];
if ( this.isAcceptingOnlyItemsAuthoredByCurrentUser )
query['authorid'] = tainacan_plugin.user_data.ID;
if (this.selected.length > 0)
query['exclude'] = this.selected.map((item) => item.value);

View File

@ -71,6 +71,10 @@ class Relationship extends Metadata_Type {
'accept_draft_items' => [
'title' => __( 'List and accept draft items on the relation', 'tainacan' ),
'description' => __( 'Include draft items as possible options to the relationship metadata.', 'tainacan' ),
],
'accept_only_items_authored_by_current_user' => [
'title' => __( 'Bind items only by current author', 'tainacan' ),
'description' => __( 'Accept stabelishing the replationship only with items authored by the current user editing the item.', 'tainacan' ),
]
];
}
@ -121,6 +125,7 @@ class Relationship extends Metadata_Type {
case 'display_in_related_items':
case 'accept_draft_items':
case 'accept_only_items_authored_by_current_user':
if ($option_value == 'yes')
$readable_option_value = __('Yes', 'tainacan');
else if ($option_value == 'no')
@ -177,13 +182,19 @@ class Relationship extends Metadata_Type {
// empty is ok
if ( !empty($this->get_option('display_in_related_items')) && !in_array($this->get_option('display_in_related_items'), ['yes', 'no']) ) {
return [
'display_in_related_items' => __('Display in related items must be a option yes or no','tainacan')
'display_in_related_items' => __('Display in related items must be an option yes or no','tainacan')
];
}
// empty is ok
if ( !empty($this->get_option('accept_draft_items')) && !in_array($this->get_option('accept_draft_items'), ['yes', 'no']) ) {
return [
'accept_draft_items' => __('Accept draft items must be a option yes or no','tainacan')
'accept_draft_items' => __('Accept draft items must be an option yes or no','tainacan')
];
}
// empty is ok
if ( !empty($this->get_option('accept_only_items_authored_by_current_user')) && !in_array($this->get_option('accept_only_items_authored_by_current_user'), ['yes', 'no']) ) {
return [
'accept_only_items_authored_by_current_user' => __('Bind items only by current author must be an option yes or no','tainacan')
];
}

View File

@ -59,6 +59,8 @@
custom-class="tainacan-modal"
:close-button-aria-label="$i18n.get('close')">
<term-edition-form
:metadatum-id="itemMetadatum.metadatum.id"
:item-id="itemMetadatum.item.id"
:is-hierarchical="isHierarchical"
:taxonomy-id="taxonomyId"
:original-form="{ id: 'new', name: newTermName ? newTermName : '' }"
@ -71,6 +73,8 @@
<!-- Term creation panel, used on item submission block for a simpler term creation -->
<transition name="filter-item">
<term-creation-panel
:metadatum-id="itemMetadatum.metadatum.id"
:item-id="itemMetadatum.item.id"
:is-hierarchical="isHierarchical"
v-if="isTermCreationPanelOpen"
:taxonomy-id="taxonomyId"
@ -162,7 +166,7 @@
this.taxonomyId = metadata_type_options.taxonomy_id;
this.taxonomy = metadata_type_options.taxonomy;
this.allowNewFromOptions = this.allowNew === false ? false : metadata_type_options.allow_new_terms == 'yes';
this.allowNewFromOptions = this.allowNew === false ? false : metadata_type_options.allow_new_terms == 'yes' && this.$userCaps.hasCapability('tnc_rep_edit_taxonomies');
this.getTermsId();
},

View File

@ -72,7 +72,7 @@
class="button"
id="view-collection-button">
<span class="icon">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-openurl"/>
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
<span class="is-hidden-mobile">{{ $i18n.get('label_view_collection_on_website') }}</span>
</a>
@ -85,7 +85,7 @@
class="button"
id="view-repository-button--taxonomies">
<span class="icon">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-openurl"/>
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
<span class="is-hidden-mobile">{{ $i18n.get('label_view_taxonomies_on_website') }}</span>
</a>
@ -98,7 +98,7 @@
class="button"
id="view-repository-button">
<span class="icon">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-openurl"/>
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-openurl"/>
</span>
<span class="is-hidden-mobile">{{ $i18n.get('label_view_collections_on_website') }}</span>
</a>

View File

@ -273,7 +273,7 @@
<section
v-if="!isLoadingFilters &&
!((filters.length >= 0 && isRepositoryLevel) || filters.length > 0)"
class="is-grouped-centered section">
class="is-grouped-centered">
<div class="content has-text-gray has-text-centered">
<p>
<span class="icon is-large">

View File

@ -648,7 +648,7 @@ AdminOptionsHelperPlugin.install = function (Vue, options = {}) {
* hideItemEditionMetadataTypes
* allowItemEditionModalInsideModal // Not recommended!
* itemEditionDocumentInsideTabs
* itemEditionAttachmentInsideTabs
* itemEditionAttachmentsInsideTabs
* hideBulkEditionPageTitle

View File

@ -236,7 +236,8 @@ export const fetchCollection = ({ commit, }, id) => {
export const fetchCollectionBasics = ({ commit }, {collectionId, isContextEdit }) => {
return new Promise((resolve, reject) => {
let endpoint = '/collections/' + collectionId + '?fetch_only=name,url,status,allow_comments,hide_items_thumbnail_on_lists';
let endpoint = '/collections/' + collectionId + '?fetch_only=name,url,status,allow_comments,hide_items_thumbnail_on_lists,item_enabled_document_types,item_document_label,item_thumbnail_label,item_enable_thumbnail,item_attachment_label,item_enable_attachments,item_enable_metadata_focus_mode,item_enable_metadata_required_filter,item_enable_metadata_searchbar,item_enable_metadata_collapses';
if (isContextEdit)
endpoint += '&context=edit';

View File

@ -159,7 +159,14 @@ export const fetchTerms = ({}, {taxonomyId, fetchOnly, search, all, order, offse
});
};
export const sendChildTerm = ({ commit }, { taxonomyId, term }) => {
export const sendChildTerm = ({ commit }, { taxonomyId, term, itemId, metadatumId }) => {
if ( itemId != undefined )
term['item_id'] = itemId;
if ( metadatumId != undefined )
term['metadatum_id'] = metadatumId;
return new Promise(( resolve, reject ) => {
axios.tainacan.post(`/taxonomy/${taxonomyId}/terms/`, term)
.then( res => {
@ -172,7 +179,14 @@ export const sendChildTerm = ({ commit }, { taxonomyId, term }) => {
});
};
export const updateTerm = ({}, { taxonomyId, term }) => {
export const updateTerm = ({}, { taxonomyId, term, itemId, metadatumId }) => {
if ( itemId != undefined )
term['item_id'] = itemId;
if ( metadatumId != undefined )
term['metadatum_id'] = metadatumId;
return new Promise(( resolve, reject ) => {
axios.tainacan.patch(`/taxonomy/${taxonomyId}/terms/${term.id}`, term)
.then( res => {

View File

@ -36,7 +36,7 @@
<div
class="column"
:class="!$adminOptions.hideItemSingleDocument || !$adminOptions.hideItemSingleThumbnail ? 'is-7' : 'is-12'">
:class="shouldDisplayItemSingleDocument || shouldDisplayItemSingleThumbnail ? 'is-7' : 'is-12'">
<!-- Hook for extra Form options -->
<template v-if="hasBeginRightForm">
@ -179,7 +179,7 @@
</div>
<div
v-if="!$adminOptions.hideItemSingleDocument || !$adminOptions.hideItemSingleThumbnail"
v-if="shouldDisplayItemSingleDocument || shouldDisplayItemSingleThumbnail"
class="column is-5">
<div class="sticky-container">
@ -193,22 +193,22 @@
<!-- Document -------------------------------- -->
<div
v-if="!$adminOptions.hideItemSingleDocument"
v-if="shouldDisplayItemSingleDocument"
class="section-label">
<label>
<span class="icon has-text-gray4 tainacan-icon-1-125em">
<i :class="'tainacan-icon tainacan-icon-' + ( (!item.document_type || item.document_type == 'empty' ) ? 'item' : (item.document_type == 'attachment' ? 'attachments' : item.document_type))"/>
</span>
{{ item.document != undefined && item.document != null && item.document != '' ? $i18n.get('label_document') : $i18n.get('label_document_empty') }}
{{ collection && collection.item_document_label ? collection.item_document_label : ( (item.document != undefined && item.document != null && item.document != '') ? $i18n.get('label_document') : $i18n.get('label_document_empty') ) }}
</label>
</div>
<div
v-if="!$adminOptions.hideItemSingleDocument"
v-if="shouldDisplayItemSingleDocument"
class="section-box document-field">
<div
v-if="item.document !== undefined && item.document !== null &&
item.document_type !== undefined && item.document_type !== null &&
item.document !== '' && item.document_type !== 'empty'"
item.document_type !== undefined && item.document_type !== null &&
item.document !== '' && item.document_type !== 'empty'"
class="document-field-content">
<div v-html="item.document_as_html"/>
</div>
@ -216,20 +216,19 @@
<p>{{ $i18n.get('info_no_document_to_item') }}</p>
</div>
</div>
<!-- Thumbnail -------------------------------- -->
<div
v-if="!$adminOptions.hideItemSingleThumbnail"
v-if="shouldDisplayItemSingleThumbnail"
class="section-label">
<label>
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-image"/>
</span>
{{ $i18n.get('label_thumbnail') }}
{{ collection && collection.item_thumbnail_label ? collection.item_thumbnail_label : $i18n.get('label_thumbnail') }}
</label>
</div>
<div
v-if="!$adminOptions.hideItemSingleThumbnail"
v-if="shouldDisplayItemSingleThumbnail"
class="section-box section-thumbnail">
<div class="thumbnail-field">
<file-item
@ -270,14 +269,14 @@
<!-- Attachments -------------------------------- -->
<div
v-if="!$adminOptions.hideItemSingleAttachments"
v-if="shouldDisplayItemSingleAttachments"
class="section-label">
<label slot="header">
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-1-125em tainacan-icon-attachments"/>
</span>
<span>
{{ $i18n.get('label_attachments') }}&nbsp;
{{ collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments') }}&nbsp;
<span
v-if="totalAttachments"
class="has-text-gray has-text-weight-normal">
@ -287,11 +286,12 @@
</label>
</div>
<div
v-if="item != undefined && item.id != undefined && !isLoading && !$adminOptions.hideItemSingleAttachments"
v-if="item != undefined && item.id != undefined && !isLoading && shouldDisplayItemSingleAttachments"
class="section-box section-attachments">
<attachments-list
:item="item"
:form="item" />
:form="item"
:collection="collection" />
</div>
<!-- Hook for extra Form options -->
@ -304,8 +304,7 @@
</div>
</div>
</div>
<footer class="footer">
@ -537,6 +536,21 @@
}
return pageTabs;
},
shouldDisplayItemSingleDocument() {
return !this.$adminOptions.hideItemSingleDocument &&
( this.collection && this.collection.item_enabled_document_types && (
( this.collection.item_enabled_document_types['attachment'] && this.collection.item_enabled_document_types['attachment']['enabled'] === 'yes' ) ||
( this.collection.item_enabled_document_types['text'] && this.collection.item_enabled_document_types['text']['enabled'] === 'yes' ) ||
( this.collection.item_enabled_document_types['url'] && this.collection.item_enabled_document_types['url']['enabled'] === 'yes' )
)
);
},
shouldDisplayItemSingleThumbnail() {
return !this.$adminOptions.hideItemSingleThumbnail && (this.collection && this.collection.item_enable_thumbnail === 'yes');
},
shouldDisplayItemSingleAttachments() {
return !this.$adminOptions.hideItemSingleAttachments && (this.collection && this.collection.item_enable_attachments === 'yes');
}
},
created() {
// Obtains item and collection ID

View File

@ -304,14 +304,14 @@
position: -webkit-sticky !important;
right: 0px;
top: auto;
width: 80px;
width: 100px;
.actions-container {
display: flex;
position: relative;
padding: 0;
height: 100%;
width: 80px;
width: 100px;
z-index: 9;
background-color: var(--tainacan-white);
float: right;

View File

@ -131,7 +131,7 @@
}
.metadata-title {
flex-shrink: 0;
padding: 0.6em 5em 0.5em 2.75em;
padding: 0.6em 7em 0.5em 2.75em;
min-height: 40px;
position: relative;
font-size: 1em !important;

View File

@ -102,7 +102,7 @@
}
.metadata-title {
flex-shrink: 0;
padding: 0.5em 4.75em 0.5em 2.75em;
padding: 0.5em 7em 0.5em 2.75em;
min-height: 40px;
position: relative;
font-size: 1em !important;

View File

@ -110,7 +110,7 @@
}
.metadata-title {
flex-shrink: 0;
padding: 0.5em 4.75em 0.5em 2.75em;
padding: 0.5em 7em 0.5em 2.75em;
font-size: 1.0em !important;
min-height: 40px;
position: relative;

View File

@ -297,12 +297,21 @@ class Admin {
$cur_user = wp_get_current_user();
$user_caps = array();
$prefs = array();
$user_data = array();
if ( $cur_user instanceof \WP_User ) {
$tainacan_caps = \tainacan_roles()->get_repository_caps_slugs();
foreach ($tainacan_caps as $tcap) {
$user_caps[$tcap] = current_user_can( $tcap );
}
$prefs = get_user_meta( $cur_user->ID, 'tainacan_prefs', true );
if ( $cur_user->data && isset($cur_user->data->user_email) && isset($cur_user->data->display_name) ) {
$user_data = array(
'ID' => $cur_user->ID,
'email' => $cur_user->data->user_email,
'display_name' => $cur_user->data->display_name
);
}
}
$settings = [
@ -314,6 +323,7 @@ class Admin {
'i18n' => $tainacan_admin_i18n,
'user_caps' => $user_caps,
'user_prefs' => $prefs,
'user_data' => $user_data,
'base_url' => $TAINACAN_BASE_URL,
'plugin_dir_url' => plugin_dir_url( __DIR__ ),
'admin_url' => admin_url(),

View File

@ -220,7 +220,9 @@
{{ $i18n.getHelperMessage('items', '_thumbnail_id') }}
</p>
</div>
<div class="section-toggle">
<div
v-if="!hideFileModalButton || !hideTextModalButton || !hideLinkModalButton"
class="section-toggle">
<p>{{ showThumbnailInput ? $i18n.get('info_thumbnail_custom') : $i18n.get('info_thumbnail_default_from_document') }}</p>
<div class="field has-addons">
<b-switch
@ -232,7 +234,7 @@
</div>
</div>
<div
v-if="!isLoading && showThumbnailInput"
v-if="!isLoading && showThumbnailInput || (hideFileModalButton && hideTextModalButton && hideLinkModalButton)"
class="section-box section-thumbnail"
id="tainacan-item-metadatum_id-thumbnail">
<b-upload

View File

@ -284,7 +284,7 @@ function tainacan_blocks_get_category_icon_script() {
wp_enqueue_script(
'tainacan-blocks-register-category-icon',
$TAINACAN_BASE_URL . '/assets/js/tainacan_blocks_category_icon.js',
array('wp-blocks'),
array('wp-blocks', 'wp-element'),
$TAINACAN_VERSION
);
}

View File

@ -321,6 +321,8 @@ return apply_filters( 'tainacan-i18n', [
'label_select_all_terms' => __( 'Select all taxonomy terms', 'tainacan' ),
'label_all_terms_selected' => __( 'All terms selected', 'tainacan' ),
'label_add_or_update_attachments' => __( 'Add or update attachments', 'tainacan' ),
/* translators: by default this the plural of attachments */
'label_add_or_update_%s' => __( 'Add or update %s', 'tainacan' ),
'label_blank_collection' => __( 'Blank collection', 'tainacan' ),
/* translators: the metadata scheme https://dublincore.org/ */
'label_dublin_core' => __( 'Dublin Core', 'tainacan' ),
@ -703,6 +705,10 @@ return apply_filters( 'tainacan-i18n', [
'label_multiple_terms' => __( 'Multiple terms', 'tainacan' ),
'label_multiple' => __( 'Multiple', 'tainacan' ),
'label_separator' => __( 'Separator', 'tainacan' ),
'label_items_list_options' => __( 'Items list options', 'tainacan' ),
'label_item_edition_form_options' => __( 'Item edition form options', 'tainacan' ),
'label_item_submission_options' => __( 'Item submission options', 'tainacan' ),
'label_metadata_related_features' => __( 'Metadata related features', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
@ -839,6 +845,7 @@ return apply_filters( 'tainacan-i18n', [
'info_no_user_found' => __( 'No user was found with this name.', 'tainacan' ),
'info_no_item_found_filter' => __( 'No item was found here with these filters.', 'tainacan' ),
'info_no_item_found' => __( 'No item was found.', 'tainacan' ),
'info_no_item_authored_by_you_found' => __( 'No item authored by you was found.', 'tainacan' ),
'info_item_not_saved' => __( 'Warning: Item not saved.', 'tainacan' ),
'info_no_associated_role' => __( 'No associated role.', 'tainacan' ),
'info_error_deleting_collection' => __( 'Error on deleting collection.', 'tainacan' ),
@ -868,6 +875,8 @@ return apply_filters( 'tainacan-i18n', [
/* translators: This is displayed before sentences like "Showing items 2 to 8 of 12 */
'info_showing_items' => __( 'Showing items ', 'tainacan' ),
'info_showing_attachments' => __( 'Showing attachments ', 'tainacan' ),
/* translators: This is displayed before sentences like "Showing attachments 2 to 8 of 12 */
'info_showing_%s' => __( 'Showing %s ', 'tainacan' ),
'info_showing_collections' => __( 'Showing collections ', 'tainacan' ),
'info_showing_taxonomies' => __( 'Showing taxonomies ', 'tainacan' ),
'info_showing_activities' => __( 'Showing activities ', 'tainacan' ),
@ -907,6 +916,8 @@ return apply_filters( 'tainacan-i18n', [
'info_help_term_description' => __( 'The description of the Term.', 'tainacan' ),
'info_help_parent_term' => __( 'The parent term', 'tainacan' ),
'info_no_attachments_on_item_yet' => __( 'The are no attachments on this item so far.', 'tainacan' ),
/* translators: This is displayed to indicate that there are no attachments yet. The attachments label can be tweked by user. */
'info_no_%s_on_item_yet' => __( 'The are no %s on this item so far.', 'tainacan' ),
'info_repository_metadata_inheritance' => __( 'Repository Metadata will be inherited by all collections.', 'tainacan' ),
'info_repository_filters_inheritance' => __( 'Repository Filters will be inherited by all collections.', 'tainacan' ),
'info_create_filters' => __( 'Click or Drag and Drop Metadata here for creating a new Filter.', 'tainacan' ),