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 { ...@@ -142,6 +142,7 @@ export default {
this.setInitialState({ this.setInitialState({
selectedLabels, selectedLabels,
}); });
this.updateLabelsSetState();
}, },
showDropdownContents(showDropdownContents) { showDropdownContents(showDropdownContents) {
this.setContentIsOnViewport(showDropdownContents); this.setContentIsOnViewport(showDropdownContents);
...@@ -184,7 +185,7 @@ export default { ...@@ -184,7 +185,7 @@ export default {
document.removeEventListener('click', this.handleDocumentClick); document.removeEventListener('click', this.handleDocumentClick);
}, },
methods: { methods: {
...mapActions(['setInitialState', 'toggleDropdownContents']), ...mapActions(['setInitialState', 'toggleDropdownContents', 'updateLabelsSetState']),
/** /**
* This method differentiates between * This method differentiates between
* dispatched actions and calls necessary method. * dispatched actions and calls necessary method.
......
...@@ -65,3 +65,5 @@ export const createLabel = ({ state, dispatch }, label) => { ...@@ -65,3 +65,5 @@ export const createLabel = ({ state, dispatch }, label) => {
export const updateSelectedLabels = ({ commit }, labels) => export const updateSelectedLabels = ({ commit }, labels) =>
commit(types.UPDATE_SELECTED_LABELS, { 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'; ...@@ -18,3 +18,5 @@ export const TOGGLE_DROPDOWN_CONTENTS = 'TOGGLE_DROPDOWN_CONTENTS';
export const UPDATE_SELECTED_LABELS = 'UPDATE_SELECTED_LABELS'; export const UPDATE_SELECTED_LABELS = 'UPDATE_SELECTED_LABELS';
export const TOGGLE_DROPDOWN_CONTENTS_CREATE_VIEW = 'TOGGLE_DROPDOWN_CONTENTS_CREATE_VIEW'; 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 { ...@@ -37,13 +37,10 @@ export default {
const selectedLabelIds = state.selectedLabels.map((label) => label.id); const selectedLabelIds = state.selectedLabels.map((label) => label.id);
state.labelsFetchInProgress = false; state.labelsFetchInProgress = false;
state.labelsFetched = true; state.labelsFetched = true;
state.labels = labels.reduce((allLabels, label) => { state.labels = labels.map((label) => ({
allLabels.push({ ...label,
...label, set: selectedLabelIds.includes(label.id),
set: selectedLabelIds.includes(label.id), }));
});
return allLabels;
}, []);
}, },
[types.RECEIVE_SET_LABELS_FAILURE](state) { [types.RECEIVE_SET_LABELS_FAILURE](state) {
state.labelsFetchInProgress = false; state.labelsFetchInProgress = false;
...@@ -80,4 +77,12 @@ export default { ...@@ -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