Skip to content

Commit

Permalink
Merge pull request #132 from lat-lon/feature/sortCollections-194
Browse files Browse the repository at this point in the history
Improved collections order in HTML by sorting by id
  • Loading branch information
copierrj authored Sep 25, 2024
2 parents 31af75d + 71029b8 commit 9678a98
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion deegree-ogcapi-features/src/main/resources/collections.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ <h5 v-cloak>{{ collection.title }}</h5>
var baseUrl = retrieveBaseUrl();
const response = await fetch( baseUrl, {headers: {'Accept': 'application/json' } } );
const json = await response.json();
this.collections = json.collections;
this.collections = sortCollections(json.collections);
this.collectionsMetadata = parseCollectionsMetadataLinks(this.collections);
this.licenseLink = parseLinks(json, 'license', 'text/plain');
}
Expand Down Expand Up @@ -258,6 +258,14 @@ <h5 v-cloak>{{ collection.title }}</h5>
return links[0];
}

function sortCollections(collections){
return collections.sort((c1, c2) => {
const c1Id = c1.id;
const c2Id = c2.id;
return c1Id.localeCompare(c2Id);
});
}

function parseCollectionsMetadataLinks(collections){
const metadataLinksPerCollection = {};
collections.forEach(function(collection){
Expand Down

0 comments on commit 9678a98

Please sign in to comment.