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

front: remove document panel & fix chip style #5602

Merged
merged 2 commits into from
Nov 10, 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
137 changes: 41 additions & 96 deletions front/src/applications/operationalStudies/views/Study.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@ import OptionsSNCF from 'common/BootstrapSNCF/OptionsSNCF';
import ScenarioCard from 'modules/scenario/components/ScenarioCard';
import { setFailure } from 'reducers/main';
import ScenarioCardEmpty from 'modules/scenario/components/ScenarioCardEmpty';
import { VscLink, VscFile, VscFiles } from 'react-icons/vsc';
import { FaPencilAlt } from 'react-icons/fa';
import { budgetFormat } from 'utils/numbers';
import { useModal } from 'common/BootstrapSNCF/ModalSNCF';
import { useDispatch } from 'react-redux';
import DateBox from 'applications/operationalStudies/components/Study/DateBox';
import StateStep from 'applications/operationalStudies/components/Study/StateStep';
import {
PostSearchApiArg,
ScenarioResult,
StudyWithScenarios,
osrdEditoastApi,
} from 'common/api/osrdEditoastApi';
import { PostSearchApiArg, ScenarioResult, osrdEditoastApi } from 'common/api/osrdEditoastApi';
import AddOrEditStudyModal from 'modules/study/components/AddOrEditStudyModal';
import BreadCrumbs from '../components/BreadCrumbs';
import FilterTextField from '../components/FilterTextField';
Expand All @@ -35,15 +29,6 @@ type SortOptions =
| 'LastModifiedAsc'
| 'LastModifiedDesc';

// While files property is not implemented in studies
type StudyWithFileType = StudyWithScenarios & {
files: {
filename: string;
url: string;
name: string;
}[];
};

function displayScenariosList(
scenariosList: ScenarioResult[],
setFilterChips: (filterChips: string) => void
Expand Down Expand Up @@ -135,43 +120,6 @@ export default function Study() {
setSortOption(e.target.value as SortOptions);
};

// TODO: use Files when it is implemented in the backend
const getFileSection = () => (
<div className="study-details-files">
<div className="study-details-files-title">
<span className="mr-2">
<VscFiles />
</span>
{t('filesAndLinks')}
<span className="ml-auto">
{(study as StudyWithFileType).files ? (study as StudyWithFileType).files.length : 0}
</span>
</div>
<div className="study-details-files-list">
{(study as StudyWithFileType).files?.map((file) => {
const isUrl = Math.random() > 0.5;
return (
<a
href={file.url}
key={nextId()}
target="_blank"
rel="noreferrer"
className={isUrl ? 'url' : 'file'}
>
<span className="study-details-files-list-name">
<span className="mr-1">{isUrl ? <VscLink /> : <VscFile />}</span>
{file.name}
</span>
<span className="study-details-files-list-link">
{isUrl ? file.url : file.filename}
</span>
</a>
);
})}
</div>
</div>
);

const getScenarioList = async () => {
if (projectId && studyId) {
if (filter) {
Expand Down Expand Up @@ -267,50 +215,47 @@ export default function Study() {
translation="modified"
/>
</div>
<div className="row">
<div className="col-xl-9 col-lg-8 col-md-7">
<div className="study-details-name">
<div className="study-name">{study.name}</div>
<button
className="study-details-modify-button"
type="button"
onClick={() =>
openModal(<AddOrEditStudyModal editionMode study={study} />, 'xl')
}
>
<span className="study-details-modify-button-text">{t('modifyStudy')}</span>
<FaPencilAlt />
</button>
</div>
{study.study_type && (
<div className="study-details-type">
{t(`studyCategories.${study.study_type}`)}
</div>
)}
<div className="study-details-description">{study.description}</div>
{study.state && (
<div className="study-details-state">
{studyStates.map(
(state, idx) =>
project.id &&
study.id &&
study.state && (
<StateStep
key={nextId()}
projectID={project.id}
studyID={study.id}
number={idx + 1}
studyName={study.name}
state={state}
done={idx <= studyStates.indexOf(study.state as StudyState)}
tags={study.tags}
/>
)
)}
</div>
)}
<div className="d-flex flex-column p-2">
<div className="study-details-name">
<div className="study-name">{study.name}</div>
<button
className="study-details-modify-button"
type="button"
onClick={() =>
openModal(<AddOrEditStudyModal editionMode study={study} />, 'xl')
}
>
<span className="study-details-modify-button-text">{t('modifyStudy')}</span>
<FaPencilAlt />
</button>
</div>
<div className="col-xl-3 col-lg-4 col-md-5">{getFileSection()}</div>
{study.study_type && (
<div className="study-details-type">
{t(`studyCategories.${study.study_type}`)}
</div>
)}
<div className="study-details-description">{study.description}</div>
{study.state && (
<div className="study-details-state">
{studyStates.map(
(state, idx) =>
project.id &&
study.id &&
study.state && (
<StateStep
key={nextId()}
projectID={project.id}
studyID={study.id}
number={idx + 1}
studyName={study.name}
state={state}
done={idx <= studyStates.indexOf(study.state as StudyState)}
tags={study.tags}
/>
)
)}
</div>
)}
</div>

{study.service_code || study.business_code || study.budget ? (
Expand Down
2 changes: 1 addition & 1 deletion front/src/common/BootstrapSNCF/ChipsSNCF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function ChipsSNCF({
data-role="typewriter"
type="text"
data-testid="chips-input"
className="chips-input stretchy"
className="chips-input"
id={chipsID}
onKeyDown={validateInput}
value={chipInputValue}
Expand Down
29 changes: 0 additions & 29 deletions front/src/stories/storybook.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions front/src/styles/scss/_overrideBootstrapSNCF.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
.form-control-container .chips-input {
width: auto !important;
flex-grow: 1;
min-height: 2.45rem;
line-height: 1;
}

Expand All @@ -96,7 +95,8 @@ button.chips.chips-btn {
* LABELS
*
*/
label, .labels {
label,
.labels {
display: flex !important;
align-items: center !important;
white-space: nowrap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.study-view {
.study-details {
position: relative;
width: 100%;
margin-bottom: 1rem;
min-height: 15rem;
.study-details-dates {
display: flex;
flex-wrap: wrap;
Expand Down Expand Up @@ -154,50 +155,6 @@
}
}
}
.study-details-files {
border: 2px solid var(--primary);
border-radius: 4px;
margin-bottom: 0.25rem;
.study-details-files-title {
display: flex;
align-items: center;
font-weight: 500;
padding: 0.25rem 0.5rem;
color: var(--white);
background-color: var(--primary);
}
.study-details-files-list {
display: flex;
flex-direction: column;
overflow: auto;
height: 12rem;
a {
display: flex;
flex-direction: column;
padding: 0.25rem 0.5rem;
transition: 0.2s;
&.url {
color: var(--cyan);
&:hover {
background-color: var(--cyan);
}
}
&:hover {
background-color: var(--primary);
color: var(--white);
}
.study-details-files-list-name {
display: flex;
align-items: center;
font-weight: 500;
}
.study-details-files-list-link {
font-size: 0.8rem;
margin-left: 1.5rem;
}
}
}
}
.study-details-financials {
display: flex;
align-items: center;
Expand Down
Loading