Skip to content

Commit e66edb4

Browse files
wolfganggreschusvirgilchiriacluejoh
authored
BC-7625 Do not hide add card (#3984)
* Remove the edit-share logic from the MediaBoard * Revert "Remove the edit-share logic from the MediaBoard" This reverts commit 222679e. * Remove the logic for edit mode from the Card.store, Board, and BoardAddCardButton components. * Remove shared edit mode logic from Board and Card REST APIs * Remove edit mode logic from Card.store and update Board.vue to reflect changes * Remove edit mode logic from Board and Card REST APIs * Restrict list item detection to exclude title elements in InlineEditInteractionHandler * Update InlineEditInteractionHandler to enable capture option and refine list item detection * stop displaying add button when a card of the boardcolumn is currently in editmode * Add tests to verify the visibility of the add card button while editing cards. * Refactor BoardColumn tests to streamline setup and improve add card button visibility checks during edit mode * Implement edit mode handling for add card button visibility in BoardColumn tests --------- Co-authored-by: virgilchiriac <[email protected]> Co-authored-by: Johannes Lueder <[email protected]>
1 parent 6aab40e commit e66edb4

File tree

3 files changed

+55
-12
lines changed

3 files changed

+55
-12
lines changed

src/modules/feature/board/board/BoardAddCardButton.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<div ref="sticky" class="d-flex justify-center button-background pb-4 pt-2 sticky">
33
<VBtn
4-
v-if="!isEditMode"
54
elevation="6"
65
class="bg-white"
76
icon
@@ -18,10 +17,7 @@
1817
</template>
1918

2019
<script setup lang="ts">
21-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
22-
import { useSharedEditMode } from "@/modules/util/board/editMode.composable"; // FIX_CIRCULAR_DEPENDENCY
2320
import { mdiPlus } from "@icons/material";
24-
import { computed } from "vue";
2521
2622
defineProps({
2723
dataTestid: {
@@ -32,10 +28,7 @@ defineProps({
3228
3329
const emit = defineEmits(["add-card"]);
3430
35-
const { editModeId } = useSharedEditMode();
3631
const onAddCard = () => emit("add-card");
37-
38-
const isEditMode = computed(() => editModeId.value !== undefined);
3932
</script>
4033

4134
<style scoped>

src/modules/feature/board/board/BoardColumn.unit.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import setupStores from "@@/tests/test-utils/setupStores";
77
import { useBoardPermissions, useBoardStore, useForceRender } from "@data-board";
88
import { createMock } from "@golevelup/ts-vitest";
99
import { createTestingPinia } from "@pinia/testing";
10-
import { useDragAndDrop, useSharedLastCreatedElement } from "@util-board";
10+
import { useDragAndDrop, useSharedEditMode, useSharedLastCreatedElement } from "@util-board";
1111
import { setActivePinia } from "pinia";
1212
import { computed, nextTick, ref } from "vue";
1313

@@ -46,6 +46,7 @@ describe("BoardColumn", () => {
4646
const column = columnResponseFactory.build({
4747
cards,
4848
});
49+
const { setEditModeId } = useSharedEditMode();
4950
document.body.setAttribute("data-app", "true");
5051
mockedUserPermissions.mockReturnValue({
5152
...defaultPermissions,
@@ -66,7 +67,7 @@ describe("BoardColumn", () => {
6667

6768
const store = mockedPiniaStoreTyping(useBoardStore);
6869

69-
return { wrapper, store, cards, column };
70+
return { wrapper, store, cards, column, setEditModeId };
7071
};
7172

7273
describe("when component is mounted", () => {
@@ -335,4 +336,46 @@ describe("BoardColumn", () => {
335336
});
336337
});
337338
});
339+
340+
describe("when editing a card", () => {
341+
it("should not show addCardButton in the same column", async () => {
342+
const { wrapper, setEditModeId, cards } = setup();
343+
const cardId = cards[0].cardId;
344+
setEditModeId(cardId);
345+
await nextTick();
346+
347+
const addCardButtons = wrapper.findAllComponents({
348+
name: "BoardAddCardButton",
349+
});
350+
expect(addCardButtons).toHaveLength(0);
351+
});
352+
353+
it("should show addCardButton in any other column", async () => {
354+
const { setEditModeId: originalSetEditModeId, wrapper: originalWrapper } = setup();
355+
const { cards: siblingCards } = setup();
356+
357+
originalSetEditModeId(siblingCards[0].cardId);
358+
await nextTick();
359+
360+
const addCardButtons = originalWrapper.findAllComponents({
361+
name: "BoardAddCardButton",
362+
});
363+
expect(addCardButtons).toHaveLength(1);
364+
});
365+
it("should show addCardButton in same column if edit mode is stopped", async () => {
366+
const { wrapper, setEditModeId, cards } = setup();
367+
368+
const cardId = cards[0].cardId;
369+
setEditModeId(cardId);
370+
await nextTick();
371+
372+
setEditModeId(undefined);
373+
await nextTick();
374+
375+
const addCardButtons = wrapper.findAllComponents({
376+
name: "BoardAddCardButton",
377+
});
378+
expect(addCardButtons).toHaveLength(1);
379+
});
380+
});
338381
});

src/modules/feature/board/board/BoardColumn.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import BoardColumnHeader from "./BoardColumnHeader.vue";
7777
import { useBoardStore } from "@/modules/data/board/Board.store"; // FIX_CIRCULAR_DEPENDENCY
7878
import { BoardColumn } from "@/types/board/Board";
7979
import { useBoardPermissions, useForceRender } from "@data-board";
80-
import { extractDataAttribute, useDragAndDrop } from "@util-board";
80+
import { extractDataAttribute, useDragAndDrop, useSharedEditMode } from "@util-board";
8181
import { useDebounceFn } from "@vueuse/core";
8282
import { SortableEvent } from "sortablejs";
8383
import { Sortable } from "sortablejs-vue3";
@@ -106,7 +106,7 @@ const emit = defineEmits<{
106106
107107
const boardStore = useBoardStore();
108108
const reactiveIndex = toRef(props, "index");
109-
109+
const { editModeId } = useSharedEditMode();
110110
const { hasEditPermission, hasMovePermission, hasCreateColumnPermission } = useBoardPermissions();
111111
112112
const columnClasses = computed(() => {
@@ -120,7 +120,14 @@ const columnClasses = computed(() => {
120120
});
121121
122122
const { isDragging, dragStart, dragEnd } = useDragAndDrop();
123-
const showAddButton = computed(() => hasCreateColumnPermission.value && isDragging.value === false);
123+
124+
const isCardOfColumnInEditMode = computed(
125+
() => props.column.cards.find((c) => c.cardId === editModeId.value) !== undefined
126+
);
127+
128+
const showAddButton = computed(
129+
() => hasCreateColumnPermission.value && isDragging.value === false && !isCardOfColumnInEditMode.value
130+
);
124131
125132
const isNotFirstColumn = computed(() => props.index !== 0);
126133
const isNotLastColumn = computed(() => props.index !== props.columnCount - 1);

0 commit comments

Comments
 (0)