Skip to content

Commit

Permalink
Merge branch 'main' into N21-1783-remove-lti-message-type
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap authored Apr 19, 2024
2 parents d82bd9d + 26d77f0 commit fa9f54f
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 19 deletions.
31 changes: 31 additions & 0 deletions src/components/molecules/CommonCartridgeExportModal.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => {
getVersion: "1.1.0",
getTopics: ["topic"],
getTasks: ["task"],
getColumnBoards: ["columnBoards"],
startExport: jest.fn(),
resetExportFlow: jest.fn(),
});
Expand Down Expand Up @@ -130,13 +131,15 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => {
const allTopics = wrapper.findComponent(
'[data-testid="all-topics-checkbox"]'
);

expect(
allTopics
.findAll("input")
.some((input) => input.attributes("value") === "true")
).toBe(true);

await allTopics.trigger("click");

expect(
allTopics
.findAll("input")
Expand All @@ -154,18 +157,46 @@ describe("@/components/molecules/CommonCartridgeExportModal", () => {
const allTasks = wrapper.findComponent(
'[data-testid="all-tasks-checkbox"]'
);

expect(
allTasks
.findAll("input")
.some((input) => input.attributes("value") === "true")
).toBe(true);

await allTasks.trigger("click");

expect(
allTasks
.findAll("input")
.some((input) => input.attributes("value") === "false")
).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);
});
});
});
76 changes: 69 additions & 7 deletions src/components/molecules/CommonCartridgeExportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,56 @@
</p>
</div>
<v-container class="pt-0">
<v-checkbox
class="check-options"
v-model="allTasksSelected"
data-testid="all-tasks-checkbox"
:indeterminate="someTasksSelected"
@click="toggleAllTasks"
:label="$t('pages.room.modal.course.export.options.tasks')"
density="compact"
/>
<v-checkbox
class="check-options ml-8"
v-for="item in allTasks"
v-model="item.isSelected"
:key="item.id"
:label="item.title"
density="compact"
/>
<v-checkbox
class="check-options"
v-model="allTopicsSelected"
data-testid="all-topics-checkbox"
:indeterminate="someTopicsSelected"
@click="toggleAllTopics"
:label="$t('pages.room.modal.course.export.options.topics')"
density="compact"
/>
<v-checkbox
class="check-options ml-8"
v-for="item in allTopics"
v-model="item.isSelected"
:key="item.id"
:label="item.title"
density="compact"
/>
<v-checkbox
class="check-options"
v-model="allTasksSelected"
data-testid="all-tasks-checkbox"
:indeterminate="someTasksSelected"
@click="toggleAllTasks"
:label="$t('pages.room.modal.course.export.options.tasks')"
v-model="allColumnBoardsSelected"
data-testid="all-column-boards-checkbox"
:indeterminate="someColumnBoardsSelected"
@click="toggleAllColumnBoards"
:label="$t('pages.room.modal.course.export.options.columnBoards')"
density="compact"
/>
<v-checkbox
class="check-options ml-8"
v-for="item in allTasks"
v-for="item in allColumnBoards"
v-model="item.isSelected"
:key="item.id"
:label="item.title"
density="compact"
/>
</v-container>
</div>
Expand Down Expand Up @@ -187,14 +208,20 @@ const allTopicsSelected = computed(() => {
const allTasks = ref<Array<Selection>>([]);
const allTasksSelected = computed(() => {
return allTasks.value.every((topic) => topic.isSelected);
return allTasks.value.every((task) => task.isSelected);
});
const allColumnBoards = ref<Array<Selection>>([]);
const allColumnBoardsSelected = computed(() => {
return allColumnBoards.value.every((columnBoard) => columnBoard.isSelected);
});
watch(
() => roomModule.getRoomData.elements,
(newValue) => {
allTopics.value = [];
allTasks.value = [];
allColumnBoards.value = [];
newValue.forEach((element: any) => {
if (element.type === BoardElementResponseTypeEnum.Lesson) {
Expand All @@ -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,
});
}
});
}
);
Expand All @@ -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();
Expand All @@ -245,6 +287,9 @@ function onCloseDialog(): void {
allTopics.value.forEach((topic) => {
topic.isSelected = true;
});
allColumnBoards.value.forEach((columnBoard) => {
columnBoard.isSelected = true;
});
}
function onNext(): void {
Expand All @@ -267,9 +312,13 @@ async function onExport(): Promise<void> {
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();
}
Expand All @@ -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);
}
Expand All @@ -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;
});
}
</script>

<style lang="scss" scoped>
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,7 @@ export default {
"pages.room.modal.course.export.options.header": "Export-Einstellung",
"pages.room.modal.course.export.options.topics": "Themen",
"pages.room.modal.course.export.options.tasks": "Aufgaben ohne Themen",
"pages.room.modal.course.export.options.columnBoards": "Spalten-Boards",
"pages.room.modal.course.export.version1.1":
"Common Cartridge Version 1.1 (z.B. kompatibel mit Moodle)",
"pages.room.modal.course.export.version1.3": "Common Cartridge Version 1.3",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ export default {
"pages.room.modal.course.export.options.header": "Export settings",
"pages.room.modal.course.export.options.topics": "Topics",
"pages.room.modal.course.export.options.tasks": "Tasks without Topic",
"pages.room.modal.course.export.options.columnBoards": "Column boards",
"pages.room.modal.course.export.version1.1":
"Common Cartridge Version 1.1 (e.g. compatible with Moodle)",
"pages.room.modal.course.export.version1.3": "Common Cartridge Version 1.3",
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@ export default {
"pages.room.modal.course.export.options.header": "Exportar configuración",
"pages.room.modal.course.export.options.topics": "Temas",
"pages.room.modal.course.export.options.tasks": "Tareas sin tema",
"pages.room.modal.course.export.options.columnBoards": "Tableros de columna",
"pages.room.modal.course.export.version1.1":
"Common Cartridge versión 1.1 (p. ej. compatible con Moodle)",
"pages.room.modal.course.export.version1.3": "Common Cartridge versión 1.3",
Expand Down
1 change: 1 addition & 0 deletions src/locales/uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ export default {
"pages.room.modal.course.export.options.header": "Експорт налаштувань",
"pages.room.modal.course.export.options.topics": "Теми",
"pages.room.modal.course.export.options.tasks": "Завдання без теми",
"pages.room.modal.course.export.options.columnBoards": "Дошки для колонн",
"pages.room.modal.course.export.version1.1":
"Загальний картридж версії 1.1 (наприклад, сумісні з Moodle)",
"pages.room.modal.course.export.version1.3": "Загальний картридж версії 1.3",
Expand Down
36 changes: 24 additions & 12 deletions src/pages/administration/ClassOverview.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
:full-width="true"
data-testid="admin-class-title"
>
<v-tabs class="tabs-max-width mb-5" grow v-model="activeTab">
<v-tab value="next" data-testid="admin-class-next-year-tab">
<span>{{ nextYear }}</span>
</v-tab>
<v-tab value="current" data-testid="admin-class-current-year-tab">
<span>{{ currentYear }}</span>
</v-tab>
<v-tab value="archive" data-testid="admin-class-previous-years-tab">
<span>{{ t("pages.administration.classes.label.archive") }}</span>
</v-tab>
</v-tabs>

<template #header>
<h1 class="text-h3 pl-2">
{{ t("pages.administration.classes.index.title") }}
</h1>
<div class="mx-n6 mx-md-0 pb-0 d-flex justify-center">
<v-tabs class="tabs-max-width" grow v-model="activeTab">
<v-tab value="next" data-testid="admin-class-next-year-tab">
<span>{{ nextYear }}</span>
</v-tab>
<v-tab value="current" data-testid="admin-class-current-year-tab">
<span>{{ currentYear }}</span>
</v-tab>
<v-tab value="archive" data-testid="admin-class-previous-years-tab">
<span>{{ t("pages.administration.classes.label.archive") }}</span>
</v-tab>
</v-tabs>
</div>
</template>
<v-data-table-server
:headers="headers"
:items="classes"
Expand Down Expand Up @@ -460,3 +466,9 @@ const getInstituteTitle: ComputedRef<string> = computed(() => {
}
});
</script>

<style scoped>
.v-tabs {
margin-bottom: -2px;
}
</style>
1 change: 1 addition & 0 deletions src/pages/rooms/room-details.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const getWrapper = (
getVersion: "",
getTopics: [],
getTasks: [],
getColumnBoards: [],
startExportFlow: jest.fn(),
});
shareModule = createModuleMocks(ShareModule, {
Expand Down
6 changes: 6 additions & 0 deletions src/serverApi/v3/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,12 @@ export interface CourseExportBodyParams {
* @memberof CourseExportBodyParams
*/
tasks: Array<string>;
/**
* The list of ids of column boards which should be exported. If empty no column boards are exported.
* @type {Array<string>}
* @memberof CourseExportBodyParams
*/
columnBoards: Array<string>;
}
/**
*
Expand Down
13 changes: 13 additions & 0 deletions src/store/common-cartridge-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand All @@ -22,6 +23,7 @@ export default class CommonCartridgeExportModule extends VuexModule {
version: this.getVersion,
topics: this.getTopics,
tasks: this.getTasks,
columnBoards: this.getColumnBoards,
});
}

Expand All @@ -30,6 +32,7 @@ export default class CommonCartridgeExportModule extends VuexModule {
this.setVersion("");
this.setTopics([]);
this.setTasks([]);
this.setColumnBoards([]);
this.setIsExportModalOpen(true);
}

Expand All @@ -38,6 +41,7 @@ export default class CommonCartridgeExportModule extends VuexModule {
this.setVersion("");
this.setTopics([]);
this.setTasks([]);
this.setColumnBoards([]);
this.setIsExportModalOpen(false);
}

Expand All @@ -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;
Expand All @@ -76,4 +85,8 @@ export default class CommonCartridgeExportModule extends VuexModule {
get getTasks(): string[] {
return this.tasks;
}

get getColumnBoards(): string[] {
return this.columnBoards;
}
}
Loading

0 comments on commit fa9f54f

Please sign in to comment.