diff --git a/src/components/molecules/CommonCartridgeExportModal.unit.ts b/src/components/molecules/CommonCartridgeExportModal.unit.ts index 5cc11c3081..2c7aa897c1 100644 --- a/src/components/molecules/CommonCartridgeExportModal.unit.ts +++ b/src/components/molecules/CommonCartridgeExportModal.unit.ts @@ -25,6 +25,7 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => { getVersion: "1.1.0", getTopics: ["topic"], getTasks: ["task"], + getColumnBoards: ["columnBoards"], startExport: jest.fn(), resetExportFlow: jest.fn(), }); @@ -130,6 +131,7 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => { const allTopics = wrapper.findComponent( '[data-testid="all-topics-checkbox"]' ); + expect( allTopics .findAll("input") @@ -137,6 +139,7 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => { ).toBe(true); await allTopics.trigger("click"); + expect( allTopics .findAll("input") @@ -154,6 +157,7 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => { const allTasks = wrapper.findComponent( '[data-testid="all-tasks-checkbox"]' ); + expect( allTasks .findAll("input") @@ -161,6 +165,7 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => { ).toBe(true); await allTasks.trigger("click"); + expect( allTasks .findAll("input") @@ -168,4 +173,30 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => { ).toBe(false); }); }); + + describe("toggleAllColumnBoards", () => { + it("should start with true and change the value when click", async () => { + const wrapper = setup(); + const nextBtn = wrapper.findComponent('[data-testid="dialog-next-btn"]'); + await nextBtn.trigger("click"); + + const allColumnBoards = wrapper.findComponent( + '[data-testid="all-column-boards-checkbox"]' + ); + + expect( + allColumnBoards + .findAll("input") + .some((input) => input.attributes("value") === "true") + ).toBe(true); + + await allColumnBoards.trigger("click"); + + expect( + allColumnBoards + .findAll("input") + .some((input) => input.attributes("value") === "false") + ).toBe(false); + }); + }); }); diff --git a/src/components/molecules/CommonCartridgeExportModal.vue b/src/components/molecules/CommonCartridgeExportModal.vue index 5b0c463f15..f84b00f947 100644 --- a/src/components/molecules/CommonCartridgeExportModal.vue +++ b/src/components/molecules/CommonCartridgeExportModal.vue @@ -48,6 +48,23 @@

+ + @@ -187,7 +208,12 @@ const allTopicsSelected = computed(() => { const allTasks = ref>([]); const allTasksSelected = computed(() => { - return allTasks.value.every((topic) => topic.isSelected); + return allTasks.value.every((task) => task.isSelected); +}); + +const allColumnBoards = ref>([]); +const allColumnBoardsSelected = computed(() => { + return allColumnBoards.value.every((columnBoard) => columnBoard.isSelected); }); watch( @@ -195,6 +221,7 @@ watch( (newValue) => { allTopics.value = []; allTasks.value = []; + allColumnBoards.value = []; newValue.forEach((element: any) => { if (element.type === BoardElementResponseTypeEnum.Lesson) { @@ -212,6 +239,14 @@ watch( id: element.content.id, }); } + + if (element.type === BoardElementResponseTypeEnum.ColumnBoard) { + allColumnBoards.value.push({ + isSelected: true, + title: element.content.title, + id: element.content.id, + }); + } }); } ); @@ -235,6 +270,13 @@ const someTasksSelected = computed(() => { ); }); +const someColumnBoardsSelected = computed(() => { + return ( + allColumnBoards.value.some((columnBoard) => columnBoard.isSelected) && + !allColumnBoardsSelected.value + ); +}); + function onCloseDialog(): void { emit("dialog-closed", false); commonCartridgeExportModule.resetExportFlow(); @@ -245,6 +287,9 @@ function onCloseDialog(): void { allTopics.value.forEach((topic) => { topic.isSelected = true; }); + allColumnBoards.value.forEach((columnBoard) => { + columnBoard.isSelected = true; + }); } function onNext(): void { @@ -267,9 +312,13 @@ async function onExport(): Promise { const taskIds = allTasks.value .filter((task) => task.isSelected) .map((task) => task.id); + const columnBoardIds = allColumnBoards.value + .filter((columnBoard) => columnBoard.isSelected) + .map((columnBoard) => columnBoard.id); commonCartridgeExportModule.setTopics(topicIds); commonCartridgeExportModule.setTasks(taskIds); + commonCartridgeExportModule.setColumnBoards(columnBoardIds); await commonCartridgeExportModule.startExport(); onCloseDialog(); } @@ -283,6 +332,10 @@ function onBack(): void { allTopics.value.forEach((topic) => { topic.isSelected = true; }); + // AI next 3 lines + allColumnBoards.value.forEach((columnBoard) => { + columnBoard.isSelected = true; + }); commonCartridgeExportModule.setIsExportModalOpen(true); } @@ -301,6 +354,15 @@ function toggleAllTasks(): void { task.isSelected = newValue; }); } + +function toggleAllColumnBoards(): void { + // AI next 5 lines + const newValue = !allColumnBoardsSelected.value; + + allColumnBoards.value.forEach((columnBoard) => { + columnBoard.isSelected = newValue; + }); +} diff --git a/src/pages/rooms/room-details.unit.ts b/src/pages/rooms/room-details.unit.ts index 99227004f1..db156aaaec 100644 --- a/src/pages/rooms/room-details.unit.ts +++ b/src/pages/rooms/room-details.unit.ts @@ -136,6 +136,7 @@ const getWrapper = ( getVersion: "", getTopics: [], getTasks: [], + getColumnBoards: [], startExportFlow: jest.fn(), }); shareModule = createModuleMocks(ShareModule, { diff --git a/src/serverApi/v3/api.ts b/src/serverApi/v3/api.ts index dcc0ffed31..533c9faf16 100644 --- a/src/serverApi/v3/api.ts +++ b/src/serverApi/v3/api.ts @@ -1531,6 +1531,12 @@ export interface CourseExportBodyParams { * @memberof CourseExportBodyParams */ tasks: Array; + /** + * The list of ids of column boards which should be exported. If empty no column boards are exported. + * @type {Array} + * @memberof CourseExportBodyParams + */ + columnBoards: Array; } /** * diff --git a/src/store/common-cartridge-export.ts b/src/store/common-cartridge-export.ts index 3762a2dde8..ac4789b15e 100644 --- a/src/store/common-cartridge-export.ts +++ b/src/store/common-cartridge-export.ts @@ -11,6 +11,7 @@ export default class CommonCartridgeExportModule extends VuexModule { private version = ""; private topics: string[] = []; private tasks: string[] = []; + private columnBoards: string[] = []; @Action async startExport(): Promise { @@ -22,6 +23,7 @@ export default class CommonCartridgeExportModule extends VuexModule { version: this.getVersion, topics: this.getTopics, tasks: this.getTasks, + columnBoards: this.getColumnBoards, }); } @@ -30,6 +32,7 @@ export default class CommonCartridgeExportModule extends VuexModule { this.setVersion(""); this.setTopics([]); this.setTasks([]); + this.setColumnBoards([]); this.setIsExportModalOpen(true); } @@ -38,6 +41,7 @@ export default class CommonCartridgeExportModule extends VuexModule { this.setVersion(""); this.setTopics([]); this.setTasks([]); + this.setColumnBoards([]); this.setIsExportModalOpen(false); } @@ -56,6 +60,11 @@ export default class CommonCartridgeExportModule extends VuexModule { this.tasks = taskIds; } + @Mutation + setColumnBoards(columnBoardIds: string[]) { + this.columnBoards = columnBoardIds; + } + @Mutation setIsExportModalOpen(open: boolean): void { this.isExportModalOpen = open; @@ -76,4 +85,8 @@ export default class CommonCartridgeExportModule extends VuexModule { get getTasks(): string[] { return this.tasks; } + + get getColumnBoards(): string[] { + return this.columnBoards; + } } diff --git a/src/store/common-cartridge-export.unit.ts b/src/store/common-cartridge-export.unit.ts index 102a1a849e..2afb2493f9 100644 --- a/src/store/common-cartridge-export.unit.ts +++ b/src/store/common-cartridge-export.unit.ts @@ -19,6 +19,7 @@ describe("commonCartridgeExportModule", () => { commonCartridgeExportModule.setVersion("1.1.0"); commonCartridgeExportModule.setTopics(["topic"]); commonCartridgeExportModule.setTasks(["task"]); + commonCartridgeExportModule.setColumnBoards(["columnBoard"]); commonCartridgeExportModule.startExport(); @@ -26,6 +27,7 @@ describe("commonCartridgeExportModule", () => { version: "1.1.0", topics: ["topic"], tasks: ["task"], + columnBoards: ["columnBoard"], }); }); }); @@ -37,11 +39,13 @@ describe("commonCartridgeExportModule", () => { commonCartridgeExportModule.setVersion("1.1.0"); commonCartridgeExportModule.setTopics(["topic"]); commonCartridgeExportModule.setTasks(["task"]); + commonCartridgeExportModule.setColumnBoards(["columnBoard"]); commonCartridgeExportModule.startExportFlow(); expect(commonCartridgeExportModule.getVersion).toBe(""); expect(commonCartridgeExportModule.getTopics).toEqual([]); expect(commonCartridgeExportModule.getTasks).toEqual([]); + expect(commonCartridgeExportModule.getColumnBoards).toEqual([]); expect(commonCartridgeExportModule.getIsExportModalOpen).toBe(true); }); }); @@ -53,11 +57,13 @@ describe("commonCartridgeExportModule", () => { commonCartridgeExportModule.setVersion("1.1.0"); commonCartridgeExportModule.setTopics(["topic"]); commonCartridgeExportModule.setTasks(["task"]); + commonCartridgeExportModule.setColumnBoards(["columnBoard"]); commonCartridgeExportModule.resetExportFlow(); expect(commonCartridgeExportModule.getVersion).toBe(""); expect(commonCartridgeExportModule.getTopics).toEqual([]); expect(commonCartridgeExportModule.getTasks).toEqual([]); + expect(commonCartridgeExportModule.getColumnBoards).toEqual([]); expect(commonCartridgeExportModule.getIsExportModalOpen).toBe(false); }); }); @@ -105,5 +111,18 @@ describe("commonCartridgeExportModule", () => { expect(commonCartridgeExportModule.getTasks).toEqual(["task"]); }); }); + + // AI next 11 lines + describe("setColumnBoards", () => { + it("should set columnBoards to the given value", () => { + const commonCartridgeExportModule = new CommonCartridgeExportModule({}); + + commonCartridgeExportModule.setColumnBoards(["columnBoard"]); + + expect(commonCartridgeExportModule.getColumnBoards).toEqual([ + "columnBoard", + ]); + }); + }); }); }); diff --git a/src/store/room.ts b/src/store/room.ts index d475a7c79b..ca64dedd8e 100644 --- a/src/store/room.ts +++ b/src/store/room.ts @@ -194,6 +194,7 @@ export default class RoomModule extends VuexModule { version: "1.1.0" | "1.3.0"; topics: string[]; tasks: string[]; + columnBoards: string[]; }): Promise { this.resetBusinessError(); try { @@ -207,6 +208,7 @@ export default class RoomModule extends VuexModule { { topics: exportSettings.topics, tasks: exportSettings.tasks, + columnBoards: exportSettings.columnBoards, }, { responseType: "blob", diff --git a/src/store/room.unit.ts b/src/store/room.unit.ts index 94949755ab..fb303d36e4 100644 --- a/src/store/room.unit.ts +++ b/src/store/room.unit.ts @@ -364,6 +364,7 @@ describe("room module", () => { version: "1.1.0", topics: [], tasks: [], + columnBoards: [], }) ).resolves.not.toBeDefined(); @@ -385,6 +386,7 @@ describe("room module", () => { version: "1.1.0", topics: [], tasks: [], + columnBoards: [], }); expect(roomModule.businessError).toStrictEqual(error);