Commit 60981067 authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

implements future timeslot deletion for #30

parent 35c3005a
......@@ -120,6 +120,29 @@
>
</div>
</b-modal>
<b-modal
ref="modalEmissionManagerDeleteTimeslots"
title="Deleting timeslots"
size="lg"
centered
hide-footer
no-close-on-esc
no-close-on-backdrop
>
<div align="center">
<img
src="../assets/radio.gif"
alt="loading schedule data"
>
<b-progress
:value="deletion.count"
:max="deletion.amount"
variant="info"
animated
/>
</div>
</b-modal>
</div>
</template>
......@@ -141,6 +164,10 @@ export default {
modal: false,
schedule: false,
scheduleTimeslots: false,
},
deletion: {
amount: 0,
count: 0,
}
}
},
......@@ -177,9 +204,47 @@ export default {
})
},
deleteAllFutureTimeslots (scheduleId, timeslotId) {
this.$log.debug(scheduleId, timeslotId)
this.notYetImplemented()
deleteAllFutureTimeslots (scheduleId) {
let startDate = new Date(this.timeslot.start)
let toDelete = []
for (let slot of this.scheduleTimeslots) {
if (new Date(slot.start) >= startDate) {
toDelete.push(slot.id)
}
}
if (toDelete.length === this.scheduleTimeslots.length) {
this.$log.debug('deleting full schedule')
this.deleteFullSchedule(scheduleId)
}
else {
this.deletion.amount = toDelete.length
this.deletion.count = 0
this.$refs.modalEmissionManagerDeleteTimeslots.show()
let uri = process.env.VUE_APP_API_STEERING + 'shows/' + this.show.id + '/schedules/' + scheduleId + '/'
for (let i in toDelete) {
this.$log.debug('Deleting timeslot', toDelete[i])
axios.delete(uri + 'timeslots/' + toDelete[i] + '/', {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.$parent.user.access_token }
}).then(() => {
this.deletion.count++
this.$log.debug('deleted ' + this.deletion.count + ' timeslots')
if (this.deletion.count === this.deletion.amount) {
this.$parent.renderView(null)
this.$refs.modalEmissionManagerDeleteTimeslots.hide()
this.$refs.modalEmissionManagerEdit.hide()
}
}).catch(error => {
this.$log.error(error.response.status + ' ' + error.response.statusText)
this.$log.error(error.response)
alert('Error: could not delete full timeslot. See console for details.')
})
}
}
},
loadSchedule (id) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment