Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into BC-7511-highlight-course-pages
  • Loading branch information
odalys-dataport committed Jun 19, 2024
2 parents 895e629 + 73be006 commit ccded13
Show file tree
Hide file tree
Showing 14 changed files with 899 additions and 22 deletions.
10 changes: 10 additions & 0 deletions src/components/templates/DefaultWireframe.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<template>
<div class="wireframe-container">
<div
aria-live="polite"
id="notify-screen-reader-polite"
class="d-sr-only"
/>
<div
aria-live="assertive"
id="notify-screen-reader-assertive"
class="d-sr-only"
/>
<div
class="wireframe-header sticky"
:class="{ 'old-layout': oldLayoutEnabled }"
Expand Down
28 changes: 28 additions & 0 deletions src/composables/ariaLiveNotifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const useAriaLiveNotifier = () => {
const notifyOnScreenReader = (
message: string,
importance: "off" | "polite" | "assertive" = "polite"
) => {
// should be a div with aria-live="polite | assertive" attribute
// and should be appended to the upper level of the DOM tree
// the aria-live attribute should be set polite or assertive based on the importance of the message
const element = document.getElementById(
importance === "polite"
? "notify-screen-reader-polite"
: "notify-screen-reader-assertive"
);

if (!element) {
console.error(
`Element with id 'notify-screen-reader-${importance}' not found`
);
return;
}

element.innerHTML += `<span>${message}</span>`;
};

return {
notifyOnScreenReader,
};
};
32 changes: 32 additions & 0 deletions src/composables/ariaLiveNotifier.unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useAriaLiveNotifier } from "./ariaLiveNotifier";

describe("useAriaLiveNotifier", () => {
beforeEach(() => {
document.body.innerHTML = `
<div>
<div id="notify-screen-reader-polite"></div>
<div id="notify-screen-reader-assertive"></div>
</div>`;
});
it("should notify on screen reader on 'aria-live=assertive' mode", () => {
jest.useFakeTimers();
const { notifyOnScreenReader } = useAriaLiveNotifier();
const element = document.getElementById("notify-screen-reader-assertive");
const message = "Assertive screen reader message";
notifyOnScreenReader(message, "assertive");

jest.advanceTimersByTime(3000);
expect(element?.innerHTML).toBe(`<span>${message}</span>`);
});

it("should notify on screen reader on 'aria-live=polite' mode", () => {
jest.useFakeTimers();
const { notifyOnScreenReader } = useAriaLiveNotifier();
const element = document.getElementById("notify-screen-reader-polite");
const message = "Polite screen reader message";
notifyOnScreenReader(message, "polite");

jest.advanceTimersByTime(3000);
expect(element?.innerHTML).toBe(`<span>${message}</span>`);
});
});
26 changes: 26 additions & 0 deletions src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,32 @@ export default {
"{type} konnte nicht geladen werden.",
"components.board.notifications.errors.notUpdated":
"Die Änderungen konnten nicht gespeichert werden.",
"components.board.screenReader.notification.cardCreated.success":
"Eine Karte wurde von einem anderen Benutzer in Spalte {columnPosition} erstellt.",
"components.board.screenReader.notification.columnCreated.success":
"Eine Spalte wurde von einem anderen Benutzer erstellt.",
"components.board.screenReader.notification.cardDeleted.success":
"Eine Karte wurde von einem anderen Benutzer gelöscht.",
"components.board.screenReader.notification.columnDeleted.success":
"Eine Spalte wurde von einem anderen Benutzer gelöscht.",
"components.board.screenReader.notification.cardMovedInSameColumn.success":
"In Spalte {columnPosition} wurde eine Karte an Position {newPosition} verschoben.",
"components.board.screenReader.notification.cardMovedToAnotherColumn.success":
"Eine Karte wurde von Spalte {fromColumnPosition} in Spalte {toColumnPosition} verschoben.",
"components.board.screenReader.notification.columnMoved.success":
"Eine Spalte wurde von Position {oldPosition} an Position {newPosition} verschoben.",
"components.board.screenReader.notification.boardTitleUpdated.success":
"Der Boardtitel wurde von einem anderen Benutzer in {newTitle} geändert",
"components.board.screenReader.notification.boardVisibilityUpdated.published":
"Das Board wurde von einem anderen Benutzer veröffentlicht",
"components.board.screenReader.notification.boardVisibilityUpdated.draft":
"Das Board wurde von einem anderen Benutzer auf den Entwurfsstatus zurückgesetzt.",
"components.board.screenReader.notification.columnTitleUpdated.success":
"Titel von Spalte {columnPosition} wurde von einem anderen Benutzer in {newTitle} geändert.",
"components.board.screenReader.notification.cardTitleUpdated.success":
"Titel von Karte {cardPosition} in Spalte {columnPosition} wurde von einem anderen Benutzer in {newTitle} geändert.",
"components.board.screenReader.notification.cardUpdated.success":
"Karte {cardPosition} in Spalte {columnPosition} wurde von einem anderen Benutzer aktualisiert.",
"components.board": "Board",
"components.boardCard": "Karte",
"components.boardColumn": "Spalte",
Expand Down
27 changes: 26 additions & 1 deletion src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,32 @@ export default {
"{type} could not be loaded.",
"components.board.notifications.errors.notUpdated":
"Your changes could not be saved.",

"components.board.screenReader.notification.cardCreated.success":
"A card was created by another user in column {columnPosition}.",
"components.board.screenReader.notification.columnCreated.success":
"A column was created by another user.",
"components.board.screenReader.notification.cardDeleted.success":
"A card was deleted by another user.",
"components.board.screenReader.notification.columnDeleted.success":
"A column was deleted by another user.",
"components.board.screenReader.notification.cardMovedInSameColumn.success":
"In column {columnPosition}, a card was moved to position {newPosition}.",
"components.board.screenReader.notification.cardMovedToAnotherColumn.success":
"A card was moved from column {fromColumnPosition} to column {toColumnPosition}.",
"components.board.screenReader.notification.columnMoved.success":
"A column was moved from position {oldPosition} to position {newPosition}.",
"components.board.screenReader.notification.boardTitleUpdated.success":
"The board title was changed to {newTitle} by another user.",
"components.board.screenReader.notification.boardVisibilityUpdated.published":
"The board was published by another user.",
"components.board.screenReader.notification.boardVisibilityUpdated.draft":
"The board was reverted to draft by another user.",
"components.board.screenReader.notification.columnTitleUpdated.success":
"Title of column {columnPosition} was changed to {newTitle} by another user.",
"components.board.screenReader.notification.cardTitleUpdated.success":
"Title of card {cardPosition} in column {columnPosition} was changed to {newTitle} by another user.",
"components.board.screenReader.notification.cardUpdated.success":
"Card {cardPosition} in column {columnPosition} was updated by another user.",
"components.board": "board",
"components.boardCard": "card",
"components.boardColumn": "column",
Expand Down
26 changes: 26 additions & 0 deletions src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,32 @@ export default {
"{type} no se ha podido cargar.",
"components.board.notifications.errors.notUpdated":
"No se han podido guardar los cambios.",
"components.board.screenReader.notification.cardCreated.success":
"Otro usuario ha creado una tarjeta en la columna {columnPosition}.",
"components.board.screenReader.notification.columnCreated.success":
"Una columna fue creada por otro usuario.",
"components.board.screenReader.notification.cardDeleted.success":
"Una tarjeta fue eliminada por otro usuario.",
"components.board.screenReader.notification.columnDeleted.success":
"Una columna fue eliminada por otro usuario.",
"components.board.screenReader.notification.cardMovedInSameColumn.success":
"En la columna {columnPosition}, se ha movido una carta a la posición {newPosition}.",
"components.board.screenReader.notification.cardMovedToAnotherColumn.success":
"Se ha movido una tarjeta de la columna {fromColumnPosition} a la columna {toColumnPosition}.",
"components.board.screenReader.notification.columnMoved.success":
"Se ha movido una columna de la posición {oldPosition} a la posición {newPosition}.",
"components.board.screenReader.notification.boardTitleUpdated.success":
"El título del tablero fue cambiado a {newTitle} por otro usuario.",
"components.board.screenReader.notification.boardVisibilityUpdated.published":
"El tablero fue publicado por otro usuario.",
"components.board.screenReader.notification.boardVisibilityUpdated.draft":
"El tablero fue revertido a borrador por otro usuario.",
"components.board.screenReader.notification.columnTitleUpdated.success":
"El título de la columna {columnPosition} fue cambiado a {newTitle} por otro usuario.",
"components.board.screenReader.notification.cardTitleUpdated.success":
"El título de la tarjeta {cardPosition} en la columna {columnPosition} fue cambiado a {newTitle} por otro usuario.",
"components.board.screenReader.notification.cardUpdated.success":
"La tarjeta {cardPosition} de la columna {columnPosition} ha sido actualizada por otro usuario.",
"components.board": "tablero",
"components.boardCard": "tarjeta",
"components.boardColumn": "columna",
Expand Down
26 changes: 26 additions & 0 deletions src/locales/uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,32 @@ export default {
"{type}: не вдалося завантажити.",
"components.board.notifications.errors.notUpdated":
"Зберегти зміни не вдалося.",
"components.board.screenReader.notification.cardCreated.success":
"Картку було створено іншим користувачем у колонці {columnPosition}.",
"components.board.screenReader.notification.columnCreated.success":
"Колонку створив інший користувач.",
"components.board.screenReader.notification.cardDeleted.success":
"Картка була видалена іншим користувачем.",
"components.board.screenReader.notification.columnDeleted.success":
"Стовпець був видалений іншим користувачем.",
"components.board.screenReader.notification.cardMovedInSameColumn.success":
"У колонці {columnPosition} картку було переміщено на позицію {newPosition}.",
"components.board.screenReader.notification.cardMovedToAnotherColumn.success":
"Картку було переміщено зі стовпчика {fromColumnPosition} до стовпчика {toColumnPosition}.",
"components.board.screenReader.notification.columnMoved.success":
"Стовпець було переміщено з позиції {oldPosition} в позицію {newPosition}.",
"components.board.screenReader.notification.boardTitleUpdated.success":
"Назву дошки було змінено на {newTitle} іншим користувачем.",
"components.board.screenReader.notification.boardVisibilityUpdated.published":
"Дошку опублікував інший користувач.",
"components.board.screenReader.notification.boardVisibilityUpdated.draft":
"Дошка була повернута до чернетки іншим користувачем.",
"components.board.screenReader.notification.columnTitleUpdated.success":
"Заголовок стовпчика {columnPosition} було змінено на {newTitle} іншим користувачем.",
"components.board.screenReader.notification.cardTitleUpdated.success":
"Заголовок картки {cardPosition} у колонці {columnPosition} було змінено на {newTitle} іншим користувачем.",
"components.board.screenReader.notification.cardUpdated.success":
"Картку {cardPosition} у стовпчику {columnPosition} було оновлено іншим користувачем.",
"components.board": "Дошка",
"components.boardCard": "Картка",
"components.boardColumn": "Колонка",
Expand Down
1 change: 1 addition & 0 deletions src/modules/data/board/Board.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export const useBoardStore = defineStore("boardStore", () => {
return {
board,
isLoading,
getCardLocation,
getColumnIndex,
getColumnId,
getLastColumnIndex,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/data/board/Card.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export const useCardStore = defineStore("cardStore", () => {
card.elements.push(payload.newElement);
}

lastCreatedElementId.value = payload.newElement.id;
if (payload.isOwnAction === true) {
lastCreatedElementId.value = payload.newElement.id;
setFocus(payload.newElement.id);
}
return payload.newElement;
Expand Down
Loading

0 comments on commit ccded13

Please sign in to comment.