Datatype facet improved with user-friendly terms for the different types.
This commit is contained in:
parent
03a55f6a58
commit
0126ae9f85
|
@ -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"
|
* 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
|
* TODO: This should be corrected directly in the index
|
||||||
*/
|
*/
|
||||||
get alias(): string {
|
get categoryAlias(): string {
|
||||||
// return this.categoryName == "doctype" ? "datatype" : this.categoryName;
|
// return this.categoryName == "doctype" ? "datatype" : this.categoryName;
|
||||||
// console.log("getAlias!");
|
// console.log("getAlias!");
|
||||||
switch (this.categoryName) {
|
switch (this.categoryName) {
|
||||||
|
@ -35,12 +35,48 @@ export default class ActiveFacetCategory extends Vue {
|
||||||
case "subjects":
|
case "subjects":
|
||||||
return "keyword";
|
return "keyword";
|
||||||
case "doctype":
|
case "doctype":
|
||||||
return "datatype";
|
return "Data Type";
|
||||||
default:
|
default:
|
||||||
return this.categoryName;
|
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> {
|
// get filterItems(): Array<string> {
|
||||||
// return this.data;
|
// return this.data;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<input v-bind:id="alias" v-bind:name="alias" type="checkbox" checked="checked" class="css-checkbox" @click.prevent="deactivateFacetCategory()" />
|
<input v-bind:id="categoryAlias" v-bind:name="categoryAlias" type="checkbox" checked="checked" class="css-checkbox" @click.prevent="deactivateFacetCategory()" />
|
||||||
<label v-bind:for="alias" class="css-label">
|
<label v-bind:for="categoryAlias" class="css-label">
|
||||||
<span>{{ alias + ": " }}</span>
|
<span>{{ categoryAlias + ": " }}</span>
|
||||||
<a v-if="filterItems && filterItems.length > 0" class="gsaterm">{{ filterItems.join(" | ") }}</a>
|
<!-- <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>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -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.
|
* 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"
|
* 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);
|
// console.log("filterName:", this.filterName);
|
||||||
// return this.filterName == "datatype" ? "doctype" : this.filterName;
|
// return this.filterName == "datatype" ? "doctype" : this.filterName;
|
||||||
|
|
||||||
|
@ -34,12 +34,38 @@ export default class FacetCategory extends Vue {
|
||||||
case "subjects":
|
case "subjects":
|
||||||
return "keyword";
|
return "keyword";
|
||||||
case "doctype":
|
case "doctype":
|
||||||
return "datatype";
|
return "Data Type";
|
||||||
default:
|
default:
|
||||||
return this.filterName;
|
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<FilterItem> {
|
// get filterItems(): Array<FilterItem> {
|
||||||
// return this.data;
|
// return this.data;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="card panel-default">
|
<div class="card panel-default">
|
||||||
<!-- <h3 class="panel-title filterViewModelName">{{ filterName }}</h3> -->
|
<!-- <h3 class="panel-title filterViewModelName">{{ filterName }}</h3> -->
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title titlecase filterViewModelName">{{ alias }}</h3>
|
<h3 class="panel-title titlecase filterViewModelName">{{ categoryAlias }}</h3>
|
||||||
<!-- <h3 class="panel-title titlecase filterViewModelName">{{ filterName }}</h3> -->
|
<!-- <h3 class="panel-title titlecase filterViewModelName">{{ filterName }}</h3> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -10,7 +10,8 @@
|
||||||
<ul class="filter-items list-unstyled" v-bind:class="{ limited: facetItems.length > 1 && collapsed }">
|
<ul class="filter-items list-unstyled" v-bind:class="{ limited: facetItems.length > 1 && collapsed }">
|
||||||
<li v-for="(item, index) in facetItems" v-bind:key="index" class="list-group-item titlecase">
|
<li v-for="(item, index) in facetItems" v-bind:key="index" class="list-group-item titlecase">
|
||||||
<!-- <span :class="item.Active ? 'disabled' : ''" @click.prevent="activateItem(item)">{{ item.val }} ({{ item.count }}) </span> -->
|
<!-- <span :class="item.Active ? 'disabled' : ''" @click.prevent="activateItem(item)">{{ item.val }} ({{ item.count }}) </span> -->
|
||||||
<span v-bind:class="item.active ? 'disabled' : ''" @click.prevent="activateItem(item)">{{ item.val }} ({{ item.count }}) </span>
|
<!-- <span v-bind:class="item.active ? 'disabled' : ''" @click.prevent="activateItem(item)">{{ item.val }} ({{ item.count }}) </span> -->
|
||||||
|
<span v-bind:class="item.active ? 'disabled' : ''" @click.prevent="activateItem(item)">{{ itemAlias(item.val) }} ({{ item.count }}) </span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- <ul class="overflowing" v-if="overflowing == true">
|
<!-- <ul class="overflowing" v-if="overflowing == true">
|
||||||
|
|
|
@ -462,7 +462,7 @@ class DatasetService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("body:", body);
|
// console.log("body:", body);
|
||||||
|
|
||||||
const stations = api.post<OpenSearchResponse>(base, body);
|
const stations = api.post<OpenSearchResponse>(base, body);
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ export default class SearchViewComponent extends Vue {
|
||||||
// console.log(res.hits.hits);
|
// console.log(res.hits.hits);
|
||||||
// console.log(res.hits.total.value); console.log(res);
|
// console.log(res.hits.total.value); console.log(res);
|
||||||
// console.log("results:");
|
// console.log("results:");
|
||||||
console.log(res);
|
// console.log(res);
|
||||||
|
|
||||||
// for (const key in this.results) {
|
// for (const key in this.results) {
|
||||||
// if (Object.prototype.hasOwnProperty.call(this.results, key)) {
|
// if (Object.prototype.hasOwnProperty.call(this.results, key)) {
|
||||||
|
@ -398,7 +398,7 @@ export default class SearchViewComponent extends Vue {
|
||||||
|
|
||||||
// Method to clear facet category filter
|
// Method to clear facet category filter
|
||||||
onClearFacetCategoryOPEN(categoryName: string): void {
|
onClearFacetCategoryOPEN(categoryName: string): void {
|
||||||
// console.log("onClearFacetCategory");
|
console.log("onClearFacetCategory");
|
||||||
delete this.activeFilterCategories[categoryName];
|
delete this.activeFilterCategories[categoryName];
|
||||||
|
|
||||||
// Trigger new search with updated filter
|
// Trigger new search with updated filter
|
||||||
|
@ -448,7 +448,7 @@ export default class SearchViewComponent extends Vue {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (error: string) => this.errorHandler(error),
|
error: (error: string) => this.errorHandler(error),
|
||||||
complete: () => console.log("clear facet category completed"),
|
complete: () => console.log("Clear facet category completed"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
<div class="col col-8 column is-8 results_column" style="padding-top: 1.2rem; padding-right: 1rem; padding-left: 1rem">
|
<div class="col col-8 column is-8 results_column" style="padding-top: 1.2rem; padding-right: 1rem; padding-left: 1rem">
|
||||||
<div v-if="activeFilterCategories && Object.keys(activeFilterCategories).length > 0" class="column">
|
<div v-if="activeFilterCategories && Object.keys(activeFilterCategories).length > 0" class="column">
|
||||||
<span v-for="(values, key, index) in activeFilterCategories" v-bind:key="index" class="active-filter-items">
|
<span v-for="(values, key, index) in activeFilterCategories" v-bind:key="index" class="active-filter-items">
|
||||||
|
<!-- {{ values }} {{key}} {{index }} -->
|
||||||
<active-facet-category
|
<active-facet-category
|
||||||
v-bind:filterItems="values"
|
v-bind:filterItems="values"
|
||||||
v-bind:categoryName="key"
|
v-bind:categoryName="key"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user