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
const getMetaDatas = (path = []) =>
get(layouts, [...contentTypePath, 'metadatas', ...path], {});
const getListLayout = () =>
get(layouts, [...contentTypePath, 'layouts', 'list'], []);
@ -190,7 +191,11 @@ function ListView({
});
}
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 {
type: ON_CHANGE_LIST_LABELS,
keys: name.split('.'),
name,
slug,
value,
};
}

View File

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