Skip to content

Commit

Permalink
Simple calendar support
Browse files Browse the repository at this point in the history
References:
Signed-off-by: Tortue Torche <tortuetorche@users.noreply.github.com>
nextcloud#121, nextcloud#136 and nextcloud#411
  • Loading branch information
tortuetorche committed Mar 5, 2020
1 parent 67553fd commit aac0c8b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/js/components/VoteTable/VoteCalendarLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script>
export default {
name: 'VoteCalendarLink',
methods: {
newEvent(option) {
const dateTimeStart = option.timestamp
const dateTimeEnd = moment.unix(dateTimeStart).add(1, 'hour').unix()
const calendarRoot = 'apps/calendar'
const calendarView = 'timeGridWeek' // timeGridDay, 'timeGridWeek' or 'dayGridMonth'
const calendarTimeRange = moment.unix(dateTimeStart).format('Y-MM-DD') // 'now' or 'yyyy-mm-dd'
const calendarAction = 'new'
const calendarMode = 'sidebar' // 'popover' or 'sidebar'
const calendarIsAllDay = '0'
const calendarUrl = OC.generateUrl(calendarRoot + '/' + calendarView + '/' + calendarTimeRange + '/' + calendarAction + '/' + calendarMode + '/' + calendarIsAllDay + '/' + dateTimeStart + '/' + dateTimeEnd)
return calendarUrl
}
}
}
</script>
19 changes: 19 additions & 0 deletions src/js/components/VoteTable/VoteList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<PollItemText v-if="poll.type === 'textPoll'" :option="option" />
<PollItemDate v-if="poll.type === 'datePoll'" :option="option" />

<div v-if="acl.allowEdit && poll.type === 'datePoll'" class="new-event">
<a class="button icon-calendar-000"
:title="t('polls', 'Add a calendar event')"
:href="newCalendarEventLink(option)" />
</div>

<div class="counter">
<div v-if="yesVotes(option.pollOptionText)" class="yes" :style="{ flex: yesVotes(option.pollOptionText) }">
<span> {{ yesVotes(option.pollOptionText) }} </span>
Expand All @@ -51,6 +57,7 @@
<script>
import PollItemText from '../Base/PollItemText'
import PollItemDate from '../Base/PollItemDate'
import VoteCalendarLink from './VoteCalendarLink'
import VoteTableItem from './VoteTableItem'
import { mapState, mapGetters } from 'vuex'

Expand Down Expand Up @@ -116,6 +123,10 @@ export default {
.then(() => {
// this.$emit('voteSaved')
})
},

newCalendarEventLink(option) {
return VoteCalendarLink.methods.newEvent(option)
}
}
}
Expand Down Expand Up @@ -180,6 +191,14 @@ export default {
flex: 0;
}

.new-event {
display: flex;

.button {
padding: 15px;
}
}

> li {
display: flex;
align-items: center;
Expand Down
31 changes: 30 additions & 1 deletion src/js/components/VoteTable/VoteTableHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
</div>
</div>

<div v-if="acl.allowEdit && poll.type === 'datePoll'" class="new-event">
<a class="button"
:class="{
primary: isWinner,
'icon-calendar': isWinner,
'icon-calendar-000': !isWinner
}"
:title="t('polls', 'Add a calendar event')"
:href="newCalendarEventLink(option)" />
</div>

<div class="counter">
<div class="yes">
<span> {{ yesVotes }} </span>
Expand All @@ -54,6 +65,7 @@

<script>
import { mapState, mapGetters } from 'vuex'
import VoteCalendarLink from './VoteCalendarLink'

export default {
name: 'VoteTableHeader',
Expand All @@ -80,7 +92,8 @@ export default {
computed: {
...mapState({
poll: state => state.poll,
votes: state => state.votes.list
votes: state => state.votes.list,
acl: state => state.acl
}),
...mapGetters([
'votesRank',
Expand Down Expand Up @@ -119,6 +132,12 @@ export default {
}).maybe
)
}
},

methods: {
newCalendarEventLink(option) {
return VoteCalendarLink.methods.newEvent(option)
}
}
}

Expand All @@ -133,6 +152,16 @@ export default {
font-weight: bold;
color: #49bc49;
}

.new-event {
align-items: center;
display: flex;
justify-content: center;

.button {
padding: 15px;
}
}
}

.counter {
Expand Down

0 comments on commit aac0c8b

Please sign in to comment.