Skip to content

Commit 3088f2f

Browse files
committed
Implementatie uitpakken van Lichtcircuit. Ook kleine aanpassing aan de afstand tussen lichtpunt en schakelaars in lichtcircuit zodat het schema er exact hetzelfde uit ziet na uitpakken.
1 parent 9b039d2 commit 3088f2f

File tree

4 files changed

+128
-5
lines changed

4 files changed

+128
-5
lines changed

builddate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
var CONF_builddate="20250119-200745"
1+
var CONF_builddate="20250122-195057"

eendraadschema.js

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ var __extends = (this && this.__extends) || (function () {
6969
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7070
};
7171
})();
72+
var __rest = (this && this.__rest) || function (s, e) {
73+
var t = {};
74+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75+
t[p] = s[p];
76+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
77+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79+
t[p[i]] = s[p[i]];
80+
}
81+
return t;
82+
};
7283
function deepClone(obj) {
7384
var _out = new obj.constructor;
7485
var getType = function (n) {
@@ -3834,7 +3845,7 @@ var Electro_Item = /** @class */ (function (_super) {
38343845
// -- Displays the Expand button for the Electro_item, in case the item is expandable --
38353846
Electro_Item.prototype.toHTMLFooter = function () {
38363847
if (this.isExpandable()) {
3837-
return (" <button title=\"Meerdere schakelaars omzetten in indivuele schakelaars\" style=\"background-color:lightblue;\" onclick=\"HLExpand(".concat(this.id, ")\">Uitpakken</button>"));
3848+
return (" <button title=\"Meerdere elementen (bvb schakelaars) omzetten in indivuele elementen\" style=\"background-color:lightblue;\" onclick=\"HLExpand(".concat(this.id, ")\">Uitpakken</button>"));
38383849
}
38393850
else {
38403851
return ("");
@@ -4611,8 +4622,58 @@ var Lichtcircuit = /** @class */ (function (_super) {
46114622
}
46124623
output += ", Aantal lichtpunten: " + this.selectPropToHTML('aantal_lichtpunten', ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]);
46134624
output += ", Adres/tekst: " + this.stringPropToHTML('adres', 5);
4625+
output += this.toHTMLFooter();
46144626
return (output);
46154627
};
4628+
Lichtcircuit.prototype.countExpandableElements = function () {
4629+
var countExpandableElements = (this.props.aantal_lichtpunten == "0") ? 0 : 1;
4630+
switch (this.props.type_schakelaar) {
4631+
case "enkelpolig":
4632+
case "dubbelpolig":
4633+
countExpandableElements += (+this.props.aantal_schakelaars);
4634+
break;
4635+
default:
4636+
countExpandableElements += 1;
4637+
}
4638+
return countExpandableElements;
4639+
};
4640+
Lichtcircuit.prototype.isExpandable = function () {
4641+
return this.countExpandableElements() > 1;
4642+
};
4643+
Lichtcircuit.prototype.expand = function () {
4644+
//Nieuwe schakelaars maken, alle eigenschappen kopieren behalve type en aantal_lichtpunten
4645+
//Het adres nemen we over van het this element
4646+
var schakelaars = new Schakelaars(this.sourcelist);
4647+
var _a = this.props, type = _a.type, aantal_lichtpunten = _a.aantal_lichtpunten, rest = __rest(_a, ["type", "aantal_lichtpunten"]);
4648+
Object.assign(schakelaars.props, rest);
4649+
schakelaars.props.adres = this.props.adres;
4650+
if (+(this.props.aantal_lichtpunten) > 0) { // Er is minstens 1 lichtpunt
4651+
// Eerst schakelaars in het schema hangen vlak voor het this element zodat ze een id krijgen
4652+
this.sourcelist.insertItemBeforeId(schakelaars, this.id);
4653+
// Dan het this element door een nieuw lichtpunt vervangen
4654+
var lichtpunt = new Lichtpunt(this.sourcelist);
4655+
lichtpunt.props.aantal = this.props.aantal_lichtpunten;
4656+
lichtpunt.props.is_halfwaterdicht = this.props.is_halfwaterdicht;
4657+
lichtpunt.id = this.id;
4658+
if (this.getParent().props.type == "Meerdere verbruikers") {
4659+
lichtpunt.parent = this.getParent().id;
4660+
}
4661+
else {
4662+
lichtpunt.parent = schakelaars.id;
4663+
}
4664+
var ordinal = this.sourcelist.getOrdinalById(this.id); // Deze kan hier pas komen want de ordinal is gewijzigd door het invoegen van de schakelaars
4665+
this.sourcelist.data[ordinal] = lichtpunt;
4666+
}
4667+
else { // enkel schakelaars
4668+
// Het this element door de schakelaars vervangen
4669+
schakelaars.id = this.id;
4670+
schakelaars.parent = this.getParent().id;
4671+
var ordinal = this.sourcelist.getOrdinalById(this.id);
4672+
this.sourcelist.data[ordinal] = schakelaars;
4673+
}
4674+
// schakelaars uitpakken in elementen
4675+
schakelaars.expand();
4676+
};
46164677
Lichtcircuit.prototype.toSVG = function (sitplan, mirrortext) {
46174678
var _a;
46184679
if (sitplan === void 0) { sitplan = false; }
@@ -4633,7 +4694,7 @@ var Lichtcircuit = /** @class */ (function (_super) {
46334694
}
46344695
if (this.props.aantal_lichtpunten >= 1) { //1 of meerdere lampen
46354696
// Teken de lamp
4636-
endx = startx + 30;
4697+
endx = startx + 29;
46374698
mySVG.data += '<line x1="' + startx + '" x2="' + endx + '" y1="25" y2="25" stroke="black" />'
46384699
+ '<use xlink:href="#lamp" x="' + endx + '" y="25" />';
46394700
// Teken aantal lampen en symbool 'h' voor halfwaterdicht
@@ -4654,6 +4715,7 @@ var Lichtcircuit = /** @class */ (function (_super) {
46544715
mySVG.data += "<text transform=\"scale(-1,1) translate(".concat(-2 * endx, ",0)\" x=\"").concat(endx, "\" y=\"10\" ").concat(textoptions, ">").concat(htmlspecialchars(print_str_upper), "</text>");
46554716
}
46564717
// Teken een leiding achter de lamp indien er nog kinderen zijn
4718+
endx++;
46574719
if (this.heeftVerbruikerAlsKind())
46584720
mySVG.data += '<line x1="' + endx + '" y1="25" x2="' + (endx + 10) + '" y2="25" stroke="black" />';
46594721
// Bepaal finale Bounding Box om het geheel te tekenen

src/List_Item/Electro_Item.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class Electro_Item extends List_Item {
181181

182182
toHTMLFooter() {
183183
if (this.isExpandable()) {
184-
return(` <button title="Meerdere schakelaars omzetten in indivuele schakelaars" style="background-color:lightblue;" onclick="HLExpand(${this.id})">Uitpakken</button>`);
184+
return(` <button title="Meerdere elementen (bvb schakelaars) omzetten in indivuele elementen" style="background-color:lightblue;" onclick="HLExpand(${this.id})">Uitpakken</button>`);
185185
} else {
186186
return("");
187187
}

src/List_Item/Schakelaars/Lichtcircuit.ts

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,69 @@ class Lichtcircuit extends Schakelaars {
4242

4343
output += ", Aantal lichtpunten: " + this.selectPropToHTML('aantal_lichtpunten',["0","1","2","3","4","5","6","7","8","9","10"]);
4444
output += ", Adres/tekst: " + this.stringPropToHTML('adres',5);
45+
46+
output += this.toHTMLFooter();
47+
4548
return(output);
4649
}
4750

51+
countExpandableElements(): number {
52+
let countExpandableElements = (this.props.aantal_lichtpunten == "0") ? 0 : 1;
53+
switch (this.props.type_schakelaar) {
54+
case "enkelpolig": case "dubbelpolig":
55+
countExpandableElements += (+this.props.aantal_schakelaars);
56+
break;
57+
default:
58+
countExpandableElements += 1;
59+
}
60+
return countExpandableElements;
61+
}
62+
63+
isExpandable() {
64+
return this.countExpandableElements() > 1;
65+
}
66+
67+
expand() {
68+
69+
//Nieuwe schakelaars maken, alle eigenschappen kopieren behalve type en aantal_lichtpunten
70+
//Het adres nemen we over van het this element
71+
let schakelaars = new Schakelaars(this.sourcelist);
72+
const {type, aantal_lichtpunten, ...rest} = this.props;
73+
Object.assign(schakelaars.props, rest);
74+
schakelaars.props.adres = this.props.adres;
75+
76+
if (+(this.props.aantal_lichtpunten) > 0) { // Er is minstens 1 lichtpunt
77+
78+
// Eerst schakelaars in het schema hangen vlak voor het this element zodat ze een id krijgen
79+
this.sourcelist.insertItemBeforeId(schakelaars,this.id);
80+
81+
// Dan het this element door een nieuw lichtpunt vervangen
82+
let lichtpunt = new Lichtpunt(this.sourcelist);
83+
lichtpunt.props.aantal = this.props.aantal_lichtpunten;
84+
lichtpunt.props.is_halfwaterdicht = this.props.is_halfwaterdicht;
85+
lichtpunt.id = this.id;
86+
if (this.getParent().props.type == "Meerdere verbruikers") {
87+
lichtpunt.parent = this.getParent().id;
88+
} else {
89+
lichtpunt.parent = schakelaars.id;
90+
}
91+
let ordinal = this.sourcelist.getOrdinalById(this.id); // Deze kan hier pas komen want de ordinal is gewijzigd door het invoegen van de schakelaars
92+
this.sourcelist.data[ordinal] = lichtpunt;
93+
94+
} else { // enkel schakelaars
95+
96+
// Het this element door de schakelaars vervangen
97+
schakelaars.id = this.id;
98+
schakelaars.parent = this.getParent().id;
99+
let ordinal = this.sourcelist.getOrdinalById(this.id);
100+
this.sourcelist.data[ordinal] = schakelaars;
101+
102+
}
103+
104+
// schakelaars uitpakken in elementen
105+
schakelaars.expand();
106+
}
107+
48108
toSVG(sitplan: boolean = false, mirrortext: boolean = false) {
49109
let mySVG:SVGelement = new SVGelement();
50110
let tekenKeten: Array<Schakelaar> = [];
@@ -65,7 +125,7 @@ class Lichtcircuit extends Schakelaars {
65125

66126
if (this.props.aantal_lichtpunten >= 1) { //1 of meerdere lampen
67127
// Teken de lamp
68-
endx = startx + 30;
128+
endx = startx + 29;
69129
mySVG.data += '<line x1="' + startx + '" x2="' + endx + '" y1="25" y2="25" stroke="black" />'
70130
+ '<use xlink:href="#lamp" x="' + endx + '" y="25" />';
71131

@@ -86,6 +146,7 @@ class Lichtcircuit extends Schakelaars {
86146
}
87147

88148
// Teken een leiding achter de lamp indien er nog kinderen zijn
149+
endx++;
89150
if (this.heeftVerbruikerAlsKind()) mySVG.data += '<line x1="'+endx+'" y1="25" x2="'+(endx+10)+'" y2="25" stroke="black" />';
90151

91152
// Bepaal finale Bounding Box om het geheel te tekenen

0 commit comments

Comments
 (0)