Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(card) : #MAG-114 add board cards #365

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/deployment/magneto/conf.json.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fr.cgi~magneto~2.0.0",
"name": "fr.cgi~magneto~${magnetoVersion}",
"config": {
"main" : "fr.cgi.magneto.Magneto",
"port" : 8205,
Expand Down
3 changes: 1 addition & 2 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>fr.cgi</groupId>
<artifactId>magneto</artifactId>
<version>2.0.0</version>
<version>2.0-SNAPSHOT</version>
<scm>
<connection>scm:git:https://github.com/OPEN-ENT-NG/magneto.git</connection>
<developerConnection>scm:git:https://github.com/OPEN-ENT-NG/magneto.git</developerConnection>
Expand All @@ -32,7 +32,6 @@
</repositories>
<properties>
<toolsVersion>2.0.0-final</toolsVersion>
<vertxCronTimer>2.0.0</vertxCronTimer>
<powerMockVersion>2.0.2</powerMockVersion>
<mockitoVersion>[2.0,3.0)</mockitoVersion>
<entCoreVersion>6.0-SNAPSHOT</entCoreVersion>
Expand Down
2 changes: 2 additions & 0 deletions backend/src/main/resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"magneto.card.options.delete": "Supprimer",
"magneto.card.options.move": "Déplacer",
"magneto.comments": "Commentaires",
"magneto.add": "Ajouter",
"magneto.add.comment": "Ajouter un commentaire",
"magneto.add.comment.error": "Une erreur est survenue lors de l'ajout du commentaire.",
"magneto.update.comment.error": "Une erreur est survenue lors de la mise à jour du commentaire.",
Expand Down Expand Up @@ -176,6 +177,7 @@
"group.school.Guest": "Invités de l'{{0}}.",
"magneto.return": "Retour",
"magneto.card.saved.by": "Crée par {{0}}, modifié par {{1}}",
"magneto.boards.collection": "Collection de tableaux",
"magneto.cards.collection": "Collection d'aimants",
"magneto.cards.collection.mine": "Dans mes tableaux",
"magneto.cards.collection.shared": "Dans les tableaux partagés",
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"concurrently": "8.2.1",
"csstype": "3.1.2",
"dotenv-cli": "^7.4.2",
"edifice-ts-client": "1.5.23",
"edifice-ts-client": "1.7.4",
"eslint": "8.51.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.28.1",
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/components/app-view/AppView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ export const AppView: FC = () => {
const [searchBarResetter, resetSearchBar] = useState(0);
const { currentFolder, folders, setSelectedFoldersIds, setSelectedFolders } =
useFoldersNavigation();
const { boards, selectedBoards, setSelectedBoards, setSelectedBoardsIds } =
useBoardsNavigation();
const {
boards,
selectedBoards,
setSelectedBoards,
setSelectedBoardsIds,
boardsLoading,
} = useBoardsNavigation();
const [dragAndDropBoards, setDragAndDropBoards] = useState<Board[]>([]);
const [showModal, setShowModal] = useState(false);
const [modalProps, setModalProps] = useState({
Expand Down Expand Up @@ -183,6 +188,8 @@ export const AppView: FC = () => {
<BoardList
searchText={searchText}
onDragAndDrop={handleDragAndDropBoards}
boards={boards}
boardsLoading={boardsLoading}
/>
<ToasterContainer
reset={resetBoardsAndFolders}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import { FC, useState } from "react";

import { Button, SearchBar } from "@edifice-ui/react";
import CloseIcon from "@mui/icons-material/Close";
import { Box, IconButton, Modal, Typography } from "@mui/material";
import { useTranslation } from "react-i18next";

import {
closeButtonStyle,
contentContainerStyle,
duplicateButtonStyle,
headerStyle,
modalContainerStyle,
modalFooterStyle,
titleStyle,
} from "./style";
import { InputValueState, BoardCreateMagnetBoardModalProps } from "./types";
import { useRenderContent } from "./useRenderContent";
import { initialInputvalue } from "./utils";
import { TabList } from "../tab-list/TabList";
import { CURRENTTAB_STATE } from "../tab-list/types";
import { BOARD_TABS_CONFIG } from "../tab-list/utils";
import { useMediaLibrary } from "~/providers/MediaLibraryProvider";

export const BoardCreateMagnetBoardModal: FC<
BoardCreateMagnetBoardModalProps
> = ({ open, onClose }) => {
const [inputValue, setInputValue] =
useState<InputValueState>(initialInputvalue);
const { currentTab } = inputValue;
const { t } = useTranslation("magneto");
const { setIsCreateMagnetOpen, setSelectedBoardData } = useMediaLibrary();

const handleTabChange = (newValue: CURRENTTAB_STATE) => {
setInputValue((prevState) => ({
...prevState,
currentTab: newValue,
selectedBoardId: null,
}));
};

const handleSearchChange = (newValue: string) => {
setInputValue((prevState) => ({
...prevState,
search: newValue,
selectedBoardId: null,
}));
};

const handleClose = () => {
setInputValue(initialInputvalue);
onClose();
};

const handleSubmit = async () => {
if (inputValue.selectedBoardId) {
setSelectedBoardData(inputValue.selectedBoardId);
setIsCreateMagnetOpen(true);
handleClose();
}
};

return (
<Modal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t'as la MessageModal d'Alice qui embarque le plus gros du style de nos modales

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai repris BoardCreateMagnetMagnetModal qui a sa propre Modal aussi, je verrais pour factoriser avec MessageModal si il faut, mais c'était pour gagner du temps vu qu'elles sont relativement ressemblantes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai essayé de reprendre avec MessageModal, mais comme le style de container principal de la modal n'est pas le même (au niveau de la height et width notamment) l'affichage est tout cassé, ça va demander plus de travail, je vois au retour des vacances si ça prendra beaucoup de temps

open={open}
onClose={onClose}
aria-labelledby="modal-title"
aria-describedby="modal-create-magnet-magnet"
>
<Box sx={modalContainerStyle}>
<Box sx={headerStyle}>
<Typography
id="modal-title"
variant="h4"
component="h2"
sx={titleStyle}
>
{t("magneto.boards.collection")}
</Typography>
<IconButton
onClick={onClose}
aria-label="close"
sx={closeButtonStyle}
>
<CloseIcon fontSize="inherit" />
</IconButton>
</Box>
<Box sx={{ width: "100%", padding: "2rem 10%", margin: "auto" }}>
<SearchBar
onChange={(e) => {
handleSearchChange(e.target.value);
}}
placeholder={t("magneto.search.placeholder")}
size="md"
isVariant
className="searchbar"
/>
</Box>
<Box
sx={{
width: "100%",
pb: "1rem",
margin: "auto",
display: "flex",
justifyContent: "center",
}}
>
<TabList
currentTab={currentTab}
onChange={handleTabChange}
tabsConfig={BOARD_TABS_CONFIG}
/>
</Box>
<Box sx={contentContainerStyle}>
{useRenderContent(inputValue, setInputValue)}
</Box>
<Box sx={modalFooterStyle}>
<Box sx={duplicateButtonStyle}>
<Button
color="tertiary"
type="button"
variant="ghost"
onClick={() => handleClose()}
>
{t("magneto.cancel")}
</Button>
<Button
onClick={() => handleSubmit()}
disabled={!inputValue.selectedBoardId}
>
{t("magneto.add")}
</Button>
</Box>
</Box>
</Box>
</Modal>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
ul.grid {
padding-top: 1.5rem;
padding-right: 1.6rem;
display: grid;
grid-template-columns: repeat(
4,
minmax(0, 1fr)
); /* Force equal width columns */
gap: 1.6rem;
width: 100% !important;
}

li.boardSizing {
/* Remove any width constraints */
min-width: 0;

.card {
width: 100%;
padding: unset !important;
margin: unset !important;
display: flex;
flex-wrap: wrap !important;
flex-direction: column;
max-width: 100%; /* Ensure card doesn't overflow */

.board-number-magnets {
display: flex;
justify-content: center;
align-items: center;

svg {
color: #ffb600;
font-size: 1.4rem;
}

svg + p {
font-size: 1.2rem;
margin: 0;
}
}

.board-about {
display: flex;
justify-content: space-between;
width: 100%;

.board-about-left-content,
.board-about-right-content {
margin: 0 !important;
display: flex;
gap: 0.4rem;
align-items: center;

.med-resource-card-text {
font-size: 1.2rem;
}
}
}
}
}

.title {
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 1.4rem;
}

.card-body {
width: 100%;
padding: 1.2rem;
}
Loading
Loading