diff --git a/src/classes/entities/class-tainacan-filter.php b/src/classes/entities/class-tainacan-filter.php index 8f8a2a705..76894e2b3 100644 --- a/src/classes/entities/class-tainacan-filter.php +++ b/src/classes/entities/class-tainacan-filter.php @@ -19,7 +19,8 @@ class Filter extends Entity { $max_options, $filter_type, $filter_type_options, - $begin_with_filter_collapsed; + $begin_with_filter_collapsed, + $display_in_repository_level_lists; static $post_type = 'tainacan-filter'; public $enabled_for_collection = true; @@ -179,6 +180,15 @@ class Filter extends Entity { return $this->get_mapped_property('begin_with_filter_collapsed'); } + /** + * Return 'yes' or 'no' to the option of display in repository level lists + * + * @return string + */ + public function get_display_in_repository_level_lists() { + return $this->get_mapped_property('display_in_repository_level_lists'); + } + /** * Define the filter name @@ -252,6 +262,15 @@ class Filter extends Entity { $this->set_mapped_property('begin_with_filter_collapsed', $begin_with_filter_collapsed); } + /** + * Tells if filter should appear in repository level lists, even belonging to a collection + * + * @param string $display_in_repository_level_lists + */ + public function set_display_in_repository_level_lists($display_in_repository_level_lists) { + $this->set_mapped_property('display_in_repository_level_lists', $display_in_repository_level_lists); + } + /** * Transient property used to store the status of the filter for a particular collection * diff --git a/src/classes/repositories/class-tainacan-filters.php b/src/classes/repositories/class-tainacan-filters.php index af9cc77b3..6affb9fe3 100644 --- a/src/classes/repositories/class-tainacan-filters.php +++ b/src/classes/repositories/class-tainacan-filters.php @@ -79,6 +79,16 @@ class Filters extends Repository { 'enum' => [ 'yes', 'no' ], 'default' => 'no' ], + 'display_in_repository_level_lists' => [ + 'map' => 'meta', + 'title' => __( 'Display in repository level lists', 'tainacan' ), + 'type' => 'string', + 'description' => __( 'With this option enabled, the filter will appear even in repository level items lists, such as the complete items list and the term items list.', 'tainacan' ), + 'on_error' => __( 'Please set the "Display in repository level lists" value as "yes" or "no"', 'tainacan' ), + 'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no + 'enum' => [ 'yes', 'no' ], + 'default' => 'no' + ], 'collection_id' => [ 'map' => 'meta', 'title' => __( 'Collection', 'tainacan' ), diff --git a/src/views/admin/components/edition/filter-edition-form.vue b/src/views/admin/components/edition/filter-edition-form.vue index d7ec575f0..25ead57f0 100644 --- a/src/views/admin/components/edition/filter-edition-form.vue +++ b/src/views/admin/components/edition/filter-edition-form.vue @@ -152,7 +152,7 @@ - + +   + + + + + { @@ -306,13 +330,15 @@ export default { let formObj = {}; for (let [key, value] of formData.entries()) { - if (key === 'begin_with_filter_collapsed') + if (key === 'begin_with_filter_collapsed' || key === 'display_in_repository_level_lists') formObj[key] = (value == 'yes' || value == true) ? 'yes' : 'no'; else formObj[key] = value; } if (formObj['begin_with_filter_collapsed'] === undefined) formObj['begin_with_filter_collapsed'] = 'no'; + if (formObj['display_in_repository_level_lists'] === undefined) + formObj['display_in_repository_level_lists'] = 'no'; this.fillExtraFormData(formObj); this.isLoading = true; diff --git a/src/views/admin/components/search/filters-items-list.vue b/src/views/admin/components/search/filters-items-list.vue index 367c7bad8..bf4e68bed 100644 --- a/src/views/admin/components/search/filters-items-list.vue +++ b/src/views/admin/components/search/filters-items-list.vue @@ -2,7 +2,6 @@