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
8a45f85d
Commit
8a45f85d
authored
Sep 26, 2019
by
jackie / Andrea Ida Malkah Klaura
Browse files
FIX
#21
show update modals use minimal required show object
parent
a5ec7564
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/components/ShowManagerModalShow.vue
View file @
8a45f85d
...
...
@@ -502,203 +502,218 @@ export default {
the info set through the modal.
*/
methods
:
{
/* returns a new minimal object from the current show object with all
properties needed for a PUT request to the /show/ endpoint */
getUpdateShowObject
()
{
let
s
=
{}
s
.
name
=
this
.
show
.
name
s
.
slug
=
this
.
show
.
slug
s
.
short_description
=
this
.
show
.
short_description
s
.
fundingcategory
=
this
.
show
.
fundingcategory
s
.
type
=
this
.
show
.
type
// we do not want the arrays do be passed as references, because the
// current show object should not get modified when the update object
// gets modified, therefore we use slice to clone the arrays
s
.
category
=
this
.
show
.
category
.
slice
()
s
.
hosts
=
this
.
show
.
hosts
.
slice
()
s
.
owners
=
this
.
show
.
owners
.
slice
()
s
.
language
=
this
.
show
.
language
.
slice
()
s
.
topic
=
this
.
show
.
topic
.
slice
()
s
.
musicfocus
=
this
.
show
.
musicfocus
.
slice
()
return
s
},
/*
Functions to update certain infos about a show through the API
The API always takes the full show object, so even if we only change one
single item in a show we have to send the whole show.
This also means we could use just one save function. Here we could think
about refactoring. It is important than to check which of the items have
changed and to restore those items in case the update fails.
For now we have single function for every modal to save only the bits
regarding this modal.
Functions to update certain infos about a show should first check out a
new show object with getUpdateShowObject and then modify / add those
properties that actually get changed
TODO: think about refactoring all those function to one or few functions
*/
saveName
(
event
)
{
if
(
this
.
string
!==
this
.
show
.
name
)
{
event
.
preventDefault
()
this
.
backupstring
=
this
.
show
.
name
this
.
s
how
.
name
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
name
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
name
=
this
.
string
this
.
$refs
.
modalShowName
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
name
=
this
.
backupstring
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show name. See console for details.
'
)
})
}
},
saveShortDescription
(
event
)
{
if
(
this
.
string
!==
this
.
show
.
short_description
)
{
event
.
preventDefault
()
this
.
backupstring
=
this
.
show
.
short_description
this
.
s
how
.
short_description
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
short_description
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
short_description
=
this
.
string
this
.
$refs
.
modalShowShortDescription
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
short_description
=
this
.
backupstring
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show
\'
s short description. See console for details.
'
)
})
}
},
saveDescription
(
event
)
{
if
(
this
.
string
!==
this
.
show
.
description
)
{
event
.
preventDefault
()
this
.
backupstring
=
this
.
show
.
description
this
.
s
how
.
description
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
description
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
description
=
this
.
string
this
.
$refs
.
modalShowDescription
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
description
=
this
.
backupstring
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show description. See console for details.
'
)
})
}
},
saveEmail
(
event
)
{
if
(
this
.
string
!==
this
.
show
.
email
)
{
event
.
preventDefault
()
this
.
backupstring
=
this
.
show
.
email
this
.
s
how
.
email
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
email
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
email
=
this
.
string
this
.
$refs
.
modalShowEmail
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
email
=
this
.
backupstring
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show e-mail contact. See console for details.
'
)
})
}
},
saveWebsite
(
event
)
{
if
(
this
.
string
!==
this
.
show
.
website
)
{
event
.
preventDefault
()
this
.
backupstring
=
this
.
show
.
website
this
.
s
how
.
website
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
website
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
website
=
this
.
string
this
.
$refs
.
modalShowWebsite
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
website
=
this
.
backupstring
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show website. See console for details.
'
)
})
}
},
saveCBAid
(
event
)
{
if
(
this
.
id
!==
this
.
show
.
cba_series_id
)
{
event
.
preventDefault
()
this
.
backupid
=
this
.
show
.
cba_series_id
this
.
s
how
.
cba_series_id
=
this
.
id
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
cba_series_id
=
this
.
string
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
cba_series_id
=
this
.
id
this
.
$refs
.
modalShowCBAid
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
cba_series_id
=
this
.
backupid
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the CBA show id. See console for details.
'
)
})
}
},
saveShowType
(
event
)
{
if
(
this
.
id
!==
this
.
show
.
type
)
{
event
.
preventDefault
()
this
.
backupid
=
this
.
show
.
type
this
.
s
how
.
type
=
this
.
id
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
type
=
this
.
id
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
type
=
this
.
id
this
.
$parent
.
getType
()
this
.
$refs
.
modalShowType
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
type
=
this
.
backupid
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show type. See console for details.
'
)
})
}
},
savePredecessor
(
event
)
{
if
(
this
.
id
!==
this
.
show
.
predecessor
)
{
event
.
preventDefault
()
this
.
backupid
=
this
.
show
.
predecessor_id
this
.
s
how
.
predecessor_id
=
this
.
id
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
predecessor_id
=
this
.
id
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
predecessor_id
=
this
.
id
this
.
$refs
.
modalShowPredecessor
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
predecessor
=
this
.
backupid
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show predecessor. See console for details.
'
)
})
}
},
saveFundingCategory
(
event
)
{
if
(
this
.
id
!==
this
.
show
.
fundingcategory
)
{
event
.
preventDefault
()
this
.
backupid
=
this
.
show
.
fundingcategory
this
.
s
how
.
fundingcategory
=
this
.
id
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
fundingcategory
=
this
.
id
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
fundingcategory
=
this
.
id
this
.
$parent
.
getFundingCategory
()
this
.
$refs
.
modalShowType
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
fundingcategory
=
this
.
backupid
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show
\'
funding category. See console for details.
'
)
})
}
},
saveCategories
(
event
)
{
this
.
$log
.
debug
(
'
saveCategories
'
,
this
.
array
,
this
.
show
.
category
)
if
(
this
.
array
.
length
!==
this
.
show
.
category
.
length
||
!
this
.
array
.
every
((
value
,
index
)
=>
value
===
this
.
show
.
category
[
index
]))
{
event
.
preventDefault
()
let
updatedShow
=
{
name
:
this
.
show
.
name
,
slug
:
this
.
show
.
slug
,
short_description
:
this
.
show
.
short_description
,
fundingcategory
:
this
.
show
.
fundingcategory
,
type
:
this
.
show
.
type
,
hosts
:
this
.
show
.
hosts
,
language
:
this
.
show
.
language
,
musicfocus
:
this
.
show
.
musicfocus
,
owners
:
this
.
show
.
owners
,
topic
:
this
.
show
.
topic
,
}
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedShow
.
category
=
this
.
array
let
uri
=
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
axios
.
put
(
uri
,
updatedShow
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
$parent
.
shows
[
this
.
$parent
.
currentShow
].
category
=
updatedShow
.
categor
y
this
.
$parent
.
shows
[
this
.
$parent
.
currentShow
].
category
=
this
.
arra
y
this
.
$parent
.
getCategories
()
this
.
$refs
.
modalShowCategories
.
hide
()
}).
catch
(
error
=>
{
...
...
@@ -708,38 +723,40 @@ export default {
})
}
},
saveTopics
(
event
)
{
if
(
this
.
array
.
length
!==
this
.
show
.
topic
.
length
||
!
this
.
array
.
every
((
value
,
index
)
=>
value
===
this
.
show
.
topic
[
index
]))
{
event
.
preventDefault
()
this
.
backuparray
=
this
.
show
.
topic
this
.
s
how
.
topic
=
this
.
array
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
topic
=
this
.
array
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
topic
=
this
.
array
this
.
$parent
.
getTopics
()
this
.
$refs
.
modalShowTopics
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
topic
=
this
.
backuparray
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show
\'
s topics. See console for details.
'
)
})
}
},
saveMusicFocus
(
event
)
{
if
(
this
.
array
.
length
!==
this
.
show
.
musicfocus
.
length
||
!
this
.
array
.
every
((
value
,
index
)
=>
value
===
this
.
show
.
musicfocus
[
index
]))
{
event
.
preventDefault
()
this
.
backuparray
=
this
.
show
.
musicfocus
this
.
s
how
.
musicfocus
=
this
.
array
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
musicfocus
=
this
.
array
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
musicfocus
=
this
.
array
this
.
$parent
.
getMusicfocus
()
this
.
$refs
.
modalShowMusicFocus
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
musicfocus
=
this
.
backuparray
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show
\'
s music focus. See console for details.
'
)
...
...
@@ -749,16 +766,16 @@ export default {
saveLanguages
(
event
)
{
if
(
this
.
array
.
length
!==
this
.
show
.
language
.
length
||
!
this
.
array
.
every
((
value
,
index
)
=>
value
===
this
.
show
.
language
[
index
]))
{
event
.
preventDefault
()
this
.
backuparray
=
this
.
show
.
language
this
.
s
how
.
language
=
this
.
array
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
language
=
this
.
array
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
language
=
this
.
array
this
.
$parent
.
getLanguages
()
this
.
$refs
.
modalShowLanguages
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
language
=
this
.
backuparray
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show
\'
s languages. See console for details.
'
)
...
...
@@ -768,16 +785,16 @@ export default {
saveHosts
(
event
)
{
if
(
this
.
array
.
length
!==
this
.
show
.
hosts
.
length
||
!
this
.
array
.
every
((
value
,
index
)
=>
value
===
this
.
show
.
hosts
[
index
]))
{
event
.
preventDefault
()
this
.
backuparray
=
this
.
show
.
hosts
this
.
s
how
.
hosts
=
this
.
array
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
this
.
s
how
,
{
let
updatedShow
=
this
.
getUpdateShowObject
()
updatedS
how
.
hosts
=
this
.
array
axios
.
put
(
process
.
env
.
VUE_APP_API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/
'
,
updatedS
how
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
this
.
$parent
.
$parent
.
user
.
access_token
}
}).
then
(()
=>
{
this
.
show
.
hosts
=
this
.
array
this
.
$parent
.
getHosts
()
this
.
$refs
.
modalShowHosts
.
hide
()
}).
catch
(
error
=>
{
this
.
show
.
hosts
=
this
.
backuparray
this
.
$log
.
error
(
error
.
response
.
status
+
'
'
+
error
.
response
.
statusText
)
this
.
$log
.
error
(
error
.
response
)
alert
(
'
Error: could not save the show
\'
s hosts. See console for details.
'
)
...
...
Write
Preview
Supports
Markdown
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