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
td
color-span(v-bind:color="eventTypes[RSVPItem.eventTypeHash].color")
span {{ RSVPItem.startTime }} - {{ RSVPItem.endTime }}
span {{ RSVPItem.startTime.format() }} - {{ RSVPItem.endTime.format() }}
td
template(v-for="(member, index) in RSVPItem.members")
template(v-if="index > 0")

View File

@ -6,8 +6,10 @@
router-link(v-bind:to="{ name: 'publicSlotSelectionView', params: { hash: hash, day: day } }")
| {{ day }}
p
em Times are in {{ timezone }} timezone.
p.
Times are in
#[em {{ timezone }}]
timezone.
</template>
<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 } }")
| {{ slot.timeBegin }} - {{ slot.timeEnd }}
p
em Times are in {{ timezone }} timezone.
p.
Times are in
#[em {{ timezone }}]
timezone.
</template>
<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,
endTime: null,
members: [],
@ -6,4 +10,37 @@ const RSVP = {
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

View File

@ -4,11 +4,15 @@
event-types-nav(v-bind:eventTypes="eventTypes")
ul
p(v-if="loading") Loading...
ul(v-if="RSVPItems")
li(v-for="(RSVPItemsForDay, day) in RSVPItems")
dashboard-day(v-bind:day="day", v-bind:RSVPItemsForDay="RSVPItemsForDay", v-bind:eventTypes="eventTypes")
p
em Times are in {{ timezone }} timezone.
p.
Times are in
#[em {{ timezone }}]
timezone.
</template>
<style lang="stylus" scoped>
@ -27,55 +31,17 @@
import cozySDK from 'cozysdk-client'
import moment from 'moment-timezone'
// Models import
import RSVP from '../models/RSVP'
// Components imports
import eventTypesNav from '../components/eventTypesNav.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 {
data () {
// Default data
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: {
"15toto": {
length: 15,
@ -90,7 +56,44 @@ export default {
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: {

View File

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