listview dropdown filter fix

This commit is contained in:
Virginie Ky 2019-11-21 14:24:11 +01:00
parent 83048b38d8
commit 4551c2f383
3 changed files with 18 additions and 13 deletions

View File

@ -121,6 +121,7 @@ function ListView({
// Helpers // Helpers
const getMetaDatas = (path = []) => const getMetaDatas = (path = []) =>
get(layouts, [...contentTypePath, 'metadatas', ...path], {}); get(layouts, [...contentTypePath, 'metadatas', ...path], {});
const getListLayout = () => const getListLayout = () =>
get(layouts, [...contentTypePath, 'layouts', 'list'], []); get(layouts, [...contentTypePath, 'layouts', 'list'], []);
@ -190,7 +191,11 @@ function ListView({
}); });
} }
onChangeListLabels({ onChangeListLabels({
target: { name: `${slug}.${name}`, value: !value }, target: {
name,
slug,
value: !value,
},
}); });
}; };

View File

@ -53,10 +53,11 @@ export function getLayoutSucceeded(layout, uid) {
}; };
} }
export function onChangeListLabels({ target: { name, value } }) { export function onChangeListLabels({ target: { name, slug, value } }) {
return { return {
type: ON_CHANGE_LIST_LABELS, type: ON_CHANGE_LIST_LABELS,
keys: name.split('.'), name,
slug,
value, value,
}; };
} }

View File

@ -42,18 +42,17 @@ function mainReducer(state = initialState, action) {
.updateIn(['layouts', action.uid], () => fromJS(action.layout)) .updateIn(['layouts', action.uid], () => fromJS(action.layout))
.updateIn(['initialLayouts', action.uid], () => fromJS(action.layout)); .updateIn(['initialLayouts', action.uid], () => fromJS(action.layout));
case ON_CHANGE_LIST_LABELS: { case ON_CHANGE_LIST_LABELS: {
const { const { name, slug, value } = action;
keys: [slug, label],
value,
} = action;
return state.updateIn(['layouts', slug, 'layouts', 'list'], list => { return state.updateIn(
if (value) { ['layouts', slug, 'contentType', 'layouts', 'list'],
return list.push(label); list => {
if (value) {
return list.push(name);
}
return list.filter(l => l !== name);
} }
);
return list.filter(l => l !== label);
});
} }
case RESET_LIST_LABELS: case RESET_LIST_LABELS:
return state.updateIn(['layouts', action.slug], () => return state.updateIn(['layouts', action.slug], () =>