Skip to content

Commit da88001

Browse files
authored
1934 get stop roof from varustelutiedot table (#1938)
* Get stop.roof from armamentInfo entity * Small fix * Small tweak
1 parent ec1fa66 commit da88001

File tree

13 files changed

+52
-35
lines changed

13 files changed

+52
-35
lines changed

cypress/integration/nodeView.spec.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ const _fillStopRequiredFields = () => {
225225
cy.getTestElement('section').click();
226226
cy.getTestElement('dropdownOption').eq(2).click();
227227

228-
cy.getTestElement('roof').click();
229-
cy.getTestElement('dropdownOption').first().click();
230-
231228
cy.getTestElement('tariffi').click();
232229
cy.getTestElement('dropdownOption').first().click();
233230
};

src/codeLists/propertyCodeLists.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const stopPropertyCodeList: IStopPropertyCodeList = {
3535
modifiedBy: 'MUOKANNUT',
3636
modifiedOn: 'MUOKATTU PVM',
3737
platform: 'LAITURI',
38-
roof: 'PYSÄKKIKATOS',
3938
radius: 'SÄDE',
4039
hastusId: 'HASTUS-PAIKKA',
4140
stopAreaId: 'PYSÄKKIALUE',

src/components/overlays/SavePrompt.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ const _getPropertyValue = (model: Model, property: string, data: Object | null,
130130
},
131131
stop: {
132132
municipality: () => codeListStore.getCodeListLabel('Kunta (KELA)', value),
133-
roof: () => codeListStore.getCodeListLabel('Pysäkkityyppi', value),
134133
tariffi: () => codeListStore.getCodeListLabel('Tariffialue', value),
135134
},
136135
stopArea: {

src/components/sidebar/nodeView/StopForm.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import InputContainer from '~/components/controls/InputContainer';
1010
import TextContainer from '~/components/controls/TextContainer';
1111
import ButtonType from '~/enums/buttonType';
1212
import { INode, IStop } from '~/models';
13+
import IArmamentInfo from '~/models/IArmamentInfo';
1314
import IHastusArea from '~/models/IHastusArea';
1415
import IStopArea from '~/models/IStopArea';
1516
import navigator from '~/routing/navigator';
@@ -48,34 +49,37 @@ interface IStopFormProps {
4849
}
4950

5051
interface IStopFormState {
51-
isRiseCountLoading: boolean;
52-
riseCount: number;
52+
isArmamentInfoLoading: boolean;
53+
passengerCount: number;
54+
roof: string;
5355
}
5456

5557
@inject('codeListStore', 'nodeStore', 'modalStore')
5658
@observer
5759
class StopForm extends Component<IStopFormProps, IStopFormState> {
5860
state = {
59-
isRiseCountLoading: true,
60-
riseCount: 0,
61+
isArmamentInfoLoading: true,
62+
passengerCount: 0,
63+
roof: '',
6164
};
6265
componentDidMount() {
63-
this.fetchRiseCount();
66+
this.fetchArmamentInfo();
6467
}
6568

66-
private fetchRiseCount = async () => {
69+
private fetchArmamentInfo = async () => {
6770
if (this.props.isNewStop) {
6871
return;
6972
}
7073
this.setState({
71-
isRiseCountLoading: true,
74+
isArmamentInfoLoading: true,
7275
});
73-
const riseCount = await StopService.fetchRiseCount({
76+
const armamentInfo: IArmamentInfo = await StopService.fetchArmamentInfo({
7477
nodeId: this.props.node.id,
7578
});
7679
this.setState({
77-
riseCount,
78-
isRiseCountLoading: false,
80+
passengerCount: armamentInfo.passengerCount,
81+
roof: armamentInfo.roof,
82+
isArmamentInfoLoading: false,
7983
});
8084
};
8185

@@ -360,13 +364,11 @@ class StopForm extends Component<IStopFormProps, IStopFormState> {
360364
data-cy='section'
361365
/>
362366
<Dropdown
363-
onChange={updateStopProperty!('roof')}
364367
items={this.props.codeListStore!.getDropdownItemList('Pysäkkityyppi')}
365-
selected={stop.roof}
366-
disabled={isEditingDisabled}
368+
selected={this.state.roof}
369+
isLoading={this.state.isArmamentInfoLoading}
370+
disabled={true}
367371
label='PYSÄKKIKATOS'
368-
validationResult={stopInvalidPropertiesMap['roof']}
369-
data-cy='roof'
370372
/>
371373
</div>
372374
<div className={s.flexRow}>
@@ -445,9 +447,9 @@ class StopForm extends Component<IStopFormProps, IStopFormState> {
445447
{!this.props.isNewStop && (
446448
<div className={s.flexRow}>
447449
<TextContainer
448-
isLoading={this.state.isRiseCountLoading}
450+
isLoading={this.state.isArmamentInfoLoading}
449451
label='NOUSIJAMÄÄRÄ'
450-
value={this.state.riseCount}
452+
value={this.state.passengerCount}
451453
/>
452454
</div>
453455
)}

src/factories/nodeStopFactory.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class StopFactory {
2222
placeNameFi: node.pyspaikannimi,
2323
placeNameSw: node.pyspaikannimir,
2424
platform: node.pyslaituri,
25-
roof: node.pyskatos,
2625
postalNumber: node.postinro,
2726
section: node.vyohyke,
2827
};
@@ -48,7 +47,6 @@ class StopFactory {
4847
placeNameFi: '',
4948
placeNameSw: '',
5049
platform: '',
51-
roof: '',
5250
postalNumber: '',
5351
section: '',
5452
};

src/models/IArmamentInfo.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface IArmamentInfo {
2+
passengerCount: number;
3+
roof: string;
4+
}
5+
6+
export default IArmamentInfo;

src/models/IStop.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export default interface IStop extends IStopPrimaryKey {
1313
modifiedBy?: string;
1414
modifiedOn?: Date;
1515
platform?: string;
16-
roof: string;
1716
radius: number;
1817
hastusId?: string;
1918
stopAreaId?: string;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface IExternalArmamentInfo {
2+
nousijat: number;
3+
pysakkityyppi: string;
4+
}
5+
6+
export default IExternalArmamentInfo;

src/models/externals/IExternalStop.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export default interface IExternalStop {
1111
pyskuka?: string;
1212
pysviimpvm?: Date;
1313
pyslaituri?: string;
14-
pyskatos: string;
1514
pystyyppi: string;
1615
pyssade: number;
1716
pyssuunta: string;

src/models/validationModels/stopValidationModel.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const stopValidationModel: IStopValidationModel = {
2121
modifiedBy: '',
2222
modifiedOn: '',
2323
platform: `min:0|max:3|string`,
24-
roof: 'required|min:2|max:2|string',
2524
radius: `required|min:0|max:${constants.INTEGER_MAX_VALUE}|numeric`,
2625
hastusId: 'min:0|max:6|string',
2726
stopAreaId: 'required|min:0|max:6|string',

0 commit comments

Comments
 (0)