Skip to content

Commit bd28e0c

Browse files
authored
Merge pull request #36 from marvin-wtt/feat/swap-prev-group
feat: add label of the previous group to the swap icon
2 parents 0268e7e + f48dd44 commit bd28e0c

File tree

4 files changed

+67
-7
lines changed

4 files changed

+67
-7
lines changed

src/components/BaseFlight.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<base-vehicle-group
2525
v-for="(group, i) in flightSeries.vehicleGroups"
2626
:key="`vg-${i}`"
27-
:label="`Group ${String.fromCharCode(65 + i)}`"
27+
:label="`Group ${vehicleGroupLabel(i)}`"
2828
:flight-series
2929
:flight-leg
3030
:group
@@ -61,6 +61,7 @@ import { useFlightStore } from 'stores/flight';
6161
import { useProjectSettings } from 'src/composables/projectSettings';
6262
import { validateFlightLegAndSeries } from 'src/util/flight-validator';
6363
import { NULL_ID } from 'app/src-common/constants';
64+
import { vehicleGroupLabel } from 'src/util/group';
6465
6566
const flightStore = useFlightStore();
6667
const { availablePeople, availableCars, availableBalloons } =

src/components/BaseVehiclePersonCell.vue

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<div
3131
v-if="status"
32-
class="q-ml-xs"
32+
class="q-ml-xs no-wrap row items-center"
3333
>
3434
<q-icon
3535
:name="status.icon"
@@ -41,6 +41,14 @@
4141
{{ status.text }}
4242
</q-tooltip>
4343
</q-icon>
44+
45+
<span
46+
v-if="status.suffix"
47+
class="status-suffix"
48+
:class="`text-${status.color}`"
49+
>
50+
{{ status.suffix }}
51+
</span>
4452
</div>
4553
</div>
4654

@@ -104,6 +112,7 @@ import { useQuasar } from 'quasar';
104112
import { useProjectStore } from 'stores/project';
105113
import { useProjectSettings } from 'src/composables/projectSettings';
106114
import PersonInfoMenu from 'components/PersonInfoMenu.vue';
115+
import { vehicleGroupLabel } from 'src/util/group';
107116
108117
const quasar = useQuasar();
109118
const projectStore = useProjectStore();
@@ -149,6 +158,7 @@ interface StatusInfo {
149158
color: string;
150159
text: string;
151160
icon: string;
161+
suffix?: string | undefined;
152162
}
153163
154164
const flightsLabel = computed<string>(() => {
@@ -185,7 +195,7 @@ const status = computed<StatusInfo | undefined>(() => {
185195
operatorInfo.value,
186196
multiLegStatus.value,
187197
languageStatus.value,
188-
].filter((info) => info !== false)[0];
198+
].find((info): info is StatusInfo => info !== false);
189199
});
190200
191201
const overfillStatus: StatusInfo | false = overfilled
@@ -280,6 +290,7 @@ const multiLegStatus = computed<StatusInfo | false>(() => {
280290
icon: 'sym_o_swap_horiz',
281291
color: 'negative',
282292
text: `${person.name} was assigned to different group in previous flight`,
293+
suffix: findPreviousGroupLabel(person.id),
283294
};
284295
});
285296
@@ -334,13 +345,15 @@ function onDragEnd() {
334345
if (!person) {
335346
return;
336347
}
348+
337349
removePersonFromVehicle(person.id);
338350
}
339351
340352
function onEdit() {
341353
if (!project.value || !person) {
342354
return;
343355
}
356+
344357
quasar
345358
.dialog({
346359
component: EditPersonDialog,
@@ -381,21 +394,63 @@ function wasInSameVehicleGroupInPreviousLeg(personId: string): boolean {
381394
return false;
382395
}
383396
384-
// Collect all vehicle IDs of this group
385397
const groupVehicleIds = [group.balloonId, ...group.carIds];
386398
387-
// Check if person was in any of these vehicles in the first leg
388399
return groupVehicleIds.some((vid) => {
389400
const assignment = previousLeg.assignments[vid];
390401
if (!assignment) {
391402
return false;
392403
}
404+
393405
return (
394406
assignment.operatorId === personId ||
395407
assignment.passengerIds.includes(personId)
396408
);
397409
});
398410
}
411+
412+
function findPreviousGroupLabel(personId: string): string | undefined {
413+
if (isFirstLeg.value) {
414+
return undefined;
415+
}
416+
417+
const idx = flightSeries.legs.findIndex((l) => l.id === flightLeg.id);
418+
const previousLeg = flightSeries.legs[idx - 1];
419+
if (!previousLeg) {
420+
return undefined;
421+
}
422+
423+
const previousGroupIndex = flightSeries.vehicleGroups
424+
.map((group) => [group.balloonId, ...group.carIds])
425+
.findIndex((vehicleIds) => {
426+
return vehicleIds.some((vehicleId) => {
427+
const assignment = previousLeg.assignments[vehicleId];
428+
if (!assignment) {
429+
return false;
430+
}
431+
432+
return (
433+
assignment.operatorId === personId ||
434+
assignment.passengerIds.includes(personId)
435+
);
436+
});
437+
});
438+
439+
if (previousGroupIndex === -1) {
440+
return undefined;
441+
}
442+
443+
return vehicleGroupLabel(previousGroupIndex);
444+
}
399445
</script>
400446

401-
<style scoped></style>
447+
<style scoped>
448+
/* Compact “badge-like” suffix aligned to the icon */
449+
.status-suffix {
450+
margin-left: 2px;
451+
font-size: 0.8em;
452+
line-height: 1;
453+
font-weight: 600;
454+
vertical-align: middle;
455+
}
456+
</style>

src/components/PersonInfoMenu.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ import type {
163163
} from 'app/src-common/entities';
164164
import { storeToRefs } from 'pinia';
165165
import { useProjectStore } from 'stores/project';
166+
import { vehicleGroupLabel } from 'src/util/group';
166167
167168
const projectStore = useProjectStore();
168169
const { project } = storeToRefs(projectStore);
@@ -245,7 +246,7 @@ function buildHistoryForSeriesList(
245246
group.balloonId === vehicleId || group.carIds.includes(vehicleId),
246247
);
247248
const groupLetter =
248-
groupIndex >= 0 ? String.fromCharCode(65 + groupIndex) : undefined;
249+
groupIndex >= 0 ? vehicleGroupLabel(groupIndex) : undefined;
249250
250251
const existing = vehicleMapForSeries.get(vehicleId);
251252

src/util/group.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function vehicleGroupLabel(index: number): string {
2+
return String.fromCharCode(65 + index);
3+
}

0 commit comments

Comments
 (0)