Skip to content

Commit

Permalink
front: update column styles in time stops table
Browse files Browse the repository at this point in the history
Signed-off-by: Alice Khoudli <[email protected]>
  • Loading branch information
Synar committed Oct 25, 2024
1 parent 90c537c commit 8e3a731
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 48 deletions.
8 changes: 4 additions & 4 deletions front/public/locales/en/timesStops.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"calculatedDepartureTime": "calculated departure time",
"dayCounter": "D+{{count}}",
"departureTime": "requested departure time",
"diffMargins": "margins diff. (s)",
"diffMargins": "margins diff. (s)",
"name": "CI",
"ch": "ch",
"ch": "CH",
"noPathLoaded": "No path loaded",
"realMargin": "real margin (s)",
"realMargin": "real margin (s)",
"receptionOnClosedSignal": "reception on closed signal",
"shortSlipDistance": "Short Slip Distance",
"shortSlipDistance": "short slip distance",
"stopTime": "stopping time (s)",
"theoreticalMargin": "theoretical margin",
"theoreticalMarginPlaceholder": "% or min/100km",
Expand Down
10 changes: 5 additions & 5 deletions front/public/locales/fr/timesStops.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"calculatedDepartureTime": "départ calculé",
"dayCounter": "J+{{count}}",
"departureTime": "départ demandé",
"diffMargins": "diff. marges (s)",
"diffMargins": "diff. marges (s)",
"name": "CI",
"ch": "ch",
"ch": "CH",
"noPathLoaded": "Aucun chemin chargé",
"shortSlipDistance": "Faible glissement",
"realMargin": "marge réelle (s)",
"realMargin": "marge réelle (s)",
"receptionOnClosedSignal": "réception sur signal fermé",
"shortSlipDistance": "faible glissement",
"stopTime": "temps d'arrêt (s)",
"theoreticalMargin": "marge théorique",
"theoreticalMarginPlaceholder": "% ou min/100km",
"theoreticalMarginSeconds": "marge théorique linéaire (s)",
"theoreticalMarginSeconds": "marge linéaire théorique (s)",
"waypoint": "Via {{id}}"
}
5 changes: 3 additions & 2 deletions front/src/modules/timesStops/TimesStopsOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const TimesStopsOutput = ({
<TimesStops
rows={enrichedOperationalPoints}
tableType={TableType.Output}
cellClassName={({ rowData: rowData_ }) => {
cellClassName={({ rowData: rowData_, columnId }) => {
const rowData = rowData_ as TimeStopsRow;
const arrivalScheduleNotRespected = rowData.arrival?.time
? rowData.calculatedArrival !== rowData.arrival.time
Expand All @@ -57,9 +57,10 @@ const TimesStopsOutput = ({
return cx({
'warning-schedule': arrivalScheduleNotRespected,
'warning-margin': negativeDiffMargins,
'secondary-code-column': columnId === 'ch',
});
}}
headerRowHeight={65}
headerRowHeight={50}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,29 @@ export const useTimeStopsColumns = <T extends TimeStopsRow>(
isOutputTable
? [
{
...disabledTextColumn('theoreticalMarginSeconds', t('theoreticalMarginSeconds'), {
alignRight: true,
}),
...disabledTextColumn('theoreticalMarginSeconds', t('theoreticalMarginSeconds')),
headerClassName: 'padded-header',
...fixedWidth(110),
},
{
...disabledTextColumn('calculatedMargin', t('realMargin'), {
alignRight: true,
}),
...fixedWidth(120),
...disabledTextColumn('calculatedMargin', t('realMargin')),
headerClassName: 'padded-header',
...fixedWidth(90),
},
{
...disabledTextColumn('diffMargins', t('diffMargins'), { alignRight: true }),
...fixedWidth(120),
...disabledTextColumn('diffMargins', t('diffMargins')),
headerClassName: 'padded-header',
...fixedWidth(90),
},
{
...disabledTextColumn('calculatedArrival', t('calculatedArrivalTime')),
...fixedWidth(95),
headerClassName: 'padded-header',
...fixedWidth(105),
},
{
...disabledTextColumn('calculatedDeparture', t('calculatedDepartureTime')),
...fixedWidth(97),
headerClassName: 'padded-header',
...fixedWidth(105),
},
]
: []
Expand All @@ -69,56 +70,69 @@ export const useTimeStopsColumns = <T extends TimeStopsRow>(
{
...keyColumn('name', createTextColumn()),
title: t('name'),
...(isOutputTable && {
component: ({ rowData }) => (
<span title={rowData.name} className="ml-1 text-nowrap overflow-hidden">
{rowData.name}
</span>
),
}),
disabled: true,
minWidth: isOutputTable ? 180 : 300,
minWidth: isOutputTable ? undefined : 300,
maxWidth: isOutputTable ? 560 : undefined,
},
{
...keyColumn('ch', createTextColumn()),
title: t('ch'),
disabled: true,
maxWidth: 45,
...fixedWidth(45),
},
{
...keyColumn('arrival', timeColumn(isOutputTable)),
alignRight: true,
title: t('arrivalTime'),
headerClassName: 'padded-header',
...fixedWidth(105),

// We should not be able to edit the arrival time of the origin
disabled: ({ rowIndex }) => isOutputTable || rowIndex === 0,
},
{
...keyColumn('departure', timeColumn(isOutputTable)),
title: t('departureTime'),

// We should not be able to edit the departure time of the origin
disabled: ({ rowIndex }) => isOutputTable || rowIndex === 0,
},
{
...keyColumn(
'stopFor',
createTextColumn({
continuousUpdates: false,
alignRight: true,
})
),
title: t('stopTime'),
headerClassName: 'padded-header',
disabled: isOutputTable,
maxWidth: isOutputTable ? 90 : undefined,
maxWidth: isOutputTable ? 100 : undefined,
grow: 0.6,
},
{
...keyColumn('departure', timeColumn(isOutputTable)),
title: t('departureTime'),
headerClassName: 'padded-header',
...fixedWidth(105),

// We should not be able to edit the departure time of the origin
disabled: ({ rowIndex }) => isOutputTable || rowIndex === 0,
},
{
...keyColumn('onStopSignal', checkboxColumn as Partial<Column<boolean | undefined>>),
title: t('receptionOnClosedSignal'),
headerClassName: 'padded-header',
...fixedWidth(97),

// We should not be able to edit the reception on close signal if stopFor is not filled
// except for the destination
...fixedWidth(94),
disabled: ({ rowData, rowIndex }) =>
isOutputTable || (rowIndex !== allWaypoints.length - 1 && !rowData.stopFor),
},
{
...keyColumn('shortSlipDistance', checkboxColumn as Partial<Column<boolean | undefined>>),
title: t('shortSlipDistance'),
headerClassName: 'padded-header',
...fixedWidth(94),
disabled: ({ rowData, rowIndex }) =>
isOutputTable || (rowIndex !== allWaypoints.length - 1 && !rowData.onStopSignal),
Expand All @@ -128,7 +142,6 @@ export const useTimeStopsColumns = <T extends TimeStopsRow>(
'theoreticalMargin',
createTextColumn({
continuousUpdates: false,
alignRight: true,
placeholder: !isOutputTable ? t('theoreticalMarginPlaceholder') : '',
formatBlurredInput: (value) => {
if (!value || value === '0%') return '';
Expand All @@ -142,8 +155,10 @@ export const useTimeStopsColumns = <T extends TimeStopsRow>(
cellClassName: ({ rowData }) =>
cx({ invalidCell: !isOutputTable && !rowData.isMarginValid }),
title: t('theoreticalMargin'),
headerClassName: 'padded-header',
minWidth: 100,
maxWidth: 140,
disabled: ({ rowIndex }) => isOutputTable || rowIndex === allWaypoints.length - 1,
...fixedWidth(110),
},
...extraOutputColumns,
] as Column<T>[];
Expand Down
1 change: 0 additions & 1 deletion front/src/modules/timesStops/styles/_readOnlyTime.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.read-only-time {
// using px to conform with the padding in the react-datasheet-grid library class .dsg-input
padding: 0 10px;
text-align: right;
width: 100%;
}
12 changes: 11 additions & 1 deletion front/src/modules/timesStops/styles/_timesStopsDatasheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@
.activeRow {
font-weight: semibold;
color: var(--black100);
.dsg-cell-gutter {
.dsg-cell-gutter,
.secondary-code-column {
font-weight: normal;
}
}

.padded-header > * {
padding-left: 8px;
padding-right: 16px;
}

.secondary-code-column {
color: var(--grey50);
}

.invalidCell {
color: red !important;
}
Expand Down
2 changes: 1 addition & 1 deletion front/tests/011-op-times-and-stops-tab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ test.describe('Times and Stops Tab Verification', () => {
translations.name,
translations.ch,
translations.arrivalTime,
translations.departureTime,
translations.stopTime,
translations.departureTime,
translations.receptionOnClosedSignal,
translations.shortSlipDistance,
translations.theoreticalMargin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
},
{
"row": 2,
"values": ["Mid_West_station", "BV", "11:47:40", "11:52:40", "300", "1min/100km"]
"values": ["Mid_West_station", "BV", "11:47:40", "300", "11:52:40", "1min/100km"]
},
{
"row": 3,
"values": ["Mid_East_station", "BV", "12:05:21", "12:07:25", "124", ""]
"values": ["Mid_East_station", "BV", "12:05:21", "124", "12:07:25", ""]
},
{
"row": 4,
"values": ["North_East_station", "BV", "", "", "0", ""]
"values": ["North_East_station", "BV", "", "0", "", ""]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
},
{
"row": 3,
"values": ["Mid_East_station", "BV", "13:58:19", "13:58:40", "21", ""]
"values": ["Mid_East_station", "BV", "13:58:19", "21", "13:58:40", ""]
},
{
"row": 4,
"values": ["North_East_station", "BV", "", "", "0", ""]
"values": ["North_East_station", "BV", "", "0", "", ""]
}
]
9 changes: 6 additions & 3 deletions front/tests/pages/op-output-table-page-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OperationalStudiesOutputTablePage {
constructor(page: Page) {
this.page = page;
this.columnHeaders = page.locator(
'[class="dsg-cell dsg-cell-header"] .dsg-cell-header-container'
'.dsg-cell.dsg-cell-header:not(.dsg-cell-gutter) .dsg-cell-header-container'
);
this.tableRows = page.locator('.osrd-simulation-container .time-stops-datasheet .dsg-row');
}
Expand Down Expand Up @@ -69,9 +69,12 @@ class OperationalStudiesOutputTablePage {
calculatedDeparture,
] = await Promise.all([
await OperationalStudiesOutputTablePage.getCellValue(
cells.nth(headerIndexMap[translations.name])
cells.nth(headerIndexMap[translations.name]),
false
),
await OperationalStudiesOutputTablePage.getCellValue(
cells.nth(headerIndexMap[translations.ch])
),
await OperationalStudiesOutputTablePage.getCellValue(cells.nth(headerIndexMap.Ch)),
await OperationalStudiesOutputTablePage.getCellValue(
cells.nth(headerIndexMap[translations.arrivalTime]),
false
Expand Down

0 comments on commit 8e3a731

Please sign in to comment.