diff --git a/components/messages.js b/components/messages.js index 016d3c4c..e183281b 100644 --- a/components/messages.js +++ b/components/messages.js @@ -137,7 +137,7 @@ export const labels = defineMessages({ untitled: { id: 'labels.untitled', defaultMessage: 'Untitled' }, type: { id: 'labels.type', defaultMessage: 'Type' }, filters: { id: 'labels.filters', defaultMessage: 'Filters' }, - groupBy: { id: 'labels.group-by', defaultMessage: 'Group by' }, + breakdown: { id: 'labels.breakdown', defaultMessage: 'Breakdown' }, true: { id: 'labels.true', defaultMessage: 'True' }, false: { id: 'labels.false', defaultMessage: 'False' }, equals: { id: 'labels.equals', defaultMessage: 'Equals' }, @@ -150,6 +150,13 @@ export const labels = defineMessages({ doesNotContain: { id: 'labels.does-not-contain', defaultMessage: 'Does not contain' }, before: { id: 'labels.before', defaultMessage: 'Before' }, after: { id: 'labels.after', defaultMessage: 'After' }, + total: { id: 'labels.total', defaultMessage: 'Total' }, + sum: { id: 'labels.sum', defaultMessage: 'Sum' }, + average: { id: 'labels.average', defaultMessage: 'Average' }, + min: { id: 'labels.min', defaultMessage: 'Min' }, + max: { id: 'labels.max', defaultMessage: 'Max' }, + unique: { id: 'labels.unique', defaultMessage: 'Unique' }, + value: { id: 'labels.value', defaultMessage: 'Value' }, }); export const messages = defineMessages({ diff --git a/components/pages/reports/FieldAggregateForm.js b/components/pages/reports/FieldAggregateForm.js index f4298c16..cdcbdacc 100644 --- a/components/pages/reports/FieldAggregateForm.js +++ b/components/pages/reports/FieldAggregateForm.js @@ -1,27 +1,30 @@ import { Form, FormRow, Menu, Item } from 'react-basics'; - -const options = { - number: [ - { label: 'SUM', value: 'sum' }, - { label: 'AVERAGE', value: 'average' }, - { label: 'MIN', value: 'min' }, - { label: 'MAX', value: 'max' }, - ], - date: [ - { label: 'MIN', value: 'min' }, - { label: 'MAX', value: 'max' }, - ], - string: [ - { label: 'COUNT', value: 'count' }, - { label: 'DISTINCT', value: 'distinct' }, - ], -}; +import { useMessages } from 'hooks'; export default function FieldAggregateForm({ name, type, onSelect }) { + const { formatMessage, labels } = useMessages(); + + const options = { + number: [ + { label: formatMessage(labels.sum), value: 'sum' }, + { label: formatMessage(labels.average), value: 'average' }, + { label: formatMessage(labels.min), value: 'min' }, + { label: formatMessage(labels.max), value: 'max' }, + ], + date: [ + { label: formatMessage(labels.min), value: 'min' }, + { label: formatMessage(labels.max), value: 'max' }, + ], + string: [ + { label: formatMessage(labels.total), value: 'total' }, + { label: formatMessage(labels.unique), value: 'unique' }, + ], + }; + const items = options[type]; const handleSelect = value => { - onSelect({ name, value }); + onSelect({ name, type, value }); }; return ( diff --git a/components/pages/reports/FieldFilterForm.js b/components/pages/reports/FieldFilterForm.js index e4272c69..021ea97e 100644 --- a/components/pages/reports/FieldFilterForm.js +++ b/components/pages/reports/FieldFilterForm.js @@ -17,7 +17,7 @@ export default function FieldFilterForm({ name, type, onSelect }) { return (
- onSelect({ name, value: ['eq', value] })}> + onSelect({ name, type, value: ['eq', value] })}> {items.map(value => { return {filters[value]}; })} @@ -46,7 +46,7 @@ export default function FieldFilterForm({ name, type, onSelect }) {