summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsuntala <suntala@hotmail.com>2018-08-29 15:51:17 +0200
committersuntala <suntala@hotmail.com>2018-08-29 15:51:17 +0200
commita65f35305bbd55a9f9a6759e57fa1fc317883a35 (patch)
treeae2d870e144a9445cb2db8e6801514ba08ab09d7 /src
parentec51d04dc19dc9d63d08c5b3a1368c4f53bf2efa (diff)
parent699af87659b724df00df77da2c9b66ec9013c2d6 (diff)
Merge branch 'vue-import-progress' of https://github.com/nextcloud/contacts into vue-import-progress
Diffstat (limited to 'src')
-rw-r--r--src/components/Settings/SettingsImportContacts.vue8
-rw-r--r--src/services/parseVcf.js4
-rw-r--r--src/store/addressbooks.js5
-rw-r--r--src/store/importState.js10
4 files changed, 26 insertions, 1 deletions
diff --git a/src/components/Settings/SettingsImportContacts.vue b/src/components/Settings/SettingsImportContacts.vue
index 23a4990c..80f418f7 100644
--- a/src/components/Settings/SettingsImportContacts.vue
+++ b/src/components/Settings/SettingsImportContacts.vue
@@ -88,12 +88,20 @@ export default {
let file = event.target.files[0]
let reader = new FileReader()
let selectedAddressbook = this.selectedAddressbook
+<<<<<<< HEAD
// this.$store.dispatch('changeStage', 'parsing')
let self = this
reader.onload = function(e) {
// self.$store.dispatch('changeStage', 'importing')
self.$store.dispatch('getContactsFromAddressBook', { vcf: reader.result, addressbook: selectedAddressbook, importState: this.importState })
// self.$store.dispatch('changeStage', 'default')
+=======
+ this.$emit('clicked', { importing: true })
+ let self = this
+ reader.onload = function(e) {
+ self.$store.dispatch('getContactsFromAddressBook', { vcf: reader.result, addressbook: selectedAddressbook, importState: this.importState })
+ self.$emit('fileLoaded', false)
+>>>>>>> 699af87659b724df00df77da2c9b66ec9013c2d6
}
reader.readAsText(file)
}
diff --git a/src/services/parseVcf.js b/src/services/parseVcf.js
index e74b083f..66aca511 100644
--- a/src/services/parseVcf.js
+++ b/src/services/parseVcf.js
@@ -23,11 +23,13 @@
import Contact from '../models/contact'
import Store from '../store/index'
-export default function parseVcf(data = '', addressbook) {
+export default function parseVcf(data = '', addressbook, importState) {
let regexp = /BEGIN:VCARD[\s\S]*?END:VCARD/mgi
let vCards = data.match(regexp)
let importState = Store.getters.getImportState
+ importState.total = vCards.length
+
if (!vCards) {
console.debug('Error during the parsing of the following vcf file: ', data)
return []
diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js
index 1dad9c28..062351c0 100644
--- a/src/store/addressbooks.js
+++ b/src/store/addressbooks.js
@@ -192,8 +192,13 @@ const actions = {
* @param {Object} context
* @param {Object} importDetails = { vcf, addressbook }
*/
+<<<<<<< HEAD
getContactsFromAddressBook(context, { vcf, addressbook }) {
let contacts = parseVcf(vcf, addressbook)
+=======
+ getContactsFromAddressBook(context, { vcf, addressbook, importState }) {
+ let contacts = parseVcf(vcf, addressbook, importState)
+>>>>>>> 699af87659b724df00df77da2c9b66ec9013c2d6
context.commit('appendContactsToAddressbook', { addressbook, contacts })
context.commit('appendContacts', contacts)
context.commit('sortContacts')
diff --git a/src/store/importState.js b/src/store/importState.js
index 4e387ab6..4b85085c 100644
--- a/src/store/importState.js
+++ b/src/store/importState.js
@@ -24,13 +24,18 @@ const state = {
importState: {
total: 0,
accepted: 0,
+<<<<<<< HEAD
denied: 0,
stage: 'default',
addressbook: ''
+=======
+ denied: 0
+>>>>>>> 699af87659b724df00df77da2c9b66ec9013c2d6
}
}
const mutations = {
+<<<<<<< HEAD
/**
* Increment the number of contacts accepted
*
@@ -78,6 +83,8 @@ const mutations = {
changeStage(state, stage) {
state.importState.stage = stage
}
+=======
+>>>>>>> 699af87659b724df00df77da2c9b66ec9013c2d6
}
const getters = {
@@ -85,6 +92,7 @@ const getters = {
}
const actions = {
+<<<<<<< HEAD
/**
* Increment the number of contacts accepted
*
@@ -132,6 +140,8 @@ const actions = {
changeStage(context, stage) {
context.commit('changeStage', stage)
}
+=======
+>>>>>>> 699af87659b724df00df77da2c9b66ec9013c2d6
}
export default { state, mutations, getters, actions }