Commit 2939b8b8 authored by Tim Zallmann's avatar Tim Zallmann

Show DD contents with v-if, cache labels locally

parent 4f8fb373
......@@ -315,7 +315,7 @@ export default {
</dropdown-value>
<dropdown-button v-show="dropdownButtonVisible" class="gl-mt-2" />
<dropdown-contents
v-show="dropdownButtonVisible && showDropdownContents"
v-if="dropdownButtonVisible && showDropdownContents"
ref="dropdownContents"
:render-on-top="!contentIsOnViewport"
/>
......
......@@ -21,13 +21,15 @@ export const receiveLabelsFailure = ({ commit }) => {
});
};
export const fetchLabels = ({ state, dispatch }) => {
dispatch('requestLabels');
return axios
.get(state.labelsFetchPath)
.then(({ data }) => {
dispatch('receiveLabelsSuccess', data);
})
.catch(() => dispatch('receiveLabelsFailure'));
if (!state.labelsFetched) {
dispatch('requestLabels');
return axios
.get(state.labelsFetchPath)
.then(({ data }) => {
dispatch('receiveLabelsSuccess', data);
})
.catch(() => dispatch('receiveLabelsFailure'));
}
};
export const requestCreateLabel = ({ commit }) => commit(types.REQUEST_CREATE_LABEL);
......
......@@ -36,6 +36,7 @@ export default {
// selectedLabels array.
const selectedLabelIds = state.selectedLabels.map((label) => label.id);
state.labelsFetchInProgress = false;
state.labelsFetched = true;
state.labels = labels.reduce((allLabels, label) => {
allLabels.push({
...label,
......
export default () => ({
// Initial Data
labels: [],
labelsFetched: false,
selectedLabels: [],
labelsListTitle: '',
labelsCreateTitle: '',
......
......@@ -330,7 +330,7 @@ export default {
</dropdown-value>
<dropdown-button v-show="dropdownButtonVisible" class="gl-mt-2" />
<dropdown-contents
v-show="dropdownButtonVisible && showDropdownContents"
v-if="dropdownButtonVisible && showDropdownContents"
ref="dropdownContents"
:render-on-top="!contentIsOnViewport"
:labels-create-title="labelsCreateTitle"
......
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