forked from nextcloud/tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes nextcloud#154
- Loading branch information
Showing
12 changed files
with
1,329 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<div class="component"> | ||
<div class="component__icon"> | ||
<slot name="icon" /> | ||
</div> | ||
<div class="component__items"> | ||
<AlarmListItem v-for="(alarm, index) in alarmComponents" | ||
:key="index" | ||
:alarm="alarm" | ||
:is-read-only="readOnly" | ||
@remove-alarm="removeAlarm" /> | ||
<div class="new"> | ||
<AlarmListNew v-if="!readOnly" | ||
:is-all-day="allDay" | ||
@add-alarm="addAlarm" /> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import AlarmListNew from './AlarmListNew.vue' | ||
import AlarmListItem from './AlarmListItem.vue' | ||
import { mapAlarmComponentToAlarmObject } from '../../../models/alarm.js' | ||
import ICAL from 'ical.js' | ||
import { AlarmComponent } from '@nextcloud/calendar-js' | ||
|
||
export default { | ||
name: 'AlarmList', | ||
components: { | ||
AlarmListItem, | ||
AlarmListNew, | ||
}, | ||
props: { | ||
readOnly: { | ||
type: Boolean, | ||
required: true, | ||
}, | ||
allDay: { | ||
type: Boolean, | ||
required: true, | ||
}, | ||
alarms: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
emits: [ | ||
'add-alarm', | ||
], | ||
computed: { | ||
alarmComponents() { | ||
return this.alarms.map((alarm) => { | ||
try { | ||
return mapAlarmComponentToAlarmObject(AlarmComponent.fromICALJs(alarm)) | ||
} catch (e) { | ||
// Instead of breaking the whole page when parsing an invalid alarm, | ||
// we just print a warning on the console. | ||
console.warn(e) | ||
} | ||
}).filter(Boolean) | ||
}, | ||
}, | ||
methods: { | ||
t, | ||
|
||
/** | ||
* Adds another of the default alarms to the event | ||
* | ||
* @param {number} totalSeconds Amount of seconds for the alarm | ||
*/ | ||
addAlarm(totalSeconds) { | ||
this.$emit('add-alarm', { | ||
action: 'DISPLAY', | ||
repeat: 1, | ||
trigger: ICAL.Duration.fromSeconds(totalSeconds), | ||
}) | ||
}, | ||
/** | ||
* Removes an alarm from this event | ||
* | ||
* @param {object} alarm The alarm object | ||
*/ | ||
removeAlarm(alarm) { | ||
console.debug('remove ', alarm) | ||
// TODO Implement | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.component { | ||
display: flex; | ||
border-bottom: 1px solid var(--color-border); | ||
width: 100%; | ||
color: var(--color-text-lighter); | ||
padding-bottom: 4px; | ||
|
||
.component { | ||
&__icon { | ||
display: flex; | ||
height: 44px; | ||
width: 44px; | ||
min-width: 44px; | ||
justify-content: center; | ||
|
||
.material-design-icon__svg { | ||
vertical-align: middle; | ||
} | ||
} | ||
|
||
&__items { | ||
display: flex; | ||
flex-direction: column; | ||
flex-grow: 1; | ||
gap: 4px; | ||
padding-right: 14px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
|
||
.new { | ||
margin-top: 4px; | ||
} | ||
} | ||
} | ||
} | ||
</style> |
Oops, something went wrong.