Skip to content

Commit

Permalink
[issue-nextcloud#39] Adding fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
charismatic-claire committed Nov 15, 2018
1 parent 1af40b1 commit 75eda58
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/views/Contacts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export default {

// generate groups menu from groups store
groupsMenu() {
const self = this
return this.groups.map(group => {
return {
id: group.name.replace(' ', '_'),
Expand All @@ -151,7 +152,7 @@ export default {
{
icon: 'icon-download',
text: 'Download',
action: this.downloadGroup(group) // does not work if called via 'self'. why is that?
action: () => self.downloadGroup(group)
}
]
}
Expand Down Expand Up @@ -325,27 +326,23 @@ export default {
* Download vcard promise as vcard file
*
* @param {Object} vcardPromise object to be downloaded
* @returns {Function} trigger download of resulting single vcard file
*/
downloadVcardPromise(vcardPromise) {
return function() {
vcardPromise.then(response => {
const blob = new Blob([response.data], { type: 'text/vcard' })
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
const filename = moment().format('YYYY-MM-DD_HH-mm') + '_' + response.groupName + '.vcf'
link.href = url
link.download = filename
link.click()
})
}
vcardPromise.then(response => {
const blob = new Blob([response.data], { type: 'text/vcard' })
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
const filename = moment().format('YYYY-MM-DD_HH-mm') + '_' + response.groupName + '.vcf'
link.href = url
link.download = filename
link.click()
})
},

/**
* Download group of contacts
*
* @param {Object} group of contacts to be downloaded
* @returns {Function} trigger download of resulting single vcard file
*/
downloadGroup(group) {
// get grouped contacts
Expand All @@ -372,7 +369,7 @@ export default {
}
})
// download vcard
return this.downloadVcardPromise(vcardPromise)
this.downloadVcardPromise(vcardPromise)
},

/* SEARCH */
Expand Down

0 comments on commit 75eda58

Please sign in to comment.