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
bfbd1de7
Commit
bfbd1de7
authored
Feb 16, 2018
by
Andrea Ida Malkah Klaura
Browse files
added function to post new note
parent
3a90ab18
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/components/ShowManagerModalNotes.vue
View file @
bfbd1de7
...
@@ -67,7 +67,7 @@ export default {
...
@@ -67,7 +67,7 @@ export default {
this
.
note
.
summary
=
this
.
summary
this
.
note
.
summary
=
this
.
summary
this
.
note
.
content
=
this
.
content
this
.
note
.
content
=
this
.
content
// generate the uri for the API call:
// generate the uri for the API call:
// /api/v1/shows/1/schedules/1/timeslots/1/note/1
// /api/v1/shows/1/schedules/1/timeslots/1/note/1
/
var
uri
=
process
.
env
.
API_STEERING_SHOWS
+
this
.
show
.
id
+
var
uri
=
process
.
env
.
API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/schedules/
'
+
this
.
scheduleID
+
'
/schedules/
'
+
this
.
scheduleID
+
'
/timeslots/
'
+
this
.
timeslotID
+
'
/timeslots/
'
+
this
.
timeslotID
+
...
@@ -87,6 +87,7 @@ export default {
...
@@ -87,6 +87,7 @@ export default {
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'
Error:
'
)
console
.
log
(
'
Error:
'
)
console
.
log
(
error
)
console
.
log
(
error
)
alert
(
'
There was an error while trying to update the note:
'
+
error
)
// as there was an error saving the show, we have to make sure
// as there was an error saving the show, we have to make sure
// to restore the initial values of the note object
// to restore the initial values of the note object
this
.
note
.
title
=
this
.
backuptitle
this
.
note
.
title
=
this
.
backuptitle
...
@@ -100,7 +101,61 @@ export default {
...
@@ -100,7 +101,61 @@ export default {
}
}
},
},
new
()
{
new
()
{
console
.
log
(
'
trying to create a new note
'
)
// only try to save if any data was filled in
if
(
this
.
title
!==
''
&&
this
.
summary
!==
''
&&
this
.
content
!==
''
)
{
// prevent the modal from closing automatically on click
event
.
preventDefault
()
// prepare the new note
this
.
note
=
{
show
:
this
.
show
.
id
,
timeslot
:
this
.
timeslotID
,
host
:
null
,
// TODO: implement
title
:
this
.
title
,
slug
:
''
,
// TODO: implement
summary
:
this
.
summary
,
content
:
this
.
content
,
ppoi
:
'
(0.5,0.5)
'
,
// TODO: implement
height
:
null
,
// TODO: implement
width
:
null
,
// TODO: implement
image
:
null
,
// TODO: implement
status
:
1
,
// TODO: implement
start
:
''
,
// TODO: implement
cba_id
:
null
,
// TODO: implement
audio_url
:
''
// TODO: implement
}
// generate the uri for the API call:
// /api/v1/shows/1/schedules/1/timeslots/1/note
var
uri
=
process
.
env
.
API_STEERING_SHOWS
+
this
.
show
.
id
+
'
/schedules/
'
+
this
.
scheduleID
+
'
/timeslots/
'
+
this
.
timeslotID
+
'
/note/
'
console
.
log
(
'
trying to create a new note
'
)
console
.
log
(
uri
)
console
.
log
(
this
.
note
)
// now send the POST request with our updated note
axios
.
post
(
uri
,
this
.
note
,
{
withCredentials
:
true
,
transformResponse
:
[
debugErrorResponse
]
}).
then
(
response
=>
{
console
.
log
(
'
Response:
'
)
console
.
log
(
response
)
// everything was fine, we can close the modal now
this
.
$refs
.
modalNote
.
hide
()
}).
catch
(
error
=>
{
console
.
log
(
'
Error:
'
)
console
.
log
(
error
)
alert
(
'
There was an error while trying to posting the new note:
'
+
error
)
// as there was an error saving the show, we have to make sure
// to restore the initial values of the note object
this
.
note
.
title
=
this
.
backuptitle
this
.
note
.
summary
=
this
.
backupsummary
this
.
note
.
content
=
this
.
backupcontent
// and we leave the modal open, so no call to its .hide function here
})
// if nothing was changed, just close the modal
}
else
{
this
.
$refs
.
modalNote
.
hide
()
}
},
},
saveNote
(
event
)
{
saveNote
(
event
)
{
if
(
typeof
this
.
note
.
start
===
'
undefined
'
)
{
if
(
typeof
this
.
note
.
start
===
'
undefined
'
)
{
...
...
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