Skip to content

Commit 1036c4d

Browse files
committed
front: dts: fix time display
1 parent 32f60b6 commit 1036c4d

File tree

4 files changed

+88
-60
lines changed

4 files changed

+88
-60
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.container-drivertrainschedule {
2+
max-height: 30rem;
3+
}
4+
5+
.modal-drivertrainschedule {
6+
height: 50%;
7+
}
8+
9+
.simulation-drivertrainschedule {
10+
max-height: 15rem;
11+
overflow: auto;
12+
}
13+
14+
.table-drivertrainschedule, .table-drivertrainschedule th, .table-drivertrainschedule td {
15+
border : none !important;
16+
padding-right: 10px;
17+
18+
.drivertrainschedule-pk {
19+
text-align: right;
20+
width: 2rem;
21+
}
22+
23+
.stoptime-container {
24+
.box{
25+
width:100%;
26+
display:table;
27+
.box-row {
28+
display:table-row;
29+
}
30+
.box-cell {
31+
display:table-cell;
32+
width:calc(100% / 3);
33+
text-align:left;
34+
position: relative;
35+
.box-cell::after {
36+
content: '+';
37+
position: absolute;
38+
}
39+
}
40+
}
41+
}
42+
43+
.drivertrainschedule-stop {
44+
font-weight: bold;
45+
small {
46+
font-weight: bold;
47+
}
48+
}
49+
}
50+
51+
.table-drivertrainschedule th, thead {
52+
position: sticky;
53+
top: 0;
54+
z-index: 1;
55+
}

front/src/applications/osrd/components/DriverTrainSchedule/DriverTrainScheduleHelpers.js

+32-12
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,28 @@ export default function formatStops(stop, idx, data) {
132132
stop.position,
133133
data.base.speeds
134134
);
135+
const pk = Math.round(stop.position / 100) / 10;
135136
const stopTime =
136137
getTime(stop.time).at(-1) === '+' ? (
137-
<span className="timeWithPlus">{getTime(stop.time).slice(0, -1)}</span>
138+
<span className="box-cell">{getTime(stop.time).slice(0, -1)}</span>
138139
) : (
139140
getTime(stop.time)
140141
);
141-
const pk = Math.round(stop.position / 100) / 10;
142+
const departureTime =
143+
getTime(stop.time + stop.duration).at(-1) === '+' ? (
144+
<span className="box-cell">{getTime(stop.time + stop.duration).slice(0, -1)}</span>
145+
) : (
146+
getTime(stop.time + stop.duration)
147+
);
142148
return (
143-
<tr key={nextId()} className={`${stop.duration > 0 ? 'drivertrainschedule-stop' : ''}`}>
149+
<tr
150+
key={nextId()}
151+
className={`${
152+
stop.duration > 0 || idx === 0 || idx === data.base.stops.length - 1
153+
? 'drivertrainschedule-stop'
154+
: ''
155+
}`}
156+
>
144157
<td className="text-center">
145158
<small>{idx + 1}</small>
146159
</td>
@@ -151,15 +164,22 @@ export default function formatStops(stop, idx, data) {
151164
<div className="drivertrainschedule-pk">{Number.isInteger(pk) ? `${pk}.0` : pk}</div>
152165
</td>
153166
<td>{stop.name || 'Unknown'}</td>
154-
<td className="text-center drivertrainschedule-stop-time">
155-
{stop.duration > 0 ? (
156-
<>
157-
<span>{stopTime}</span>
158-
<span className="ml-2">{stop.duration > 0 && getTime(stop.time + stop.duration)}</span>
159-
</>
160-
) : (
161-
stopTime
162-
)}
167+
<td className="stoptime-container">
168+
<div className="box">
169+
<div className="box-row">
170+
<div className="box-cell">
171+
{stop.duration > 0 || idx === data.base.stops.length - 1 ? stopTime : ''}
172+
</div>
173+
<div className="box-cell px-2 px-md-0">
174+
{stop.duration > 0 || idx === 0 || idx === data.base.stops.length - 1 ? '' : stopTime}
175+
</div>
176+
<div className="box-cell">
177+
{(stop.duration > 0 && idx < data.base.stops.length - 1) || idx === 0
178+
? departureTime
179+
: ''}
180+
</div>
181+
</div>
182+
</div>
163183
</td>
164184
<td>
165185
<div

front/src/applications/osrd/views/OSRDSimulation/OSRDSimulation.scss

-48
Original file line numberDiff line numberDiff line change
@@ -123,54 +123,6 @@ select.sm {
123123
overflow: auto;
124124
}
125125

126-
// Driver Train Schedule
127-
128-
.container-drivertrainschedule {
129-
max-height: 30rem;
130-
}
131-
132-
.modal-drivertrainschedule {
133-
height: 50%;
134-
}
135-
136-
137-
138-
.simulation-drivertrainschedule {
139-
max-height: 15rem;
140-
overflow: auto;
141-
}
142-
143-
.table-drivertrainschedule, .table-drivertrainschedule th, .table-drivertrainschedule td {
144-
border : none !important;
145-
padding-right: 10px;
146-
147-
.drivertrainschedule-pk {
148-
text-align: right;
149-
width: 2rem;
150-
}
151-
152-
.drivertrainschedule-stop {
153-
font-weight: bold;
154-
small {
155-
font-weight: bold;
156-
}
157-
.timeWithPlus::after {
158-
content: '+';
159-
}
160-
}
161-
.drivertrainschedule-stop-time{
162-
position: relative;
163-
164-
.timeWithPlus::after :not(.drivertrainschedule-stop) {
165-
content: '+';
166-
display: inline;
167-
position: absolute;
168-
bottom: 0;
169-
}
170-
}
171-
172-
}
173-
174126
.table-drivertrainschedule th, thead {
175127
position: sticky;
176128
top: 0;

front/src/applications/osrd/views/OSRDSimulation/OSRDSimulation.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import './OSRDSimulation.scss';
2+
import 'applications/osrd/components/DriverTrainSchedule/DriverTrainSchedule.scss';
23

34
import React, { useEffect, useState, useRef } from 'react';
45
import {

0 commit comments

Comments
 (0)