Skip to content
Snippets Groups Projects
Commit 76773c02 authored by François Grand's avatar François Grand
Browse files

fix: a linked parameter remains linked after deleting target module

refs #329
refs nghyd#571
parent c6dce7dd
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,7 @@ import { PreBarrageParams } from "./prebarrage/pre_barrage_params";
import { PbCloison } from "./prebarrage/pb_cloison";
import { PbBassin } from "./prebarrage/pb_bassin";
import { PbBassinParams } from "./prebarrage/pb_bassin_params";
import { ParamValueMode } from "./param/param-value-mode";
export class Session {
......@@ -198,6 +199,7 @@ export class Session {
for (const n of this._nubs) {
if (n.uid === sn.uid) {
this._nubs.splice(i, 1);
this.fixDanglingLinks();
return;
}
i++;
......@@ -205,6 +207,22 @@ export class Session {
throw new Error(`Session.deleteNub() : le Nub (uid ${sn.uid}) à supprimer n'a pas été trouvé`);
}
/**
* set parameters linked to non exsting modules to fixed mode
*/
private fixDanglingLinks() {
for (const n of this._nubs) {
for (const p of n.parameterIterator) {
if (p.valueMode === ParamValueMode.LINK) {
const targetId = p.referencedValue.nub.uid;
if (this.findNubByUid(targetId) === undefined) {
p.valueMode = ParamValueMode.SINGLE;
}
}
}
}
}
/**
* Returns a JSON representation of (a part of) the current session
* @param options an object having Nub uids as keys, with extra data object as values;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment