Skip to content

Commit

Permalink
front: rs-editor: add base power class field
Browse files Browse the repository at this point in the history
  • Loading branch information
SharglutDev committed Oct 4, 2023
1 parent 95b275d commit 6d14e30
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 15 deletions.
1 change: 1 addition & 0 deletions front/public/locales/en/rollingstock.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"addNewRollingStock": "New rolling stock",
"addNewTractionMode": "Add a new traction mode",
"basePowerClass": "Power class",
"cancelAction": "Would you like to cancel this action?",
"cancelUpdateRollingStock": "Do you really want to cancel your changes?",
"chooseRollingStock": "Select a rolling stock to display informations",
Expand Down
1 change: 1 addition & 0 deletions front/public/locales/fr/rollingstock.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"addNewRollingStock": "Nouveau matériel roulant",
"addNewTractionMode": "Ajouter un nouveau mode de traction",
"basePowerClass": "Classe de puissance",
"cancelAction": "Souhaitez-vous annuler cette action ?",
"cancelUpdateRollingStock": "Annuler la mise à jour du matériel roulant?",
"chooseRollingStock": "Sélectionnez un matériel roulant pour en afficher les informations.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const RollingStockEditorParameterFormColumn = ({
if (property.enum) {
return (
<div
className="d-flex align-items-center justify-content-between rollingstock-editor-select"
className="d-flex align-items-center justify-content-between rollingstock-editor-select mb-4"
key={index}
>
<SelectSNCF
Expand Down Expand Up @@ -187,9 +187,10 @@ const RollingStockEditorParameterFormColumn = ({
min={property.min}
max={property.max}
isInvalid={
Number.isNaN(rollingStockValues[property.title]) ||
(rollingStockValues[property.title] as number) < (property.min as number) ||
(rollingStockValues[property.title] as number) > (property.max as number)
property.type === 'number' &&
(Number.isNaN(rollingStockValues[property.title]) ||
(rollingStockValues[property.title] as number) < (property.min as number) ||
(rollingStockValues[property.title] as number) > (property.max as number))
}
errorMsg={
property.max
Expand All @@ -202,11 +203,16 @@ const RollingStockEditorParameterFormColumn = ({
})
}
unit={property.unit}
value={rollingStockValues[property.title] as number}
value={
property.title !== 'basePowerClass'
? (rollingStockValues[property.title] as number)
: (rollingStockValues[property.title] as string)
}
onChange={(e) =>
setRollingStockValues({
...rollingStockValues,
[property.title]: parseFloat(e.target.value),
[property.title]:
property.title !== 'basePowerClass' ? parseFloat(e.target.value) : e.target.value,
})
}
sm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export default function RollingStockCardDetail({
<td className="text-primary">{t('loadingGauge')}</td>
<td>{rollingStock.loading_gauge}</td>
</tr>
<tr>
<td className="text-primary">{t('basePowerClass')}</td>
<td>{rollingStock.base_power_class}</td>
</tr>
</tbody>
</table>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const SearchRollingStock = ({
mustResetFilters,
setMustResetFilters,
}: SearchRollingStockProps) => {
const { t } = useTranslation('rollingStockEditor');
const { t } = useTranslation('rollingstock');

const [filters, setFilters] = useState<Filters>({
text: '',
Expand Down Expand Up @@ -206,7 +206,7 @@ const SearchRollingStock = ({
<span className="text-primary mr-1">
<BsLightningFill />
</span>
{t('rollingstock:electric')}
{t('electric')}
</span>
}
type="checkbox"
Expand All @@ -223,7 +223,7 @@ const SearchRollingStock = ({
<span className="text-pink mr-1">
<MdLocalGasStation />
</span>
{t('rollingstock:thermal')}
{t('thermal')}
</span>
}
type="checkbox"
Expand All @@ -240,7 +240,7 @@ const SearchRollingStock = ({
<span className="text-black mr-1">
<BiLockAlt />
</span>
{t('rollingstock:locked')}
{t('locked')}
</span>
}
type="checkbox"
Expand All @@ -257,7 +257,7 @@ const SearchRollingStock = ({
<span className="text-black mr-1">
<BiLockOpenAlt />
</span>
{t('rollingstock:notLocked')}
{t('notLocked')}
</span>
}
type="checkbox"
Expand All @@ -268,8 +268,8 @@ const SearchRollingStock = ({
<div className="col-md-2 mt-1 ml-auto">
<small className="">
{filteredRollingStockList.length > 0
? `${filteredRollingStockList.length} ${t('rollingstock:resultsFound')}`
: t('rollingstock:noResultFound')}
? `${filteredRollingStockList.length} ${t('resultsFound')}`
: t('noResultFound')}
</small>
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion front/src/modules/rollingStock/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ export type RollingStockParametersValues = {
gammaValue: number;
inertiaCoefficient: number;
loadingGauge: 'G1' | 'G2' | 'GA' | 'GB' | 'GB1' | 'GC' | 'FR3.3' | 'FR3.3/GB/G2' | 'GLOTT';
basePowerClass: string | null;
rollingResistanceA: number;
rollingResistanceB: number;
rollingResistanceC: number;
electricalPowerStartupTime: number | null;
raisePantographTime: number | null;
defaultMode: string | null;
effortCurves: EffortCurves;
basePowerClass: string | null;
};

export type SchemaProperty = {
Expand Down Expand Up @@ -121,6 +121,7 @@ export enum RollingStockEditorParameter {
gammaValue = 'gammaValue',
inertiaCoefficient = 'inertiaCoefficient',
loadingGauge = 'loadingGauge',
basePowerClass = 'basePowerClass',
rollingResistanceA = 'rollingResistanceA',
rollingResistanceB = 'rollingResistanceB',
rollingResistanceC = 'rollingResistanceC',
Expand Down Expand Up @@ -243,6 +244,11 @@ export const RollingStockSchemaProperties: SchemaProperty[] = [
enum: ['G1', 'G2', 'GA', 'GB', 'GB1', 'GC', 'FR3.3', 'FR3.3/GB/G2', 'GLOTT'],
side: 'middle',
},
{
title: 'basePowerClass',
type: 'string',
side: 'middle',
},
{
title: 'rollingResistanceA',
type: 'number',
Expand Down
3 changes: 2 additions & 1 deletion front/src/modules/rollingStock/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export const rollingStockEditorQueryArg = (
unit: data.unit,
},
effort_curves: currentRsEffortCurve,
base_power_class: data.basePowerClass || '5',
// TODO : change it to null by default after #5204 merged
base_power_class: data.basePowerClass || '',
});

export const createEmptyCurve = (
Expand Down
7 changes: 7 additions & 0 deletions front/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4381,6 +4381,13 @@
"@types/react" "*"
csstype "^3.0.2"

"@types/react-modal@^3.16.0":
version "3.16.1"
resolved "https://registry.yarnpkg.com/@types/react-modal/-/react-modal-3.16.1.tgz#0d65e078b1290acfef8083b8cd92b7692e899720"
integrity sha512-HsH2E3luJ2hdVOAovq93x/r+CmWqbhwT8hXW05KMp3zzbSEZsBn4egnMGU/VLwScwlCRPTyZgIEPqLycaz5EOw==
dependencies:
"@types/react" "*"

"@types/react-redux@^7.1.20":
version "7.1.25"
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.25.tgz#de841631205b24f9dfb4967dd4a7901e048f9a88"
Expand Down

0 comments on commit 6d14e30

Please sign in to comment.