Commit bfde40cb authored by NataliaTepluhina's avatar NataliaTepluhina Committed by Florie Guibert

Changed board update logic

parent 248346c7
...@@ -102,9 +102,9 @@ export default { ...@@ -102,9 +102,9 @@ export default {
handleClose() { handleClose() {
this.toggleBoardItem({ boardItem: this.activeBoardItem, sidebarType: this.sidebarType }); this.toggleBoardItem({ boardItem: this.activeBoardItem, sidebarType: this.sidebarType });
}, },
handleUpdateSelectedLabels(labels) { handleUpdateSelectedLabels({ labels, id }) {
this.setActiveBoardItemLabels({ this.setActiveBoardItemLabels({
iid: this.activeBoardItem.iid, id,
projectPath: this.projectPathForActiveIssue, projectPath: this.projectPathForActiveIssue,
labelIds: labels.map((label) => getIdFromGraphQLId(label.id)), labelIds: labels.map((label) => getIdFromGraphQLId(label.id)),
labels, labels,
......
...@@ -692,7 +692,7 @@ export default { ...@@ -692,7 +692,7 @@ export default {
); );
} }
commit(types.UPDATE_BOARD_ITEM_BY_ID, { commit(types.UPDATE_BOARD_ITEM_BY_ID, {
itemId: activeBoardItem.id, itemId: input.id || activeBoardItem.id,
prop: 'labels', prop: 'labels',
value: labels, value: labels,
}); });
......
...@@ -110,6 +110,7 @@ export default { ...@@ -110,6 +110,7 @@ export default {
contentIsOnViewport: true, contentIsOnViewport: true,
issuableLabels: [], issuableLabels: [],
labelsSelectInProgress: false, labelsSelectInProgress: false,
oldIid: null,
}; };
}, },
computed: { computed: {
...@@ -140,12 +141,17 @@ export default { ...@@ -140,12 +141,17 @@ export default {
}, },
}, },
}, },
watch: {
iid(_, oldVal) {
this.oldIid = oldVal;
},
},
methods: { methods: {
handleDropdownClose(labels) { handleDropdownClose(labels) {
if (this.iid !== '') { if (this.iid !== '') {
this.updateSelectedLabels(this.getUpdateVariables(labels)); this.updateSelectedLabels(this.getUpdateVariables(labels));
} else { } else {
this.$emit('updateSelectedLabels', labels); this.$emit('updateSelectedLabels', { labels });
} }
this.collapseEditableItem(); this.collapseEditableItem();
...@@ -160,17 +166,18 @@ export default { ...@@ -160,17 +166,18 @@ export default {
let labelIds = []; let labelIds = [];
labelIds = labels.map(({ id }) => id); labelIds = labels.map(({ id }) => id);
const currentIid = this.oldIid || this.iid;
switch (this.issuableType) { switch (this.issuableType) {
case IssuableType.Issue: case IssuableType.Issue:
return { return {
iid: this.iid, iid: currentIid,
projectPath: this.fullPath, projectPath: this.fullPath,
labelIds, labelIds,
}; };
case IssuableType.MergeRequest: case IssuableType.MergeRequest:
return { return {
iid: this.iid, iid: currentIid,
labelIds, labelIds,
operationMode: MutationOperationMode.Replace, operationMode: MutationOperationMode.Replace,
projectPath: this.fullPath, projectPath: this.fullPath,
...@@ -194,7 +201,10 @@ export default { ...@@ -194,7 +201,10 @@ export default {
throw new Error(); throw new Error();
} }
this.$emit('updateSelectedLabels', data[mutationName]?.[this.issuableType].labels?.nodes); this.$emit('updateSelectedLabels', {
id: data[mutationName]?.[this.issuableType].id,
labels: data[mutationName]?.[this.issuableType].labels?.nodes,
});
}) })
.catch(() => createFlash({ message: __('An error occurred while updating labels.') })) .catch(() => createFlash({ message: __('An error occurred while updating labels.') }))
.finally(() => { .finally(() => {
......
...@@ -201,7 +201,7 @@ export default { ...@@ -201,7 +201,7 @@ export default {
issuable-type="epic" issuable-type="epic"
variant="embedded" variant="embedded"
data-qa-selector="labels_block" data-qa-selector="labels_block"
@updateSelectedLabels="handleUpdateSelectedLabels" @updateSelectedLabels="handleUpdateSelectedLabels($event.labels)"
> >
{{ __('None') }} {{ __('None') }}
</labels-select-widget> </labels-select-widget>
......
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