Skip to content
Snippets Groups Projects

Remember user preference for showing labels on work item widgets

Files
9
@@ -20,8 +20,13 @@ import {
TASKS_ANCHOR,
DEFAULT_PAGE_SIZE_CHILD_ITEMS,
DETAIL_VIEW_QUERY_PARAM_NAME,
WORKITEM_LINKS_SHOWLABELS_LOCALSTORAGEKEY,
} from '../../constants';
import { findHierarchyWidgets } from '../../utils';
import {
findHierarchyWidgets,
saveShowLabelsToLocalStorage,
getShowLabelsFromLocalStorage,
} from '../../utils';
import { removeHierarchyChild } from '../../graphql/cache_utils';
import getWorkItemTreeQuery from '../../graphql/work_item_tree.query.graphql';
import WorkItemChildrenLoadMore from '../shared/work_item_children_load_more.vue';
@@ -113,9 +118,11 @@ export default {
reportedUserId: 0,
reportedUrl: '',
widgetName: TASKS_ANCHOR,
defaultShowLabels: true,
showLabels: true,
fetchNextPageInProgress: false,
disableContent: false,
showLabelsLocalStorageKey: WORKITEM_LINKS_SHOWLABELS_LOCALSTORAGEKEY,
};
},
computed: {
@@ -175,6 +182,9 @@ export default {
return this.workItem?.workItemType?.name || '';
},
},
mounted() {
this.setShowLabelsFromLocalStorage();
},
methods: {
showAddForm(formType) {
this.$refs.workItemsLinks.showForm();
@@ -219,6 +229,16 @@ export default {
openReportAbuseModal(reply) {
this.toggleReportAbuseModal(true, reply);
},
toggleShowLabels() {
this.showLabels = !this.showLabels;
saveShowLabelsToLocalStorage(this.showLabelsLocalStorageKey, this.showLabels);
},
setShowLabelsFromLocalStorage() {
this.showLabels = getShowLabelsFromLocalStorage(
this.showLabelsLocalStorageKey,
this.defaultShowLabels,
);
},
async fetchNextPage() {
if (this.hasNextPage && !this.fetchNextPageInProgress) {
this.fetchNextPageInProgress = true;
@@ -300,7 +320,7 @@ export default {
:work-item-type="workItemType"
:show-labels="showLabels"
:show-view-roadmap-action="false"
@toggle-show-labels="showLabels = !showLabels"
@toggle-show-labels="toggleShowLabels"
/>
</template>
Loading