Newer
Older
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
<div>
<!-- Modal for adding new shows -->
<b-modal
ref="modalAddShow"
:title="$t('showCreator.title')"
:cancel-title="$t('cancel')"
size="lg"
@ok="addShow"
>
<b-container fluid>
<b-row>
<b-col cols="3"> {{ $t('showMeta.showName') }}: </b-col>
<b-col cols="9">
<b-form-input
v-model="newShow.name"
type="text"
:placeholder="$t('showMeta.showNamePlaceholder')"
/>
</b-col>
<b-col cols="3" />
<b-col cols="9">
<small class="slug">{{ $t('slug') }}: {{ temporarySlug }}</small>
</b-col>
</b-row>
<br />
<b-row>
<b-col cols="3"> {{ $t('showMeta.shortDescription') }}: </b-col>
<b-col cols="9">
<b-form-input
v-model="newShow.short_description"
type="text"
:placeholder="$t('showMeta.shortDescriptionPlaceholder')"
/>
</b-col>
</b-row>
<br />
<b-row>
<b-col cols="3"> {{ $t('showMeta.type') }}: </b-col>
<b-col cols="9">
<div v-if="!loaded.types">
<img src="/assets/radio.gif" :alt="$t('loading')" />
</div>
<div v-else>
<b-form-select v-model="newShow.type" :options="showTypeSelector" />

Konrad Mohrfeldt
committed
<p
v-if="showTypeSelector.length === 0"
v-html="$t('showCreator.missingShowTypes', { adminUrl })"
/>
</div>
</b-col>
</b-row>
<br />
<b-row>
<b-col cols="3"> {{ $t('showMeta.fundingCategory') }}: </b-col>
<b-col cols="9">
<div v-if="!loaded.fundingcategories">
<img src="/assets/radio.gif" :alt="$t('loading')" />
</div>
<div v-else>
<b-form-select
v-model="newShow.fundingcategory"
:options="showFundingCategorySelector"
/>

Konrad Mohrfeldt
committed
<p
v-if="showFundingCategorySelector.length === 0"
v-html="$t('showCreator.missingShowFundingCategories', { adminUrl })"
/>
</div>
</b-col>
</b-row>
</b-container>
</b-modal>
</div>
</template>
<script>
import slugify from '../../mixins/slugify.js'
import { mapGetters } from 'vuex'
export default {
mixins: [slugify],
props: {
callback: { type: Function, default: null },
},
data() {
return {

Konrad Mohrfeldt
committed
adminUrl: `${import.meta.env.VUE_APP_BASEURI_STEERING}/admin`,
newShow: {
name: '',
slug: '',
short_description: '',
type: 0,
fundingcategory: 0,
category: [],
hosts: [],
owners: [],
language: [],
topic: [],
musicfocus: [],
},
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
},
computed: {
loaded() {
return this.$store.state.shows.loaded
},
temporarySlug: function () {
return this.slugify(this.newShow.name)
},
showTypeSelector: function () {
return this.types.map(({ type, id }) => ({ text: type, value: id }))
},
showFundingCategorySelector: function () {
return this.fundingcategories.map(({ id, abbrev, fundingcategory }) => ({
value: id,
text: `${abbrev} (${fundingcategory})`,
}))
},
...mapGetters({
types: 'shows/types',
fundingcategories: 'shows/fundingcategories',
users: 'auth/users',
}),
},
methods: {
// create a new show and POST it to the steering API
// new shows have to at least contain a name, a slug and a short-description.
// also a valide show type and funding category have to be choosen.
// for all other categories we can use an empty array and let the user fill
// it out through the existing show manager modals, after the show is created
addShow(event) {
// prevent the modal from closing automatically on click
event.preventDefault()
// only try to add a new show if name and short description are filled out
if (this.newShow.name.trim() === '' || this.newShow.short_description.trim() === '') {
// TODO: make this nicer UI-wise (red text annotations next to input fields instead of simple alert)
alert('Please provide at least a title and a short description for this show.')
return
}
// also the type and funding category have to be set
if (this.types.findIndex((type) => type.id === this.newShow.type) === -1) {
// TODO: make this nicer UI-wise (red text annotations next to input fields instead of simple alert)
alert('Please choose a type for this show.')
return
}
if (
this.fundingcategories.findIndex((cat) => cat.id === this.newShow.fundingcategory) === -1
) {
// TODO: make this nicer UI-wise (red text annotations next to input fields instead of simple alert)
alert('Please choose a funding category for this show.')
return
}
// as the slug is a computed property we have to assign it to the new show's slug property
this.newShow.slug = this.temporarySlug
const modal = this.$refs.modalAddShow
this.$store.dispatch('shows/submitShow', {
show: this.newShow,
callback: (response) => {
modal.hide()
this.$store.commit('shows/switchShowById', response.data.id)
if (this.callback) {
this.callback()
}
},
})
},
// clear and fetch modal data and open the modal to add new shows
openModal() {
this.newShow.name = ''
this.newShow.slug = ''
this.newShow.short_description = ''
this.$refs.modalAddShow.show()
},
},
}
</script>
<style scoped>