diff --git a/src/views/admin/components/edition/item-edition-form.vue b/src/views/admin/components/edition/item-edition-form.vue index 26b8f44d5..027f60574 100644 --- a/src/views/admin/components/edition/item-edition-form.vue +++ b/src/views/admin/components/edition/item-edition-form.vue @@ -561,6 +561,33 @@ + + + + + + + + {{ $i18n.get('label_related_items') }} + + ({{ totalRelatedItems }}) + + + + + + + {{ $i18n.get("info_related_items") }} + + + + + + + @@ -800,6 +827,7 @@ import { eventBusItemMetadata } from '../../js/event-bus-item-metadata'; import wpMediaFrames from '../../js/wp-media-frames'; import FileItem from '../other/file-item.vue'; import DocumentItem from '../other/document-item.vue'; +import RelatedItemsList from '../lists/related-items-list.vue'; import CustomDialog from '../other/custom-dialog.vue'; import AttachmentsList from '../lists/attachments-list.vue'; import { formHooks } from '../../js/mixins'; @@ -811,6 +839,7 @@ export default { FileItem, DocumentItem, AttachmentsList, + RelatedItemsList, ItemMetadatumErrorsTooltip }, mixins: [ formHooks ], @@ -873,6 +902,9 @@ export default { totalAttachments() { return this.getTotalAttachments(); }, + totalRelatedItems() { + return (this.item && this.item.related_items) ? Object.values(this.item.related_items).reduce((totalItems, aRelatedItemsGroup) => totalItems + parseInt(aRelatedItemsGroup.total_items), 0) : false; + }, formErrors() { return eventBusItemMetadata && eventBusItemMetadata.errors && eventBusItemMetadata.errors.length ? eventBusItemMetadata.errors : [] } @@ -1501,7 +1533,7 @@ export default { this.fetchItem({ itemId: this.itemId, contextEdit: true, - fetchOnly: 'title,thumbnail,status,modification_date,document_type,document,comment_status,document_as_html' + fetchOnly: 'title,thumbnail,status,modification_date,document_type,document,comment_status,document_as_html,related_items' }) .then((resp) => { resp.request.then((res) => { diff --git a/src/views/admin/components/lists/related-items-list.vue b/src/views/admin/components/lists/related-items-list.vue new file mode 100644 index 000000000..8bec23d4a --- /dev/null +++ b/src/views/admin/components/lists/related-items-list.vue @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + {{ relatedItemGroup.collection_name ? relatedItemGroup.collection_name : '' }} + + + + + + + + + + + + {{ relatedItemGroup.metadata_name ? relatedItemGroup.metadata_name : '' }} + + + + + + + + + + + + + + + + + + {{ column.name }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/views/admin/pages/singles/item-page.vue b/src/views/admin/pages/singles/item-page.vue index 27dbf815e..5266c1eb7 100644 --- a/src/views/admin/pages/singles/item-page.vue +++ b/src/views/admin/pages/singles/item-page.vue @@ -253,7 +253,7 @@ - + {{ $i18n.get('metadata') }} @@ -293,7 +293,7 @@ - + @@ -313,9 +313,36 @@ @isLoadingAttachments="(isLoading) => isLoadingAttachments = isLoading" /> + + + + + + + + {{ $i18n.get('label_related_items') }} + + ({{ totalRelatedItems }}) + + + + + + + {{ $i18n.get("info_related_items") }} + + + + + + + - + {{ $i18n.get('activities') }} @@ -380,6 +407,7 @@ import ActivitiesPage from '../lists/activities-page.vue'; import ExposersModal from '../../components/modals/exposers-modal.vue'; import AttachmentsList from '../../components/lists/attachments-list.vue'; + import RelatedItemsList from '../../components/lists/related-items-list.vue'; export default { name: 'ItemPage', @@ -387,6 +415,7 @@ FileItem, DocumentItem, ActivitiesPage, + RelatedItemsList, AttachmentsList }, mixins: [formHooks], @@ -414,6 +443,9 @@ metadatumList() { return JSON.parse(JSON.stringify(this.getItemMetadata())); }, + totalRelatedItems() { + return (this.item && this.item.related_items) ? Object.values(this.item.related_items).reduce((totalItems, aRelatedItemsGroup) => totalItems + parseInt(aRelatedItemsGroup.total_items), 0) : false; + }, totalAttachments() { return this.getTotalAttachments(); }, @@ -437,7 +469,7 @@ this.fetchItem({ itemId: this.itemId, contextEdit: true, - fetchOnly: 'title,thumbnail,status,modification_date,document_type,document_mimetype,document,comment_status,document_as_html' + fetchOnly: 'title,thumbnail,status,modification_date,document_type,document_mimetype,document,comment_status,document_as_html,related_items' }) .then((resp) => { resp.request.then((item) => { @@ -717,6 +749,17 @@ } } + .attachments-list-heading { + display: flex; + align-items: center; + margin-top: 24px; + margin-bottom: 24px; + + button { + margin-right: 12px; + } + } + .footer { padding: 18px var(--tainacan-one-column); position: absolute; diff --git a/src/views/tainacan-admin-i18n.php b/src/views/tainacan-admin-i18n.php index 8bf4a9426..6b35a01a4 100644 --- a/src/views/tainacan-admin-i18n.php +++ b/src/views/tainacan-admin-i18n.php @@ -586,6 +586,7 @@ return apply_filters( 'tainacan-admin-i18n', [ 'label_pan_selection' => __( 'Pan selection', 'tainacan'), 'label_reset_zoom' => __( 'Reset zoom', 'tainacan'), 'label_chart_export_options' => __( 'Chart export options', 'tainacan'), + 'label_related_items' => __( 'Items that are related', 'tainacan'), // Instructions. More complex sentences to guide user and placeholders 'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ), @@ -870,7 +871,8 @@ return apply_filters( 'tainacan-admin-i18n', [ 'info_no_taxonomy_metadata_created' => __( 'No taxonomy metadata created yet', 'tainacan'), 'label_amount_of_metadata_of_type' => __( 'Amount of metadata of this type', 'tainacan'), 'info_child_terms_chart' => __( 'Click on the term bar on the chart aside to see its child terms (if any) in this panel', 'tainacan' ), - + 'info_related_items' => __( 'These are items that are related to this item via their own relationship type metadata. You can edit such relation on their pages.', 'tainacan'), + /* Activity actions */ 'action_update-metadata-value' => __( 'Item Metadata Value Updates', 'tainacan'), 'action_update' => __( 'General Updates', 'tainacan'),
+ {{ $i18n.get("info_related_items") }} +