From 961ab09ad1c10dcabdf516d16fcfee9ddd00737c Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Wed, 11 Oct 2023 16:32:36 -0300 Subject: [PATCH] Adds more options to tweak item edition form options. #811. --- .../entities/class-tainacan-collection.php | 30 +---- .../class-tainacan-collections.php | 10 +- .../edition/collection-edition-form.vue | 115 ++++++++++++------ .../edition/item-attachments-edition-form.vue | 7 +- .../edition/item-document-edition-form.vue | 2 +- .../components/edition/item-edition-form.vue | 2 +- .../edition/item-thumbnail-edition-form.vue | 2 +- .../components/lists/attachments-list.vue | 7 +- src/views/admin/js/admin-utilities.js | 2 +- .../js/store/modules/collection/actions.js | 2 +- src/views/admin/pages/singles/item-page.vue | 5 +- src/views/tainacan-i18n.php | 7 +- 12 files changed, 105 insertions(+), 86 deletions(-) diff --git a/src/classes/entities/class-tainacan-collection.php b/src/classes/entities/class-tainacan-collection.php index b4922de52..b782e118c 100644 --- a/src/classes/entities/class-tainacan-collection.php +++ b/src/classes/entities/class-tainacan-collection.php @@ -44,8 +44,7 @@ class Collection extends Entity { $item_enabled_document_types, $item_document_label, $item_thumbnail_label, - $item_attachment_label_singular, - $item_attachment_label_plural, + $item_attachment_label, $item_enable_attachments, $item_enable_metadata_focus_mode, $item_enable_metadata_required_filter, @@ -650,22 +649,13 @@ class Collection extends Entity { return $this->get_mapped_property('item_thumbnail_label'); } - /** - * Get the singular label for the attachment section in this collection. - * - * @return string The singular label for the attachment section. - */ - function get_item_attachment_label_singular() { - return $this->get_mapped_property('item_attachment_label_singular'); - } - /** * 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_plural() { - return $this->get_mapped_property('item_attachment_label_plural'); + function get_item_attachment_label() { + return $this->get_mapped_property('item_attachment_label'); } /** @@ -1018,24 +1008,14 @@ class Collection extends Entity { $this->set_mapped_property('item_thumbnail_label', $value); } - /** - * Set the singular label for the attachment section in this collection. - * - * @param string $value The singular label for the attachment section. - * @return void - */ - function set_item_attachment_label_singular( $value ) { - $this->set_mapped_property('item_attachment_label_singular', $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_plural( $value ) { - $this->set_mapped_property('item_attachment_label_plural', $value); + function set_item_attachment_label( $value ) { + $this->set_mapped_property('item_attachment_label', $value); } /** diff --git a/src/classes/repositories/class-tainacan-collections.php b/src/classes/repositories/class-tainacan-collections.php index 7e454d114..2844c3fc5 100644 --- a/src/classes/repositories/class-tainacan-collections.php +++ b/src/classes/repositories/class-tainacan-collections.php @@ -387,15 +387,7 @@ class Collections extends Repository { 'default' => __( 'Thumbnail', 'tainacan' ), //'validation' => v::stringType(), ], - 'item_attachment_label_singular' => [ - 'map' => 'meta', - 'title' => __( 'Attachments singular label', 'tainacan' ), - 'type' => 'string', - 'description' => __( 'The singular label for the attachments section in the item edition form', 'tainacan' ), - 'default' => __( 'Attachment', 'tainacan' ), - //'validation' => v::stringType(), - ], - 'item_attachment_label_plural' => [ + 'item_attachment_label' => [ 'map' => 'meta', 'title' => __( 'Attachments plural label', 'tainacan' ), 'type' => 'string', diff --git a/src/views/admin/components/edition/collection-edition-form.vue b/src/views/admin/components/edition/collection-edition-form.vue index 81a5fc818..04ba53f77 100644 --- a/src/views/admin/components/edition/collection-edition-form.vue +++ b/src/views/admin/components/edition/collection-edition-form.vue @@ -239,6 +239,28 @@ v-show="showItemEditionFormOptions" class="options-columns"> + + + +
+ + + + + {{ documentType.label }} + +
+
+
- -   - - - - - -
+
+ :label="$i18n.getHelperTitle('collections', 'item_enable_attachments')"> +   + - + :title="$i18n.getHelperTitle('collections', 'item_enable_attachments')" + :message="$i18n.getHelperMessage('collections', 'item_enable_attachments')"/> + + :label="$i18n.getHelperTitle('collections', 'item_attachment_label')"> + :title="$i18n.getHelperTitle('collections', 'item_attachment_label')" + :message="$i18n.getHelperMessage('collections', 'item_attachment_label')"/> + v-model="form.item_attachment_label" />
+ + +
+ + {{ $i18n.getHelperTitle('collections', 'item_enable_metadata_collapses') }} + + + {{ $i18n.getHelperTitle('collections', 'item_enable_metadata_focus_mode') }} + + + {{ $i18n.getHelperTitle('collections', 'item_enable_metadata_required_filter') }} + + + {{ $i18n.getHelperTitle('collections', 'item_enable_metadata_searchbar') }} + +
+
+ - {{ collection && collection.item_attachment_label_plural ? collection.item_attachment_label_plural : $i18n.get('label_attachments') }}  + {{ collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments') }} 
diff --git a/src/views/admin/components/edition/item-document-edition-form.vue b/src/views/admin/components/edition/item-document-edition-form.vue index fa48a1acc..574a04143 100644 --- a/src/views/admin/components/edition/item-document-edition-form.vue +++ b/src/views/admin/components/edition/item-document-edition-form.vue @@ -10,7 +10,7 @@ {{ 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') ) }}
diff --git a/src/views/admin/components/lists/attachments-list.vue b/src/views/admin/components/lists/attachments-list.vue index 0b52edb86..fe314c9d9 100644 --- a/src/views/admin/components/lists/attachments-list.vue +++ b/src/views/admin/components/lists/attachments-list.vue @@ -18,7 +18,7 @@ - {{ $i18n.get('label_document') }} + {{ collection && collection.item_document_label ? collection.item_document_label : $i18n.get('label_document') }}

-

{{ $i18n.get('info_no_attachments_on_item_yet') }}

+

{{ $i18n.getWithVariables('info_no_%s_on_item_yet', [ collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments') ]) }}

@@ -63,7 +63,7 @@ v-if="attachments.length > 0">
{{ - $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, }, diff --git a/src/views/admin/js/admin-utilities.js b/src/views/admin/js/admin-utilities.js index 7500fc01a..c290a908a 100644 --- a/src/views/admin/js/admin-utilities.js +++ b/src/views/admin/js/admin-utilities.js @@ -636,7 +636,7 @@ AdminOptionsHelperPlugin.install = function (Vue, options = {}) { * hideItemEditionMetadataTypes * allowItemEditionModalInsideModal // Not recommended! * itemEditionDocumentInsideTabs - * itemEditionAttachmentInsideTabs + * itemEditionAttachmentsInsideTabs * hideBulkEditionPageTitle diff --git a/src/views/admin/js/store/modules/collection/actions.js b/src/views/admin/js/store/modules/collection/actions.js index 67110c4eb..4f973c090 100644 --- a/src/views/admin/js/store/modules/collection/actions.js +++ b/src/views/admin/js/store/modules/collection/actions.js @@ -236,7 +236,7 @@ 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,item_enabled_document_types,item_document_label,item_thumbnail_label,item_attachment_label_singular,item_attachment_label_plural,item_enable_attachments,item_enable_metadata_focus_mode,item_enable_metadata_required_filter,item_enable_metadata_searchbar,item_enable_metadata_collapses'; + 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_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'; diff --git a/src/views/admin/pages/singles/item-page.vue b/src/views/admin/pages/singles/item-page.vue index fe10f7bbb..e496cc3e1 100644 --- a/src/views/admin/pages/singles/item-page.vue +++ b/src/views/admin/pages/singles/item-page.vue @@ -277,7 +277,7 @@ - {{ collection && collection.item_attachment_label_plural ? collection.item_attachment_label_plural : $i18n.get('label_attachments') }}  + {{ collection && collection.item_attachment_label ? collection.item_attachment_label : $i18n.get('label_attachments') }}  @@ -291,7 +291,8 @@ class="section-box section-attachments"> + :form="item" + :collection="collection" />
diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php index d4d723132..95e0e71eb 100644 --- a/src/views/tainacan-i18n.php +++ b/src/views/tainacan-i18n.php @@ -701,7 +701,8 @@ return apply_filters( 'tainacan-i18n', [ 'label_separator' => __( 'Separator', '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' ), 'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ), @@ -866,6 +867,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' ), @@ -904,6 +907,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' ),