Commit aa14b441 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Added a hack to set labels

Changelog: changed
parent 5e43724c
......@@ -142,6 +142,7 @@ export default {
this.setInitialState({
selectedLabels,
});
this.updateLabelsSetState();
},
showDropdownContents(showDropdownContents) {
this.setContentIsOnViewport(showDropdownContents);
......@@ -184,7 +185,7 @@ export default {
document.removeEventListener('click', this.handleDocumentClick);
},
methods: {
...mapActions(['setInitialState', 'toggleDropdownContents']),
...mapActions(['setInitialState', 'toggleDropdownContents', 'updateLabelsSetState']),
/**
* This method differentiates between
* dispatched actions and calls necessary method.
......
......@@ -65,3 +65,5 @@ export const createLabel = ({ state, dispatch }, label) => {
export const updateSelectedLabels = ({ commit }, labels) =>
commit(types.UPDATE_SELECTED_LABELS, { labels });
export const updateLabelsSetState = ({ commit }) => commit(types.UPDATE_LABELS_SET_STATE);
......@@ -18,3 +18,5 @@ export const TOGGLE_DROPDOWN_CONTENTS = 'TOGGLE_DROPDOWN_CONTENTS';
export const UPDATE_SELECTED_LABELS = 'UPDATE_SELECTED_LABELS';
export const TOGGLE_DROPDOWN_CONTENTS_CREATE_VIEW = 'TOGGLE_DROPDOWN_CONTENTS_CREATE_VIEW';
export const UPDATE_LABELS_SET_STATE = 'UPDATE_LABELS_SET_STATE';
......@@ -37,13 +37,10 @@ export default {
const selectedLabelIds = state.selectedLabels.map((label) => label.id);
state.labelsFetchInProgress = false;
state.labelsFetched = true;
state.labels = labels.reduce((allLabels, label) => {
allLabels.push({
...label,
set: selectedLabelIds.includes(label.id),
});
return allLabels;
}, []);
state.labels = labels.map((label) => ({
...label,
set: selectedLabelIds.includes(label.id),
}));
},
[types.RECEIVE_SET_LABELS_FAILURE](state) {
state.labelsFetchInProgress = false;
......@@ -80,4 +77,12 @@ export default {
}
}
},
[types.UPDATE_LABELS_SET_STATE](state) {
const selectedLabelIds = state.selectedLabels.map((label) => label.id);
state.labels = state.labels.map((label) => ({
...label,
set: selectedLabelIds.includes(label.id),
}));
},
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment