-
-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to block JID when declining contact request
Also adds the ability to add checkboxes to the `confirm` modal.
- Loading branch information
Showing
11 changed files
with
122 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,43 @@ | ||
import { html } from "lit"; | ||
import { html } from 'lit'; | ||
import { __ } from 'i18n'; | ||
|
||
|
||
const tplField = (f) => html` | ||
<div> | ||
<label class="form-label"> | ||
${f.label || ''} | ||
<input type="text" | ||
name="${f.name}" | ||
class="${(f.challenge_failed) ? 'error' : ''} form-control form-control--labeled" | ||
?required="${f.required}" | ||
placeholder="${f.placeholder}" /> | ||
</label> | ||
</div> | ||
`; | ||
/** | ||
* @param {import("../types").Field} f | ||
*/ | ||
function tplField(f) { | ||
return f.type === 'checkbox' | ||
? html` <div class="form-check"> | ||
<input name="${f.name}" class="form-check-input" type="checkbox" value="" id="${f.name}" /> | ||
<label class="form-check-label" for="${f.name}">${f.label}</label> | ||
</div>` | ||
: html`<div> | ||
<label class="form-label"> | ||
${f.label || ''} | ||
<input | ||
type="text" | ||
name="${f.name}" | ||
class="${f.challenge_failed ? 'error' : ''} form-control form-control--labeled" | ||
?required="${f.required}" | ||
placeholder="${f.placeholder}" | ||
/> | ||
</label> | ||
</div>`; | ||
} | ||
|
||
/** | ||
* @param {import('../confirm').default} el | ||
*/ | ||
export default (el) => { | ||
return html` | ||
<form class="converse-form converse-form--modal confirm" action="#" @submit=${ev => el.onConfimation(ev)}> | ||
<div> | ||
${ el.model.get('messages')?.map(message => html`<p>${message}</p>`) } | ||
</div> | ||
${ el.model.get('fields')?.map(f => tplField(f)) } | ||
<div> | ||
<button type="submit" class="btn btn-primary">${__('OK')}</button> | ||
<input type="button" class="btn btn-secondary" data-bs-dismiss="modal" value="${__('Cancel')}"/> | ||
</div> | ||
</form>`; | ||
} | ||
return html` <form | ||
class="converse-form converse-form--modal confirm" | ||
action="#" | ||
@submit=${(ev) => el.onConfimation(ev)} | ||
> | ||
<div>${el.model.get('messages')?.map(/** @param {string} msg */ (msg) => html`<p>${msg}</p>`)}</div> | ||
${el.model.get('fields')?.map(/** @param {import('../types').Field} f */ (f) => tplField(f))} | ||
<div> | ||
<button type="submit" class="btn btn-primary">${__('Confirm')}</button> | ||
<input type="button" class="btn btn-secondary" data-bs-dismiss="modal" value="${__('Cancel')}" /> | ||
</div> | ||
</form>`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
export type Field = { | ||
type: 'text'|'checkbox' | ||
label: string; // The form label for the input field. | ||
name: string; // The name for the input field. | ||
challenge?: string; // A challenge value that must be provided by the user. | ||
challenge_failed?: boolean; | ||
placeholder?: string; // The placeholder for the input field. | ||
required?: boolean; // Whether the field is required or not | ||
value?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
export type Field = { | ||
type: 'text' | 'checkbox'; | ||
label: string; | ||
name: string; | ||
challenge?: string; | ||
challenge_failed?: boolean; | ||
placeholder?: string; | ||
required?: boolean; | ||
value?: string; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |