Skip to content
Snippets Groups Projects
Commit ddf86c5f authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

refactor: remove old Vuex note store

refs #127
parent 3877f834
No related branches found
No related tags found
No related merge requests found
......@@ -163,7 +163,6 @@ export default {
...mapGetters({
selectedShow: 'shows/selectedShow',
timeslots: 'shows/timeslots',
notes: 'shows/notes',
playlists: 'playlists/playlists',
getTimeslotById: 'shows/getTimeslotById',
}),
......
......@@ -32,7 +32,6 @@ const state = {
schedules: [],
scheduleTimeslots: [],
timeslots: [],
notes: [],
types: [],
fundingCategories: [],
categories: [],
......@@ -43,7 +42,6 @@ const state = {
loaded: {
shows: false,
timeslots: false,
notes: false,
schedule: false,
scheduleTimeslots: false,
schedules: false,
......@@ -68,7 +66,6 @@ const getters = {
schedules: (state) => state.schedules,
scheduleTimeslots: (state) => state.scheduleTimeslots,
timeslots: (state) => state.timeslots,
notes: (state) => state.notes,
types: (state) => state.types,
fundingCategories: (state) => state.fundingCategories,
categories: (state) => state.categories,
......@@ -129,17 +126,6 @@ const mutations = {
state.timeslots.splice(index, 1, slot)
},
setNotes(state, notes) {
state.notes = notes
},
addNote(state, note) {
state.notes.push(note)
},
setNote(state, note) {
const index = state.notes.findIndex((n) => n.id === note.id)
state.notes.splice(index, 1, note)
},
setName(state, data) {
const index = state.shows.findIndex((s) => s.id === data.id)
state.shows[index].name = data.text
......@@ -298,39 +284,6 @@ const actions = {
})
},
fetchNotes(ctx, data) {
ctx.commit('loading', 'notes')
// we only have to make an API call if there are actually any notes
// otherwise the notes are just and empty array
if (data.notes.length === 0) {
ctx.commit('setNotes', [])
ctx.commit('finishLoading', 'notes')
return
}
const uri = createSteeringURL(
'shows',
data.id,
'notes',
new URLSearchParams({ ids: data.notes.join(',') }),
)
this.$log.debug('fetchNotes: uri:', uri)
axios
.get(uri)
.then((response) => {
ctx.commit('setNotes', response.data)
ctx.commit('finishLoading', 'notes')
if (data && typeof data.callback === 'function') {
data.callback(response)
}
})
.catch((error) => {
handleApiError(this, error, 'could not load notes')
if (data && typeof data.callbackCancel === 'function') {
data.callbackCancel()
}
})
},
fetchMetaArray(ctx, data) {
ctx.commit('loading', data.property)
const subPath = decamelize(data.property, { separator: '-' })
......@@ -387,55 +340,6 @@ const actions = {
})
},
submitNote(ctx, data) {
let uri = createSteeringURL(
'shows',
data.id,
'schedules',
data.scheduleID,
'timeslots',
data.timeslotID,
'note',
)
if (data.update) {
uri += data.note.id + '/'
}
const method = data.update ? 'put' : 'post'
const formData = new FormData()
// We serialize the data to a FormData object, so we can send the image
// as binary blob to the Steering API.
for (const [key, value] of Object.entries(data.note)) {
formData.append(key, value)
}
axios
.request({
url: uri,
method: method,
data: formData,
responseType: 'json', // we need this explicitly here, as it does not seem to work automagically as in GET and PUT requests
})
.then((response) => {
if (data.update) {
ctx.commit('setNote', response.data)
} else {
ctx.commit('addNote', response.data)
}
if (data && typeof data.callback === 'function') {
data.callback(response)
}
})
.catch((error) => {
const msg = data.update ? 'could not update note' : 'could not add new note'
handleApiError(this, error, msg)
if (data && typeof data.callbackCancel === 'function') {
data.callbackCancel()
}
})
},
updateShow(ctx, data) {
const uri = createSteeringURL('shows', data.id)
axios
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment