summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-08-28 16:02:43 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-08-28 16:02:43 +0200
commitea5973c1a58c2dcca8bafd94e6233aac96155e18 (patch)
tree96557d051ea31f1a71f492976385532335243a81 /src
parent62c320e30be62ea95aa25496c68752b7f3b45957 (diff)
rebase and commit
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/Settings/SettingsAddressbook.vue2
-rw-r--r--src/components/Settings/SettingsAddressbookShare.vue.orig184
-rw-r--r--src/components/SettingsSection.vue4
-rw-r--r--src/store/addressbooks.js12
-rw-r--r--src/store/addressbooks.js.orig264
5 files changed, 5 insertions, 461 deletions
diff --git a/src/components/Settings/SettingsAddressbook.vue b/src/components/Settings/SettingsAddressbook.vue
index cdceca25..fee2e324 100644
--- a/src/components/Settings/SettingsAddressbook.vue
+++ b/src/components/Settings/SettingsAddressbook.vue
@@ -45,7 +45,7 @@
<script>
import popoverMenu from '../core/popoverMenu'
-import shareAddressbook from './SettingsAddressbookShare'
+import shareAddressBook from './SettingsAddressbookShare'
import clickOutside from 'vue-click-outside'
diff --git a/src/components/Settings/SettingsAddressbookShare.vue.orig b/src/components/Settings/SettingsAddressbookShare.vue.orig
deleted file mode 100644
index 5e8d7d1a..00000000
--- a/src/components/Settings/SettingsAddressbookShare.vue.orig
+++ /dev/null
@@ -1,184 +0,0 @@
-<!--
- - @copyright Copyright (c) 2018 Team Popcorn <teampopcornberlin@gmail.com>
- -
- - @author Team Popcorn <teampopcornberlin@gmail.com>
- -
- - @license GNU AGPL version 3 or any later version
- -
- - This program is free software: you can redistribute it and/or modify
- - it under the terms of the GNU Affero General Public License as
- - published by the Free Software Foundation, either version 3 of the
- - License, or (at your option) any later version.
- -
- - This program is distributed in the hope that it will be useful,
- - but WITHOUT ANY WARRANTY; without even the implied warranty of
- - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- - GNU Affero General Public License for more details.
- -
- - You should have received a copy of the GNU Affero General Public License
- - along with this program. If not, see <http://www.gnu.org/licenses/>.
- -
--->
-
-<template>
- <div class="addressbook-shares">
- <multiselect
- id="users-groups-search"
- :options="usersOrGroups"
- :searchable="true"
- :loading="isLoading"
- :internal-search="false"
- :options-limit="250"
- :limit="3"
- :max-height="600"
- :show-no-results="true"
- :placeholder="placeholder"
- :class="{ 'showContent': inputGiven }"
- open-direction="bottom"
- class="multiselect-vue"
- @search-change="asyncFind"
- @input="shareAddressbook">
- <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">
- <div class="option__desc">
- <span>{{ props.option.matchstart }}</span><span class="addressbook-shares__shareematch--bold">{{ props.option.matchpattern }}</span><span>{{ props.option.matchend }} {{ props.option.matchtag }}</span>
- </div>
- </template>
- <span slot="noResult">{{ noResult }} </span>
- </multiselect>
- <!-- 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.displayname + sharee.group" :sharee="sharee" />
- </ul>
- </div>
-</template>
-
-<script>
-import clickOutside from 'vue-click-outside'
-import api from '../../services/api'
-import Multiselect from 'vue-multiselect'
-import addressBookSharee from './SettingsAddressbookSharee'
-import debounce from 'debounce'
-
-export default {
- name: 'SettingsShareAddressbook',
- components: {
- clickOutside,
- Multiselect,
- addressBookSharee
- },
- directives: {
- clickOutside,
- debounce
- },
- props: {
- addressbook: {
- type: Object,
- default() {
- return {}
- }
- }
- },
- data() {
- return {
- isLoading: false,
- inputGiven: false,
- usersOrGroups: []
- }
- },
- computed: {
- placeholder() {
- return t('contacts', 'Share with users or groups')
- },
- noResult() {
- return t('contacts', 'No users or groups')
- }
- },
- methods: {
- /**
- * Share addressbook
- *
- * @param {Object} chosenUserOrGroup
- */
- shareAddressbook({ sharee, id, group }) {
- let addressbook = this.addressbook
- this.$store.dispatch('shareAddressbook', { addressbook, sharee, id, group })
- },
-
- /**
- * Format responses from axios.all and add them to the option array
- *
- * @param {Array} matches Array of matches returned from the axios request
- * @param {String} query
- * @param {Boolean} group
- */
- formatMatchResults(matches, query, group) {
- if (matches.length < 1) {
- return
- }
- let regex = new RegExp(query, 'i')
- let existingSharees = this.addressbook.shares.map(share => share.id + share.group)
- matches = matches.filter(share => existingSharees.indexOf(share.id + group) === -1)
- // this.usersOrGroups.concat(
- this.usersOrGroups = this.usersOrGroups.concat(matches.map(match => {
- let matchResult = match.displayname.split(regex)
- if (matchResult.length < 1) {
- return
- }
- return {
- sharee: match.displayname,
- id: match.id,
- matchstart: matchResult[0],
- matchpattern: match.displayname.match(regex)[0],
- matchend: matchResult[1],
- matchtag: group ? '(group)' : '(user)',
- group
- }
- }))
-<<<<<<< HEAD
- console.log(this.usersOrGroups) // eslint-disable-line
-=======
->>>>>>> made additional changes for PR.
- },
-
- /**
- * Use Axios api call to find matches to the query from the existing Users & Groups
- *
- * @param {String} query
- */
- asyncFind: debounce(function(query) {
- this.isLoading = true
- this.usersOrGroups = []
- if (query.length > 0) {
- api.all([
- api.get(OC.linkToOCS('cloud', 2) + 'users/details?search=' + query),
- api.get(OC.linkToOCS('cloud', 2) + 'groups/details?search=' + query)
- ]).then(response => {
- let matchingUsers = Object.values(response[0].data.ocs.data.users)
- let matchingGroups = response[1].data.ocs.data.groups
- try {
- this.formatMatchResults(matchingUsers, query, false)
- } catch (error) {
- console.debug(error)
- }
- try {
- this.formatMatchResults(matchingGroups, query, true)
- } catch (error) {
- console.debug(error)
- }
- }).then(() => {
-
- this.isLoading = false
- })
- this.inputGiven = true
- } else {
- this.inputGiven = false
- }
- }, 500)
- }
-}
-</script>
diff --git a/src/components/SettingsSection.vue b/src/components/SettingsSection.vue
index d3248a70..f5a8968a 100644
--- a/src/components/SettingsSection.vue
+++ b/src/components/SettingsSection.vue
@@ -33,8 +33,8 @@
</template>
<script>
-import addressbook from '../components/Settings/SettingsAddressbook'
-import addAddressbook from '../components/Settings/SettingsNewAddressbook'
+import addressBook from '../components/Settings/SettingsAddressbook'
+import addAddressBook from '../components/Settings/SettingsNewAddressbook'
import importContacts from '../components/Settings/SettingsImportContacts'
import sortContacts from '../components/Settings/SettingsSortContacts'
diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js
index ed2e03c6..bb1858f2 100644
--- a/src/store/addressbooks.js
+++ b/src/store/addressbooks.js
@@ -177,20 +177,12 @@ const actions = {
owner: 'admin',
dav: addressbook
}
- ]
- // fake request
- return new Promise((resolve, reject) => {
- return setTimeout(() => {
- addressbooks.forEach(addressbook => {
- context.commit('addAddressbooks', addressbook)
- })
- resolve()
- return addressbooks
- }, 1000)
})
+
addressbooks.forEach(addressbook => {
context.commit('addAddressbooks', addressbook)
})
+
return addressbooks
},
diff --git a/src/store/addressbooks.js.orig b/src/store/addressbooks.js.orig
deleted file mode 100644
index 9e8670dc..00000000
--- a/src/store/addressbooks.js.orig
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/* eslint-disable-next-line import/no-webpack-loader-syntax */
-import vcfFile from '!raw-loader!./FakeName.vcf'
-import parseVcf from '../services/parseVcf'
-import Vue from 'vue'
-
-import client from '../services/cdav'
-
-const addressbookModel = {
- id: '',
- displayName: '',
- enabled: true,
- owner: '',
- shares: [],
- contacts: {},
- url: ''
-}
-
-const state = {
- addressbooks: []
-}
-
-const mutations = {
-
- /**
- * Add addressbook into state
- *
- * @param {Object} state Default state
- * @param {Object} addressbooks Addressbook
- */
- addAddressbooks(state, addressbook) {
- // extend the addressbook to the default model
- state.addressbooks.push(Object.assign({}, addressbookModel, addressbook))
- },
-
- /**
- * Append a list of contacts to an addressbook
- * and remove duplicates
- *
- * @param {Object} state
- * @param {Object} data
- * @param {Object} data.addressbook the addressbook
- * @param {Contact[]} data.contacts array of contacts to append
- */
- appendContactsToAddressbook(state, { addressbook, contacts }) {
- addressbook = state.addressbooks.find(search => search === addressbook)
-
- // convert list into an array and remove duplicate
- addressbook.contacts = contacts.reduce((list, contact) => {
- if (list[contact.uid]) {
- console.debug('Duplicate contact overrided', list[contact.uid], contact)
- }
- Vue.set(list, contact.uid, contact)
- return list
- }, addressbook.contacts)
- },
-
- /**
- * Add a contact to an addressbook and overwrite if duplicate uid
- *
- * @param {Object} state
- * @param {Contact} contact
- */
- addContactToAddressbook(state, contact) {
- let addressbook = state.addressbooks.find(search => search.id === contact.addressbook.id)
- Vue.set(addressbook.contacts, contact.uid, contact)
- },
-
- /**
- * Delete a contact in a specified addressbook
- *
- * @param {Object} state
- * @param {Contact} contact the contact to delete
- */
- deleteContactFromAddressbook(state, contact) {
- let addressbook = state.addressbooks.find(search => search.id === contact.addressbook.id)
- Vue.delete(addressbook, contact.uid)
- },
-
- /**
- * Share addressbook with a user or group
- *
- * @param {Object} state
- * @param {Object} data
- * @param {Object} data.addressbook the addressbook
- * @param {String} data.sharee the sharee
- * @param {Boolean} data.id id
- * @param {Boolean} data.group group
- */
- shareAddressbook(state, { addressbook, sharee, id, group }) {
- addressbook = state.addressbooks.find(search => search.id === addressbook.id)
- let newSharee = {
- displayname: sharee,
- id: id,
- writeable: false,
- group: group
- }
- addressbook.shares.push(newSharee)
- },
-
- /**
- * Remove Sharee from addressbook shares list
- *
- * @param {Object} state
- * @param {Object} sharee the sharee
- */
- removeSharee(state, sharee) {
- let addressbook = state.addressbooks.find(search => {
- for (let i in search.shares) {
- if (search.shares[i] === sharee) {
- return true
- }
- }
- })
- addressbook.shares.splice(addressbook.shares.indexOf(sharee), 1)
- },
-
- /**
- * Toggle sharee's writable permission
- *
- * @param {Object} state
- * @param {Object} sharee the sharee
- */
- updateShareeWritable(state, sharee) {
- let addressbook = state.addressbooks.find(search => {
- for (let i in search.shares) {
- if (search.shares[i] === sharee) {
- return true
- }
- }
- })
- sharee = addressbook.shares.find(search => search === sharee)
- sharee.writeable = !sharee.writeable
- }
-
-}
-
-const getters = {
- getAddressbooks: state => state.addressbooks
-}
-
-const actions = {
-
- /**
- * Retrieve and commit addressbooks
- *
- * @param {Object} context
- * @returns {Promise} fetch and commit
- */
- async getAddressbooks(context) {
- let addressbooks = client.addressbookHomes.map(addressbook => {
- return {
- id: 'ab1',
- displayName: 'Addressbook 1',
- enabled: true,
- owner: 'admin',
- dav: addressbook
- }
- ]
- // fake request
- return new Promise((resolve, reject) => {
- return setTimeout(() => {
- addressbooks.forEach(addressbook => {
- context.commit('addAddressbooks', addressbook)
- })
- resolve()
- return addressbooks
- }, 1000)
- })
- addressbooks.forEach(addressbook => {
- context.commit('addAddressbooks', addressbook)
- })
- return addressbooks
- },
-
- /**
- * Retrieve the contacts of the specified addressbook
- * and commit the results
- *
- * @param {Object} context
- * @param {Object} addressbook
- */
- async getContactsFromAddressBook(context, addressbook) {
- let contacts = parseVcf(vcfFile, addressbook)
- context.commit('appendContactsToAddressbook', { addressbook, contacts })
- context.commit('appendContacts', contacts)
- context.commit('sortContacts')
- context.commit('appendGroupsFromContacts', contacts)
- },
-
- /**
- * Remove sharee from Addressbook
- * @param {Object} context Current context
- * @param {Object} sharee Addressbook sharee object
- */
- removeSharee(context, sharee) {
- // Remove sharee from addressbook.
- context.commit('removeSharee', sharee)
- },
-
- /**
- * Toggle permissions of Addressbook Sharees writeable rights
- * @param {Object} context Current context
- * @param {Object} sharee Addressbook sharee object
- */
- toggleShareeWritable(context, sharee) {
- // Toggle sharee edit permissions.
- context.commit('updateShareeWritable', sharee)
- },
-
- /**
- * Share Adressbook with User or Group
- * @param {Object} context Current context
- * @param {Object} data.addressbook the addressbook
- * @param {String} data.sharee the sharee
- * @param {Boolean} data.id id
- * @param {Boolean} data.group group
- */
- shareAddressbook(context, { addressbook, sharee, id, group }) {
- // Share addressbook with entered group or user
-<<<<<<< HEAD
- context.commit('shareAddressbook', { addressbook, sharee, group })
- },
-
- /**
- * Move a contact to the provided addressbook
- *
- * @param {Object} context
- * @param {Object} data
- * @param {Contact} data.contact
- * @param {Object} data.addressbook
- */
- moveContactToAddressbook(context, { contact, addressbook }) {
- context.commit('deleteContactFromAddressbook', contact)
- context.commit('updateContactAddressbook', { contact, addressbook })
- context.commit('addContactToAddressbook', contact)
-=======
- context.commit('shareAddressbook', { addressbook, sharee, id, group })
->>>>>>> added id to sharees and used this to look for existing shares, however there is still some error in the code that does not effectively implement the filter function. Added debounce package and function.
- }
-}
-
-export default { state, mutations, getters, actions }