Skip to content

Commit

Permalink
fix: move bool/select value translations to labels
Browse files Browse the repository at this point in the history
  • Loading branch information
dziraf committed Jan 23, 2024
1 parent 1800d2d commit 666b3f3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import allowOverride from '../../../hoc/allow-override.js'
const BooleanPropertyValue: React.FC<ShowPropertyProps> = (props) => {
const { record, property, resource } = props

const { translateProperty } = useTranslation()
const { tl } = useTranslation()

const rawValue = record?.params[property.path]

if (typeof rawValue === 'undefined' || rawValue === '') {
return null
}
const base = mapValue(rawValue)
const translation = translateProperty(`${property.path}.${rawValue}`, resource.id, {
const translation = tl(`${property.path}.${rawValue}`, resource.id, {
defaultValue: base,
})

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/components/property-type/boolean/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const boolValue = (s: string): boolean => {

const Filter: React.FC<FilterPropertyProps> = (props) => {
const { property, filter = {}, onChange } = props
const { tp } = useTranslation()
const { tl } = useTranslation()
const value = typeof filter[property.path] === 'undefined' ? '' : boolValue(filter[property.path])
const options = [
{ value: true, label: tp(`${property.path}.true`, property.resourceId, { defaultValue: mapValue(true) }) },
{ value: false, label: tp(`${property.path}.false`, property.resourceId, { defaultValue: mapValue(false) }) },
{ value: true, label: tl(`${property.path}.true`, property.resourceId, { defaultValue: mapValue(true) }) },
{ value: false, label: tl(`${property.path}.false`, property.resourceId, { defaultValue: mapValue(false) }) },
]
const selected = options.find((o) => o.value === value)
const handleChange = (s) => {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/property-type/default-type/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Edit: FC<CombinedProps> = (props) => {

const SelectEdit: FC<CombinedProps> = (props) => {
const { record, property, onChange } = props
const { tp } = useTranslation()
const { tl } = useTranslation()
if (!property.availableValues) {
return null
}
Expand All @@ -34,7 +34,7 @@ const SelectEdit: FC<CombinedProps> = (props) => {
// eslint-disable-next-line max-len
const availableValues = property.availableValues.map((v) => ({
...v,
label: tp(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }),
label: tl(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }),
}))
// eslint-disable-next-line eqeqeq
const selected = availableValues.find((av) => av.value == propValue)
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/property-type/default-type/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useTranslation } from '../../../hooks/use-translation.js'

const Filter: React.FC<FilterPropertyProps> = (props) => {
const { property, onChange, filter } = props
const { tp } = useTranslation()
const { tl } = useTranslation()

const handleInputChange = (event) => {
onChange(property.path, event.target.value)
Expand All @@ -25,7 +25,7 @@ const Filter: React.FC<FilterPropertyProps> = (props) => {
if (property.availableValues) {
const availableValues = property.availableValues.map((v) => ({
...v,
label: tp(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }),
label: tl(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }),
}))
const selected = property.availableValues.find((av) => av.value === value)
return (
Expand Down

0 comments on commit 666b3f3

Please sign in to comment.