Skip to content
Snippets Groups Projects
Unverified Commit b57a0721 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Fix signature positioning mode when new items are queued or removed from the queue (#7)

parent 899b6b98
No related branches found
No related tags found
No related merge requests found
Pipeline #11364 failed
...@@ -12,7 +12,7 @@ const BUTTON2 = "button2"; ...@@ -12,7 +12,7 @@ const BUTTON2 = "button2";
* disabled: Disable the switch * disabled: Disable the switch
* *
* Events: * Events:
* change: emitted when the active name changes or the same button is clicked again * change: when button is clicked
* *
* Example: * Example:
* <my-tag name="one" name1="one" name2="two" value1="One", value2="Two"></my-tag> * <my-tag name="one" name1="one" name2="two" value1="One", value2="Two"></my-tag>
...@@ -63,22 +63,13 @@ export class TextSwitch extends LitElement { ...@@ -63,22 +63,13 @@ export class TextSwitch extends LitElement {
} }
update(changedProperties) { update(changedProperties) {
this.name = this._active === BUTTON1 ? this.name1 : this.name2;
changedProperties.forEach((oldValue, propName) => { changedProperties.forEach((oldValue, propName) => {
if (propName === "name") { if (propName === "name") {
if (this[propName] === this.name1) { if (this[propName] === this.name1) {
this._active = BUTTON1; this._active = BUTTON1;
} } else if (this[propName] === this.name2) {
if (this[propName] === this.name2) {
this._active = BUTTON2; this._active = BUTTON2;
} }
} else if (propName === "_active") {
const event = new CustomEvent("change", {
bubbles: true,
cancelable: false,
});
this.dispatchEvent(event);
} }
}); });
...@@ -87,15 +78,16 @@ export class TextSwitch extends LitElement { ...@@ -87,15 +78,16 @@ export class TextSwitch extends LitElement {
render() { render() {
const onClick = function (e) { const onClick = function (e) {
let new_id = e.target.id; this._active = e.target.id;
if (new_id === this._active) { this.name = this._active === BUTTON1 ? this.name1 : this.name2;
// send event only when buttons are clicked
const event = new CustomEvent("change", { const event = new CustomEvent("change", {
bubbles: true, bubbles: true,
cancelable: false, cancelable: false,
}); });
this.dispatchEvent(event); this.dispatchEvent(event);
}
this._active = new_id;
}; };
return html` return html`
......
...@@ -696,6 +696,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle ...@@ -696,6 +696,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle
<span class="headline">${i18n.t('qualified-pdf-upload.positioning')}:</span> <span class="headline">${i18n.t('qualified-pdf-upload.positioning')}:</span>
<vpu-textswitch name1="auto" <vpu-textswitch name1="auto"
name2="manual" name2="manual"
name="${this.queuedFilesPlacementModes[id] ?? "auto"}"
class="switch" class="switch"
value1="${i18n.t('qualified-pdf-upload.positioning-automatic')}" value1="${i18n.t('qualified-pdf-upload.positioning-automatic')}"
value2="${i18n.t('qualified-pdf-upload.positioning-manual')}" value2="${i18n.t('qualified-pdf-upload.positioning-manual')}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment