Merge pull request #812 from tainacan/feature/811

Adds item edition form options inside the collection form. #811
This commit is contained in:
Mateus Machado Luna 2023-10-16 11:47:35 -03:00 committed by GitHub
commit ccc53b3925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1110 additions and 384 deletions

View File

@ -40,7 +40,17 @@ class Collection extends Entity {
$hide_items_thumbnail_on_lists,
$submission_anonymous_user,
$submission_default_status,
$submission_use_recaptcha;
$submission_use_recaptcha,
$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}
@ -607,14 +617,103 @@ class Collection extends Entity {
/**
* Get the default metadata section properties.
*
* @param [string] $value
*
* @return void
*/
function get_default_metadata_section_properties( ) {
return $this->get_mapped_property( 'default_metadata_section_properties' );
}
/**
* 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
*
@ -750,7 +849,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']);
@ -888,6 +987,107 @@ class Collection extends Entity {
return $this->set_mapped_property( 'default_metadata_section_properties', $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

@ -330,6 +330,131 @@ class Collections extends Repository {
]
]
],
'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

@ -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

@ -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

@ -636,7 +636,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

@ -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

@ -315,6 +315,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' ),
@ -697,6 +699,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' ),
@ -862,6 +868,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' ),
@ -900,6 +908,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' ),