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

Nwz/motrice related #4482

Merged
merged 6 commits into from
Jul 4, 2023
Merged
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
1 change: 1 addition & 0 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"lodash": "^4.17.15",
"maplibre-gl": "^2.4.0",
"openapi-typescript-codegen": "^0.24.0",
"party-js": "^2.2.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1",
Expand Down
7 changes: 0 additions & 7 deletions front/public/locales/en/home.json

This file was deleted.

12 changes: 8 additions & 4 deletions front/public/locales/en/home/navbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
"fr": "Français",
"it": "Italiano",
"jp": "やまと",
"languageChoice": "Language",
"ru": "Русский",
"uk": "Українська",
"languageChoice": "Language"
}
}
"uk": "Українська"
},
"safeWord": "Safe word",
"safeWordHelp": "The \"safe word\" is used to filter project list with this word used as a transparent tag. Choose a complex word to ensure it's not already used by someone else. Use it as a tag when creating or updating a project; it will be automatically added as a tag on project creation if already entered here.",
"userSettings": "User settings",
"yourSafeWord": "Enter your safe word"
}
12 changes: 8 additions & 4 deletions front/public/locales/fr/home/navbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
"fr": "Français",
"it": "Italiano",
"jp": "やまと",
"languageChoice": "Langue de l'interface",
"ru": "Русский",
"uk": "Українська",
"languageChoice": "Langue de l'interface"
}
}
"uk": "Українська"
},
"safeWord": "Mot clé de sécurité",
"safeWordHelp": "Le « mot-clé de sécurité » permet de filtrer de manière transparente la liste des projets avec le mot renseigné, utilisé comme une étiquette. Préférez un mot compliqué dans l'idée que personne ne l'utilise par inadvertance. Ajoutez-le comme une étiquette à un projet ; il sera automatiquement ajouté à la création de projet si le mot est renseigné ici.",
"userSettings": "Paramètres utilisateur",
"yourSafeWord": "Tapez votre mot"
}
11 changes: 6 additions & 5 deletions front/public/locales/fr/operationalStudies/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
"deleteProjects": "Supprimer",
"filterPlaceholder": "Rechercher…",
"openProject": "Ouvrir",
"projectsCount_zero": "Aucun projet",
"projects": "Projets",
"projectsCount_one": "1 projet",
"projectsCount_other": "{{count}} projets",
"projects": "Projets",
"projectsCount_zero": "Aucun projet",
"safeWordActivated": "Mode « sûr » activé",
"selectedProjects_one": "1 projet sélectionné",
"selectedProjects_other": "{{count}} projets sélectionnés",
"sortOptions": {
"byName": "Tri par nom",
"byRecentDate": "Plus récents"
},
"selectedProjects_one": "1 projet sélectionné",
"selectedProjects_other": "{{count}} projets sélectionnés",
"studiesCount_zero": "Aucune étude",
"studiesCount_one": "1 étude",
"studiesCount_other": "{{count}} études",
"studiesCount_zero": "Aucune étude",
"unselectAllProjects": "Déselectionner"
}
Binary file added front/public/pictures/minimotrices/motrice_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/public/pictures/minimotrices/motrice_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions front/src/applications/operationalStudies/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
SearchProjectResult,
osrdEditoastApi,
} from 'common/api/osrdEditoastApi';
import { useSelector } from 'react-redux';
import { RootState } from 'reducers';

type SortOptions =
| 'NameAsc'
Expand All @@ -26,6 +28,7 @@ type SortOptions =

export default function Home() {
const { t } = useTranslation('operationalStudies/home');
const safeWord = useSelector((state: RootState) => state.main.safeWord);
const [sortOption, setSortOption] = useState<SortOptions>('LastModifiedDesc');
const [projectsList, setProjectsList] = useState<ProjectResult[]>([]);
const [selectedProjectIds, setSelectedProjectIds] = useState<number[]>([]);
Expand All @@ -46,7 +49,7 @@ export default function Home() {
];

const getProjectList = async () => {
if (filter) {
if (filter || safeWord !== '') {
const payload: PostSearchApiArg = {
body: {
object: 'project',
Expand All @@ -61,6 +64,9 @@ export default function Home() {
],
},
};
if (safeWord !== '') {
payload?.body?.query?.push(['search', ['tags'], safeWord]);
}
try {
const data = await postSearch(payload).unwrap();
let filteredData = [...data] as SearchProjectResult[];
Expand Down Expand Up @@ -140,7 +146,7 @@ export default function Home() {

useEffect(() => {
getProjectList();
}, [sortOption, filter]);
}, [sortOption, filter, safeWord]);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { useNavigate } from 'react-router-dom';
import { AiFillFolderOpen, AiFillCheckCircle } from 'react-icons/ai';
import nextId from 'react-id-generator';
import { dateTimeFrenchFormatting } from 'utils/date';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { updateProjectID, updateScenarioID, updateStudyID } from 'reducers/osrdconf';
import { ProjectResult } from 'common/api/osrdEditoastApi';
import { getDocument } from 'common/api/documentApi';
import cx from 'classnames';
import { RootState } from 'reducers';

type Props = {
setFilterChips: (filterChips: string) => void;
Expand All @@ -24,6 +25,7 @@ export default function ProjectCard({ setFilterChips, project, isSelected, toggl
const [imageUrl, setImageUrl] = useState<string>();
const dispatch = useDispatch();
const navigate = useNavigate();
const safeWord = useSelector((state: RootState) => state.main.safeWord);

const openProject = () => {
dispatch(updateProjectID(project.id));
Expand Down Expand Up @@ -90,17 +92,19 @@ export default function ProjectCard({ setFilterChips, project, isSelected, toggl
<div className="projects-list-project-card-tags">
{project.tags &&
project.tags.length > 0 &&
project.tags?.map((tag) => (
<div
className="projects-list-project-card-tags-tag"
key={nextId()}
role="button"
tabIndex={0}
onClick={() => setFilterChips(tag)}
>
{tag}
</div>
))}
project.tags
?.filter((tag) => tag !== safeWord)
.map((tag) => (
<div
className="projects-list-project-card-tags-tag"
key={nextId()}
role="button"
tabIndex={0}
onClick={() => setFilterChips(tag)}
>
{tag}
</div>
))}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Vias(props: ViasProps) {
<FaPlus />
</button>
)}
<div className="mb-2">
<div className="vias-list">
{vias && vias.length > 0 ? (
<DisplayVias zoomToFeaturePoint={zoomToFeaturePoint} />
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';
import projectLogo from 'assets/pictures/views/projects.svg';
import ChipsSNCF from 'common/BootstrapSNCF/ChipsSNCF';
import InputSNCF from 'common/BootstrapSNCF/InputSNCF';
Expand All @@ -14,7 +14,7 @@ import { FaPencilAlt, FaPlus, FaTrash } from 'react-icons/fa';
import { MdBusinessCenter, MdDescription, MdTitle } from 'react-icons/md';
import { RiMoneyEuroCircleLine } from 'react-icons/ri';
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { setFailure, setSuccess } from 'reducers/main';
import { updateProjectID } from 'reducers/osrdconf';
Expand All @@ -27,6 +27,7 @@ import {
osrdEditoastApi,
} from 'common/api/osrdEditoastApi';
import { postDocument } from 'common/api/documentApi';
import { RootState } from 'reducers';
import { PROJECTS_URI } from '../operationalStudiesConsts';
import PictureUploader from './PictureUploader';

Expand All @@ -45,6 +46,7 @@ export default function AddOrEditProjectModal({ editionMode, project, getProject
const [displayErrors, setDisplayErrors] = useState(false);
const dispatch = useDispatch();
const navigate = useNavigate();
const safeWord = useSelector((state: RootState) => state.main.safeWord);

const [postProject] = osrdEditoastApi.usePostProjectsMutation();
const [patchProject] = osrdEditoastApi.usePatchProjectsByProjectIdMutation();
Expand Down Expand Up @@ -163,6 +165,12 @@ export default function AddOrEditProjectModal({ editionMode, project, getProject

const debouncedObjectives = useDebounce(currentProject?.objectives, 500);

useEffect(() => {
if (safeWord !== '') {
addTag(safeWord);
}
}, [safeWord]);

return (
<div className="project-edition-modal">
<ModalHeaderSNCF withCloseButton withBorderBottom>
Expand All @@ -173,7 +181,7 @@ export default function AddOrEditProjectModal({ editionMode, project, getProject
</ModalHeaderSNCF>
<ModalBodySNCF>
<div className="row mb-3">
<div className="col-xl-4 col-lg-5 col-md-6">
<div className="col-lg-5 col-md-6">
<div className="project-edition-modal-picture">
<PictureUploader
image={currentProject?.image}
Expand All @@ -182,7 +190,7 @@ export default function AddOrEditProjectModal({ editionMode, project, getProject
/>
</div>
</div>
<div className="col-xl-8 col-lg-7 col-md-6">
<div className="col-lg-7 col-md-6">
<div className="project-edition-modal-name">
<InputSNCF
id="projectInputName"
Expand Down
Loading