Skip to content
Snippets Groups Projects
Commit 8f280c98 authored by Deepika Guliani's avatar Deepika Guliani :two:
Browse files

Add the iteration of the parent while creating tasks

parent 97fce87a
No related branches found
No related tags found
No related merge requests found
Pipeline #638456060 skipped
This commit is part of merge request !97343. Comments created here will be created in the context of that merge request.
......@@ -8,11 +8,11 @@ import { TYPE_WORK_ITEM } from '~/graphql_shared/constants';
import issueConfidentialQuery from '~/sidebar/queries/issue_confidential.query.graphql';
import { isMetaKey } from '~/lib/utils/common_utils';
import { setUrlParams, updateHistory } from '~/lib/utils/url_utility';
import projectIssueIterationQuery from 'ee/sidebar/queries/project_issue_iteration.query.graphql';
import { WIDGET_ICONS, WORK_ITEM_STATUS_TEXT, WIDGET_TYPE_HIERARCHY } from '../../constants';
import getWorkItemLinksQuery from '../../graphql/work_item_links.query.graphql';
import updateWorkItemMutation from '../../graphql/update_work_item.mutation.graphql';
import projectIssueIterationQuery from 'ee/sidebar/queries/project_issue_iteration.query.graphql';
import workItemQuery from '../../graphql/work_item.query.graphql';
import WorkItemDetailModal from '../work_item_detail_modal.vue';
import WorkItemLinkChild from './work_item_link_child.vue';
......@@ -130,6 +130,9 @@ export default {
childrenCountLabel() {
return this.isLoading && this.children.length === 0 ? '...' : this.children.length;
},
issuableIteration() {
return this.iteration?.attribute;
},
},
methods: {
toggle() {
......@@ -318,6 +321,7 @@ export default {
:issuable-gid="issuableGid"
:children-ids="childrenIds"
:parent-confidential="confidential"
:issuable-iteration="issuableIteration"
@cancel="hideAddForm"
@addWorkItemChild="addChild"
/>
......
......@@ -33,6 +33,11 @@ export default {
required: false,
default: false,
},
issuableIteration: {
type: Object,
required: false,
default: () => {},
},
},
apollo: {
workItemTypes: {
......@@ -77,6 +82,9 @@ export default {
taskWorkItemType() {
return this.workItemTypes.find((type) => type.name === TASK_TYPE_NAME)?.id;
},
issuableIterationId() {
return this.issuableIteration?.id;
},
},
methods: {
getIdFromGraphQLId,
......@@ -128,12 +136,17 @@ export default {
},
})
.then(async ({ data }) => {
await this.addIterationToWorkItem();
if (data.workItemCreate?.errors?.length) {
[this.error] = data.workItemCreate.errors;
} else {
this.unsetError();
this.$emit('addWorkItemChild', data.workItemCreate.workItem);
/**
* call update mutation only when there is an iteration associated with the issue
*/
if (this.issuableIterationId) {
await this.addIterationToWorkItem(data.workItemCreate.workItem.id);
}
}
})
.catch(() => {
......@@ -144,14 +157,14 @@ export default {
this.childToCreateTitle = null;
});
},
async addIterationToWorkItem() {
async addIterationToWorkItem(workItemId) {
await this.$apollo.mutate({
mutation: updateWorkItemMutation,
variables: {
input: {
id: this.issuableGid,
id: workItemId,
iterationWidget: {
iterationId: 'gid://gitlab/Iteration/8176',
iterationId: this.issuableIterationId,
},
},
},
......
......@@ -162,7 +162,7 @@ export default {
},
async addIterationToWorkItem() {
try {
const { data } = await this.$apollo.mutate({
await this.$apollo.mutate({
mutation: updateWorkItemMutation,
variables: {
input: {
......@@ -173,7 +173,6 @@ export default {
},
},
});
console.log(data);
} catch {
this.error = this.createErrorText;
}
......
......@@ -46,7 +46,6 @@ export default {
};
},
update(data) {
console.log(data);
return data.workspace?.attributes?.nodes || [];
},
skip() {
......@@ -65,11 +64,9 @@ export default {
return s__('WorkItem|Add iteration');
},
groupedIterationCadences() {
console.log(this.iterations);
return groupByIterationCadences(this.iterations);
},
isLoadingIterations() {
console.log(this.$apollo.queries.iterations.loading, this.$apollo.queries.iterations);
return this.$apollo.queries.iterations.loading;
},
},
......@@ -89,18 +86,18 @@ export default {
{{ iterationTitle || iterationText }}
</div>
<gl-dropdown v-if="!isLoadingIterations">
<template v-if="!isLoadingIterations" v-for="(cadence, index) in groupedIterationCadences">
<template v-for="cadence in groupedIterationCadences">
<gl-dropdown-section-header :key="cadence.title" data-testid="cadence-title">
{{ cadence.title }}
</gl-dropdown-section-header>
<gl-dropdown-item
v-for="iteration in cadence.iterations"
:key="iteration.id"
v-for="currentIteration in cadence.iterations"
:key="currentIteration.id"
is-check-item
:data-testid="`i-items`"
>
{{ iteration.period }}
{{ iteration.title }}
{{ currentIteration.period }}
{{ currentIteration.title }}
</gl-dropdown-item>
</template>
</gl-dropdown>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment