|
| 1 | +<template> |
| 2 | + <div class="cd-event-form"> |
| 3 | + <div class="cd-event-form__left-column"> |
| 4 | + <h1 class="cd-event-form__header">{{ $t('Create an event') }}</h1> |
| 5 | + <form @submit="save"> |
| 6 | + <input type="text" name="title" v-model="title" class="form-control" :placeholder="$t('e.g. October Dojo')"> |
| 7 | + <div class="cd-event-form__location"> |
| 8 | + <!-- is the text relevant when it's been modified? --> |
| 9 | + <!-- what about previous event information, default back to Dojo's or previous event ? --> |
| 10 | + {{ $t('This event uses the Dojo address.') }} |
| 11 | + <span v-show="!addressIsVisible">{{ formattedAddress }}</span> |
| 12 | + <i class="fa fa-pencil" @click="addressIsVisible = true" v-show="!addressIsVisible"></i> |
| 13 | + <i class="fa fa-times" @click="addressIsVisible = false" v-show="addressIsVisible"></i> |
| 14 | + <div v-if="addressIsVisible"> |
| 15 | + <input type="text" name="city" v-model="city" class="form-control"> |
| 16 | + <textarea name="address" v-model="address" rows="3" class="form-control"></textarea> |
| 17 | + </div> |
| 18 | + </div> |
| 19 | + <div class="cd-event-form__description"> |
| 20 | + {{ $t('This event uses the previous event description') }} |
| 21 | + <span v-show="!descriptionIsVisible">{{ truncatedDescription }}</span> |
| 22 | + <i class="fa fa-pencil" @click="descriptionIsVisible = true" v-show="!descriptionIsVisible"></i> |
| 23 | + <i class="fa fa-times" @click="descriptionIsVisible = false" v-show="descriptionIsVisible"></i> |
| 24 | + <div v-if="descriptionIsVisible"> |
| 25 | + <ckeditor :editor="editor" v-model="description"></ckeditor> |
| 26 | + </div> |
| 27 | + </div> |
| 28 | + <div class="cd-event-form__date form-group"> |
| 29 | + <input list="days" type="number" name="day" v-model="day" class="form-control"> |
| 30 | + <datalist id="days" v-model="day"> |
| 31 | + <option v-for="day in 31" :key="index" :value="day">{{ day }} </option> |
| 32 | + </datalist> |
| 33 | + <select name="month" v-model="month"> |
| 34 | + <option v-for="(month, index) in months" :value="index">{{ month }}</option> |
| 35 | + </select> |
| 36 | + <input list="years" type="number" name="year" v-model="year" class="form-control"> |
| 37 | + <datalist id="years" v-model="year"> |
| 38 | + <option v-for="year in 3" :key="index">{{ year + today.year() -1 }} </option> |
| 39 | + </datalist> |
| 40 | + </div> |
| 41 | + <div class="cd-event-form__date form-group"> |
| 42 | + <input type="datetime-local" name="day" :value="today" :min="today"> |
| 43 | + </div> |
| 44 | + <dropdown type="primary" display="splitted" class="cd-event-form__button"> |
| 45 | + <button slot="submit" type="submit" class="btn btn-primary"> |
| 46 | + {{ $t('Publish and email members') }} |
| 47 | + </button> |
| 48 | + <li><a href="#">Publish only</a></li> |
| 49 | + <li><a href="#">Save as draft</a></li> |
| 50 | + </dropdown> |
| 51 | + </form> |
| 52 | + </div> |
| 53 | + <div class="cd-event-form__right-column"> |
| 54 | + <div class="cd-event-form__info-box"> |
| 55 | + <h3 class="cd-event-form__info-box-header">Say "Hi" to our new events!</h3> |
| 56 | + <p>We simplified our events experience, read <a href="TODO">about it here</a>. To use the old more complicated interface, click <a href="TODO">Advanced Events</a></p> |
| 57 | + < p>If you need any help, < a href= "mailto:[email protected]">email support</ a>.</ p> |
| 58 | + </div> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | +</template> |
| 62 | +<script> |
| 63 | + import moment from 'moment'; |
| 64 | + import DojoService from '@/dojos/service'; |
| 65 | + import Dropdown from '@/common/cd-dropdown'; |
| 66 | + import CKEditor from '@ckeditor/ckeditor5-vue'; |
| 67 | + import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; |
| 68 | + import EventTile from './cd-event-tile'; |
| 69 | +
|
| 70 | + export default { |
| 71 | + name: 'event-form', |
| 72 | + mixins: [EventTile], |
| 73 | + components: { |
| 74 | + ckeditor: CKEditor.component, |
| 75 | + dropdown: Dropdown, |
| 76 | + }, |
| 77 | + data() { |
| 78 | + return { |
| 79 | + title: '', |
| 80 | + description: '', |
| 81 | + city: '', |
| 82 | + address: '', |
| 83 | + day: moment().date(), |
| 84 | + // TODO: momentjs get month of current locale |
| 85 | + month: moment().month(), |
| 86 | + year: new Date().getFullYear(), |
| 87 | + dojo: {}, |
| 88 | + today: moment.utc(), |
| 89 | + // |
| 90 | + editor: ClassicEditor, |
| 91 | + // state |
| 92 | + addressIsVisible: false, |
| 93 | + descriptionIsVisible: false, |
| 94 | + }; |
| 95 | + }, |
| 96 | + methods: { |
| 97 | + save(e) { |
| 98 | + e.preventDefault(); |
| 99 | + }, |
| 100 | + toggle(field) { // eslint-disable-line no-unused-vars |
| 101 | + // eslint-disable-next-line no-param-reassign |
| 102 | + field = !field; |
| 103 | + }, |
| 104 | + }, |
| 105 | + computed: { |
| 106 | + eventDay() { |
| 107 | + return moment.utc(this.day, this.month, this.year); |
| 108 | + }, |
| 109 | + truncatedDescription() { |
| 110 | + return this.description.substring(0, 20); |
| 111 | + }, |
| 112 | + formattedAddress() { |
| 113 | + return `${this.address.substring(0, 15)}... ${this.city}`; |
| 114 | + }, |
| 115 | + months() { |
| 116 | + return moment.localeData().monthsShort(); |
| 117 | + }, |
| 118 | + }, |
| 119 | + async created() { |
| 120 | + const { dojoId } = this.$route.params; |
| 121 | + this.dojo = (await DojoService.getDojoById(dojoId)).body; |
| 122 | + this.address = this.dojo.address1; |
| 123 | + this.city = this.dojo.city.name; |
| 124 | + }, |
| 125 | + }; |
| 126 | +</script> |
| 127 | +<style scoped lang="less"> |
| 128 | + @import "../common/variables"; |
| 129 | +
|
| 130 | + .cd-event-form { |
| 131 | + display: flex; |
| 132 | + flex-direction: row; |
| 133 | + padding-bottom: 5em; |
| 134 | + &__left-column { |
| 135 | + flex: 2; |
| 136 | + display: flex; |
| 137 | + flex-direction: column; |
| 138 | + padding: @margin; |
| 139 | + } |
| 140 | + &__right-column { |
| 141 | + flex: 1; |
| 142 | + display: flex; |
| 143 | + flex-direction: column; |
| 144 | + justify-content: space-around; |
| 145 | + } |
| 146 | + &__info-box { |
| 147 | + background-color: @side-column-grey; |
| 148 | + padding: @margin; |
| 149 | + &-header { |
| 150 | + margin-top: 10px; |
| 151 | + } |
| 152 | + } |
| 153 | + &__header { |
| 154 | + .title; |
| 155 | + } |
| 156 | + &__location, &__description { |
| 157 | + margin-top: @margin; |
| 158 | + } |
| 159 | + &__description { |
| 160 | + margin-bottom: @margin; |
| 161 | + } |
| 162 | + &__date { |
| 163 | + flex: 1; |
| 164 | + display: flex; |
| 165 | + flex-direction: row; |
| 166 | + // TODO: Proper styling per field, not lazy |
| 167 | + max-width: 50%; |
| 168 | + } |
| 169 | + &__button { |
| 170 | + float: right; |
| 171 | + } |
| 172 | + } |
| 173 | +</style> |
0 commit comments