Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ng-container *ngIf="startPoint.type === 'alarmGroup'">
<ng-container *ngIf="startPoint.type === 'alarmGroupStartPoint'">
{{ startPoint.alarmGroupName }}
</ng-container>
<app-transfer-point-name
*ngIf="startPoint.type === 'transferPoint'"
*ngIf="startPoint.type === 'transferStartPoint'"
[transferPointId]="startPoint.transferPointId"
></app-transfer-point-name>
12 changes: 6 additions & 6 deletions shared/src/models/utils/start-points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { getCreate } from './get-create';
export type StartPoint = AlarmGroupStartPoint | TransferStartPoint;
Comment thread
lukasrad02 marked this conversation as resolved.

export class TransferStartPoint {
@IsValue('transferPoint' as const)
public readonly type = 'transferPoint';
@IsValue('transferStartPoint' as const)
public readonly type = 'transferStartPoint';

@IsUUID(4, uuidValidationOptions)
public readonly transferPointId: UUID;
Expand All @@ -24,8 +24,8 @@ export class TransferStartPoint {
}

export class AlarmGroupStartPoint {
@IsValue('alarmGroup' as const)
public readonly type = 'alarmGroup';
@IsValue('alarmGroupStartPoint' as const)
public readonly type = 'alarmGroupStartPoint';

@IsString()
public readonly alarmGroupName: string;
Expand All @@ -51,11 +51,11 @@ export const startPointTypeOptions: TypeOptions = {
property: 'type',
subTypes: [
{
name: 'alarmGroup',
name: 'alarmGroupStartPoint',
value: AlarmGroupStartPoint,
},
{
name: 'transferPoint',
name: 'transferStartPoint',
value: TransferStartPoint,
},
],
Expand Down
143 changes: 143 additions & 0 deletions shared/src/state-migrations/19-rename-start-point-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import type { UUID } from '../utils';
import type { Migration } from './migration-functions';

export const renameStartPointTypes19: Migration = {
actions: (_initialState, actions) => {
actions.forEach((action) => {
if (
(action as { type: string } | null)?.type ===
'[Transfer] Add to transfer'
) {
const typedAction = action as {
startPoint: {
type:
| 'alarmGroup'
| 'alarmGroupStartPoint'
| 'transferPoint'
| 'transferStartPoint';
};
};
if (typedAction.startPoint.type === 'alarmGroup') {
typedAction.startPoint.type = 'alarmGroupStartPoint';
} else if (typedAction.startPoint.type === 'transferPoint') {
typedAction.startPoint.type = 'transferStartPoint';
}
}
});
},
state: (state) => {
const typedState = state as {
materials: {
[materialId: UUID]: {
position:
| {
type: 'transfer';
transfer: {
startPoint: {
type:
| 'alarmGroup'
| 'alarmGroupStartPoint'
| 'transferPoint'
| 'transferStartPoint';
};
};
}
| { type: 'coordinates' }
| { type: 'simulatedRegion' }
| { type: 'vehicle' };
Comment thread
lukasrad02 marked this conversation as resolved.
Outdated
};
};
vehicles: {
[vehicleId: UUID]: {
position:
| {
type: 'transfer';
transfer: {
startPoint: {
type:
| 'alarmGroup'
| 'alarmGroupStartPoint'
| 'transferPoint'
| 'transferStartPoint';
};
};
}
| { type: 'coordinates' }
| { type: 'simulatedRegion' }
| { type: 'vehicle' };
};
};
personnel: {
[personnelId: UUID]: {
position:
| {
type: 'transfer';
transfer: {
startPoint: {
type:
| 'alarmGroup'
| 'alarmGroupStartPoint'
| 'transferPoint'
| 'transferStartPoint';
};
};
}
| { type: 'coordinates' }
| { type: 'simulatedRegion' }
| { type: 'vehicle' };
};
};
};

Object.values(typedState.materials).forEach((material) => {
if (material.position.type === 'transfer') {
if (
material.position.transfer.startPoint.type === 'alarmGroup'
) {
material.position.transfer.startPoint.type =
'alarmGroupStartPoint';
} else if (
material.position.transfer.startPoint.type ===
'transferPoint'
) {
material.position.transfer.startPoint.type =
'transferStartPoint';
}
}
});

Object.values(typedState.vehicles).forEach((vehicle) => {
if (vehicle.position.type === 'transfer') {
if (
vehicle.position.transfer.startPoint.type === 'alarmGroup'
) {
vehicle.position.transfer.startPoint.type =
'alarmGroupStartPoint';
} else if (
vehicle.position.transfer.startPoint.type ===
'transferPoint'
) {
vehicle.position.transfer.startPoint.type =
'transferStartPoint';
}
}
});

Object.values(typedState.personnel).forEach((personnel) => {
if (personnel.position.type === 'transfer') {
if (
personnel.position.transfer.startPoint.type === 'alarmGroup'
) {
personnel.position.transfer.startPoint.type =
'alarmGroupStartPoint';
} else if (
personnel.position.transfer.startPoint.type ===
'transferPoint'
) {
personnel.position.transfer.startPoint.type =
'transferStartPoint';
}
}
});
},
};
2 changes: 2 additions & 0 deletions shared/src/state-migrations/migration-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { addSimulatedRegions15 } from './15-add-simulated-regions';
import { addMetaPosition16 } from './16-add-meta-position';
import { addTypeProperty17 } from './17-add-type-property';
import { replacePositionWithMetaPosition18 } from './18-replace-position-with-meta-position';
import { renameStartPointTypes19 } from './19-rename-start-point-types';
import { updateEocLog3 } from './3-update-eoc-log';
import { removeSetParticipantIdAction4 } from './4-remove-set-participant-id-action';
import { removeStatistics5 } from './5-remove-statistics';
Expand Down Expand Up @@ -59,4 +60,5 @@ export const migrations: {
16: addMetaPosition16,
17: addTypeProperty17,
18: replacePositionWithMetaPosition18,
19: renameStartPointTypes19,
};
2 changes: 1 addition & 1 deletion shared/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ export class ExerciseState {
*
* This number MUST be increased every time a change to any object (that is part of the state or the state itself) is made in a way that there may be states valid before that are no longer valid.
*/
static readonly currentStateVersion = 18;
static readonly currentStateVersion = 19;
}
2 changes: 1 addition & 1 deletion shared/src/store/action-reducers/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export namespace TransferActionReducers {

// Get the duration
let duration: number;
if (startPoint.type === 'transferPoint') {
if (startPoint.type === 'transferStartPoint') {
const transferStartPoint = getElement(
draftState,
'transferPoint',
Expand Down