@@ -3831,6 +3831,15 @@ var Electro_Item = /** @class */ (function (_super) {
3831
3831
output += this.selectPropToHTML('type', consumerArray);
3832
3832
return (output);
3833
3833
};
3834
+ // -- Displays the Expand button for the Electro_item, in case the item is expandable --
3835
+ Electro_Item.prototype.toHTMLFooter = function () {
3836
+ if (this.isExpandable()) {
3837
+ return (" <button title=\"Meerdere schakelaars omzetten in indivuele schakelaars\" style=\"background-color:lightblue;\" onclick=\"HLExpand(".concat(this.id, ")\">Uitpakken</button>"));
3838
+ }
3839
+ else {
3840
+ return ("");
3841
+ }
3842
+ };
3834
3843
// -- This one will get called if the type of the Electro_Item has not yet been chosen --
3835
3844
Electro_Item.prototype.toHTML = function (mode) { return (this.toHTMLHeader(mode)); }; // Implemented in the derived classes
3836
3845
// -- Get the number of the Electro_Item, if it is not defined, ask the parent
@@ -3904,6 +3913,21 @@ var Electro_Item = /** @class */ (function (_super) {
3904
3913
//this.updateSituationPlanElement(myElement); //Lijkt niet nodig aangezien dit zoiezo gebeurt in getScaledSVG bij iedere update
3905
3914
return (myElement);
3906
3915
};
3916
+ /**
3917
+ * Functie geeft aan of een Electro_Item nog verder kan uitgesplitst worden in kleinere Items.
3918
+ * Deze is vooral nuttig voor het situatieschema om groepen van schakelaars of een lichtcircuit te herkennen.
3919
+ */
3920
+ Electro_Item.prototype.isExpandable = function () {
3921
+ return false;
3922
+ };
3923
+ /**
3924
+ * Deze functie splitst een Electro_Item verder uit in kleinere Items. Dit is uiteraard enkel mogelijk indien isExpandable() true geeft.
3925
+ * De aanpassing wordt direct op de sourcelist uitgevoerd.
3926
+ */
3927
+ Electro_Item.prototype.expand = function () {
3928
+ if (!this.isExpandable())
3929
+ return;
3930
+ };
3907
3931
/**
3908
3932
* Geeft de boundary's terug van het element in het situatieplan. Deze boundary's worden gebruikt om het element te positioneren en te clippen.
3909
3933
*
@@ -4349,6 +4373,7 @@ var Schakelaars = /** @class */ (function (_super) {
4349
4373
break;
4350
4374
}
4351
4375
output += ", Adres/tekst: " + this.stringPropToHTML('adres', 5);
4376
+ output += this.toHTMLFooter();
4352
4377
return (output);
4353
4378
};
4354
4379
Schakelaars.prototype.bouwSchakelaarKeten = function (tekenKeten) {
@@ -4428,6 +4453,82 @@ var Schakelaars = /** @class */ (function (_super) {
4428
4453
break;
4429
4454
}
4430
4455
};
4456
+ Schakelaars.prototype.isExpandable = function () {
4457
+ switch (this.props.type_schakelaar) {
4458
+ case "enkelpolig":
4459
+ case "dubbelpolig":
4460
+ return (Number(this.props.aantal_schakelaars) > 1);
4461
+ default:
4462
+ return (false);
4463
+ }
4464
+ };
4465
+ Schakelaars.prototype.expand = function () {
4466
+ switch (this.props.type_schakelaar) {
4467
+ case "enkelpolig":
4468
+ if (Number(this.props.aantal_schakelaars) > 1) { // Er zijn er altijd 2 als er niet 1 is
4469
+ var adresGoesHere = Math.floor(this.props.aantal_schakelaars / 2);
4470
+ var schakelaar1 = new Schakelaars(this.sourcelist);
4471
+ Object.assign(schakelaar1.props, this.props);
4472
+ schakelaar1.props.aantal_schakelaars = 1;
4473
+ schakelaar1.props.type_schakelaar = "wissel_enkel";
4474
+ schakelaar1.props.adres = "";
4475
+ this.sourcelist.insertItemBeforeId(schakelaar1, this.id);
4476
+ var lastschakelaar = schakelaar1;
4477
+ for (var i = 0; i < Number(this.props.aantal_schakelaars) - 2; ++i) {
4478
+ var schakelaar = new Schakelaars(this.sourcelist);
4479
+ Object.assign(schakelaar.props, this.props);
4480
+ schakelaar.props.aantal_schakelaars = 1;
4481
+ schakelaar.props.type_schakelaar = "kruis_enkel";
4482
+ if (adresGoesHere == i + 1) {
4483
+ schakelaar.props.adres = this.props.adres;
4484
+ }
4485
+ else {
4486
+ schakelaar.props.adres = "";
4487
+ }
4488
+ if (this.getParent().props.type === "Meerdere verbruikers") {
4489
+ this.sourcelist.insertItemBeforeId(schakelaar, this.id);
4490
+ }
4491
+ else {
4492
+ this.sourcelist.insertChildAfterId(schakelaar, lastschakelaar.id);
4493
+ lastschakelaar = schakelaar;
4494
+ }
4495
+ }
4496
+ if (adresGoesHere == Number(this.props.aantal_schakelaars) - 1) {
4497
+ this.props.adres = this.props.adres;
4498
+ }
4499
+ else {
4500
+ this.props.adres = "";
4501
+ }
4502
+ this.props.aantal_schakelaars = 1;
4503
+ this.props.type_schakelaar = "wissel_enkel";
4504
+ if (this.getParent().props.type === "Meerdere verbruikers") {
4505
+ this.parent = this.getParent().id;
4506
+ }
4507
+ else {
4508
+ this.parent = lastschakelaar.id;
4509
+ }
4510
+ }
4511
+ break;
4512
+ case "dubbelpolig":
4513
+ if (Number(this.props.aantal_schakelaars) > 1) { // Er zijn er altijd 2 als er niet 1 is
4514
+ var schakelaar1 = new Schakelaars(this.sourcelist);
4515
+ Object.assign(schakelaar1.props, this.props);
4516
+ schakelaar1.props.aantal_schakelaars = 1;
4517
+ schakelaar1.props.type_schakelaar = "wissel_dubbel";
4518
+ schakelaar1.props.adres = "";
4519
+ this.sourcelist.insertItemBeforeId(schakelaar1, this.id);
4520
+ this.props.aantal_schakelaars = 1;
4521
+ this.props.type_schakelaar = "wissel_dubbel";
4522
+ if (this.getParent().props.type == "Meerdere verbruikers") {
4523
+ this.parent = this.getParent().id;
4524
+ }
4525
+ else {
4526
+ this.parent = schakelaar1.id;
4527
+ }
4528
+ }
4529
+ break;
4530
+ }
4531
+ };
4431
4532
Schakelaars.prototype.toSVG = function (sitplan, mirrortext) {
4432
4533
var _a;
4433
4534
if (sitplan === void 0) { sitplan = false; }
@@ -9255,6 +9356,15 @@ function HL_editmode() {
9255
9356
structure.mode = document.getElementById("edit_mode").value;
9256
9357
HLRedrawTreeHTML();
9257
9358
}
9359
+ function HLExpand(my_id) {
9360
+ var element = structure.getElectroItemById(my_id);
9361
+ if (element !== null) {
9362
+ element.expand();
9363
+ }
9364
+ structure.reSort();
9365
+ undostruct.store();
9366
+ HLRedrawTree();
9367
+ }
9258
9368
function HL_changeparent(my_id) {
9259
9369
// See what the new parentid is
9260
9370
var str_newparentid = document.getElementById("id_parent_change_" + my_id).value;
0 commit comments