Repository navigation
Vue share addressbook - #595
Conversation
| */ | ||
|
|
||
|
|
||
| @import 'settings/settings-addressbook'; |
There was a problem hiding this comment.
I would prefer all imports on the same file :)
There was a problem hiding this comment.
copy also to the copyright header I will do this when in today as the first thing I do. Sorry forgot about the debouncer I need to think how I transfer these comments to a todo for myself, I loose them on github. I will work through the other points also. The only one is addnewaddressbook that is not my work and I think @suntala has probably updated this on her branch.
There was a problem hiding this comment.
Arf, then forget about the new addressbook :) 🎉
Sorry 🙈
| @@ -0,0 +1,46 @@ | |||
| .addressbook__sharee { | |||
| @@ -0,0 +1,56 @@ | |||
| .addressbook-shares { | |||
| @@ -0,0 +1,31 @@ | |||
| // BLOCK | |||
| } | ||
| } | ||
|
|
||
| // MODIFIER No newline at end of file |
| return t('contacts', 'Share with users or groups') | ||
| }, | ||
| noResult() { | ||
| return t('contacts', 'Oops! No elements found. Consider changing the search query.') |
There was a problem hiding this comment.
Maybe too long?
I would go for something simpler I think.
| * | ||
| * @param {Object} chosenUserOrGroup | ||
| */ | ||
| shareAddressbook(chosenUserOrGroup) { |
There was a problem hiding this comment.
you can also replace chosenUserOrGroup by { sharee, group }
Easier to understand and you don't need the let xxx =
There was a problem hiding this comment.
I am not sure how this should work, the chosenUserOrGroup is an object that is the return from the custom options, it looks like this:
let newMatch = {
match: matches[i],
matchstart: matchResult[0],
matchpattern: matches[i].match(regex)[0],
matchend: matchResult[1],
matchtag: group ? '(group)' : '(user)',
matchgroup: group
}
How do I tell the multiselect to only pass on the match and matchgroup as suggested?
There was a problem hiding this comment.
You can still pass the full object and destructure the only desired props :)
({ match, matchgroup } = {
match: 0,
matchstart: 1,
matchpattern: 2,
matchend: 3,
matchtag: '(user)',
matchgroup: 4
})
match
> 0
matchgroup
> 4| for (let j = 0; j < this.addressbook.shares.length; j++) { | ||
| existingSharees.push(this.addressbook.shares[j].displayname + this.addressbook.shares[j].group) | ||
| } | ||
| for (let i = 0; i < matches.length; i++) { |
There was a problem hiding this comment.
There is a cleaner way to do that.
You can map the existing shares into an array of displaynames
let existingSharees = this.addressbook.shares.map(share => share.displayname)
Then you can filter out the shares
matches.filter(share => existingSharees.indexOf(share) === -1)
And then you can use map to create your newMatch object :)
Though this raises a few questions:
- the group/user request returns displayNames, but we can have same displayName into a same instance
- we should probably retrieve both data from the ocs api. and use ids and displayNames alongside
The api doc is not updated yet, but we can use /users/details and /groups/details to get the full data of a user.
https://github.com/nextcloud/server/blob/master/apps/provisioning_api/appinfo/routes.php#L37
Though we should then probably limit the number of results: https://github.com/nextcloud/server/blob/master/apps/provisioning_api/lib/Controller/UsersController.php#L156
There was a problem hiding this comment.
I think we are approaching this a little different. I receive a array of names from both the ocs.data.users and ocs.data.groups and pass them to my formating function with a boolean to say if this was from a group or not (ie a user) Then I cross check this against my existing sharees using displayName + group as a primary key.
I love how concise the map function is, just trying to figure out how to do this here.
There was a problem hiding this comment.
Yeah, my example is just to cross check against existing sharees :)
| // let newAddressBooksArray = addressBooks.push(addressBook) | ||
| let addressBook = this.$refs.addressBook.value | ||
| let addressBooks = this.$store.getters.getAddressbooks | ||
| let newAddressBooksArray = addressBooks.push(addressBook) |
There was a problem hiding this comment.
You cannot do that. You are not allowed to mutate data outside the store :)
| sharee.displayname = sharee | ||
| sharee.writable = false | ||
| addressbook.shares.append(newSharee) | ||
| newSharee.displayname = sharee |
There was a problem hiding this comment.
You can do that directly in the object declaration
|
@skjnldsv I believe I have covered the changes requested, sorry if I have missed any but I think this is good to go. |
| let matchingGroups = response[1].data.ocs.data.groups | ||
| try { | ||
| this.formatMatchResults(matchingUsers, query, false) | ||
| debounce(this.formatMatchResults(matchingUsers, query, false), 250, true) |
There was a problem hiding this comment.
I used 500 in the details, but this is a different behavior, so 250 is also fine :)
| <div> | ||
| <ul id="address-book-list"> | ||
| <address-book v-for="addressbook in addressbooks" :key="addressbook.id" :addressbook="addressbook" /> | ||
| <address-Book v-for="addressbook in addressbooks" :key="addressbook.id" :addressbook="addressbook" /> |
| displayname: sharee, | ||
| id: id, | ||
| writeable: false, | ||
| group: group |
There was a problem hiding this comment.
Quick tip, you can just put group since it will be the same as group: group.
But don't bother, it's just a quick knowledge bump ;)
| <template> | ||
| <li class="addressbook__sharee"> | ||
| <span class="icon icon-group" /> | ||
| <span v-if="sharee.group" class="icon icon-group" /> |
There was a problem hiding this comment.
you could just do <span :class="sharee.group ? 'icon-group' : 'icon-user'" />
| console.debug(error) | ||
| } | ||
| try { | ||
| debounce(this.formatMatchResults(matchingGroups, query, true), 250, true) |
There was a problem hiding this comment.
This is wrongly positioned, the debounce should be before the request, or we'll still get a big amount of requests which data won't be up to date. :)
There was a problem hiding this comment.
I've taken 500 for the wait, correct?
| sharee: matches[i].displayname, | ||
| id: matches[i].id, | ||
| matchstart: matchResult[0], | ||
| matchpattern: matches[i].displayname.match(regex)[0], |
There was a problem hiding this comment.
match will return undefined if no match. so undefined[0] will throw an error :)
There was a problem hiding this comment.
so I have done a check that match has a length and if not just returned out of it
| 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) | ||
| for (let i = 0; i < matches.length; i++) { |
There was a problem hiding this comment.
You can also directly do that in a map :)
this.usersOrGroups.concat(matches.map(match => {
let matchResult = match.displayname.split(regex)
return {
sharee: match.displayname,
id: match.id,
matchstart: matchResult[0],
matchpattern: match.displayname.match(regex)[0],
matchend: matchResult[1],
matchtag: group ? '(group)' : '(user)',
group
}
}))|
Nice notes! I will get on them, thank you :) @skjnldsv I have made those changes mentioned above. There is still this conflict with the js/contacts.js I am not sure how to handle this file it always seems to be an issue |
…groups based on input
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
…groups based on input
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
…uggest it if it is, avoids double keys
…hich icon to display
…r there is still some error in the code that does not effectively implement the filter function. Added debounce package and function.
…h more than 0 is given
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
1e0c066 to
ea5973c
Compare

Hi @suntala and @skjnldsv on this branch I have the changes we did in the meeting for the SCSS files. I also have been working on the share-addressbook. This is almost finished bar one styling fix, so I thought it may be worth a PR, thoughts??