-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathFormStep1.vue
More file actions
173 lines (149 loc) · 7.13 KB
/
FormStep1.vue
File metadata and controls
173 lines (149 loc) · 7.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
<div class="flex flex-col gap-4 w-full">
<FieldWrapper horizontalBreakpoint="md" :label="`${$t('event.title.label')}*`" name="title" :errors="errors">
<InputField v-model="formValues.title" required name="title" :placeholder="$t('event.title.placeholder')" />
</FieldWrapper>
<FieldWrapper horizontalBreakpoint="md" :label="$t('event.specify-the-format-of-the-activity')" name="activity_format" :errors="errors">
<SelectField v-model="formValues.activity_format" multiple name="activity_format" :options="activityFormatOptions" :placeholder="$t('event.select-option')" />
</FieldWrapper>
<FieldWrapper horizontalBreakpoint="md" :label="`${$t('event.activitytype.label')}*`" name="activity_type" :errors="errors">
<SelectField v-model="formValues.activity_type" required name="activity_type" :options="activityTypeOptions" />
<template #end>
<div class="flex gap-4 p-4 mt-2.5 w-full rounded-2xl border bg-dark-blue-50 border-dark-blue-100">
<img class="flex-shrink-0 mt-1 w-6 h-6" src="/images/icon_info.svg" />
<span class="text-xl text-slate-500">
{{ $t('event.if-no-clear-information-provide-estimate') }}
</span>
</div>
</template>
</FieldWrapper>
<FieldWrapper
horizontalBreakpoint="md"
:label="`${$t('event.address.label')} ${['open-online','invite-online'].includes(formValues.activity_type) ? '(optional)' : '*'}`"
name="location"
:errors="errors"
>
<autocomplete-geo
class="custom-geo-input"
name="location"
:placeholder="$t('event.address.placeholder')"
:location="formValues.location"
:value="formValues.location"
:geoposition="formValues.geoposition"
@onChange="handleLocationChange"
@input="handleLocationTyping"
@clear="handleLocationClear"
></autocomplete-geo>
<template #end>
<div v-if="showSelectHint" class="text-sm font-semibold text-red-600 mt-2">
{{ $t('event.please-select-address-from-dropdown') }}
</div>
</template>
</FieldWrapper>
<FieldWrapper horizontalBreakpoint="md" :label="$t('event.activity-duration')" name="duration" :errors="errors">
<div class="w-full md:w-1/2">
<SelectField v-model="formValues.duration" required name="duration" :options="durationOptions" :placeholder="$t('event.select-option')" />
</div>
</FieldWrapper>
<FieldWrapper horizontalBreakpoint="md" :label="$t('event.date')" :names="['start_date', 'end_date']" :errors="errors">
<div class="w-full flex px-3 justify-between items-center text-gray-700 whitespace-nowrap rounded-3xl border-2 border-dark-blue-200 h-[50px] bg-white">
<date-time name="start_date" :placeholder="$t('event.start.label')" :flow="['calendar', 'time']" :value="formValues.start_date" @onChange="formValues.start_date = $event" />
<span>-</span>
<date-time name="end_date" :placeholder="$t('event.end.label')" :flow="['calendar', 'time']" :value="formValues.end_date" @onChange="formValues.end_date = $event" />
</div>
</FieldWrapper>
<!-- new -->
<FieldWrapper horizontalBreakpoint="md" :label="$t('event.is-it-a-recurring-event')" name="is_recurring_event_local" :errors="errors">
<div class="flex items-center gap-8 min-h-[48px]">
<RadioField v-model="formValues.is_recurring_event_local" name="is_recurring_event_local" value="true" :label="$t('event.true')" />
<RadioField v-model="formValues.is_recurring_event_local" name="is_recurring_event_local" value="false" :label="$t('event.false')" />
</div>
<div v-if="formValues.is_recurring_event_local === 'true'" class="p-4 mt-4 w-full rounded-2xl border bg-dark-blue-50 border-dark-blue-100">
<label class="block mb-2 text-xl font-semibold text-slate-500">
{{ $t('event.how-frequently') }}
</label>
<div class="flex flex-wrap gap-8 items-center">
<RadioField v-model="formValues.recurring_event" name="recurring_event" value="daily" :label="$t('event.daily')" />
<RadioField v-model="formValues.recurring_event" name="recurring_event" value="weekly" :label="$t('event.weekly')" />
<RadioField v-model="formValues.recurring_event" name="recurring_event" value="monthly" :label="$t('event.monthly')" />
</div>
<label class="block mt-6 mb-2 text-xl font-semibold text-slate-500">
{{ $t('event.what-type-of-recurring-activity') }}
</label>
<SelectField v-model="formValues.recurring_type" name="recurring_type" :options="recurringTypeOptions" />
</div>
</FieldWrapper>
<FieldWrapper horizontalBreakpoint="md" :label="$t('event.theme-title')" name="theme" :errors="errors">
<SelectField v-model="formValues.theme" multiple required name="theme" :placeholder="$t('event.select-theme')" :options="themes" />
</FieldWrapper>
<FieldWrapper horizontalBreakpoint="md" :label="$t('event.activity-description')" name="description" :errors="errors">
<TinymceField v-model="formValues.description" name="description" />
</FieldWrapper>
</div>
</template>
<script>
import { computed } from 'vue';
import { useDataOptions } from './mixins.js';
import FieldWrapper from '../form-fields/FieldWrapper.vue';
import SelectField from '../form-fields/SelectField.vue';
import InputField from '../form-fields/InputField.vue';
import RadioField from '../form-fields/RadioField.vue';
import TinymceField from '../form-fields/TinymceField.vue';
export default {
props: {
errors: Object,
formValues: Object,
themes: Array,
location: Object,
countries: Array,
},
components: {
FieldWrapper,
SelectField,
InputField,
RadioField,
TinymceField,
},
setup(props) {
const {
activityFormatOptions,
activityTypeOptions,
durationOptions,
recurringTypeOptions,
} = useDataOptions();
const showSelectHint = computed(() => {
const isOnline = ['open-online','invite-online'].includes(props.formValues.activity_type);
return !isOnline && props.formValues.locationDirty === true && props.formValues.locationSelected === false;
});
const handleLocationTyping = (_text) => {
// Typing = need update location
props.formValues.location = '';
props.formValues.locationDirty = true;
props.formValues.locationSelected = false;
};
const handleLocationClear = () => {
props.formValues.location = '';
props.formValues.locationDirty = true;
props.formValues.locationSelected = false;
};
const handleLocationChange = ({ location, geoposition, country_iso }) => {
props.formValues.location = location || '';
props.formValues.geoposition = geoposition;
props.formValues.country_iso = country_iso;
props.formValues.locationSelected = true;
props.formValues.locationDirty = true;
};
return {
activityFormatOptions,
activityTypeOptions,
durationOptions,
recurringTypeOptions,
// UX hint
showSelectHint,
handleLocationTyping,
handleLocationClear,
handleLocationChange,
};
},
};
</script>