Skip to content

Commit

Permalink
Fishing map/fixes (#2938)
Browse files Browse the repository at this point in the history
  • Loading branch information
j8seangel authored Nov 26, 2024
2 parents dffd197 + 33f346f commit 83c62e0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
9 changes: 8 additions & 1 deletion apps/fishing-map/features/i18n/utils.datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ export const getDatasetDescriptionTranslated = (dataset: {
id: string
description?: string
}): string => {
return t(`datasets:${removeDatasetVersion(dataset?.id)}.description`, dataset?.description || '')
return (
t(`datasets:${removeDatasetVersion(dataset?.id)}.description`, {
defaultValue: dataset?.description || '',
})
// can't understand why i18next introduces an space in the url
// TODO remove this ugly fix to remove it
.replace('https://globalfishingwatch. org/', 'https://globalfishingwatch.org/')
)
}
9 changes: 7 additions & 2 deletions apps/fishing-map/features/layer-library/LayerLibraryItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useTranslation } from 'react-i18next'
import { useSelector } from 'react-redux'
import { uniq } from 'es-toolkit'
import {
Button,
FillColorBarOptions,
Expand Down Expand Up @@ -51,9 +52,13 @@ const LayerLibraryItem = (props: LayerLibraryItemProps) => {
const palette = FILL_DATAVIEWS.includes(dataview.config?.type)
? FillColorBarOptions
: LineColorBarOptions
const usedColors = dataviews.flatMap((dataview) => dataview.config?.color || [])

const usedColors = uniq(dataviews.flatMap((dataview) => dataview.config?.color || []))
const isDefaultColorUnused = !usedColors.includes(config?.color as string)
const firstUnusedcolor = palette.find((c) => !usedColors.includes(c.value))
const firstUnusedcolor =
palette.length <= usedColors.length
? palette.find((c) => !usedColors.includes(c.value))
: palette[Math.floor(Math.random() * palette.length + 1)]
const supportsColorChange = !LAYER_LIBRARY_EVENTS_IDS.includes(id)
upsertDataviewInstance({
id: `${id}${LAYER_LIBRARY_ID_SEPARATOR}${Date.now()}`,
Expand Down
7 changes: 6 additions & 1 deletion apps/fishing-map/features/map/overlays/draw/DrawDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ function MapDraw() {
/>
<IconButton
icon={mapDrawingMode === 'points' ? 'add-point' : 'add-polygon'}
tooltip={
mapDrawingMode === 'points'
? t('layer.drawAddPoint', 'Add another point')
: t('layer.drawAddPolygon', 'Add another geometry')
}
onClick={onAddPolygonClick}
/>
<IconButton
Expand All @@ -240,7 +245,7 @@ function MapDraw() {
tooltip={
!drawFeaturesIndexes.length
? t('layer.selectPolygonToRemove', 'Select the polygon to remove')
: ''
: t('layer.drawDelete', 'Delete selection')
}
onClick={drawLayer?.deleteSelectedFeature}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const selectShowTimeComparison = createSelector(
export const selectTimeComparisonValues = createSelector(
[selectReportTimeComparison],
(timeComparison): ReportTimeComparisonValues | undefined => {
if (!timeComparison) return
if (!timeComparison?.start || !timeComparison.compareStart) return

const end = getUTCDateTime(timeComparison.start)
.plus({ [timeComparison.durationType]: timeComparison.duration })
Expand Down
3 changes: 3 additions & 0 deletions apps/fishing-map/public/locales/source/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@
},
"areasOnScreen": "Areas on screen",
"color_change": "Change color",
"drawAddPoint": "Add another point",
"drawAddPolygon": "Add another geometry",
"drawDelete": "Delete selection",
"drawPoints": "Draw points",
"drawPolygon": "Draw a layer",
"drawPolygonLogin": "Register and login to draw a layer (free, 2 minutes)",
Expand Down
2 changes: 1 addition & 1 deletion libs/deck-layer-composer/src/resolvers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const resolveDeckUserLayerProps: DeckResolverFunction<BaseUserLayerProps>
}

const layer: ContextLayerConfig<string> = {
id: dataset.id,
id: `${dataview.id}-${dataset.id}`,
datasetId: dataset.id,
tilesUrl,
}
Expand Down

0 comments on commit 83c62e0

Please sign in to comment.