Skip to content

Commit

Permalink
fixup! Convert mail to task
Browse files Browse the repository at this point in the history
Signed-off-by: hamza221 <hamzamahjoubi221@gmail.com>
  • Loading branch information
hamza221 committed May 2, 2023
1 parent f7d0489 commit b839f24
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 6 deletions.
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"nextcloud_issuetemplate_builder": "^0.1.0",
"node-forge": "^1.3.1",
"p-limit": "^4.0.0",
"p-queue": "^7.3.4",
"printscout": "2.0.3",
"process": "^0.11.10",
"ramda": "^0.28.0",
Expand Down
38 changes: 35 additions & 3 deletions src/components/TaskModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ import { NcDatetimePicker as DatetimePicker, NcModal as Modal, NcMultiselect as
import jstz from 'jstz'
import logger from '../logger'
import ICAL from 'ical.js'
import Task from '../task.js'
import CalendarPickerOption from './CalendarPickerOption'
import { showError, showSuccess } from '@nextcloud/dialogs'
import moment from 'moment'
import moment from '@nextcloud/moment'
export default {
name: 'TaskModal',
Expand Down Expand Up @@ -132,6 +134,36 @@ export default {
onClose() {
this.$emit('close')
},
async createTask(taskData) {
const task = new Task('BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Nextcloud Mail v' + this.$store.getters.getAppVersion + '\nEND:VCALENDAR', taskData.calendar)
task.created = ICAL.Time.now()
task.summary = taskData.summary
task.hidesubtasks = 0
if (taskData.priority) {
task.priority = taskData.priority
}
if (taskData.complete) {
task.complete = taskData.complete
}
if (taskData.note) {
task.note = taskData.note
}
if (taskData.due) {
task.due = taskData.due
}
if (taskData.start) {
task.start = taskData.start
}
if (taskData.allDay) {
task.allDay = taskData.allDay
}
const vData = ICAL.stringify(task.jCal)
await task.calendar.dav.createVObject(vData)
return task
},
async onSave() {
this.saving = true
Expand All @@ -146,7 +178,7 @@ export default {
try {
logger.debug('create task', taskData)
this.$store.commit('createTask', taskData)
await this.createTask(taskData)
showSuccess(t('mail', 'Task created'))
Expand Down Expand Up @@ -204,4 +236,4 @@ input , textarea {
:deep(.mx-datepicker) {
width: 213px;
}
</style>
</style>
2 changes: 1 addition & 1 deletion src/store/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ export function mapDavShareeToSharee(sharee) {
isCircle: sharee.href.startsWith('principal:principals/circles/'),
uri: sharee.href,
}
}
}
5 changes: 3 additions & 2 deletions src/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { defaultTo, head, prop, sortBy } from 'ramda'
import { UNIFIED_ACCOUNT_ID } from './constants'
import { normalizedEnvelopeListId } from './normalization'
import { getCalendarHome } from '../service/caldavService'
import toCalendar from './asba'
import toCalendar from './calendar'

export const getters = {
getPreference: (state) => (key, def) => {
Expand Down Expand Up @@ -137,4 +137,5 @@ export const getters = {
}).map(calendar => toCalendar(calendar))
},
getNcVersion: (state) => state.preferences?.ncVersion,
}
getAppVersion: (state) => state.preferences?.version,
}

0 comments on commit b839f24

Please sign in to comment.