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

Changed board update logic

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