Skip to content

Commit 7ce7027

Browse files
committed
Option to hide deprecated elements from lists
1 parent 834874c commit 7ce7027

File tree

10 files changed

+145
-61
lines changed

10 files changed

+145
-61
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Option to hide deprecated elements from lists by default (prop: `hideDeprecatedByDefault`)
12+
913
### Fixed
1014

1115
- `Logs`:

README.md

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,51 @@ Examples: <https://open-eo.github.io/openeo-vue-components/>
1111

1212
**Table of Contents:**
1313

14-
1. [Usage](#usage)
15-
* [HTML](#html)
16-
* [Vue](#vue)
17-
2. [Components](#components)
18-
* [BillingPlans](#billingplans)
19-
* [Capabilities](#capabilities)
20-
* [Collection](#collection)
21-
* [Collections](#collections)
22-
* [DataTable](#datatable)
23-
* [DeprecationNotice](#deprecationnotice)
24-
* [Description](#description)
25-
* [ExperimentalNotice](#experimentalnotice)
26-
* [FederationMissingNotice](#federationmissingnotice)
27-
* [FileFormat](#fileformat)
28-
* [FileFormats](#fileformats)
29-
* [Item](#item)
30-
* [Items](#items)
31-
* [Job](#job)
32-
* [JobEstimate](#jobestimate)
33-
* [JsonSchema](#jsonschema)
34-
* [LinkList](#linklist)
35-
* [Logs](#logs)
36-
* [ModelBuilder](#modelbuilder)
37-
* [ObjectTree](#objecttree)
38-
* [Process](#process)
39-
* [Processes](#processes)
40-
* [SearchableList](#searchablelist)
41-
* [SearchBox](#searchbox)
42-
* [Service](#service)
43-
* [ServiceType](#servicetype)
44-
* [ServiceTypes](#servicetypes)
45-
* [SupportedFeatures](#supportedfeatures)
46-
* [Tabs and Tab](#tabs-and-tab)
47-
* [UdfRuntime](#udfruntime)
48-
* [UdfRuntimes](#udfruntimes)
49-
3. [Other Features](#other-features)
50-
* [FeatureList](#featurelist)
51-
* [Utils](#utils)
14+
- [Vue Components for openEO](#vue-components-for-openeo)
15+
- [Usage](#usage)
16+
- [HTML](#html)
17+
- [FontAwesome](#fontawesome)
18+
- [Vue](#vue)
19+
- [Components](#components)
20+
- [`BillingPlans`](#billingplans)
21+
- [`Capabilities`](#capabilities)
22+
- [`Collection`](#collection)
23+
- [`Collections`](#collections)
24+
- [`DataTable`](#datatable)
25+
- [`DeprecationNotice`](#deprecationnotice)
26+
- [`FederationMissingNotice`](#federationmissingnotice)
27+
- [`Description`](#description)
28+
- [`ExperimentalNotice`](#experimentalnotice)
29+
- [`FileFormat`](#fileformat)
30+
- [`FileFormats`](#fileformats)
31+
- [`JsonSchema`](#jsonschema)
32+
- [`Item`](#item)
33+
- [`Items`](#items)
34+
- [`Job`](#job)
35+
- [`JobEstimate`](#jobestimate)
36+
- [`LinkList`](#linklist)
37+
- [`Logs`](#logs)
38+
- [`ObjectTree`](#objecttree)
39+
- [`Process`](#process)
40+
- [`ModelBuilder`](#modelbuilder)
41+
- [`Processes`](#processes)
42+
- [`SearchableList`](#searchablelist)
43+
- [`SearchBox`](#searchbox)
44+
- [`Service`](#service)
45+
- [`ServiceType`](#servicetype)
46+
- [`ServiceTypes`](#servicetypes)
47+
- [`SupportedFeatures`](#supportedfeatures)
48+
- [`Tabs` and `Tab`](#tabs-and-tab)
49+
- [`Tabs`](#tabs)
50+
- [`Tab`](#tab)
51+
- [Examples](#examples)
52+
- [Simple example with three static tabs](#simple-example-with-three-static-tabs)
53+
- [Dynamically adding tabs + custom tab names appearance](#dynamically-adding-tabs--custom-tab-names-appearance)
54+
- [`UdfRuntime`](#udfruntime)
55+
- [`UdfRuntimes`](#udfruntimes)
56+
- [Other features](#other-features)
57+
- [`FeatureList`](#featurelist)
58+
- [`Utils`](#utils)
5259

5360
## Usage
5461

@@ -187,6 +194,7 @@ Shows an (expandable) list of all STAC-based collections available at a back-end
187194
- `showKeywords` / `show-keywords` (boolean): Adds the keywords to the third line of the summary if set to `true`. Defaults to `false`.
188195
- `federation` (object): The data of the `federation` property obtained from the capabilities.
189196
- `missing` (array): The identifiers of the federated back-ends that are not providing data for the list of collections due to an issue.
197+
- `hideDeprecatedByDefault`: Whether to hide deprecated items ny default. Defaults to `false`.
190198

191199
**Slots:**
192200

@@ -305,6 +313,7 @@ Visualizes all supported file formats of the back-end.
305313
- `heading` (string|null): Specifies the title of the component. If set to `null`, the title is hidden. Defaults to `File Formats`.
306314
- `federation` (object): The data of the `federation` property obtained from the capabilities.
307315
- `missing` (array): The identifiers of the federated back-ends that are not providing data for the list of file formats due to an issue.
316+
- `hideDeprecatedByDefault`: Whether to hide deprecated items ny default. Defaults to `false`.
308317

309318
*Note: At least one of `showInput` or `showOutput` must be set to `true`. Otherwise, the list will be empty.*
310319

@@ -374,6 +383,7 @@ Shows an (expandable) list of STAC-based Items.
374383
- `loadAdditionalData` / `load-additional-data` (function|null): See the corresponding prop in [`SearchableList`](#searchablelist).
375384
- `federation` (object): The data of the `federation` property obtained from the capabilities.
376385
- `missing` (array): The identifiers of the federated back-ends that are not providing data for the list of items due to an issue.
386+
- `hideDeprecatedByDefault`: Whether to hide deprecated items ny default. Defaults to `false`.
377387

378388
**Slots:**
379389

@@ -571,6 +581,7 @@ Shows an (expandable) list of all processes available at a back-end.
571581
- `loadAdditionalData` / `load-additional-data` (function|null): See the corresponding prop in [`SearchableList`](#searchablelist).
572582
- `federation` (object): The data of the `federation` property obtained from the capabilities.
573583
- `missing` (array): The identifiers of the federated back-ends that are not providing data for the list of processes due to an issue.
584+
- `hideDeprecatedByDefault`: Whether to hide deprecated items ny default. Defaults to `false`.
574585

575586
**Slots:**
576587

@@ -605,6 +616,7 @@ A template to implement searchable, sortable and collapsible lists (all optional
605616
- `allowCopy` (boolean): If set to `true`, shows a copy button for the identifier when the heading is hovered. May not work if the `summary` slot is used.
606617
- `heading` (string|null): Specifies the title of the component. If set to `null`, the title is hidden. Defaults to `null`.
607618
- `searchMinLength` / `search-min-length` (integer): The number of characters required to be given until the search starts. Defaults to `2` as it's usually not very meaningful to search for a single character.
619+
- `hideDeprecatedByDefault`: Whether to hide deprecated items ny default. Defaults to `false`.
608620
- `loadAdditionalData` / `load-additional-data` (function|null): An asynchronous function that returns newly loaded data and replaces the original data in the viewer. The function has three parameters:
609621
- `key` (integer): Gives the index (for arrays) or the key (for objects) of the toggled element in the array or object given in the prop `data`.
610622
- `identifier` (number|string): Gives the identifier of the toggled element (corresponds to the values selected via the prop `identifierKey`).
@@ -613,7 +625,7 @@ A template to implement searchable, sortable and collapsible lists (all optional
613625
**Slots:**
614626

615627
- `heading`: HTML to display the heading, which by default consists of a title (see property `heading`) and the count of elements available in total. Will also show the count of elements matching the search term, if a search term has been given. The following slot properties are made available:
616-
- `filteredCount` (integer|null): The count of elements matching the search term. `null` if no search term has been specified and all elements are shown.
628+
- `filteredCount` (integer|null): The count of elements matching the search term. `null` if no filters are applied and all elements are shown.
617629
- `totalCount` (integer): The total count of elements.
618630
- `content-start`: After heading, before searchbox and list.
619631
- `after-search-box`:
@@ -708,6 +720,7 @@ Visualizes all secondary web service types supported by the back-end.
708720
- `collapsed` (boolean|null): See the corresponding prop in [`SearchableList`](#searchablelist).
709721
- `heading` (string|null): Specifies the title of the component. If set to `null`, the title is hidden. Defaults to `Secondary Web Services`.
710722
- `federation` (object): The data of the `federation` property obtained from the capabilities.
723+
- `hideDeprecatedByDefault`: Whether to hide deprecated items ny default. Defaults to `false`.
711724

712725
**Slots:**
713726

@@ -945,6 +958,7 @@ Visualizes all UDF (user-defined function) runtimes supported by the back-end.
945958
- `collapsed` (boolean|null): See the corresponding prop in [`SearchableList`](#searchablelist).
946959
- `heading` (string|null): Specifies the title of the component. If set to `null`, the title is hidden. Defaults to `UDF Runtimes`.
947960
- `federation` (object): The data of the `federation` property obtained from the capabilities.
961+
- `hideDeprecatedByDefault`: Whether to hide deprecated items ny default. Defaults to `false`.
948962

949963
**Slots:**
950964

components/Collections.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="vue-component collections">
3-
<SearchableList :data="collections" identifierKey="id" summaryKey="title" keywordsKey="keywords" :showKeywords="showKeywords" :showSummaryOnExpand="false" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" :loadAdditionalData="loadAdditionalData" @detailsToggled="detailsToggled" allowCopy>
3+
<SearchableList :data="collections" identifierKey="id" summaryKey="title" keywordsKey="keywords" :showKeywords="showKeywords" :showSummaryOnExpand="false" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" :loadAdditionalData="loadAdditionalData" @detailsToggled="detailsToggled" :hideDeprecatedByDefault="hideDeprecatedByDefault" allowCopy>
44
<template #heading="scope"><slot name="heading" v-bind="scope" /></template>
55
<template v-if="missing" #content-start><FederationMissingNotice :missing="missing" :federation="federation" /></template>
66
<template #summary="scope"><slot name="summary" v-bind="scope" /></template>
@@ -67,6 +67,10 @@ export default {
6767
type: Boolean,
6868
default: false
6969
},
70+
hideDeprecatedByDefault: {
71+
type: Boolean,
72+
default: false
73+
},
7074
missing: {
7175
type: Array,
7276
default: null

components/FileFormats.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="vue-component file-formats">
3-
<SearchableList :data="fileFormats" summaryKey="title" keywordsKey="gis_data_types" :showSummaryOnExpand="false" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" @detailsToggled="detailsToggled">
3+
<SearchableList :data="fileFormats" summaryKey="title" keywordsKey="gis_data_types" :showSummaryOnExpand="false" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" :hideDeprecatedByDefault="hideDeprecatedByDefault" @detailsToggled="detailsToggled">
44
<template #heading="scope"><slot name="heading" v-bind="scope" /></template>
55
<template v-if="missing" #content-start><FederationMissingNotice :missing="missing" :federation="federation" /></template>
66
<template #summary="slot">
@@ -74,6 +74,10 @@ export default {
7474
type: Boolean,
7575
default: null
7676
},
77+
hideDeprecatedByDefault: {
78+
type: Boolean,
79+
default: false
80+
},
7781
missing: {
7882
type: Array,
7983
default: null

components/Items.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="vue-component items">
3-
<SearchableList :data="data" summaryKey="title" :showSummaryOnExpand="false" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" :loadAdditionalData="loadAdditionalData" @summaries="updateFeatures" @detailsToggled="detailsToggled" ref="list">
3+
<SearchableList :data="data" summaryKey="title" :showSummaryOnExpand="false" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" :hideDeprecatedByDefault="hideDeprecatedByDefault" :loadAdditionalData="loadAdditionalData" @summaries="updateFeatures" @detailsToggled="detailsToggled" ref="list">
44
<template #heading="scope"><slot name="heading" v-bind="scope" /></template>
55
<template #after-search-box>
66
<slot v-if="showMap" name="map" :geojson="geojson" :mapOptions="mapOptions">
@@ -69,6 +69,10 @@ export default {
6969
type: Boolean,
7070
default: null
7171
},
72+
hideDeprecatedByDefault: {
73+
type: Boolean,
74+
default: false
75+
},
7276
loadAdditionalData: {
7377
type: Function,
7478
default: null

components/Processes.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="vue-component processes">
3-
<SearchableList :data="processes" keywordsKey="categories" :showKeywords="showCategories" :showSummaryOnExpand="false" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" :loadAdditionalData="loadAdditionalData" @detailsToggled="detailsToggled" allowCopy>
3+
<SearchableList :data="processes" keywordsKey="categories" :showKeywords="showCategories" :showSummaryOnExpand="false" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" :hideDeprecatedByDefault="hideDeprecatedByDefault" :loadAdditionalData="loadAdditionalData" @detailsToggled="detailsToggled" allowCopy>
44
<template #heading="scope"><slot name="heading" v-bind="scope" /></template>
55
<template #content-start v-if="missing"><FederationMissingNotice :missing="missing" :federation="federation" /></template>
66
<template #summary="scope"><slot name="summary" v-bind="scope" /></template>
@@ -66,6 +66,10 @@ export default {
6666
type: Boolean,
6767
default: false
6868
},
69+
hideDeprecatedByDefault: {
70+
type: Boolean,
71+
default: false
72+
},
6973
loadAdditionalData: {
7074
type: Function,
7175
default: null

components/SearchableList.vue

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
<p>No data available.</p>
1414
</template>
1515
<template v-else>
16-
<SearchBox v-if="externalSearchTerm === null" v-model="searchTerm" :placeholder="searchPlaceholder" :minLength="searchMinLength" />
16+
<section class="action-bar">
17+
<SearchBox v-if="externalSearchTerm === null" v-model="searchTerm" :placeholder="searchPlaceholder" :minLength="searchMinLength" />
18+
<label class="deprecated" title="Show deprecated elements?">
19+
<input type="checkbox" v-model="hideDeprecated" :true-value="false" :false-value="true">
20+
Show deprecated
21+
</label>
22+
</section>
1723
<slot name="after-search-box" :filteredCount="filteredCount" :summaries="summaries"></slot>
1824
<p v-if="filteredCount === 0">No search results found.</p>
1925
<ul v-else class="list" :class="{expandable: offerDetails}">
@@ -114,6 +120,10 @@ export default {
114120
allowCopy: {
115121
type: Boolean,
116122
default: false
123+
},
124+
hideDeprecatedByDefault: {
125+
type: Boolean,
126+
default: false
117127
}
118128
},
119129
data() {
@@ -126,6 +136,7 @@ export default {
126136
// This allows with a combination of v-if and v-show to not render by default (=> null), but keep rendered versions in cache (=> false)
127137
showDetails: {},
128138
showList: this.collapsed ? null : true,
139+
hideDeprecated: this.hideDeprecatedByDefault,
129140
summaries: [],
130141
canCopy: false
131142
};
@@ -160,19 +171,11 @@ export default {
160171
this.$emit('summaries', this.summaries);
161172
}
162173
},
163-
searchTerm: {
164-
immediate: true,
165-
handler(value) {
166-
if (value.length >= this.searchMinLength) {
167-
this.summaries.forEach(item => {
168-
this.$set(item, 'show', Utils.search(this.searchTerm, [item.identifier, item.summary].concat(item.keywords)));
169-
});
170-
}
171-
else {
172-
this.summaries.forEach(item => this.$set(item, 'show', true));
173-
}
174-
this.$emit('summaries', this.summaries);
175-
}
174+
searchTerm() {
175+
this.filter();
176+
},
177+
hideDeprecated() {
178+
this.filter();
176179
},
177180
collapsed(newState) {
178181
if (newState === false) {
@@ -189,16 +192,36 @@ export default {
189192
return Utils.size(this.data);
190193
},
191194
filteredCount() {
192-
if (this.searchTerm.length >= this.searchMinLength) {
195+
if (this.hasActiveFilter()) {
193196
return this.summaries.filter(item => item.show === true).length;
194197
}
195198
return null;
196199
}
197200
},
201+
created() {
202+
this.filter();
203+
},
198204
mounted() {
199205
this.canCopy = navigator && navigator.clipboard && typeof navigator.clipboard.writeText === 'function';
200206
},
201207
methods: {
208+
hasActiveFilter() {
209+
return this.searchTerm.length >= this.searchMinLength || this.hideDeprecated;
210+
},
211+
filter() {
212+
const doSearch = this.searchTerm.length >= this.searchMinLength;
213+
this.summaries.forEach(item => {
214+
let show = true;
215+
if (this.hideDeprecated && item.deprecated) {
216+
show = false;
217+
}
218+
else if (doSearch) {
219+
show = Utils.search(this.searchTerm, [item.identifier, item.summary].concat(item.keywords))
220+
}
221+
this.$set(item, 'show', show);
222+
});
223+
this.$emit('summaries', this.summaries);
224+
},
202225
copyIdentifier(event, summary) {
203226
if (this.allowCopy && this.canCopy) {
204227
let elem = event.composedPath()[0]; // event.target doesn't work in web components
@@ -310,6 +333,25 @@ export default {
310333
content: "";
311334
}
312335
336+
.action-bar {
337+
width: 100%;
338+
display: flex;
339+
margin-bottom: 1em;
340+
padding: 1px;
341+
gap: 0.5em;
342+
343+
> .search-box {
344+
min-width: 150px;
345+
flex: 1;
346+
margin: 0;
347+
}
348+
349+
> .deprecated {
350+
white-space: nowrap;
351+
align-content: center;
352+
}
353+
}
354+
313355
.details {
314356
display: none;
315357
}

components/ServiceTypes.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="vue-component service-types">
3-
<SearchableList :data="services" summaryKey="title" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" @detailsToggled="detailsToggled">
3+
<SearchableList :data="services" summaryKey="title" :externalSearchTerm="searchTerm" :sort="sort" :offerDetails="offerDetails" :heading="heading" :collapsed="collapsed" :hideDeprecatedByDefault="hideDeprecatedByDefault" @detailsToggled="detailsToggled">
44
<template #heading="scope"><slot name="heading" v-bind="scope" /></template>
55
<template #summary="scope"><slot name="summary" v-bind="scope" /></template>
66
<template #details="slot">
@@ -52,6 +52,10 @@ export default {
5252
type: Boolean,
5353
default: null
5454
},
55+
hideDeprecatedByDefault: {
56+
type: Boolean,
57+
default: false
58+
},
5559
...FederationMixin.props
5660
},
5761
beforeCreate() {

0 commit comments

Comments
 (0)