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" v-if="error.errors.length"
:key="index"> :key="index">
<a <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' })"> @click="metadataElements[error.metadatum_id].scrollIntoView({ behavior: 'smooth', block: 'center' })">
{{ $i18n.get('label_' + getErrorMessage(error.errors)) }} {{ getErrorMessage(error.errors) }}
</a> </a>
<a <a
v-else-if="metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')]" 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, type: Boolean,
default: false default: false
}, },
showAllowCommentsSection: {
type: Boolean,
default: false
},
hideCollapses: { hideCollapses: {
type: Boolean, type: Boolean,
default: false default: false
@ -114,6 +118,22 @@ registerBlockType('tainacan/item-submission-form', {
sentFormMessage: { sentFormMessage: {
type: String, type: String,
default: __( 'Thank you. Your item was submitted to the collection.', 'tainacan' ) 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: { supports: {
@ -130,6 +150,7 @@ registerBlockType('tainacan/item-submission-form', {
hideLinkModalButton, hideLinkModalButton,
hideThumbnailSection, hideThumbnailSection,
hideAttachmentsSection, hideAttachmentsSection,
showAllowCommentsSection,
hideCollapses, hideCollapses,
baseFontSize, baseFontSize,
backgroundColor, backgroundColor,
@ -144,7 +165,11 @@ registerBlockType('tainacan/item-submission-form', {
collectionMetadata, collectionMetadata,
enabledMetadata, enabledMetadata,
sentFormHeading, sentFormHeading,
sentFormMessage sentFormMessage,
documentSectionLabel,
attachmentsSectionLabel,
thumbnailSectionLabel,
metadataSectionLabel
} = attributes; } = attributes;
const fontSizes = [ const fontSizes = [
@ -252,7 +277,7 @@ registerBlockType('tainacan/item-submission-form', {
: null } : null }
<div> <div>
<InspectorControls> <InspectorControls>
<PanelBody <PanelBody
title={ __('Submission feedback', 'tainacan') } title={ __('Submission feedback', 'tainacan') }
initialOpen={ true } > initialOpen={ true } >
@ -275,6 +300,44 @@ registerBlockType('tainacan/item-submission-form', {
/> />
</PanelBody> </PanelBody>
</InspectorControls> </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> <InspectorControls>
<PanelBody <PanelBody
title={__('Metadata Input', 'tainacan')} 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 <ToggleControl
label={__('Hide the metadata collapses', 'tainacan')} 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')} 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> </div>
) : null ) : 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>
<div style={{ flexGrow: '1' }}> <div style={{ flexGrow: '1' }}>
<div class="fake-text section-label"></div> <div class="fake-text section-label"></div>
@ -654,7 +732,12 @@ registerBlockType('tainacan/item-submission-form', {
hideLinkModalButton, hideLinkModalButton,
hideThumbnailSection, hideThumbnailSection,
hideAttachmentsSection, hideAttachmentsSection,
showAllowCommentsSection,
hideCollapses, hideCollapses,
documentSectionLabel,
thumbnailSectionLabel,
attachmentsSectionLabel,
metadataSectionLabel,
baseFontSize, baseFontSize,
inputColor, inputColor,
inputBackgroundColor, inputBackgroundColor,
@ -690,10 +773,15 @@ registerBlockType('tainacan/item-submission-form', {
hide-link-modal-button={ hideLinkModalButton.toString() } hide-link-modal-button={ hideLinkModalButton.toString() }
hide-thumbnail-section={ hideThumbnailSection.toString() } hide-thumbnail-section={ hideThumbnailSection.toString() }
hide-attachments-section={ hideAttachmentsSection.toString() } hide-attachments-section={ hideAttachmentsSection.toString() }
show-allow-comments-section={ showAllowCommentsSection.toString() }
hide-collapses={ hideCollapses.toString() } hide-collapses={ hideCollapses.toString() }
enabled-metadata={ enabledMetadata.toString() } enabled-metadata={ enabledMetadata.toString() }
sent-form-heading={ sentFormHeading } 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>
</div> </div>
} }

View File

@ -7,10 +7,15 @@
:hide-link-modal-button="$root.hideLinkModalButton ? $root.hideLinkModalButton : false" :hide-link-modal-button="$root.hideLinkModalButton ? $root.hideLinkModalButton : false"
:hide-thumbnail-section="$root.hideThumbnailSection ? $root.hideThumbnailSection : false" :hide-thumbnail-section="$root.hideThumbnailSection ? $root.hideThumbnailSection : false"
:hide-attachments-section="$root.hideAttachmentsSection ? $root.hideAttachmentsSection : 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" :hide-collapses="$root.hideCollapses ? $root.hideCollapses : false"
:enabled-metadata="$root.enabledMetadata ? $root.enabledMetadata : []" :enabled-metadata="$root.enabledMetadata ? $root.enabledMetadata : []"
:sent-form-heading="$root.sentFormHeading" :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> </template>
<script> <script>

View File

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

View File

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