Add locked property to Port and enhance port sorting logic#684
Add locked property to Port and enhance port sorting logic#684achrafmohye wants to merge 5 commits intomainfrom
Conversation
Signed-off-by: Achrafmohye <a.mohyeddine@gmail.com>
Signed-off-by: Alice Khoudli <alice.khoudli@polytechnique.org>
Signed-off-by: Achrafmohye <a.mohyeddine@gmail.com>
cfc6bb0 to
399b1d3
Compare
| positionIndex: number; // position index starts at 0, ... for each PortAlignment group | ||
| positionAlignment: PortAlignment; // defines corresponding PortAlignment group within the node | ||
| trainrunSectionId: number; // reference to the connected trainrun section | ||
| locked: boolean; |
There was a problem hiding this comment.
Please add short commeng for what this member 'locked' is used for
cf872e4 to
923f5d7
Compare
src/app/models/node.model.ts
Outdated
| originalPorts.forEach((port, index) => { | ||
| if (port.getLocked()) { | ||
| lockedIndexes.add(index); | ||
| portsToKeepLocked.push(port); |
There was a problem hiding this comment.
As I sent you before, you can simplify by dropping portsToKeepLocked doing something like :
sortPorts() {
const originalPorts = this.ports;
const lockedIndexes: Set<number> = new Set();
const portsToReorder: Port[] = [];
originalPorts.forEach((port, index) => {
if (port.getLocked()) {
lockedIndexes.add(index);
} else {
portsToReorder.push(port);
}
});
// Sort ONLY the unlocked ports
portsToReorder.sort((a, b) => {
return this.comparePorts(a, b);
});
// Insert locked ports back in their original places
const newPorts: Port[] = [];
let reorderedIndex = 0;
for (let index = 0; index < originalPorts.length; index++) {
if (lockedIndexes.has(index)) {
newPorts.push(originalPorts[index]);
} else {
newPorts.push(portsToReorder[reorderedIndex]);
reorderedIndex += 1;
}
}
this.ports = newPorts;
}
```…tions Signed-off-by: Achrafmohye <a.mohyeddine@gmail.com>
923f5d7 to
ccd74d8
Compare
|
I am not sure whether we have to migrate the new added Please dbl-check if required to migrate - if yes -> add it to : static migrateNetzgrafikDto(netzgrafikDto: NetzgrafikDto) { |
…compatibility Signed-off-by: Achrafmohye <a.mohyeddine@gmail.com>
Hi @aiAdrian, |
Close #634
Description
Port.lockedmarks a port position as user defined and immutable, automatic sorting ignore locked ports and arrange only the remaining ones around them, while preserving the locked layout across import, exportIssues
Checklist
documentation/