Skip to content

Commit

Permalink
fix: pass dismiss event to authenticate component (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
lem-onade authored Nov 22, 2021
1 parent 14e1a19 commit 805361b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export class AuthenticateComponent extends RxLitElement {

onButtonCreateWebIDClick = (): void => { this.dispatchEvent(new CustomEvent('create-webid', { bubbles: true })); };

onAlertDismissed = (): void => { this.webIdValidationResults = []; };

render(): TemplateResult {

return html`
Expand Down Expand Up @@ -128,6 +130,7 @@ export class AuthenticateComponent extends RxLitElement {
?hideCreateNewWebId="${this.hideCreateNewWebId}"
@submit-webid="${this.onSubmit}"
@create-webid="${this.onButtonCreateWebIDClick}"
@dismiss="${this.onAlertDismissed}"
.textLabel="${this.textWebIdLabel}"
.textPlaceholder="${this.textWebIdPlaceholder}"
.textNoWebId="${this.textNoWebId}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,33 @@ export class WebIdComponent extends RxLitElement {
onSubmit = (event: Event & { target: HTMLFormElement }): void => {

event.preventDefault();
this.dispatchEvent(new CustomEvent('submit-webid', { detail: event.target.querySelector<HTMLInputElement>('input[name=webid]').value }));

this.dispatchEvent(new CustomEvent('submit-webid', {
detail: event.target.querySelector<HTMLInputElement>('input[name=webid]').value,
}));

};

onButtonCreateWebIDClick = (): void => { this.dispatchEvent(new CustomEvent('create-webid')); };

onAlertDismissed = (event: CustomEvent): void => {

this.dispatchEvent(new CustomEvent(event.type, { detail: event.detail }));

};

render(): TemplateResult {

return html`
<slot name="before"></slot>
<form @submit="${this.onSubmit}">
${this.validationResults?.length > 0
? html`<alert-component exportparts="validation-alert" .translator="${this.translator}" .alert="${{ message: this.validationResults[0], type: 'warning' }}"></alert-component>`
? html`<alert-component
@dismiss="${this.onAlertDismissed}"
exportparts="validation-alert"
.translator="${this.translator}"
.alert="${{ message: this.validationResults[0], type: 'warning' }}">
</alert-component>`
: ''}
<label part="webid-label" for="webid">${this.textLabel}</label>
<input part="webid-input" type="text" id="webid" name="webid" placeholder="${this.textPlaceholder}" />
Expand Down
6 changes: 3 additions & 3 deletions packages/dgt-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
"coverageThreshold": {
"global": {
"branches": 34.61,
"functions": 35.04,
"lines": 39.46,
"statements": 39.57
"functions": 34.72,
"lines": 39.43,
"statements": 39.49
}
},
"coveragePathIgnorePatterns": [
Expand Down

0 comments on commit 805361b

Please sign in to comment.