Skip to content

Commit

Permalink
fix bug on speed and elevation track filter
Browse files Browse the repository at this point in the history
  • Loading branch information
j8seangel committed Apr 22, 2024
1 parent 1166be2 commit eb2e6be
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions apps/fishing-map/features/datasets/datasets.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ export const datasetHasSchemaFields = (dataset: Dataset, schema: SupportedDatase
if (!schemaConfig) {
return false
}
if (schemaConfig.type === 'array') {
if (schemaConfig.type === 'array' || schemaConfig.type === 'range') {
const schemaEnum = schemaConfig?.enum || schemaConfig?.items?.enum
return schemaEnum !== undefined && schemaEnum.length > 0
}
Expand Down Expand Up @@ -641,6 +641,9 @@ export type SchemaFieldSelection = {
export const VESSEL_GROUPS_MODAL_ID = 'vesselGroupsOpenModalId'

export const getActiveDatasetsInDataview = (dataview: SchemaFieldDataview) => {
if (!dataview) {
return [] as Dataset[]
}
if (dataview.category === DataviewCategory.User) {
return dataview.datasets
}
Expand Down Expand Up @@ -820,17 +823,13 @@ export const getFiltersBySchema = (
const optionsSelected = getSchemaOptionsSelectedInDataview(dataview, schema, options)
const unit = getSchemaFilterUnitInDataview(dataview, schema)
const datasetsWithSchema = getSupportedSchemaFieldsDatasets(dataview, schema)!?.map((d) => d.id)
const activeDatasets = getActiveDatasetsInActivityDataviews([
dataview as UrlDataviewInstance<DataviewType>,
])
const activeDatasets = getActiveDatasetsInDataview(dataview)?.map((d) => d.id)
const hasDatasetsWithSchema =
compatibilityOperation === 'some'
? activeDatasets.some((d) => datasetsWithSchema.includes(d))
: activeDatasets.every((d) => datasetsWithSchema.includes(d))
? activeDatasets?.some((d) => datasetsWithSchema.includes(d))
: activeDatasets?.every((d) => datasetsWithSchema.includes(d))
const incompatibleFilterSelection = getIncompatibleFilterSelection(dataview, schema)!?.length > 0
const disabled =
// TODO:deck remove this once we know why speed is disabled
schema === 'speed' ? false : !hasDatasetsWithSchema || incompatibleFilterSelection
const disabled = !hasDatasetsWithSchema || incompatibleFilterSelection
const datasetId = removeDatasetVersion(getActiveDatasetsInDataview(dataview)!?.[0]?.id)
let label: string = CONTEXT_DATASETS_SCHEMAS.includes(schema as SupportedContextDatasetSchema)
? t(`datasets:${datasetId}.schema.${schema}.keyword`, schema.toString())
Expand Down

0 comments on commit eb2e6be

Please sign in to comment.