Merge branch 'feature/388' of https://github.com/tainacan/tainacan into feature/388

This commit is contained in:
vnmedeiros 2020-10-02 14:55:41 -03:00
commit f0db298429
5 changed files with 151 additions and 46 deletions

View File

@ -18,9 +18,9 @@
v-if="error.errors.length"
:key="index">
<a
v-if="['thumbnail', 'attachment', 'document'].includes(error.metadatum_id)"
v-if="['thumbnail', 'attachments', 'document'].includes(error.metadatum_id)"
@click="metadataElements[error.metadatum_id].scrollIntoView({ behavior: 'smooth', block: 'center' })">
{{ $i18n.get('label_' + getErrorMessage(error.errors)) }}
{{ getErrorMessage(error.errors) }}
</a>
<a
v-else-if="metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')]"

View File

@ -55,6 +55,10 @@ registerBlockType('tainacan/item-submission-form', {
type: Boolean,
default: false
},
showAllowCommentsSection: {
type: Boolean,
default: false
},
hideCollapses: {
type: Boolean,
default: false
@ -114,6 +118,22 @@ registerBlockType('tainacan/item-submission-form', {
sentFormMessage: {
type: String,
default: __( 'Thank you. Your item was submitted to the collection.', 'tainacan' )
},
documentSectionLabel: {
type: String,
default: __( 'Document', 'tainacan' )
},
attachmentsSectionLabel: {
type: String,
default: __( 'Attachments', 'tainacan' )
},
thumbnailSectionLabel: {
type: String,
default: __( 'Thumbnail', 'tainacan' )
},
metadataSectionLabel: {
type: String,
default: __( 'Metadata', 'tainacan' )
}
},
supports: {
@ -130,6 +150,7 @@ registerBlockType('tainacan/item-submission-form', {
hideLinkModalButton,
hideThumbnailSection,
hideAttachmentsSection,
showAllowCommentsSection,
hideCollapses,
baseFontSize,
backgroundColor,
@ -144,7 +165,11 @@ registerBlockType('tainacan/item-submission-form', {
collectionMetadata,
enabledMetadata,
sentFormHeading,
sentFormMessage
sentFormMessage,
documentSectionLabel,
attachmentsSectionLabel,
thumbnailSectionLabel,
metadataSectionLabel
} = attributes;
const fontSizes = [
@ -252,7 +277,7 @@ registerBlockType('tainacan/item-submission-form', {
: null }
<div>
<InspectorControls>
<InspectorControls>
<PanelBody
title={ __('Submission feedback', 'tainacan') }
initialOpen={ true } >
@ -275,6 +300,44 @@ registerBlockType('tainacan/item-submission-form', {
/>
</PanelBody>
</InspectorControls>
<InspectorControls>
<PanelBody
title={ __('Section labels', 'tainacan') }
initialOpen={ false } >
<TextControl
label={ __('Document section label', 'tainacan') }
value={ documentSectionLabel }
onChange={ ( updatedSectionName ) =>{
documentSectionLabel = updatedSectionName;
setAttributes({ documentSectionLabel: documentSectionLabel });
} }
/>
<TextControl
label={ __('Thumbnail section label', 'tainacan') }
value={ thumbnailSectionLabel }
onChange={ ( updatedSectionName ) =>{
thumbnailSectionLabel = updatedSectionName;
setAttributes({ thumbnailSectionLabel: thumbnailSectionLabel });
} }
/>
<TextControl
label={ __('Attachments section label', 'tainacan') }
value={ attachmentsSectionLabel }
onChange={ ( updatedSectionName ) =>{
attachmentsSectionLabel = updatedSectionName;
setAttributes({ attachmentsSectionLabel: attachmentsSectionLabel });
} }
/>
<TextControl
label={ __('Metadata section label', 'tainacan') }
value={ metadataSectionLabel }
onChange={ ( updatedSectionName ) =>{
metadataSectionLabel = updatedSectionName;
setAttributes({ metadataSectionLabel: metadataSectionLabel });
} }
/>
</PanelBody>
</InspectorControls>
<InspectorControls>
<PanelBody
title={__('Metadata Input', 'tainacan')}
@ -361,6 +424,16 @@ registerBlockType('tainacan/item-submission-form', {
}
}
/>
<ToggleControl
label={__('Show "allow comments" section', 'tainacan')}
help={ showAllowCommentsSection ? __('Show the option to allow comments on the item page.', 'tainacan') : __('Toggle to hide the option to allow comments on the item page.', 'tainacan')}
checked={ showAllowCommentsSection }
onChange={ ( isChecked ) => {
showAllowCommentsSection = isChecked;
setAttributes({ showAllowCommentsSection: isChecked });
}
}
/>
<ToggleControl
label={__('Hide the metadata collapses', 'tainacan')}
help={ hideCollapses ? __('Do not show collapsable controls for each metadatum.', 'tainacan') : __('Toggle to show collapsable controls on each metadatum.', 'tainacan')}
@ -586,9 +659,14 @@ registerBlockType('tainacan/item-submission-form', {
</div>
) : null
}
<span class="fake-text section-label"></span>
<div class="fake-switch"><span class="fake-icon"></span><span class="fake-text"></span></div>
{
showAllowCommentsSection ?
(
<div>
<span class="fake-text section-label"></span>
<div class="fake-switch"><span class="fake-icon"></span><span class="fake-text"></span></div>
</div>
) : null }
</div>
<div style={{ flexGrow: '1' }}>
<div class="fake-text section-label"></div>
@ -654,7 +732,12 @@ registerBlockType('tainacan/item-submission-form', {
hideLinkModalButton,
hideThumbnailSection,
hideAttachmentsSection,
showAllowCommentsSection,
hideCollapses,
documentSectionLabel,
thumbnailSectionLabel,
attachmentsSectionLabel,
metadataSectionLabel,
baseFontSize,
inputColor,
inputBackgroundColor,
@ -690,10 +773,15 @@ registerBlockType('tainacan/item-submission-form', {
hide-link-modal-button={ hideLinkModalButton.toString() }
hide-thumbnail-section={ hideThumbnailSection.toString() }
hide-attachments-section={ hideAttachmentsSection.toString() }
show-allow-comments-section={ showAllowCommentsSection.toString() }
hide-collapses={ hideCollapses.toString() }
enabled-metadata={ enabledMetadata.toString() }
sent-form-heading={ sentFormHeading }
sent-form-message={ sentFormMessage }>
sent-form-message={ sentFormMessage }
document-section-label={ documentSectionLabel }
thumbnail-section-label={ thumbnailSectionLabel }
attachments-section-label={ attachmentsSectionLabel }
metadata-section-label={ metadataSectionLabel }>
</div>
</div>
}

View File

@ -7,10 +7,15 @@
:hide-link-modal-button="$root.hideLinkModalButton ? $root.hideLinkModalButton : false"
:hide-thumbnail-section="$root.hideThumbnailSection ? $root.hideThumbnailSection : false"
:hide-attachments-section="$root.hideAttachmentsSection ? $root.hideAttachmentsSection : false"
:show-allow-comments-section="$root.showAllowCommentsSection ? $root.showAllowCommentsSection : false"
:hide-collapses="$root.hideCollapses ? $root.hideCollapses : false"
:enabled-metadata="$root.enabledMetadata ? $root.enabledMetadata : []"
:sent-form-heading="$root.sentFormHeading"
:sent-form-message="$root.sentFormMessage" />
:sent-form-message="$root.sentFormMessage"
:document-section-label="$root.documentSectionLabel"
:thumbnail-section-label="$root.thumbnailSectionLabel"
:attachments-section-label="$root.attachmentsSectionLabel"
:metadata-section-label="$root.metadataSectionLabel" />
</template>
<script>

View File

@ -105,10 +105,15 @@ document.addEventListener("DOMContentLoaded", () => {
hideLinkModalButton: false,
hideThumbnailSection: false,
hideAttachmentsSection: false,
showAllowCommentsSection: false,
hideCollapses: false,
enabledMetadata: [],
sentFormHeading: '',
sentFormMessage: ''
sentFormMessage: '',
documentSectionLabel: '',
thumbnailSectionLabel: '',
attachmentsSectionLabel: '',
metadataSectionLabel: ''
},
beforeMount () {
// Collection source settings
@ -126,9 +131,21 @@ document.addEventListener("DOMContentLoaded", () => {
this.hideThumbnailSection = this.isParameterTrue('hide-thumbnail-section');
if (this.$el.attributes['hide-attachments-section'] != undefined)
this.hideAttachmentsSection = this.isParameterTrue('hide-attachments-section');
if (this.$el.attributes['show-allow-comments-section'] != undefined)
this.showAllowCommentsSection = this.isParameterTrue('show-allow-comments-section');
if (this.$el.attributes['hide-collapses'] != undefined)
this.hideCollapses = this.isParameterTrue('hide-collapses');
// Form sections labels
if (this.$el.attributes['document-section-label'] != undefined)
this.documentSectionLabel = this.$el.attributes['document-section-label'].value;
if (this.$el.attributes['thumbnail-section-label'] != undefined)
this.thumbnailSectionLabel = this.$el.attributes['thumbnail-section-label'].value;
if (this.$el.attributes['attachments-section-label'] != undefined)
this.attachmentsSectionLabel = this.$el.attributes['attachments-section-label'].value;
if (this.$el.attributes['metadata-section-label'] != undefined)
this.metadataSectionLabel = this.$el.attributes['metadata-section-label'].value;
// Form submission feedback messages
if (this.$el.attributes['sent-form-heading'] != undefined)
this.sentFormHeading = this.$el.attributes['sent-form-heading'].value;

View File

@ -23,8 +23,10 @@
<!-- Document -------------------------------- -->
<template v-if="!hideFileModalButton || !hideTextModalButton || !hideLinkModalButton">
<div class="section-label">
<label>{{ form.document != undefined && form.document != null && form.document != '' ? $i18n.get('label_document') : $i18n.get('label_document_empty') }}</label>
<div
v-if="documentSectionLabel"
class="section-label">
<label>{{ documentSectionLabel }}</label>
<help-button
:title="$i18n.getHelperTitle('items', 'document')"
:message="$i18n.getHelperMessage('items', 'document')"/>
@ -122,8 +124,10 @@
<!-- Thumbnail -------------------------------- -->
<template v-if="!hideThumbnailSection">
<div class="section-label">
<label>{{ $i18n.get('label_thumbnail') }}</label>
<div
v-if="thumbnailSectionLabel"
class="section-label">
<label>{{ thumbnailSectionLabel }}</label>
<help-button
:title="$i18n.getHelperTitle('items', '_thumbnail_id')"
:message="$i18n.getHelperMessage('items', '_thumbnail_id')"/>
@ -191,8 +195,8 @@
<template v-if="!hideAttachmentsSection">
<div class="section-label">
<label>
<span>{{ $i18n.get('label_attachments') }}</span>
<label v-if="attachmentsSectionLabel">
<span>{{ attachmentsSectionLabel }}</span>
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-attachments"/>
</span>
@ -202,7 +206,7 @@
<div
v-if="itemSubmission != undefined"
class="section-box"
id="tainacan-item-metadatum_id-attachment">
id="tainacan-item-metadatum_id-attachments">
<b-upload
expanded
v-model="form.attachments"
@ -230,7 +234,7 @@
attached
:aria-close-label="$i18n.get('delete')"
@close="form.attachments.splice(index, 1)"
:type="formErrors.find(error => error.metadatum_id == 'attachment') ? 'is-danger' : ''">
:type="formErrors.find(error => error.metadatum_id == 'attachments') ? 'is-danger' : ''">
{{ attachment.name }}
</b-tag>
</div>
@ -249,7 +253,7 @@
</template>
<!-- Comment Status ------------------------ -->
<template v-if="!hideCommentStatus">
<template v-if="showAllowCommentsSection">
<div class="section-label">
<label>{{ $i18n.get('label_comments') }}</label>
<help-button
@ -272,8 +276,8 @@
<!-- Metadata from Collection-------------------------------- -->
<div class="section-label">
<label>
<span>{{ $i18n.get('metadata') }}</span>
<label v-if="metadataSectionLabel">
<span>{{ metadataSectionLabel }}</span>
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-metadata"/>
</span>
@ -395,10 +399,15 @@ export default {
hideLinkModalButton: Boolean,
hideThumbnailSection: Boolean,
hideAttachmentsSection: Boolean,
showAllowCommentsSection: Boolean,
hideCollapses: Boolean,
enabledMetadata: Array,
sentFormHeading: String,
sentFormMessage: String
sentFormMessage: String,
documentSectionLabel: String,
thumbnailSectionLabel: String,
attachmentsSectionLabel: String,
metadataSectionLabel: String
},
data(){
return {
@ -502,19 +511,12 @@ export default {
.catch((errors) => {
if (errors.errors) {
for (let error of errors.errors) {
if (Array.isArray(error.errors)) {
for (let metadatum of Object.keys(error)) {
eventBusItemMetadata.errors.push({
metadatum_id: metadatum,
errors: error[metadatum]
});
}
} else {
for (let metadatum of Object.keys(error)) {
eventBusItemMetadata.errors.push({
metadatum_id: error,
errors: error
});
}
metadatum_id: metadatum,
errors: error[metadatum]
});
}
}
}
this.formErrorMessage = errors.error_message;
@ -528,19 +530,12 @@ export default {
.catch((errors) => {
if (errors.errors) {
for (let error of errors.errors) {
if (Array.isArray(error.errors)) {
for (let metadatum of Object.keys(error)) {
eventBusItemMetadata.errors.push({
metadatum_id: metadatum,
errors: error[metadatum]
});
}
} else {
for (let metadatum of Object.keys(error)) {
eventBusItemMetadata.errors.push({
metadatum_id: error,
errors: error
});
}
metadatum_id: metadatum,
errors: error[metadatum]
});
}
}
}
this.formErrorMessage = errors.error_message;