Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
AURA
dashboard
Commits
78226917
Commit
78226917
authored
Aug 06, 2019
by
jackie / Andrea Ida Malkah Klaura
Browse files
FIX: check for valid type & category in add show modal
parent
46dfc62d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/components/ShowManagerModalSuperuser.vue
View file @
78226917
...
...
@@ -59,7 +59,7 @@
</div>
</b-col>
</b-row>
<b-row>
<b-col
cols=
"3"
>
Funding category:
...
...
@@ -165,33 +165,54 @@ export default {
},
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.
'
)
}
else
{
// as the slug is a computed property we to assign it to the new show's slug variable
this
.
newShow
.
slug
=
this
.
temporarySlug
let
uri
=
process
.
env
.
VUE_APP_API_STEERING_SHOWS
axios
.
post
(
uri
,
this
.
newShow
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(
response
=>
{
// everything was fine, we can close the modal now
this
.
$refs
.
modalAddShow
.
hide
()
this
.
$parent
.
loadAndSwitch
(
response
.
data
.
id
)
}).
catch
(
error
=>
{
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not add new show. See console for details.
'
)
// and we leave the modal open, so no call to its .hide function here
})
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
// ready to go, let's POST this new show
let
uri
=
process
.
env
.
VUE_APP_API_STEERING_SHOWS
axios
.
post
(
uri
,
this
.
newShow
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(
response
=>
{
// everything was fine, we can close the modal now
this
.
$refs
.
modalAddShow
.
hide
()
this
.
$parent
.
loadAndSwitch
(
response
.
data
.
id
)
}).
catch
(
error
=>
{
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not add new show. See console for details.
'
)
// and we leave the modal open, so no call to its .hide function here
})
},
// delete a show by sending a DELETE to the steering API
deleteShow
(
event
)
{
// prevent the modal from closing automatically on click
event
.
preventDefault
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment