From a65ae3f03e7d70f9d9b4e692480d5f3749c5e872 Mon Sep 17 00:00:00 2001 From: Rajan Mistry Date: Thu, 7 Sep 2023 22:37:25 +0530 Subject: [PATCH] Ability to search and link work item Ability to search and link work item Changelog: added --- .../shared/work_item_token_input.vue | 26 +- .../components/work_item_detail.vue | 2 + .../work_item_links/work_item_links_form.vue | 1 - .../work_item_add_relationship_form.vue | 245 ++++++++++++++++++ .../work_item_relationship_list.vue | 2 +- .../work_item_relationships.vue | 55 +++- .../javascripts/work_items/constants.js | 17 +- .../graphql/add_linked_items.mutation.graphql | 10 + .../graphql/project_work_items.query.graphql | 1 + .../graphql/work_item.fragment.graphql | 1 + .../related_work_item_links/create_service.rb | 2 +- locale/gitlab.pot | 39 ++- .../work_items/linked_work_items_spec.rb | 89 +++++++ .../work_items/work_item_children_spec.rb | 8 +- .../work_item_relationship_list_spec.js.snap | 4 +- .../work_item_add_relationship_form_spec.js | 170 ++++++++++++ .../work_item_relationships_spec.js | 48 +++- spec/frontend/work_items/mock_data.js | 30 +++ .../work_items/pages/create_work_item_spec.js | 4 +- .../create_service_spec.rb | 2 +- 20 files changed, 718 insertions(+), 38 deletions(-) create mode 100644 app/assets/javascripts/work_items/components/work_item_relationships/work_item_add_relationship_form.vue create mode 100644 app/assets/javascripts/work_items/graphql/add_linked_items.mutation.graphql create mode 100644 spec/features/projects/work_items/linked_work_items_spec.rb create mode 100644 spec/frontend/work_items/components/work_item_relationships/work_item_add_relationship_form_spec.js diff --git a/app/assets/javascripts/work_items/components/shared/work_item_token_input.vue b/app/assets/javascripts/work_items/components/shared/work_item_token_input.vue index 7b38e83803325f..3595ab631dfc77 100644 --- a/app/assets/javascripts/work_items/components/shared/work_item_token_input.vue +++ b/app/assets/javascripts/work_items/components/shared/work_item_token_input.vue @@ -7,7 +7,6 @@ import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import projectWorkItemsQuery from '../../graphql/project_work_items.query.graphql'; import { WORK_ITEMS_TYPE_MAP, - WORK_ITEM_TYPE_ENUM_TASK, I18N_WORK_ITEM_SEARCH_INPUT_PLACEHOLDER, sprintfWorkItem, } from '../../constants'; @@ -29,7 +28,7 @@ export default { childrenType: { type: String, required: false, - default: WORK_ITEM_TYPE_ENUM_TASK, + default: '', }, childrenIds: { type: Array, @@ -53,7 +52,7 @@ export default { return { fullPath: this.fullPath, searchTerm: this.search?.title || this.search, - types: [this.childrenType], + types: this.childrenType ? [this.childrenType] : [], in: this.search ? 'TITLE' : undefined, }; }, @@ -106,6 +105,7 @@ export default { }, handleFocus() { this.searchStarted = true; + this.$emit('searching', true); }, handleMouseOver() { this.timeout = setTimeout(() => { @@ -115,11 +115,22 @@ export default { handleMouseOut() { clearTimeout(this.timeout); }, + handleBlur() { + this.$emit('searching', false); + }, + focusInputText() { + this.$nextTick(() => { + if (this.areWorkItemsToAddValid) { + this.$refs.tokenSelector.$el.querySelector('input[type="text"]').focus(); + } + }); + }, }, };