diff --git a/src/views/admin/components/metadata-types/compound/child-metadata-list.vue b/src/views/admin/components/metadata-types/compound/child-metadata-list.vue
index 04fc21d7d..3b52be8f6 100644
--- a/src/views/admin/components/metadata-types/compound/child-metadata-list.vue
+++ b/src/views/admin/components/metadata-types/compound/child-metadata-list.vue
@@ -31,14 +31,14 @@
+ v-show="(metadataNameFilterString == '' || filterByMetadatumName(metadatum)) && filterByMetadatumType(metadatum)">
@@ -55,7 +55,7 @@
{{ metadatum.name }}
-
- *
-
@@ -113,6 +102,16 @@
}">
+
+ *
+
+
{{ metadatum.name }}
-
- *
-
+
+ *
+
@@ -356,12 +389,16 @@ export default {
columnsTopY: 0,
collapseAll: false,
metadataNameFilterString: '',
+ metadataTypeFilterOptions: []
}
},
computed: {
collection() {
return this.getCollection();
},
+ hasSomeMetadataTypeFilterApplied() {
+ return this.metadataTypeFilterOptions.length && this.metadataTypeFilterOptions.some((metadatumType) => metadatumType.enabled);
+ },
availableMetadatumList: {
get() {
return this.getMetadatumTypes();
@@ -437,13 +474,20 @@ export default {
this.fetchMetadatumTypes()
.then(() => {
+ this.metadataTypeFilterOptions = JSON.parse(JSON.stringify(this.getMetadatumTypes()))
+ .map((metadatumType) => {
+ return {
+ enabled: false,
+ name: metadatumType.name,
+ type: metadatumType.className
+ }
+ });
this.isLoadingMetadatumTypes = false;
})
.catch(() => {
this.isLoadingMetadatumTypes = false;
});
this.refreshMetadata();
-
},
beforeDestroy() {
@@ -470,7 +514,7 @@ export default {
'getMetadatumTypes',
'getMetadata',
]),
- handleChange(event) {
+ handleChange(event) {
if (event.added) {
this.addNewMetadatum(event.added.element, event.added.newIndex);
} else if (event.removed) {
@@ -671,6 +715,31 @@ export default {
else
return metadatum.name.toString().toLowerCase().indexOf(this.metadataNameFilterString.toString().toLowerCase()) >= 0;
},
+ filterByMetadatumType(metadatum) {
+ if (!this.hasSomeMetadataTypeFilterApplied)
+ return true;
+
+ if (metadatum.metadata_type_object &&
+ metadatum.metadata_type_object.component == 'tainacan-compound' &&
+ metadatum.metadata_type_options &&
+ metadatum.metadata_type_options.children_objects &&
+ metadatum.metadata_type_options.children_objects.length
+ ) {
+ let childTypesArray = metadatum.metadata_type_options.children_objects.map((children) => children.metadata_type);
+ childTypesArray.push(metadatum.metadata_type);
+
+ for (let metadatumType of this.metadataTypeFilterOptions) {
+ if (metadatumType.enabled && childTypesArray.some((childType) => childType == metadatumType.type))
+ return true;
+ }
+ } else {
+ for (let metadatumType of this.metadataTypeFilterOptions) {
+ if (metadatumType.enabled && metadatum.metadata_type == metadatumType.type)
+ return true;
+ }
+ }
+ return false;
+ },
isCollapseOpen(metadatumId) {
return this.collapses[metadatumId] == true;
}
@@ -762,6 +831,26 @@ export default {
h3 {
margin-right: auto;
}
+
+ .dropdown-menu {
+ display: block;
+
+ div.dropdown-content {
+ padding: 0;
+
+ .metadata-options-container {
+ max-height: 288px;
+ overflow: auto;
+ font-size: 1.125em;
+ }
+ .dropdown-item {
+ padding: 0.25em 1.0em 0.25em 0.75em;
+ }
+ .dropdown-item span{
+ vertical-align: middle;
+ }
+ }
+ }
}
.collapse-all {
diff --git a/src/views/tainacan-admin-i18n.php b/src/views/tainacan-admin-i18n.php
index 2f0cabd09..a8b91ccd1 100644
--- a/src/views/tainacan-admin-i18n.php
+++ b/src/views/tainacan-admin-i18n.php
@@ -539,6 +539,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_compact_list' => __( 'Compact list', 'tainacan'),
'label_detailed_list' => __( 'Detailed list', 'tainacan'),
'label_view_metadata_details' => __( 'View metadata details', 'tainacan'),
+ 'label_filter_by_metadata_type' => __( 'Filter by metadatum type', 'tainacan'),
// Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),