44-->
55<template >
66 <div >
7- <NcSelect v-if =" canShare "
8- v-model =" addAcl "
9- :input-label =" t (' deck' , ' Share board with a user, group or team …' )"
7+ <NcSelectUsers v-model =" addAcl "
108 :options =" formatedSharees "
11- :user-select =" true "
12- label="displayName"
13- :loading =" isLoading || !! isSearching "
14- :disabled =" isLoading "
15- track-by="multiselectKey"
16- :internal-search =" false "
17- @input =" clickAddAcl "
18- @search =" (search , loading ) => asyncFind (search , loading ) " >
19- <template #noOptions >
20- {{ isSearching ? t('deck', 'Searching for users, groups and teams …') : t('deck', 'No participants found') }}
21- </template >
22- <template #noResult >
23- {{ isSearching ? t('deck', 'Searching for users, groups and teams …') : t('deck', 'No participants found') }}
24- </template >
25- </NcSelect >
9+ :loading =" isLoading "
10+ @search =" (search ) => asyncFind (search ) " />
2611
2712 <ul id =" shareWithList"
2813 class =" shareWithList" >
9479</template >
9580
9681<script >
97- import { NcCollectionList , NcAvatar , NcSelect , NcActions , NcActionButton , NcActionCheckbox , NcRelatedResourcesPanel } from ' @nextcloud/vue'
82+ import { NcCollectionList , NcAvatar , NcActions , NcActionButton , NcActionCheckbox , NcRelatedResourcesPanel , NcSelectUsers } from ' @nextcloud/vue'
9883import { mapGetters , mapState } from ' vuex'
9984import { getCurrentUser } from ' @nextcloud/auth'
10085import { showError , showSuccess } from ' @nextcloud/dialogs'
10186import { loadState } from ' @nextcloud/initial-state'
10287import debounce from ' lodash/debounce.js'
88+ const SOURCE_TO_SHARE_TYPE = {
89+ users: 0 ,
90+ groups: 1 ,
91+ emails: 4 ,
92+ remotes: 6 ,
93+ teams: 7 ,
94+ }
10395
10496export default {
10597 name: ' SharingTabSidebar' ,
@@ -108,7 +100,7 @@ export default {
108100 NcActions,
109101 NcActionButton,
110102 NcActionCheckbox,
111- NcSelect ,
103+ NcSelectUsers ,
112104 NcCollectionList,
113105 NcRelatedResourcesPanel,
114106 },
@@ -141,35 +133,28 @@ export default {
141133 return (uid ) => uid === getCurrentUser ().uid
142134 },
143135 formatedSharees () {
144- return this .unallocatedSharees .map (item => {
145- const subname = item .label === item .shareWithDisplayNameUnique
146- ? ' '
147- : item .shareWithDisplayNameUnique
148- const sharee = {
149- user: item .value .shareWith ,
150- displayName: item .label ,
151- subname,
152- icon: ' icon-user' ,
153- multiselectKey: item .shareType + ' :' + item .primaryKey ,
154- }
155-
156- if (item .value .shareType === 1 ) {
157- sharee .icon = ' icon-group'
158- sharee .isNoUser = true
136+ const result = this .unallocatedSharees .map (item => {
137+ const res = {
138+ ... item,
139+ displayName: item .displayname || item .name || item .label || item .id ,
140+ user: item .id ,
141+ subname: item .shareWithDisplayNameUnique || item .subline , // NcSelectUser does its own pattern matching to filter things out
159142 }
160- if (item .value .shareType === 7 ) {
161- sharee .icon = ' icon-circles'
162- sharee .isNoUser = true
163- }
164-
165- sharee .value = item .value
166- return sharee
143+ return res
167144 }).slice (0 , 10 )
145+ return result
168146 },
169147 unallocatedSharees () {
170148 return this .sharees .filter ((sharee ) => {
171149 const foundIndex = this .board .acl .findIndex ((acl ) => {
172- return acl .participant .uid === sharee .value .shareWith && acl .participant .type === sharee .value .shareType
150+ console .debug ()
151+ if (acl .participant .uid === sharee .id && acl .type === SOURCE_TO_SHARE_TYPE [sharee .source ]) {
152+ return true
153+ }
154+ if (acl .participant .id === sharee .id && acl .type === SOURCE_TO_SHARE_TYPE [sharee .source ]) {
155+ return true
156+ }
157+ return false
173158 })
174159 if (foundIndex === - 1 ) {
175160 return true
@@ -178,6 +163,15 @@ export default {
178163 })
179164 },
180165 },
166+ watch: {
167+ addAcl: {
168+ handler () {
169+ if (this .addAcl ) {
170+ this .clickAddAcl ()
171+ }
172+ },
173+ },
174+ },
181175 mounted () {
182176 this .asyncFind (' ' , () => {})
183177 },
@@ -187,15 +181,15 @@ export default {
187181 await this .$store .dispatch (' loadSharees' , query)
188182 this .isSearching = false
189183 }, 300 ),
190- async asyncFind (query , loading ) {
191- loading ( true )
184+ async asyncFind (query ) {
185+ this . isLoading = true
192186 await this .debouncedFind (query)
193- loading ( false )
187+ this . isLoading = false
194188 },
195189 async clickAddAcl () {
196190 this .addAclForAPI = {
197- type: this .addAcl .value . shareType ,
198- participant: this .addAcl .value . shareWith ,
191+ type: SOURCE_TO_SHARE_TYPE [ this .addAcl .source ] ,
192+ participant: this .addAcl .id ,
199193 permissionEdit: false ,
200194 permissionShare: false ,
201195 permissionManage: false ,
0 commit comments