Safe checking of metadtumList in item page.

This commit is contained in:
mateuswetah 2022-09-08 10:04:17 -03:00
parent 2ae1ef8d56
commit d653ddf4d6
2 changed files with 47 additions and 45 deletions

View File

@ -102,30 +102,32 @@
</span> </span>
</label> </label>
</div> </div>
<div <template v-if="metadatumList && Array.isArray(metadatumList)">
v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)"
:key="index"
class="field">
<label class="label">{{ itemMetadatum.metadatum.name }}</label>
<div <div
:class="{ v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)"
'metadata-type-textarea': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-textarea', :key="index"
'metadata-type-compound': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound', class="field">
'metadata-type-relationship': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-relationship' <label class="label">{{ itemMetadatum.metadatum.name }}</label>
}" <div
class="content"> :class="{
<component 'metadata-type-textarea': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-textarea',
:is=" 'metadata-type-compound': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound',
itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound' || 'metadata-type-relationship': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-relationship'
(itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-relationship' && }"
itemMetadatum.metadatum.metadata_type_object.options && class="content">
itemMetadatum.metadatum.metadata_type_object.options.display_related_item_metadata && <component
itemMetadatum.metadatum.metadata_type_object.options.display_related_item_metadata.length > 1 :is="
) ? 'div' : 'p'" itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound' ||
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<p><span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_provided') + `</span></p>`"/> (itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-relationship' &&
itemMetadatum.metadatum.metadata_type_object.options &&
itemMetadatum.metadatum.metadata_type_object.options.display_related_item_metadata &&
itemMetadatum.metadatum.metadata_type_object.options.display_related_item_metadata.length > 1
) ? 'div' : 'p'"
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<p><span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_provided') + `</span></p>`"/>
</div>
</div> </div>
</div> <br>
<br> </template>
</div> </div>
</div> </div>

View File

@ -463,32 +463,32 @@
v-if="metadataSection.description && (!hideHelpButtons && helpInfoBellowLabel)"> v-if="metadataSection.description && (!hideHelpButtons && helpInfoBellowLabel)">
{{ metadataSection.description }} {{ metadataSection.description }}
</p> </p>
<template v-if="metadatumList && Array.isArray(metadatumList)">
<template v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)">
<!-- JS-side hook for extra content -->
<div
:key="index"
v-if="hasBeforeHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-before"
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
<template v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)"> <tainacan-form-item
:key="index"
v-if="enabledMetadata[index] == 'true'"
:item-metadatum="itemMetadatum"
:hide-collapses="hideCollapses"
:is-collapsed="metadataCollapses[index]"
@changeCollapse="onChangeCollapse($event, index)"/>
<!-- JS-side hook for extra content --> <!-- JS-side hook for extra content -->
<div <div
:key="index" :key="index"
v-if="hasBeforeHook('metadatum')" v-if="hasAfterHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-before" class="item-submission-hook item-submission-hook-metadatum-after"
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" /> v-html="getAfterHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
</template>
<tainacan-form-item
:key="index"
v-if="enabledMetadata[index] == 'true'"
:item-metadatum="itemMetadatum"
:hide-collapses="hideCollapses"
:is-collapsed="metadataCollapses[index]"
@changeCollapse="onChangeCollapse($event, index)"/>
<!-- JS-side hook for extra content -->
<div
:key="index"
v-if="hasAfterHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-after"
v-html="getAfterHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
</template> </template>
<!-- JS-side hook for extra content --> <!-- JS-side hook for extra content -->
<div <div
v-if="hasAfterHook('metadata_section')" v-if="hasAfterHook('metadata_section')"