Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change barbuddy form to allow selection of multiple buddies #531

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ html {
@apply mr-1;
}

.form-element input:not([type='radio']),
.form-element input:not([type='radio']):not([type='checkbox']),
.form-element textarea {
@apply bg-white text-gray-800 rounded-lg block px-4 py-3 w-full;
}
Expand Down
26 changes: 26 additions & 0 deletions components/Form/FormMultiCheckbox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<label class="radio">
<input v-model="model" type="checkbox" :value="option" />
{{ label }}
</label>
</template>

<script>
export default {
props: {
value: [],
option: String,
label: String,
},
computed: {
model: {
get() {
return this.value
},
set(value) {
this.$emit('input', value)
},
},
},
}
</script>
18 changes: 10 additions & 8 deletions components/bar_buddies/BarBuddyForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ nl:
<FormInput v-model="form.pronouns" :placeholder="$t('forms.placeholder.pronouns')" />
<FormValidation name="pronouns" :errors="validationErrors" />
</FormElement>
<FormElement :label="$t('forms.label.barbuddy')" required="true">
<FormRadio v-model="form.barbuddy" :label="$t('forms.label.languages.no_preference')" option="no_preference" />
<FormRadio
<FormElement :label="$t('forms.label.barbuddy')" required="false">
<FormMultiCheckbox
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to include this component in your commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did do that

v-for="buddy in barBuddies"
:key="buddy.name"
v-model="form.barbuddy"
v-model="form.barbuddies"
:label="buddy.name"
:option="buddy.name"
/>
<FormValidation name="barbuddy" :errors="validationErrors" />
<FormValidation name="barbuddies" :errors="validationErrors" />
</FormElement>
<FormElement :label="$t('forms.label.remarks')">
<FormInput v-model="form.remarks" :placeholder="$t('forms.placeholder.remarks')" type="textarea" />
Expand Down Expand Up @@ -77,7 +76,8 @@ export default {
email: '',
phone_number: '',
pronouns: '',
barbuddy: 'no_preference',
barbuddies: [],
buddy_preferences: '',
remarks: '',
},
validationErrors: {},
Expand All @@ -86,7 +86,7 @@ export default {
},
watch: {
selected() {
this.form.barbuddy = this.selected.name
this.form.barbuddy = [this.selected.name]
},
},
methods: {
Expand All @@ -95,7 +95,9 @@ export default {

this.formStatus = 'loading'

new ReMemberForm('barbuddy')
this.form.buddy_preferences = this.form.barbuddies.join(', ')

new ReMemberForm('barbuddy2')
.submit(this.form)
.then(() => {
this.formStatus = 'finished'
Expand Down