diff --git a/src/components/active-facet-category/ActiveFacetCategory.ts b/src/components/active-facet-category/ActiveFacetCategory.ts index e349444..a1eed88 100644 --- a/src/components/active-facet-category/ActiveFacetCategory.ts +++ b/src/components/active-facet-category/ActiveFacetCategory.ts @@ -26,7 +26,7 @@ export default class ActiveFacetCategory extends Vue { * This will allow to display the customised terms "creator" and "keyword" instead of the values currently used in the OpenSearch index: "author" and "subjects" * TODO: This should be corrected directly in the index */ - get alias(): string { + get categoryAlias(): string { // return this.categoryName == "doctype" ? "datatype" : this.categoryName; // console.log("getAlias!"); switch (this.categoryName) { @@ -35,12 +35,48 @@ export default class ActiveFacetCategory extends Vue { case "subjects": return "keyword"; case "doctype": - return "datatype"; + return "Data Type"; default: return this.categoryName; } } + /** + * The alias for the items inside the "doctype / Datatype" category will be set manually in order to show user-friendly terms instead of the predefined doctypes in the DB + * If the category alias is Data Type, the name of the items is set + * NOTE: This could be corrected directly in the index + */ + filterItemsAlias(categoryAlias: string): string { + if (categoryAlias === "Data Type") { + // console.log("DataType"); + + const replacements = new Map([ + ["gis", "GIS"], + ["analysisdata", "Analysis Data"], + ["models", "Models"], + ["monitoring", "Monitoring"], + ["measurementdata", "Measurement Data"], + ["mixedtype", "Mixed Type"] + ]); + + /** + * Iterate over the filterItems array using the map method to create a new array (updatedItems). + * For each item in the array, check if the item exists as a key in the replacements map. + * - If the item exists in the replacements map, replace it with the corresponding value from the map. + * - If the item does not exist in the replacements map, keep the original item unchanged. + * The map method returns a new array where each element is either the original item or its replacement. + * */ + const updatedItems = this.filterItems.map((item) => + replacements.get(item) || item + ); + + return updatedItems.join(" | "); + } + + // console.log("other categories"); + return this.filterItems.join(" | "); + } + // get filterItems(): Array { // return this.data; // } diff --git a/src/components/active-facet-category/active-facet-category.vue b/src/components/active-facet-category/active-facet-category.vue index 94df81f..ffd6734 100644 --- a/src/components/active-facet-category/active-facet-category.vue +++ b/src/components/active-facet-category/active-facet-category.vue @@ -1,9 +1,11 @@ diff --git a/src/components/face-category/FacetCategory.ts b/src/components/face-category/FacetCategory.ts index 4729410..af24c91 100644 --- a/src/components/face-category/FacetCategory.ts +++ b/src/components/face-category/FacetCategory.ts @@ -22,9 +22,9 @@ export default class FacetCategory extends Vue { /** * The alias for the Active facet box will be set depending on the name of the category. * This will allow to display the customised terms "creator" and "keyword" instead of the values currently used in the OpenSearch index: "author" and "subjects" - * TODO: This should be corrected directly in the index + * NOTE: This should be corrected directly in the index */ - get alias(): string { + get categoryAlias(): string { // console.log("filterName:", this.filterName); // return this.filterName == "datatype" ? "doctype" : this.filterName; @@ -34,12 +34,38 @@ export default class FacetCategory extends Vue { case "subjects": return "keyword"; case "doctype": - return "datatype"; + return "Data Type"; default: return this.filterName; } } + /** + * The alias for the items inside the "doctype / Datatype" category will be set manually in order to show user-friendly terms instead of the predefined doctypes in the DB + * NOTE: This could be corrected directly in the index + */ + itemAlias(val: string): string { + // console.log("filterName:", this.filterName); + // return this.filterName == "datatype" ? "doctype" : this.filterName; + + switch (val) { + case "gis": + return "GIS"; + case "analysisdata": + return "Analysis Data"; + case "models": + return "Models"; + case "monitoring": + return "Monitoring"; + case "measurementdata": + return "Measurement Data"; + case "mixedtype": + return "Mixed Type"; + default: + return val; + } + } + // get filterItems(): Array { // return this.data; // } diff --git a/src/components/face-category/facet-category.vue b/src/components/face-category/facet-category.vue index a4c71dc..b7c5c1d 100644 --- a/src/components/face-category/facet-category.vue +++ b/src/components/face-category/facet-category.vue @@ -2,7 +2,7 @@
-

{{ alias }}

+

{{ categoryAlias }}

@@ -10,7 +10,8 @@
  • - {{ item.val }} ({{ item.count }}) + + {{ itemAlias(item.val) }} ({{ item.count }})