From 6ee630b31b64521a603d7681f36010cc17cc62e8 Mon Sep 17 00:00:00 2001 From: Ricardo Dahis Date: Mon, 4 Nov 2024 18:08:11 +1100 Subject: [PATCH 1/2] feat: observation_level table order working --- .../components/atoms/ObservationLevelTable.js | 23 +++++++++++++------ .../api/rawDataSources/getRawDataSource.js | 1 + next/pages/api/tables/getTable.js | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/next/components/atoms/ObservationLevelTable.js b/next/components/atoms/ObservationLevelTable.js index f1f04f21..8d2bda79 100644 --- a/next/components/atoms/ObservationLevelTable.js +++ b/next/components/atoms/ObservationLevelTable.js @@ -18,16 +18,25 @@ export default function ObservationLevel({ resource }) { const headers = [t('observationLevelTable.entityHeader'), t('observationLevelTable.columnsHeader')]; - let array = [] - const keys = Object.keys(resource?.observationLevels) + function sortElements(a, b) { + if (a.order < b.order) { + return -1; + } + if (a.order > b.order) { + return 1; + } + return 0; + } - keys.forEach((elm) => { - const value = resource?.observationLevels[elm] + let array = []; + const keys = Object.keys(resource?.observationLevels); + const sortedLevels = Object.values(resource?.observationLevels).sort(sortElements); + sortedLevels.forEach((value) => { const valueEntity = () => { - if(value.entity[`name${capitalize(locale)}`]) return value.entity[`name${capitalize(locale)}`] - if(value.entity.name) return value.entity.name - return t('observationLevelTable.notProvided') + if(value.entity[`name${capitalize(locale)}`]) return value.entity[`name${capitalize(locale)}`]; + if(value.entity.name) return value.entity.name; + return t('observationLevelTable.notProvided'); } const valueColumns = () => { diff --git a/next/pages/api/rawDataSources/getRawDataSource.js b/next/pages/api/rawDataSources/getRawDataSource.js index cadc8bdb..4b9fc868 100644 --- a/next/pages/api/rawDataSources/getRawDataSource.js +++ b/next/pages/api/rawDataSources/getRawDataSource.js @@ -61,6 +61,7 @@ async function getRawDataSource(id, locale = 'pt') { edges { node { _id + order columns { edges { node { diff --git a/next/pages/api/tables/getTable.js b/next/pages/api/tables/getTable.js index a921390d..83a369a1 100644 --- a/next/pages/api/tables/getTable.js +++ b/next/pages/api/tables/getTable.js @@ -105,6 +105,7 @@ async function getTable(id, locale='pt') { edges { node { _id + order columns { edges { node { From 5e6d6e9fb0a374a3b9e6245662af48aca1ea0b78 Mon Sep 17 00:00:00 2001 From: Ricardo Dahis Date: Wed, 6 Nov 2024 15:41:52 +1100 Subject: [PATCH 2/2] feat: table.isDeprecated --- next/pages/api/tables/getTable.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/next/pages/api/tables/getTable.js b/next/pages/api/tables/getTable.js index 4352e55c..ead6eb75 100644 --- a/next/pages/api/tables/getTable.js +++ b/next/pages/api/tables/getTable.js @@ -46,6 +46,11 @@ async function getTable(id, locale='pt') { } } version + status { + _id + slug + } + isDeprecated temporalCoverage spatialCoverage fullTemporalCoverage