Skip to content

Commit d116421

Browse files
committed
Aanpassingen helpertip:
- er kan nu aangegeven worden of de "nooit meer weergeven" optie per default aan staat voor een tip of niet. Bugfix schakelaars/lichtcircuit: - Defaukt symbolen werden niet correct toegevoegd aan SVGSymbols en daardoor niet altijdweergegeven in het situatieschema. Mousedrag class: - De mousedrag class heeft een nieuwe interne state om te checken of er effectief een drag (verandering van positie) heeft plaats gevonden of enkel een klik. SituationPlanElement: - Bugfix, probleem met het roteren van symbolen die werden geladen vanuit bestand over hoeken tussen 90 en 270 graden opgelost. SituationPlanView: - Rotatieprobleem opgelost (zie boven) - Pijltjestoetsen kunnen nu ook gebruikt worden voor verplaatsing van symbolen - Beperkte aanpassing van de helpertip voor het situatieschema zelf.
1 parent 61e2248 commit d116421

File tree

8 files changed

+139
-20
lines changed

8 files changed

+139
-20
lines changed

builddate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
var CONF_builddate="20250125-215843"
1+
var CONF_builddate="20250202-145724"

eendraadschema.js

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,8 +1753,9 @@ var HelperTip = /** @class */ (function () {
17531753
this.storagePrefix = storagePrefix;
17541754
}
17551755
// Show the helper tip if it hasn't been dismissed before
1756-
HelperTip.prototype.show = function (key, htmlContent) {
1756+
HelperTip.prototype.show = function (key, htmlContent, checked) {
17571757
var _this = this;
1758+
if (checked === void 0) { checked = false; }
17581759
var neverDisplayKey = "".concat(this.storagePrefix, ".").concat(key, ".neverDisplay");
17591760
var displayedInThisSessionKey = "".concat(this.storagePrefix, ".").concat(key, ".displayedInThisSession");
17601761
// Check if the tip was dismissed before
@@ -1799,8 +1800,9 @@ var HelperTip = /** @class */ (function () {
17991800
checkboxLabel.style.marginTop = '10px';
18001801
var checkbox = document.createElement('input');
18011802
checkbox.type = 'checkbox';
1803+
checkbox.checked = checked;
18021804
checkboxLabel.appendChild(checkbox);
1803-
var checkboxText = document.createTextNode(' Deze tekst niet meer weergeven');
1805+
var checkboxText = document.createTextNode(' Deze tekst nooit meer weergeven in deze browser.');
18041806
var italicText = document.createElement('i');
18051807
italicText.appendChild(checkboxText);
18061808
checkboxLabel.appendChild(italicText);
@@ -1991,6 +1993,7 @@ var MouseDrag = /** @class */ (function () {
19911993
this.startOffsetLeft = 0;
19921994
this.startOffsetTop = 0;
19931995
this.zoomfactor = 1;
1996+
this.hassMoved = false;
19941997
}
19951998
/**
19961999
* Start the drag.
@@ -2011,6 +2014,7 @@ var MouseDrag = /** @class */ (function () {
20112014
this.startOffsetLeft = startOffsetLeft;
20122015
this.startOffsetTop = startOffsetTop;
20132016
this.zoomfactor = zoomfactor;
2017+
this.hassMoved = false;
20142018
};
20152019
/**
20162020
* Return the new left and top position of the box based on the current mouse position.
@@ -2021,6 +2025,8 @@ var MouseDrag = /** @class */ (function () {
20212025
MouseDrag.prototype.returnNewLeftTop = function (mousex, mousey) {
20222026
if (mousex === void 0) { mousex = 0; }
20232027
if (mousey === void 0) { mousey = 0; }
2028+
if (mousex != this.startDragx || mousey != this.startDragy)
2029+
this.hassMoved = true;
20242030
return ({
20252031
left: (mousex - this.startDragx) / this.zoomfactor + this.startOffsetLeft,
20262032
top: (mousey - this.startDragy) / this.zoomfactor + this.startOffsetTop
@@ -2333,7 +2339,7 @@ var SituationPlanElement = /** @class */ (function () {
23332339
}
23342340
return false;
23352341
};
2336-
SituationPlanElement.prototype.rotates360degrees = function () {
2342+
SituationPlanElement.prototype.isEDSSymbolAndRotates360degrees = function () {
23372343
if (this.isEendraadschemaSymbool()) {
23382344
var electroElement = structure.getElectroItemById(this.electroItemId);
23392345
if (electroElement != null) {
@@ -2342,7 +2348,7 @@ var SituationPlanElement = /** @class */ (function () {
23422348
}
23432349
return false;
23442350
}
2345-
return true;
2351+
return false;
23462352
};
23472353
/**
23482354
* setAdres
@@ -2482,7 +2488,7 @@ var SituationPlanElement = /** @class */ (function () {
24822488
rotate = rotate % 360;
24832489
var spiegel = false;
24842490
if ((rotate >= 90) && (rotate < 270)) {
2485-
if (_this.rotates360degrees())
2491+
if (_this.isEDSSymbolAndRotates360degrees())
24862492
spiegel = true;
24872493
if (_this.isEendraadschemaSymbool())
24882494
rotate = rotate + 180;
@@ -2682,15 +2688,23 @@ var SituationPlanView = /** @class */ (function () {
26822688
* @param event - De gebeurtenis die de sleepactie stopt (muisklik release of touchend).
26832689
*/
26842690
this.stopDrag = function (event) {
2691+
function showArrowHelp() {
2692+
var helperTip = new HelperTip(appDocStorage);
2693+
helperTip.show('sitplan.arrowdrag', "<h3>Tip: Symbolen verplaatsen</h3>\n <p>Voor fijnere controle tijdens het verschuiven van symbolen kan u ook de pijltjes op het toetsenbord gebruiken.</p>", true);
2694+
}
26852695
event.stopPropagation();
26862696
switch (event.type) {
26872697
case 'mouseup':
26882698
document.removeEventListener('mousemove', _this.processDrag);
26892699
document.removeEventListener('mouseup', _this.stopDrag);
2700+
if (_this.mousedrag.hassMoved)
2701+
showArrowHelp();
26902702
break;
26912703
case 'touchend':
26922704
document.removeEventListener('touchmove', _this.processDrag);
26932705
document.removeEventListener('touchend', _this.stopDrag);
2706+
if (_this.mousedrag.hassMoved)
2707+
showArrowHelp();
26942708
break;
26952709
default:
26962710
console.error('Ongeldige event voor stopDrag functie');
@@ -2733,6 +2747,8 @@ var SituationPlanView = /** @class */ (function () {
27332747
// Verwijder alle selecties wanneer we ergens anders klikken dan op een box
27342748
this.event_manager.addEventListener(outerdiv, 'mousedown', function () { _this.clearSelection(); });
27352749
this.event_manager.addEventListener(outerdiv, 'touchstart', function () { _this.clearSelection(); });
2750+
// Voegt event handlers toe voor de pijltjestoesten
2751+
this.attachArrowKeys();
27362752
}
27372753
/**
27382754
* Maakt deze instance ongedaan en verwijderd alle door deze instance aangemaakte elementen uit de DOM.
@@ -2945,10 +2961,13 @@ var SituationPlanView = /** @class */ (function () {
29452961
function getRotationTransform(sitPlanElement) {
29462962
if (!sitPlanElement)
29472963
return '';
2948-
var rotation = sitPlanElement.rotate % 360;
2964+
var rotation = sitPlanElement.rotate;
2965+
while (rotation < 0)
2966+
rotation += 360;
2967+
rotation = rotation % 360;
29492968
var spiegel = false;
29502969
if ((rotation >= 90) && (rotation < 270)) {
2951-
if (sitPlanElement.rotates360degrees())
2970+
if (sitPlanElement.isEDSSymbolAndRotates360degrees())
29522971
spiegel = true;
29532972
if (sitPlanElement.isEendraadschemaSymbool())
29542973
rotation -= 180;
@@ -3157,6 +3176,45 @@ var SituationPlanView = /** @class */ (function () {
31573176
}
31583177
this.updateRibbon();
31593178
};
3179+
/**
3180+
* Voegt eventlisteners toe om pijltjestoetsen te hanteren.
3181+
*
3182+
* Wanneer een pijltjestoets wordt ingedrukt, en er is een box geselecteerd, dan wordt de positie van de box aangepast.
3183+
* De positie van de box wordt aangepast door de posx of posy van het element in het situatieplan te veranderen.
3184+
* Daarna wordt de functie updateSymbolAndLabelPosition aangeroepen om de positie van het symbool en het label van de box te updaten.
3185+
*/
3186+
SituationPlanView.prototype.attachArrowKeys = function () {
3187+
var _this = this;
3188+
this.event_manager.addEventListener(document, 'keydown', function (event) {
3189+
if (_this.outerdiv.style.display == 'none')
3190+
return; // Check if we are really in the situationplan, if not, the default scrolling action will be executed by the browser
3191+
if (document.getElementById('popupOverlay') != null)
3192+
return; // We need the keys when editing symbol properties.
3193+
if (_this.selectedBox) { // Check if we have a selected box, if not, the default scrolling action will be executed by the browser
3194+
event.preventDefault();
3195+
var sitPlanElement = _this.selectedBox.sitPlanElementRef;
3196+
if (!sitPlanElement)
3197+
return;
3198+
switch (event.key) {
3199+
case 'ArrowLeft':
3200+
sitPlanElement.posx -= 1;
3201+
break;
3202+
case 'ArrowRight':
3203+
sitPlanElement.posx += 1;
3204+
break;
3205+
case 'ArrowUp':
3206+
sitPlanElement.posy -= 1;
3207+
break;
3208+
case 'ArrowDown':
3209+
sitPlanElement.posy += 1;
3210+
break;
3211+
default:
3212+
return;
3213+
}
3214+
_this.updateSymbolAndLabelPosition(sitPlanElement);
3215+
}
3216+
});
3217+
};
31603218
/**
31613219
* Hangt een klik event listener aan het gegeven element met als doel de huidig geselecteerde box te verwijderen.
31623220
*
@@ -3371,7 +3429,7 @@ function showSituationPlanPage() {
33713429
structure.sitplanview.redraw();
33723430
// Initialize the HelperTip with the storage
33733431
var helperTip = new HelperTip(appDocStorage);
3374-
helperTip.show('sitplan.introductie', "<h3>Situatieschema</h3>\n <p>Op deze pagina kan u een situatieschema tekenen</p>\n <p>Laad een plattegrond met de knop \"Uit bestand\" en voeg symbolen toe met de knop \"Uit schema\".</p>\n <p>Klik <a href=\"Documentation/sitplandoc.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">hier</a> om in een nieuw venster de documentatie te bekijken.</p>\n <p>Het situatieschema werd recent toegevoegd aan het programma en zal nog verder ontwikkeld worden over de komende weken. Opmerkingen zijn welkom in het \"contact\"-formulier.</p>");
3432+
helperTip.show('sitplan.introductie', "<h3>Situatieschema tekenen</h3>\n <p>Op deze pagina kan u een situatieschema tekenen.</p>\n <p>Laad een plattegrond met de knop \"Uit bestand\" en voeg symbolen toe met de knop \"Uit schema\".</p>\n <p>Klik <a href=\"Documentation/sitplandoc.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">hier</a> om in een nieuw venster de documentatie te bekijken.</p>\n <p>Het situatieschema werd recent toegevoegd aan het programma en zal nog verder ontwikkeld worden over de komende weken. Opmerkingen zijn welkom in het \"contact\"-formulier.</p>");
33753433
}
33763434
/**
33773435
* Een serie functies om een formulier te tonen met edit-functionaliteiten voor symbolen in het situatieplan
@@ -4402,7 +4460,7 @@ var Schakelaar = /** @class */ (function () {
44024460
Schakelaar.prototype.defaulttoDrawReturnObj = function (startx, symbol) {
44034461
var outputstr = "";
44044462
var endx = startx + 20;
4405-
SVGSymbols.addSymbol(symbol);
4463+
SVGSymbols.addSymbol(symbol.substring(1));
44064464
outputstr += '<line x1="' + startx + '" x2="' + endx + '" y1="25" y2="25" stroke="black" />'
44074465
+ '<use xlink:href="' + symbol + '" x="' + endx + '" y="25" />';
44084466
return ({ endx: endx, str: outputstr, lowerbound: null });
@@ -4932,6 +4990,7 @@ var Lichtcircuit = /** @class */ (function (_super) {
49324990
if (this.props.aantal_lichtpunten >= 1) { //1 of meerdere lampen
49334991
// Teken de lamp
49344992
endx = startx + 29;
4993+
SVGSymbols.addSymbol('lamp');
49354994
mySVG.data += '<line x1="' + startx + '" x2="' + endx + '" y1="25" y2="25" stroke="black" />'
49364995
+ '<use xlink:href="#lamp" x="' + endx + '" y="25" />';
49374996
// Teken aantal lampen en symbool 'h' voor halfwaterdicht

src/List_Item/Schakelaars/Lichtcircuit.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ class Lichtcircuit extends Schakelaars {
126126
if (this.props.aantal_lichtpunten >= 1) { //1 of meerdere lampen
127127
// Teken de lamp
128128
endx = startx + 29;
129+
130+
SVGSymbols.addSymbol('lamp');
129131
mySVG.data += '<line x1="' + startx + '" x2="' + endx + '" y1="25" y2="25" stroke="black" />'
130132
+ '<use xlink:href="#lamp" x="' + endx + '" y="25" />';
131133

src/List_Item/Schakelaars/Schakelaar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class Schakelaar {
227227
let outputstr:string = "";
228228
let endx = startx + 20;
229229

230-
SVGSymbols.addSymbol(symbol);
230+
SVGSymbols.addSymbol(symbol.substring(1));
231231

232232
outputstr += '<line x1="' + startx + '" x2="' + endx + '" y1="25" y2="25" stroke="black" />'
233233
+ '<use xlink:href="' + symbol + '" x="' + endx + '" y="25" />';

src/documentation/HelperTip.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class HelperTip {
88
}
99

1010
// Show the helper tip if it hasn't been dismissed before
11-
show(key: string, htmlContent: string): void {
11+
show(key: string, htmlContent: string, checked: boolean = false): void {
1212
const neverDisplayKey = `${this.storagePrefix}.${key}.neverDisplay`;
1313
const displayedInThisSessionKey = `${this.storagePrefix}.${key}.displayedInThisSession`;
1414

@@ -60,9 +60,10 @@ class HelperTip {
6060

6161
const checkbox = document.createElement('input');
6262
checkbox.type = 'checkbox';
63+
checkbox.checked = checked;
6364
checkboxLabel.appendChild(checkbox);
6465

65-
const checkboxText = document.createTextNode(' Deze tekst niet meer weergeven');
66+
const checkboxText = document.createTextNode(' Deze tekst nooit meer weergeven in deze browser.');
6667
const italicText = document.createElement('i');
6768
italicText.appendChild(checkboxText);
6869
checkboxLabel.appendChild(italicText);

src/sitplan/MouseDrag.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class MouseDrag {
1010
private startOffsetTop: number = 0;
1111
private zoomfactor: number = 1;
1212

13+
public hassMoved: boolean = false;
14+
1315
/**
1416
* Start the drag.
1517
* @param mousex The x position of the mouse when the drag starts.
@@ -26,6 +28,7 @@ class MouseDrag {
2628
this.startOffsetLeft = startOffsetLeft;
2729
this.startOffsetTop = startOffsetTop;
2830
this.zoomfactor = zoomfactor;
31+
this.hassMoved = false;
2932
}
3033

3134
/**
@@ -35,6 +38,7 @@ class MouseDrag {
3538
* @returns An object with the new left and top position of the box.
3639
*/
3740
returnNewLeftTop(mousex: number = 0, mousey: number = 0) {
41+
if (mousex != this.startDragx || mousey != this.startDragy) this.hassMoved = true;
3842
return ( {
3943
left: (mousex - this.startDragx) / this.zoomfactor + this.startOffsetLeft,
4044
top: (mousey - this.startDragy) / this.zoomfactor + this.startOffsetTop});

src/sitplan/SituationPlanElement.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class SituationPlanElement {
9999

100100
private static readonly ROTATES_360_DEGREES_TYPES = new Set(['Contactdoos','Lichtpunt','Drukknop','Media','Schakelaars','Lichtcircuit']);
101101

102-
rotates360degrees(): boolean {
102+
isEDSSymbolAndRotates360degrees(): boolean {
103103
if (this.isEendraadschemaSymbool()) {
104104
let electroElement: Electro_Item = structure.getElectroItemById(this.electroItemId);
105105
if (electroElement != null) {
@@ -108,7 +108,7 @@ class SituationPlanElement {
108108
}
109109
return false;
110110
}
111-
return true;
111+
return false;
112112
}
113113

114114
/**
@@ -254,7 +254,7 @@ class SituationPlanElement {
254254
let spiegel = false;
255255

256256
if ( (rotate >= 90) && (rotate < 270) ) {
257-
if (this.rotates360degrees()) spiegel = true;
257+
if (this.isEDSSymbolAndRotates360degrees()) spiegel = true;
258258
if (this.isEendraadschemaSymbool()) rotate = rotate + 180;
259259
}
260260

src/sitplan/SituationPlanView.ts

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class SituationPlanView {
3636
// Verwijder alle selecties wanneer we ergens anders klikken dan op een box
3737
this.event_manager.addEventListener(outerdiv, 'mousedown', () => { this.clearSelection(); } );
3838
this.event_manager.addEventListener(outerdiv, 'touchstart', () => { this.clearSelection(); } );
39+
40+
// Voegt event handlers toe voor de pijltjestoesten
41+
this.attachArrowKeys();
3942
}
4043

4144
/**
@@ -256,11 +259,13 @@ class SituationPlanView {
256259
function getRotationTransform(sitPlanElement: SituationPlanElement | null): string {
257260
if (!sitPlanElement) return '';
258261

259-
let rotation: number = sitPlanElement.rotate % 360;
262+
let rotation: number = sitPlanElement.rotate;
263+
while (rotation < 0) rotation += 360;
264+
rotation = rotation % 360;
260265
let spiegel: boolean = false;
261266

262267
if ((rotation >= 90) && (rotation < 270)) {
263-
if (sitPlanElement.rotates360degrees()) spiegel = true;
268+
if (sitPlanElement.isEDSSymbolAndRotates360degrees()) spiegel = true;
264269
if (sitPlanElement.isEendraadschemaSymbool()) rotation -= 180;
265270
}
266271

@@ -478,16 +483,25 @@ class SituationPlanView {
478483
* @param event - De gebeurtenis die de sleepactie stopt (muisklik release of touchend).
479484
*/
480485
private stopDrag = (event) => {
486+
function showArrowHelp() {
487+
const helperTip = new HelperTip(appDocStorage);
488+
helperTip.show('sitplan.arrowdrag',
489+
`<h3>Tip: Symbolen verplaatsen</h3>
490+
<p>Voor fijnere controle tijdens het verschuiven van symbolen kan u ook de pijltjes op het toetsenbord gebruiken.</p>`,true);
491+
}
492+
481493
event.stopPropagation();
482494

483495
switch (event.type) {
484496
case 'mouseup':
485497
document.removeEventListener('mousemove', this.processDrag);
486498
document.removeEventListener('mouseup', this.stopDrag);
499+
if (this.mousedrag.hassMoved) showArrowHelp();
487500
break;
488501
case 'touchend':
489502
document.removeEventListener('touchmove', this.processDrag);
490503
document.removeEventListener('touchend', this.stopDrag);
504+
if (this.mousedrag.hassMoved) showArrowHelp();
491505
break;
492506
default:
493507
console.error('Ongeldige event voor stopDrag functie');
@@ -555,6 +569,45 @@ class SituationPlanView {
555569
this.updateRibbon();
556570
}
557571

572+
/**
573+
* Voegt eventlisteners toe om pijltjestoetsen te hanteren.
574+
*
575+
* Wanneer een pijltjestoets wordt ingedrukt, en er is een box geselecteerd, dan wordt de positie van de box aangepast.
576+
* De positie van de box wordt aangepast door de posx of posy van het element in het situatieplan te veranderen.
577+
* Daarna wordt de functie updateSymbolAndLabelPosition aangeroepen om de positie van het symbool en het label van de box te updaten.
578+
*/
579+
attachArrowKeys() {
580+
581+
this.event_manager.addEventListener(document, 'keydown', (event) => {
582+
if (this.outerdiv.style.display == 'none') return; // Check if we are really in the situationplan, if not, the default scrolling action will be executed by the browser
583+
if (document.getElementById('popupOverlay') != null) return; // We need the keys when editing symbol properties.
584+
585+
if (this.selectedBox) { // Check if we have a selected box, if not, the default scrolling action will be executed by the browser
586+
event.preventDefault();
587+
const sitPlanElement = (this.selectedBox as any).sitPlanElementRef;
588+
if (!sitPlanElement) return;
589+
590+
switch (event.key) {
591+
case 'ArrowLeft':
592+
sitPlanElement.posx -= 1;
593+
break;
594+
case 'ArrowRight':
595+
sitPlanElement.posx += 1;
596+
break;
597+
case 'ArrowUp':
598+
sitPlanElement.posy -= 1;
599+
break;
600+
case 'ArrowDown':
601+
sitPlanElement.posy += 1;
602+
break;
603+
default:
604+
return;
605+
}
606+
this.updateSymbolAndLabelPosition(sitPlanElement);
607+
}
608+
});
609+
}
610+
558611
/**
559612
* Hangt een klik event listener aan het gegeven element met als doel de huidig geselecteerde box te verwijderen.
560613
*
@@ -900,8 +953,8 @@ function showSituationPlanPage() {
900953
// Initialize the HelperTip with the storage
901954
const helperTip = new HelperTip(appDocStorage);
902955
helperTip.show('sitplan.introductie',
903-
`<h3>Situatieschema</h3>
904-
<p>Op deze pagina kan u een situatieschema tekenen</p>
956+
`<h3>Situatieschema tekenen</h3>
957+
<p>Op deze pagina kan u een situatieschema tekenen.</p>
905958
<p>Laad een plattegrond met de knop "Uit bestand" en voeg symbolen toe met de knop "Uit schema".</p>
906959
<p>Klik <a href="Documentation/sitplandoc.pdf" target="_blank" rel="noopener noreferrer">hier</a> om in een nieuw venster de documentatie te bekijken.</p>
907960
<p>Het situatieschema werd recent toegevoegd aan het programma en zal nog verder ontwikkeld worden over de komende weken. Opmerkingen zijn welkom in het "contact"-formulier.</p>`);

0 commit comments

Comments
 (0)