Snooze snoozes
The API call works, and it doesn't appear in the journal; just need to write the page to view snoozed requests, so they can unsnoozed if required
This commit is contained in:
parent
f6881afaa5
commit
c3a46daba1
@ -66,6 +66,13 @@ export default {
|
||||
*/
|
||||
journal: () => http.get('journal'),
|
||||
|
||||
/**
|
||||
* Snooze a request until the given time
|
||||
* @param requestId {string} The ID of the prayer request to be snoozed
|
||||
* @param until {number} The ticks until which the request should be snoozed
|
||||
*/
|
||||
snoozeRequest: (requestId, until) => http.post(`request/${requestId}/snooze`, { until }),
|
||||
|
||||
/**
|
||||
* Update a prayer request
|
||||
* @param request The request (should have requestId, status, and updateText properties)
|
||||
|
@ -18,6 +18,8 @@ article
|
||||
notes-edit(:events='eventBus'
|
||||
:toast='toast')
|
||||
full-request(:events='eventBus')
|
||||
snooze-request(:events='eventBus'
|
||||
:toast='toast')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -31,6 +33,7 @@ import FullRequest from './request/FullRequest'
|
||||
import NewRequest from './request/NewRequest'
|
||||
import NotesEdit from './request/NotesEdit'
|
||||
import RequestCard from './request/RequestCard'
|
||||
import SnoozeRequest from './request/SnoozeRequest'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
@ -41,7 +44,8 @@ export default {
|
||||
FullRequest,
|
||||
NewRequest,
|
||||
NotesEdit,
|
||||
RequestCard
|
||||
RequestCard,
|
||||
SnoozeRequest
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
@ -53,7 +53,7 @@ export default {
|
||||
this.events.$emit('notes', this.request)
|
||||
},
|
||||
snooze () {
|
||||
// Nothing yet
|
||||
this.events.$emit('snooze', this.request.requestId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
72
src/app/src/components/request/SnoozeRequest.vue
Normal file
72
src/app/src/components/request/SnoozeRequest.vue
Normal file
@ -0,0 +1,72 @@
|
||||
<template lang="pug">
|
||||
b-modal(v-model='snoozeVisible'
|
||||
header-bg-variant='mpj'
|
||||
header-text-variant='light'
|
||||
size='lg'
|
||||
title='Snooze Prayer Request'
|
||||
@edit='openDialog()')
|
||||
b-form
|
||||
b-form-group(label='Until'
|
||||
label-for='until')
|
||||
b-input#until(type='date'
|
||||
v-model='form.snoozedUntil'
|
||||
autofocus)
|
||||
div.w-100.text-right(slot='modal-footer')
|
||||
b-btn(variant='primary'
|
||||
:disabled='!isValid'
|
||||
@click='snoozeRequest()') Snooze
|
||||
|
|
||||
b-btn(variant='outline-secondary'
|
||||
@click='closeDialog()') Cancel
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
export default {
|
||||
name: 'snooze-request',
|
||||
props: {
|
||||
toast: { required: true },
|
||||
events: { required: true }
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
snoozeVisible: false,
|
||||
form: {
|
||||
requestId: '',
|
||||
snoozedUntil: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.events.$on('snooze', this.openDialog)
|
||||
},
|
||||
computed: {
|
||||
isValid () {
|
||||
return !isNaN(Date.parse(this.form.snoozedUntil))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeDialog () {
|
||||
this.form.requestId = ''
|
||||
this.form.snoozedUntil = ''
|
||||
this.snoozeVisible = false
|
||||
},
|
||||
openDialog (requestId) {
|
||||
this.form.requestId = requestId
|
||||
this.snoozeVisible = true
|
||||
},
|
||||
async snoozeRequest () {
|
||||
await this.$store.dispatch(actions.SNOOZE_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestId: this.form.requestId,
|
||||
until: Date.parse(this.form.snoozedUntil)
|
||||
})
|
||||
this.toast.showToast(`Request snoozed until ${this.form.snoozedUntil}`, { theme: 'success' })
|
||||
this.closeDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -6,5 +6,7 @@ export default {
|
||||
/** Action to load the user's prayer journal */
|
||||
LOAD_JOURNAL: 'load-journal',
|
||||
/** Action to update a request */
|
||||
UPDATE_REQUEST: 'update-request'
|
||||
UPDATE_REQUEST: 'update-request',
|
||||
/** Action to snooze a request */
|
||||
SNOOZE_REQUEST: 'snooze-request'
|
||||
}
|
||||
|
@ -109,6 +109,17 @@ export default new Vuex.Store({
|
||||
logError(err)
|
||||
progress.fail()
|
||||
}
|
||||
},
|
||||
async [actions.SNOOZE_REQUEST] ({ commit }, { progress, requestId, until }) {
|
||||
progress.start()
|
||||
try {
|
||||
await api.snoozeRequest(requestId, until)
|
||||
const request = await api.getRequest(requestId)
|
||||
commit(mutations.REQUEST_UPDATED, request.data)
|
||||
} catch (err) {
|
||||
logError(err)
|
||||
progress.fail()
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {},
|
||||
|
Loading…
Reference in New Issue
Block a user