F# API (#18)
- API is now F# / Giraffe / EF Core - Snoozed requests are complete #17 - Updated doc links in preparation for transfer to Bit Badger Solutions organization's repository
This commit was merged in pull request #18.
This commit is contained in:
committed by
GitHub
parent
d1fd5f68e7
commit
8becb8cea4
@@ -10,6 +10,7 @@ article
|
||||
b-table(small hover :fields='fields' :items='log')
|
||||
template(slot='action' scope='data').
|
||||
{{ data.item.status }} on #[span.text-nowrap {{ formatDate(data.item.asOf) }}]
|
||||
template(slot='text' scope='data' v-if='data.item.text') {{ data.item.text.fields[0] }}
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -44,12 +45,12 @@ export default {
|
||||
},
|
||||
lastText () {
|
||||
return this.request.history
|
||||
.filter(hist => hist.text > '')
|
||||
.sort(asOfDesc)[0].text
|
||||
.filter(hist => hist.text)
|
||||
.sort(asOfDesc)[0].text.fields[0]
|
||||
},
|
||||
log () {
|
||||
return (this.request.notes || [])
|
||||
.map(note => ({ asOf: note.asOf, text: note.notes, status: 'Notes' }))
|
||||
.map(note => ({ asOf: note.asOf, text: { case: 'Some', fields: [ note.notes ] }, status: 'Notes' }))
|
||||
.concat(this.request.history)
|
||||
.sort(asOfDesc)
|
||||
.slice(1)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -12,11 +12,13 @@ b-navbar(toggleable='sm'
|
||||
b-navbar-nav
|
||||
b-nav-item(v-if='isAuthenticated'
|
||||
to='/journal') Journal
|
||||
b-nav-item(v-if='hasSnoozed'
|
||||
to='/snoozed') Snoozed
|
||||
b-nav-item(v-if='isAuthenticated'
|
||||
to='/answered') Answered
|
||||
b-nav-item(v-if='isAuthenticated'): a(@click.stop='logOff()') Log Off
|
||||
b-nav-item(v-if='!isAuthenticated'): a(@click.stop='logOn()') Log On
|
||||
b-nav-item(href='https://danieljsummers.github.io/myPrayerJournal/'
|
||||
b-nav-item(href='https://bit-badger.github.io/myPrayerJournal/'
|
||||
target='_blank'
|
||||
@click.stop='') Docs
|
||||
</template>
|
||||
@@ -35,7 +37,12 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState([ 'isAuthenticated' ])
|
||||
hasSnoozed () {
|
||||
return this.isAuthenticated &&
|
||||
Array.isArray(this.journal) &&
|
||||
this.journal.filter(req => req.snoozedUntil > Date.now()).length > 0
|
||||
},
|
||||
...mapState([ 'journal', 'isAuthenticated' ])
|
||||
},
|
||||
methods: {
|
||||
logOn () {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<template lang="pug">
|
||||
article
|
||||
page-title(title='Snoozed Requests')
|
||||
p(v-if='!loaded') Loading journal...
|
||||
div(v-if='loaded').mpj-snoozed-list
|
||||
p.text-center(v-if='requests.length === 0'): em.
|
||||
No snoozed requests found; return to #[router-link(:to='{ name: "Journal" } ') your journal]
|
||||
p.mpj-snoozed-text(v-for='req in requests' :key='req.requestId')
|
||||
| {{ req.text }}
|
||||
br
|
||||
br
|
||||
b-btn(@click='cancelSnooze(req.requestId)'
|
||||
size='sm'
|
||||
variant='outline-secondary')
|
||||
icon(name='times')
|
||||
= ' Cancel Snooze'
|
||||
small.text-muted: em.
|
||||
Snooze expires #[date-from-now(:value='req.snoozedUntil')]
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use static'
|
||||
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
export default {
|
||||
name: 'answered',
|
||||
data () {
|
||||
return {
|
||||
requests: [],
|
||||
loaded: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
toast () {
|
||||
return this.$parent.$refs.toast
|
||||
},
|
||||
...mapState(['journal', 'isLoadingJournal'])
|
||||
},
|
||||
methods: {
|
||||
async ensureJournal () {
|
||||
if (!Array.isArray(this.journal)) {
|
||||
this.loaded = false
|
||||
await this.$store.dispatch(actions.LOAD_JOURNAL, this.$Progress)
|
||||
}
|
||||
this.requests = this.journal
|
||||
.filter(req => req.snoozedUntil > Date.now())
|
||||
.sort((a, b) => a.snoozedUntil - b.snoozedUntil)
|
||||
this.loaded = true
|
||||
},
|
||||
async cancelSnooze (requestId) {
|
||||
await this.$store.dispatch(actions.SNOOZE_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestId: requestId,
|
||||
until: 0
|
||||
})
|
||||
this.toast.showToast('Request un-snoozed', { theme: 'success' })
|
||||
this.ensureJournal()
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
await this.ensureJournal()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mpj-snoozed-list p {
|
||||
border-top: solid 1px lightgray;
|
||||
}
|
||||
.mpj-snoozed-list p:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
</style>
|
||||
@@ -2,8 +2,8 @@
|
||||
b-list-group-item
|
||||
| {{ history.status }}
|
||||
|
|
||||
small.text-muted {{ asOf }}
|
||||
div(v-if='hasText').mpj-request-text {{ history.text }}
|
||||
small.text-muted(:title='actualDate') {{ asOf }}
|
||||
div(v-if='history.text').mpj-request-text {{ history.text.fields[0] }}
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -20,8 +20,8 @@ export default {
|
||||
asOf () {
|
||||
return moment(this.history.asOf).fromNow()
|
||||
},
|
||||
hasText () {
|
||||
return this.history.text.length > 0
|
||||
actualDate () {
|
||||
return moment(this.history.asOf).format('LLLL')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export default {
|
||||
this.events.$emit('notes', this.request)
|
||||
},
|
||||
snooze () {
|
||||
// Nothing yet
|
||||
this.events.$emit('snooze', this.request.requestId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user