summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJessica <jessica@Absolventas-MacBook-Pro.local>2018-08-13 18:08:27 +0200
committerJessica <jessica@Absolventas-MacBook-Pro.local>2018-08-13 18:08:27 +0200
commitf75b4fc1da0cf6529acc16826733b4e732137b01 (patch)
treeab675b435eb13edbd20d8117eea989afb79faa69 /src
parentf1f91e9d43a65d618a3ea71a55a1b314e73c7877 (diff)
working version of shareAdressbook, adds sharees to addressbook object
Diffstat (limited to 'src')
-rw-r--r--src/components/Settings/SettingsAddressbookShare.vue51
-rw-r--r--src/components/Settings/SettingsAddressbookSharee.vue1
-rw-r--r--src/components/Settings/SettingsSortContacts.vue4
-rw-r--r--src/store/addressbooks.js13
4 files changed, 31 insertions, 38 deletions
diff --git a/src/components/Settings/SettingsAddressbookShare.vue b/src/components/Settings/SettingsAddressbookShare.vue
index a57542a9..c1f8d7e6 100644
--- a/src/components/Settings/SettingsAddressbookShare.vue
+++ b/src/components/Settings/SettingsAddressbookShare.vue
@@ -24,33 +24,32 @@
<div class="addressbook__shares">
<multiselect
id="users-groups-search"
- v-model="selectedUserOrGroup"
:options="usersOrGroups"
:searchable="true"
:loading="isLoading"
:internal-search="false"
- :clear-on-select="false"
- :close-on-select="false"
:options-limit="250"
:limit="3"
:max-height="600"
:show-no-results="false"
:placeholder="placeholder"
+ track-by="match"
+ label="match"
open-direction="bottom"
class="multiselect-vue"
- @search-change="asyncFind">
+ @search-change="asyncFind"
+ @input="addSharee">
+ <template slot="singleLabel" slot-scope="props"><span class="option__desc"><span class="option__title">{{ props.option.matchpattern }}</span></span></template>
<template slot="option" slot-scope="props">
- <span class="">{{ props.option.matchstart }}</span><span class="" style="font-weight: bold;">{{ props.option.matchpattern }}</span><span class="">{{ props.option.matchend }}{{ props.option.matchtag }}</span>
- </template>
- <template slot="clear" slot-scope="props">
- <div v-if="selectedUserOrGroup.length" class="multiselect__clear" @mousedown.prevent.stop="clearAll(props.search)" />
+ <div class="option__desc">
+ <span class="">{{ props.option.matchstart }}</span><span class="" style="font-weight: bold;">{{ props.option.matchpattern }}</span><span class="">{{ props.option.matchend }} {{ props.option.matchtag }}</span>
+ </div>
</template>
<span slot="noResult">{{ noResult }} </span>
</multiselect>
- <!-- <pre class="language-json"><code>{{ selectedUserOrGroup }}</code></pre> -->
<!-- list of user or groups addressbook is shared with -->
<ul v-if="addressbook.shares.length > 0" class="addressbook__shares__list">
- <address-book-sharee v-for="sharee in addressbook.shares" :key="sharee.name" :sharee="sharee" />
+ <address-book-sharee v-for="sharee in addressbook.shares" :key="sharee.displayname" :sharee="sharee" />
</ul>
</div>
</template>
@@ -83,9 +82,7 @@ export default {
data() {
return {
isLoading: false,
- usersOrGroups: [],
- selectedUserOrGroup: [],
- templateSharee: { displayname: '', writeable: false }
+ usersOrGroups: []
}
},
computed: {
@@ -97,25 +94,25 @@ export default {
}
},
methods: {
- addSharee(sharee) {
- let newSharee = {}
- Object.assign({}, this.templateSharee, newSharee)
- // not working yet need to work on!
- this.$store.dispatch('shareAddressbook', newSharee)
+ addSharee(chosenUserOrGroup) {
+ let payload = []
+ payload.push(this.addressbook)
+ payload.push(chosenUserOrGroup.match)
+ this.$store.dispatch('shareAddressbook', payload)
},
formatMatchResults(matches, query, matchTag) {
// format response from axios.all and add them to the option array
- /*
- * Case issue for query, matchpattern should reflect case in match not the query
- */
-
+ if (matches.length < 1) {
+ return
+ }
for (let i = 0; i < matches.length; i++) {
let regex = new RegExp(query, 'i')
let matchResult = matches[i].split(regex)
let newMatch = {
+ match: matches[i] + ' ' + matchTag,
matchstart: matchResult[0],
- matchpattern: query,
+ matchpattern: matches[i].match(regex)[0],
matchend: matchResult[1],
matchtag: matchTag
}
@@ -134,12 +131,12 @@ export default {
let matchingUsers = response[0].data.ocs.data.users
let matchingGroups = response[1].data.ocs.data.groups
try {
- this.formatMatchResults(matchingUsers, query, ' (user)')
+ this.formatMatchResults(matchingUsers, query, '(user)')
} catch (error) {
console.debug(error)
}
try {
- this.formatMatchResults(matchingGroups, query, ' (group)')
+ this.formatMatchResults(matchingGroups, query, '(group)')
} catch (error) {
console.debug(error)
}
@@ -148,10 +145,6 @@ export default {
this.isLoading = false
})
}
- },
-
- clearAll() {
- this.selectedUserOrGroup = []
}
}
}
diff --git a/src/components/Settings/SettingsAddressbookSharee.vue b/src/components/Settings/SettingsAddressbookSharee.vue
index f28b35ed..0cccb8b2 100644
--- a/src/components/Settings/SettingsAddressbookSharee.vue
+++ b/src/components/Settings/SettingsAddressbookSharee.vue
@@ -66,7 +66,6 @@ export default {
setTimeout(() => { this.$store.dispatch('removeSharee', this.sharee) }, 500)
},
editSharee() {
- // not working yet need to work on!
this.$store.dispatch('toggleShareeWritable', this.sharee)
}
}
diff --git a/src/components/Settings/SettingsSortContacts.vue b/src/components/Settings/SettingsSortContacts.vue
index 440e7d00..72e2b6c7 100644
--- a/src/components/Settings/SettingsSortContacts.vue
+++ b/src/components/Settings/SettingsSortContacts.vue
@@ -66,11 +66,11 @@ export default {
key: 'firstName'
},
{
- label: t('contacts', 'Lastname'),
+ label: t('contacts', 'Last name'),
key: 'lastName'
},
{
- label: t('contacts', 'Display-name'),
+ label: t('contacts', 'Display name'),
key: 'displayName'
}
]
diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js
index 301a3446..9697fb2d 100644
--- a/src/store/addressbooks.js
+++ b/src/store/addressbooks.js
@@ -102,12 +102,12 @@ const mutations = {
* @param {Object} data
* @param {Object} data.addressbook the addressbook
*/
- shareAddressbook(state, addressbook, sharee) {
+ shareAddressbook(state, [ addressbook, sharee ]) {
addressbook = state.addressbooks.find(search => search === addressbook)
let newSharee = {}
- sharee.displayname = sharee
- sharee.writable = false
- addressbook.shares.append(newSharee)
+ newSharee.displayname = sharee
+ newSharee.writeable = false
+ addressbook.shares.push(newSharee)
},
/**
@@ -125,7 +125,7 @@ const mutations = {
}
}
})
- addressbook.shares.splice(sharee, 1)
+ addressbook.shares.splice(addressbook.shares.indexOf(sharee), 1)
},
/**
@@ -250,8 +250,9 @@ const actions = {
* @param {Object} addressbook Addressbook selected
* @param {Object} sharee Addressbook sharee object
*/
- shareAddressbook(contect, addressbook, sharee) {
+ shareAddressbook(context, [ addressbook, sharee ]) {
// Share addressbook with entered group or user
+ context.commit('shareAddressbook', [ addressbook, sharee ])
}
}