|
6 | 6 | <div class="cd-event-form">
|
7 | 7 | <h3 v-show="!editing" class="cd-event-form__header">{{ `${$t('Create an event for')} ${dojo.name}` }}</h3>
|
8 | 8 | <h3 v-show="editing" class="cd-event-form__header">{{ `${$t('Edit event:')} ${eventName}` }}</h3>
|
9 |
| - <form @submit="save"> |
| 9 | + <form v-on:submit.prevent="save"> |
10 | 10 |
|
11 | 11 | <div v-if="submitError">
|
12 | 12 | <h3 class="text-danger">{{ $t('There was an error processing this request. Please try again or contact support') }}</h3>
|
|
16 | 16 | <input type="text" data-cy="title" name="name" v-model="eventName" class="form-control" data-vv-name="eventName" v-validate="'required'" data-vv-validate-on="blur" :placeholder="$t('e.g. October Dojo')">
|
17 | 17 |
|
18 | 18 | <div class="cd-event-form__location">
|
19 |
| - {{ $t('This event uses the address') }}: |
20 |
| - <span v-show="!addressIsVisible">{{ formattedAddress }}</span> |
21 |
| - <i class="fa fa-pencil" @click="addressIsVisible = true" v-show="!addressIsVisible"></i> |
22 |
| - <i class="fa fa-times" @click="addressIsVisible = false" v-show="addressIsVisible"></i> |
23 |
| - <div v-if="addressIsVisible"> |
| 19 | + {{ $t('Event address:') }} |
| 20 | + <span v-show="!customAddressFormIsVisible">{{ truncatedAddress }}</span> |
| 21 | + <i class="fa fa-pencil pointer" @click="customAddressFormIsVisible = true" v-show="!customAddressFormIsVisible"></i> |
| 22 | + <i class="fa fa-times pointer" @click="customAddressFormIsVisible = false" v-show="customAddressFormIsVisible"></i> |
| 23 | + <div v-if="customAddressFormIsVisible"> |
24 | 24 | <input type="text" name="city" v-model="eventCity" class="form-control">
|
25 | 25 | <textarea name="address" v-model="eventAddress" rows="3" class="form-control"></textarea>
|
26 | 26 | </div>
|
27 | 27 | </div>
|
28 | 28 |
|
29 | 29 | <div class="cd-event-form__description">
|
30 |
| - {{ $t('This event uses the description') }}: |
31 |
| - <span v-show="!descriptionIsVisible">{{ truncatedDescription }}</span> |
32 |
| - <i class="fa fa-pencil" @click="descriptionIsVisible = true" v-show="!descriptionIsVisible"></i> |
33 |
| - <i class="fa fa-times" @click="descriptionIsVisible = false" v-show="descriptionIsVisible"></i> |
| 30 | + {{ $t('Event description:') }} |
| 31 | + <span v-show="!customDescriptionFormIsVisible">{{ truncatedDescription }}</span> |
| 32 | + <i class="fa fa-pencil pointer" @click="customDescriptionFormIsVisible = true" v-show="!customDescriptionFormIsVisible"></i> |
| 33 | + <i class="fa fa-times pointer" @click="customDescriptionFormIsVisible = false" v-show="customDescriptionFormIsVisible"></i> |
34 | 34 |
|
35 | 35 | <p class="text-danger" v-show="errors.has('eventDescription:required')">{{ $t('Description is required') }}</p>
|
36 | 36 | <input type="hidden" v-model="eventDescription" v-validate="'required'" name="eventDescription" />
|
37 |
| - <div v-if="descriptionIsVisible"> |
| 37 | + <div v-if="customDescriptionFormIsVisible"> |
38 | 38 | <VueTrix v-model="eventDescription" ref="trixEditor" />
|
39 | 39 | </div>
|
40 | 40 | </div>
|
41 | 41 |
|
42 | 42 | <h4 class="cd-event__section-title">{{ $t('Date and Time') }}</h4>
|
43 | 43 | <div>
|
| 44 | + <p class="text-danger" v-show="errors.has('eventDate:required')">{{ $t('Event date is required') }}</p> |
44 | 45 | <p class="text-danger" v-show="errors.has('startTime:required')">{{ $t('Start time is required') }}</p>
|
45 | 46 | <p class="text-danger" v-show="errors.has('endTime:required')">{{ $t('Finish time is required') }}</p>
|
46 | 47 | <p class="text-danger" v-show="errors.has('endTime:after')">{{ $t('Finish time must be after start time') }}</p>
|
|
51 | 52 | <VueCtkDateTimePicker v-model="eventDate"
|
52 | 53 | name="eventDate"
|
53 | 54 | v-validate="'required'"
|
54 |
| - :only-date="true" |
55 |
| - :input-size="'sm'" |
56 |
| - :format="'YYYY-MM-DD'" |
57 |
| - :formatted="'ll'" |
58 |
| - :no-label=true |
59 |
| - :color="'#73449B'" |
| 55 | + only-date |
| 56 | + input-size="sm" |
| 57 | + format="YYYY-MM-DD" |
| 58 | + formatted="ll" |
| 59 | + no-label |
| 60 | + color="#73449B" |
60 | 61 | />
|
61 | 62 | </div>
|
62 | 63 |
|
63 | 64 | <div class="col-sm-3 flow">
|
64 | 65 | <VueCtkDateTimePicker v-model="startTime"
|
65 | 66 | name="startTime"
|
66 |
| - v-validate="'required'" |
67 |
| - :only-time="true" |
68 |
| - :input-size="'sm'" |
69 |
| - :format="'HH:mm'" |
70 |
| - :formatted="'HH:mm'" |
71 |
| - :minute-interval=10 |
72 |
| - :no-label=true |
| 67 | + v-validate="'required|date_format:HH:mm'" |
| 68 | + only-time |
| 69 | + input-size="sm" |
| 70 | + format="HH:mm" |
| 71 | + formatted="HH:mm" |
| 72 | + minute-interval=10 |
| 73 | + no-label |
73 | 74 | ref="startTimePicker"
|
74 |
| - :color="'#73449B'" |
| 75 | + color="#73449B" |
75 | 76 | />
|
76 | 77 | </div>
|
77 | 78 | <div class="col-sm-1 flow">
|
|
82 | 83 |
|
83 | 84 | <div class="col-sm-3 flow">
|
84 | 85 | <VueCtkDateTimePicker v-model="endTime"
|
85 |
| - v-validate="'date_format:HH:mm|after:startTimePicker'" |
| 86 | + v-validate="'required|date_format:HH:mm|after:startTimePicker'" |
86 | 87 | name="endTime"
|
87 |
| - :only-time="true" |
88 |
| - :input-size="'sm'" |
89 |
| - :format="'HH:mm'" |
90 |
| - :formatted="'HH:mm'" |
91 |
| - :minute-interval=10 |
92 |
| - :no-label=true |
93 |
| - :color="'#73449B'" |
| 88 | + only-time |
| 89 | + input-size="sm" |
| 90 | + format="HH:mm" |
| 91 | + formatted="HH:mm" |
| 92 | + minute-interval=10 |
| 93 | + no-label |
| 94 | + color="#73449B" |
94 | 95 | />
|
95 | 96 | </div>
|
96 | 97 | </div>
|
|
126 | 127 | </div>
|
127 | 128 | </form>
|
128 | 129 | <div class="flow">
|
129 |
| - <p>We simplified our events experience, read <a href="TODO">about it here</a>. |
| 130 | + <p>We simplified our events experience, read <a href="https://coderdojo.com/?p=17691">about it here</a>. |
130 | 131 | <br/>
|
131 | 132 | If you need to customise your event further you can still use the <a :href="`/dashboard/dojo/${dojo.id}/event-form`">advanced events form</a></p>
|
132 | 133 | </div>
|
|
158 | 159 | },
|
159 | 160 | data() {
|
160 | 161 | return {
|
161 |
| - addressIsVisible: false, |
162 |
| - descriptionIsVisible: false, |
| 162 | + customAddressFormIsVisible: false, |
| 163 | + customDescriptionFormIsVisible: false, |
163 | 164 | dojo: {},
|
164 | 165 | editing: false,
|
165 | 166 | latestEvent: undefined,
|
|
186 | 187 | EventStore.commit('setDojoId', this.dojo.id);
|
187 | 188 | EventStore.commit('setCreatedBy', this.loggedInUser.id);
|
188 | 189 | },
|
| 190 | + stripHtml(htmlString) { |
| 191 | + // removes html tags and non breaking spaces |
| 192 | + return htmlString.replace(/(<[^<|>]+?>)|( )/gi, ' '); |
| 193 | + }, |
189 | 194 | async validateForm() {
|
190 | 195 | try {
|
191 | 196 | const res = await this.$validator.validateAll();
|
|
195 | 200 | }
|
196 | 201 | },
|
197 | 202 |
|
198 |
| - async save(e) { |
199 |
| - e.preventDefault(); |
| 203 | + async save() { |
200 | 204 | const valid = await this.validateForm();
|
201 | 205 | if (valid) {
|
202 | 206 | try {
|
|
279 | 283 | },
|
280 | 284 | },
|
281 | 285 | truncatedDescription() {
|
282 |
| - const str = EventStore.getters.description.replace(/(<[^<|>]+?>)|( )/gi, ' '); |
| 286 | + const str = this.stripHtml(EventStore.getters.description); |
283 | 287 | const words = str.split(' ').filter(word => word !== '');
|
284 | 288 | return `${words.slice(0, 6).join(' ')}... `;
|
285 | 289 | },
|
286 |
| - formattedAddress() { |
287 |
| - const str = EventStore.getters.address.replace(/(<[^<|>]+?>)|( )/gi, ' '); |
| 290 | + truncatedAddress() { |
| 291 | + const str = this.stripHtml(EventStore.getters.address); |
288 | 292 | const words = str.split(' ').filter(word => word !== '');
|
289 | 293 | return `${words.slice(0, 5).join(' ')}... ${this.eventCity}`;
|
290 | 294 | },
|
|
358 | 362 | width: 100%;
|
359 | 363 | }
|
360 | 364 | }
|
| 365 | +
|
| 366 | + .pointer { |
| 367 | + cursor: pointer; |
| 368 | + } |
361 | 369 | </style>
|
0 commit comments