This commit is contained in:
Lucas Verney 2016-11-09 17:12:42 -05:00
parent 7abed1dbaa
commit b94c6bfdf0
6 changed files with 117 additions and 73 deletions

View File

@ -2,7 +2,7 @@
tr tr
td td
color-span(v-bind:color="eventTypes[RSVPItem.eventTypeHash].color") color-span(v-bind:color="eventTypes[RSVPItem.eventTypeHash].color")
span {{ RSVPItem.startTime }} - {{ RSVPItem.endTime }} span {{ RSVPItem.startTime.format() }} - {{ RSVPItem.endTime.format() }}
td td
template(v-for="(member, index) in RSVPItem.members") template(v-for="(member, index) in RSVPItem.members")
template(v-if="index > 0") template(v-if="index > 0")

View File

@ -6,8 +6,10 @@
router-link(v-bind:to="{ name: 'publicSlotSelectionView', params: { hash: hash, day: day } }") router-link(v-bind:to="{ name: 'publicSlotSelectionView', params: { hash: hash, day: day } }")
| {{ day }} | {{ day }}
p p.
em Times are in {{ timezone }} timezone. Times are in
#[em {{ timezone }}]
timezone.
</template> </template>
<style lang="stylus" scoped> <style lang="stylus" scoped>

View File

@ -6,8 +6,10 @@
router-link(v-bind:to="{ name: 'publicContactInfosView', params: { hash: hash, day: day, timeBegin: slot.timeBegin, timeEnd: slot.timeEnd } }") router-link(v-bind:to="{ name: 'publicContactInfosView', params: { hash: hash, day: day, timeBegin: slot.timeBegin, timeEnd: slot.timeEnd } }")
| {{ slot.timeBegin }} - {{ slot.timeEnd }} | {{ slot.timeBegin }} - {{ slot.timeEnd }}
p p.
em Times are in {{ timezone }} timezone. Times are in
#[em {{ timezone }}]
timezone.
</template> </template>
<style lang="stylus" scoped> <style lang="stylus" scoped>

View File

@ -1,4 +1,8 @@
const RSVP = { import cozySDK from 'cozysdk-client'
import moment from 'moment-timezone'
// Define model fields
const RSVPDefaultFields = {
startTime: null, startTime: null,
endTime: null, endTime: null,
members: [], members: [],
@ -6,4 +10,37 @@ const RSVP = {
status: null status: null
} }
// Define view
cozySDK.defineView(
'rsvp',
'all',
doc => emit(doc._id, doc),
error => error && console.error(error)
)
cozySDK.defineView(
'rsvp',
'by_day',
(doc) => {
// TODO
const day = 'TODO'
emit(day, doc)
},
error => error && console.error(error)
)
// Constructor
class RSVP {
constructor (fields={}) {
Object.assign(this, RSVPDefaultFields, fields)
this.startTime = moment.unix(this.startTime)
this.endTime = moment.unix(this.endTime)
}
static getFromView(view='all') {
return cozySDK.queryView('rsvp', view, {});
}
}
export default RSVP export default RSVP

View File

@ -4,11 +4,15 @@
event-types-nav(v-bind:eventTypes="eventTypes") event-types-nav(v-bind:eventTypes="eventTypes")
ul p(v-if="loading") Loading...
ul(v-if="RSVPItems")
li(v-for="(RSVPItemsForDay, day) in RSVPItems") li(v-for="(RSVPItemsForDay, day) in RSVPItems")
dashboard-day(v-bind:day="day", v-bind:RSVPItemsForDay="RSVPItemsForDay", v-bind:eventTypes="eventTypes") dashboard-day(v-bind:day="day", v-bind:RSVPItemsForDay="RSVPItemsForDay", v-bind:eventTypes="eventTypes")
p p.
em Times are in {{ timezone }} timezone. Times are in
#[em {{ timezone }}]
timezone.
</template> </template>
<style lang="stylus" scoped> <style lang="stylus" scoped>
@ -27,55 +31,17 @@
import cozySDK from 'cozysdk-client' import cozySDK from 'cozysdk-client'
import moment from 'moment-timezone' import moment from 'moment-timezone'
// Models import
import RSVP from '../models/RSVP'
// Components imports // Components imports
import eventTypesNav from '../components/eventTypesNav.vue' import eventTypesNav from '../components/eventTypesNav.vue'
import dashboardDay from '../components/dashboardDay.vue' import dashboardDay from '../components/dashboardDay.vue'
cozySDK.defineView('rsvp', 'test', function complexMap(doc) {
emit(doc.docType, doc);
}, err => err && console.log(err));
let promise = cozySDK.queryView('rsvp', 'test', {})
promise.then((res) => {
console.log(res)
})
export default { export default {
data () { data () {
// Default data
return { return {
RSVPItems: {
"Tuesday, November 8, 2016": [
{
startTime: "09:30am",
endTime: "9:45am",
members: [
{
name: "Phyks",
email: "phyks@example.com"
}
],
eventTypeHash: "15toto",
status: null
}
],
"Wednesday, November 9, 2016": [
{
startTime: "09:45am",
endTime: "10:15am",
members: [
{
name: "Toto",
email: "toto@example.com"
},
{
name: "Toto mother",
email: "lameredetoto@example.com"
}
],
eventTypeHash: "30toto",
status: "discarded"
}
]
},
eventTypes: { eventTypes: {
"15toto": { "15toto": {
length: 15, length: 15,
@ -90,7 +56,44 @@ export default {
color: "red" color: "red"
} }
}, },
timezone: moment.tz.guess() // Current user timezone
timezone: moment.tz.guess(),
// RSVP items
RSVPItems: null,
// An error message
error: null,
// Loading boolean
loading: false
}
},
created() {
// Fetch data on component creation
this.fetchData()
},
watch: {
// Fetch data if the route changes
'$route': 'fetchData'
},
methods: {
fetchData () {
this.error = null
this.RSVPItems = null
this.loading = true
return RSVP.getFromView('by_day').then((data) => {
this.RSVPItems = {}
data.forEach((RSVPItem) => {
if (!this.RSVPItems[RSVPItem.key]) {
this.RSVPItems[RSVPItem.key] = []
}
this.RSVPItems[RSVPItem.key].push(new RSVP(RSVPItem.value))
})
this.loading = false
}).catch((error) => {
this.RSVPItems = null
this.loading = false
this.error = error
})
} }
}, },
components: { components: {

View File

@ -1,10 +1,10 @@
<template lang="pug"> <template lang="pug">
div div
h1 h1.
color-span(v-bind:color="eventType.color") #[color-span(v-bind:color="eventType.color")]
| {{ eventType.length }} minutes meeting {{ eventType.length }} minutes meeting
| with&#32; with
a(v-bind:href="'mailto:' + owner.email") {{ owner.name }} #[a(v-bind:href="'mailto:' + owner.email") {{ owner.name }}]
router-view router-view