Skip to content

Commit 6bb7e25

Browse files
authored
Merge pull request #4569 from c2corg/smart-origin/ffcam_livraison1
feat: Smart/Origin: ffcam livraison1
2 parents 95f02bc + e5ff119 commit 6bb7e25

13 files changed

Lines changed: 2614 additions & 2373 deletions

File tree

Lines changed: 36 additions & 0 deletions
Loading

src/components/generics/inputs/InputAddress.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ export default {
224224
225225
/** Takes selected address proposition */
226226
selectAddress(proposition) {
227-
this.localData.selectedAddress = proposition;
228227
this.localData.address = this.formatProposition(proposition);
228+
this.localData.selectedAddress = proposition;
229+
this.localData.selectedAddress.address = this.localData.address;
229230
this.localData.coordinates = proposition.geometry.coordinates;
230231
this.localData.showAddressPropositions = false;
231232
},

src/js/plan-a-trip-utils.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
export default {
2+
/** Format time for displaying : YYYYMMDDTHHMMSS -> HH:MM */
3+
formatTime(dateTimeString) {
4+
if (!dateTimeString) return '';
5+
return dateTimeString.substring(9, 11) + ':' + dateTimeString.substring(11, 13);
6+
},
7+
8+
/** Format duration for displaying : h / min */
9+
formatDuration(seconds) {
10+
if (!seconds && seconds !== 0) return '';
11+
const hours = Math.floor(seconds / 3600);
12+
const minutes = Math.floor((seconds % 3600) / 60);
13+
14+
if (hours > 0) {
15+
return `${hours} h ${minutes > 0 ? minutes + ' min' : ''}`;
16+
}
17+
return `${minutes} min`;
18+
},
19+
20+
/** Gets icons according to the nature of the transport */
21+
getTransportIcon(section) {
22+
if (!section.display_informations) return '';
23+
24+
const mode = section.display_informations.commercial_mode?.toLowerCase() || '';
25+
if (mode.includes('bus')) return 'bus';
26+
if (mode.includes('tram')) return 'tram';
27+
if (mode.includes('métro') || mode.includes('metro')) return 'tram';
28+
if (mode.includes('train')) return 'train';
29+
if (mode.includes('car')) return 'bus';
30+
31+
return 'bus';
32+
},
33+
34+
/** Manage different spellings of transports */
35+
getTransportClass(section) {
36+
if (!section.display_informations) return '';
37+
38+
const mode = section.display_informations.commercial_mode?.toLowerCase() || '';
39+
40+
if (mode.includes('bus')) return 'bus';
41+
if (mode.includes('tram')) return 'tram';
42+
if (mode.includes('métro') || mode.includes('metro')) return 'tram';
43+
if (mode.includes('train')) return 'train';
44+
if (mode.includes('car')) return 'bus';
45+
46+
return 'bus';
47+
},
48+
49+
/** Method to calculate distance in meters */
50+
getDistance(section) {
51+
if (section.distance) {
52+
return Math.round(section.distance);
53+
}
54+
return section.path && section.path.length > 0
55+
? Math.round(section.path.reduce((acc, step) => acc + (step.length || 0), 0))
56+
: 0;
57+
},
58+
59+
/** Method to get accessibility icons */
60+
getAccessibilityIcon(section) {
61+
if (!section.display_informations || !section.display_informations.equipments) {
62+
return {
63+
bike: false,
64+
wheelchair: false,
65+
};
66+
}
67+
68+
return {
69+
bike: section.display_informations.equipments.includes('has_bike_accepted'),
70+
wheelchair: section.display_informations.equipments.includes('has_wheelchair'),
71+
};
72+
},
73+
74+
/** Each route follows the same sequence of colors */
75+
getRouteColor(section) {
76+
if (section.mode === 'walking') return '00008B';
77+
if (section.type === 'public_transport' || section.type === 'on_demand_transport') {
78+
const color = section.display_informations?.color;
79+
return color === 'FFFFFF' ? '808080' : color || '808080';
80+
}
81+
return '808080';
82+
},
83+
84+
/** Creates the class based on color */
85+
getTransportColorClass(section) {
86+
if (section.display_informations?.color) {
87+
return 'transport-color-' + section.display_informations.color.replace('#', '');
88+
}
89+
return 'transport-color-default';
90+
},
91+
92+
/** Formats the journey time in minutes and hours */
93+
formatJourneyDuration(seconds) {
94+
if (!seconds && seconds !== 0) return '';
95+
96+
const hours = Math.floor(seconds / 3600);
97+
const minutes = Math.floor((seconds % 3600) / 60);
98+
99+
if (hours > 0) {
100+
return `${hours}h${minutes.toString().padStart(2, '0')}`;
101+
}
102+
return `${minutes} min`;
103+
},
104+
105+
/** Get section duration directly when available, fallback to 0 */
106+
calculateSectionDuration(section) {
107+
if (section.duration !== undefined && section.duration !== null) {
108+
return section.duration;
109+
}
110+
return 0;
111+
},
112+
};

0 commit comments

Comments
 (0)