add radio and checkboxes steps

This commit is contained in:
Alex Turchyn
2023-05-23 22:10:05 +03:00
parent 90e579ad01
commit f1da37d1ec
4 changed files with 67 additions and 18 deletions
+1 -1
View File
@@ -41,7 +41,7 @@
v-for="(area, index) in areas"
:key="index"
>
{{ area }}
Area {{ index + 1 }}
<button @click="removeArea(area)">
&times;
</button>
+18 -7
View File
@@ -4,8 +4,7 @@ import { actionable } from '@github/catalyst/lib/actionable'
export default actionable(targetable(class extends HTMLElement {
static [target.static] = [
'form',
'completed',
'submitButton'
'completed'
]
static [targets.static] = [
@@ -22,16 +21,28 @@ export default actionable(targetable(class extends HTMLElement {
})
}
submitSignature () {
this.submitButton.click()
}
setVisibleStep (uuid) {
this.steps.forEach((step) => {
step.classList.toggle('hidden', step.dataset.fieldUuid !== uuid)
})
this.fields.find(f => f.id === uuid).focus()
this.fields.find(f => f.id === uuid)?.focus()
}
submitSignature (e) {
e.target.okButton.disabled = true
fetch(this.form.action, {
method: this.form.method,
body: new FormData(this.form)
}).then(response => {
console.log('Form submitted successfully!', response)
this.moveNextStep()
}).catch(error => {
console.error('Error submitting form:', error)
}).finally(() => {
e.target.okButton.disabled = false
})
}
submitForm (e) {
+5 -1
View File
@@ -7,7 +7,9 @@ import { DirectUpload } from '@rails/activestorage'
export default actionable(targetable(class extends HTMLElement {
static [target.static] = [
'canvas',
'input'
'input',
'okButton',
'clearButton'
]
connectedCallback () {
@@ -17,6 +19,8 @@ export default actionable(targetable(class extends HTMLElement {
submit (e) {
e?.preventDefault()
this.okButton.disabled = true
this.canvas.toBlob((blob) => {
const file = new File([blob], 'signature.jpg', { type: 'image/jpg' })