Skip to content

Commit

Permalink
feat: add filter sector vocab for transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Apr 19, 2021
1 parent 90e754d commit 38d09c8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
30 changes: 24 additions & 6 deletions src/app/components/datadisplay/Lists/ListControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import { ModuleStore } from 'app/modules/querybuilder-module/state/store';
import styled from 'styled-components/macro';
import { Palette } from 'app/theme';
import Typography from '@material-ui/core/Typography';
Expand Down Expand Up @@ -67,19 +68,36 @@ const ListCategory = styled((props) => <Typography {...props} />)`

//todo: look into virtualized lists https://material-ui.com/components/lists/
export const ListControls = (props: Props) => {
const store = ModuleStore.useStore();
const [checked, setChecked] = React.useState(props.addedFilterOptions || []);

const handleToggle = (value) => () => {
const currentIndex = checked.indexOf(value as never);
const newChecked = [...checked];

// eslint-disable-next-line no-unused-expressions
currentIndex === -1
? newChecked.push(value as never)
: newChecked.splice(currentIndex, 1);
if (currentIndex === -1) {
newChecked.push(value as never);
} else {
newChecked.splice(currentIndex, 1);
const filterKey =
value === 'Default language'
? 'language'
: value
.split(' ')
.map(
(key: string, index: number) =>
`${
index === 0 ? key[0].toLowerCase() : key[0].toUpperCase()
}${key.substr(1)}`
)
.join('');
store.set(filterKey)([]);
}

if (props.onCheckChange) {
props.onCheckChange(newChecked);
}

// eslint-disable-next-line no-unused-expressions
props.onCheckChange && props.onCheckChange(newChecked);
setChecked(newChecked);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export function getSectorVocabs(data: any, rowFormat: string) {
}
switch (rowFormat) {
case 'activity':
return `sector_vocabulary:(${data.join(' ')})`;
return `(transaction_sector_vocabulary:(${data.join(
' '
)}) OR sector_vocabulary:(${data.join(' ')}))`;
case 'transaction':
return `(transaction_sector_vocabulary:(${data.join(
' '
Expand Down

0 comments on commit 38d09c8

Please sign in to comment.