forked from geolba/tethys.frontend
Datatype facet improved with user-friendly terms for the different types.
This commit is contained in:
parent
03a55f6a58
commit
0126ae9f85
7 changed files with 81 additions and 15 deletions
|
@ -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<string, string>([
|
||||
["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<string> {
|
||||
// return this.data;
|
||||
// }
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<template>
|
||||
<div>
|
||||
<input v-bind:id="alias" v-bind:name="alias" type="checkbox" checked="checked" class="css-checkbox" @click.prevent="deactivateFacetCategory()" />
|
||||
<label v-bind:for="alias" class="css-label">
|
||||
<span>{{ alias + ": " }}</span>
|
||||
<a v-if="filterItems && filterItems.length > 0" class="gsaterm">{{ filterItems.join(" | ") }}</a>
|
||||
<input v-bind:id="categoryAlias" v-bind:name="categoryAlias" type="checkbox" checked="checked" class="css-checkbox" @click.prevent="deactivateFacetCategory()" />
|
||||
<label v-bind:for="categoryAlias" class="css-label">
|
||||
<span>{{ categoryAlias + ": " }}</span>
|
||||
<!-- <a v-if="filterItems && filterItems.length > 0" class="gsaterm">{{ filterItems.join(" | ") }}</a> -->
|
||||
<a v-if="filterItems && filterItems.length > 0" class="gsaterm">{{ filterItemsAlias(categoryAlias) }}</a>
|
||||
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue