From 51f39da3b77d69496e307eefbd627aa9304d0e0a Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Mon, 16 Oct 2023 11:21:19 -0300 Subject: [PATCH] Also adds option to hide thumbnail section. #811. --- .../entities/class-tainacan-collection.php | 20 +++++ .../class-tainacan-collections.php | 10 +++ .../edition/collection-edition-form.vue | 79 +++++++++++++------ .../edition/item-document-edition-form.vue | 10 +-- .../components/edition/item-edition-form.vue | 27 +++++-- .../js/store/modules/collection/actions.js | 2 +- src/views/admin/pages/singles/item-page.vue | 25 ++++-- 7 files changed, 126 insertions(+), 47 deletions(-) diff --git a/src/classes/entities/class-tainacan-collection.php b/src/classes/entities/class-tainacan-collection.php index b782e118c..bcd0d2463 100644 --- a/src/classes/entities/class-tainacan-collection.php +++ b/src/classes/entities/class-tainacan-collection.php @@ -44,6 +44,7 @@ class Collection extends Entity { $item_enabled_document_types, $item_document_label, $item_thumbnail_label, + $item_enable_thubmnail, $item_attachment_label, $item_enable_attachments, $item_enable_metadata_focus_mode, @@ -649,6 +650,15 @@ class Collection extends Entity { return $this->get_mapped_property('item_thumbnail_label'); } + /** + * Check if thumbnail are enabled for this collection. + * + * @return string 'yes' if thumbnail are enabled, 'no' otherwise. + */ + function get_item_enable_thumbnail() { + return $this->get_mapped_property('item_enable_thumbnail'); + } + /** * Get the plural label for the attachment section in this collection. * @@ -1008,6 +1018,16 @@ class Collection extends Entity { $this->set_mapped_property('item_thumbnail_label', $value); } + /** + * Enable or disable thumbnail for this collection. + * + * @param string $value 'yes' to enable thumbnail, 'no' to disable. + * @return void + */ + function set_item_enable_thumbnail( $value ) { + $this->set_mapped_property('item_enable_thumbnail', $value); + } + /** * Set the plural label for the attachment section in this collection. * diff --git a/src/classes/repositories/class-tainacan-collections.php b/src/classes/repositories/class-tainacan-collections.php index 2844c3fc5..3337beb57 100644 --- a/src/classes/repositories/class-tainacan-collections.php +++ b/src/classes/repositories/class-tainacan-collections.php @@ -387,6 +387,16 @@ class Collections extends Repository { 'default' => __( 'Thumbnail', 'tainacan' ), //'validation' => v::stringType(), ], + 'item_enable_thumbnail' => [ + 'map' => 'meta', + 'title' => __( 'Item thumbnail', 'tainacan' ), + 'type' => 'string', + 'description' => __( 'If enabled, each item can have a thumbnail customized instead of the one automatically generated based on the item document.', 'tainacan' ), + 'default' => 'yes', + 'on_error' => __( 'Value should be yes or no', 'tainacan' ), + 'enum' => [ 'yes', 'no' ], + 'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no + ], 'item_attachment_label' => [ 'map' => 'meta', 'title' => __( 'Attachments plural label', 'tainacan' ), diff --git a/src/views/admin/components/edition/collection-edition-form.vue b/src/views/admin/components/edition/collection-edition-form.vue index 5309a9b00..ceff53e9c 100644 --- a/src/views/admin/components/edition/collection-edition-form.vue +++ b/src/views/admin/components/edition/collection-edition-form.vue @@ -260,31 +260,30 @@ v-show="showItemEditionFormOptions" class="options-columns"> - - - -
- - - - - {{ documentType.label }} - -
-
- - -
+ +
+ +
+ + + + + {{ documentType.label }} + +
+
+ +
+ + +
+ +   + + + div { + break-inside: avoid; + } + &>div:not(.field) { -moz-column-count: 2; -moz-column-gap: 0; @@ -1740,7 +1769,7 @@ export default { } .status-radios { display: flex; - + margin: 5px 0; .control-lable { display: flex; align-items: center; 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 574a04143..cfb8f0c29 100644 --- a/src/views/admin/components/edition/item-document-edition-form.vue +++ b/src/views/admin/components/edition/item-document-edition-form.vue @@ -1,8 +1,6 @@