|
31 | 31 | <template #label> |
32 | 32 | <tooltip-label :title="$t('label.account')" :tooltip="apiParams.addAccountToProject.account.description"/> |
33 | 33 | </template> |
34 | | - <a-select |
35 | | - show-search |
| 34 | + <a-auto-complete |
36 | 35 | v-model:value="form.account" |
37 | 36 | :placeholder="apiParams.addAccountToProject.account.description" |
38 | | - v-focus="true" |
39 | | - :filterOption="false" |
40 | | - @search="fetchAccounts" |
41 | | - > |
42 | | - <template v-if="load.accounts" #notFoundContent> |
43 | | - <a-spin size="small" /> |
44 | | - </template> |
45 | | - <template v-if="!load.accounts"> |
46 | | - <a-select-option v-for="account in accounts" :key="account.name" :value="account.name"> |
47 | | - <span v-if="account.icon"> |
48 | | - <resource-icon :image="account.icon.base64image" size="1x" style="margin-right: 5px"/> |
49 | | - </span> |
50 | | - <block-outlined v-else style="margin-right: 5px" /> |
51 | | - {{ account.name }} |
52 | | - </a-select-option> |
53 | | - </template> |
54 | | - </a-select> |
| 37 | + :filterOption="filterOption" |
| 38 | + :options="accounts" |
| 39 | + > |
| 40 | + <template v-if="load.accounts" #notFoundContent> |
| 41 | + <a-spin size="small" /> |
| 42 | + </template> |
| 43 | + <template v-if="!load.accounts" #option="account"> |
| 44 | + <span v-if="account.icon"> |
| 45 | + <resource-icon :image="account.icon.base64image" size="1x" style="margin-right: 5px"/> |
| 46 | + </span> |
| 47 | + <block-outlined v-else style="margin-right: 5px" /> |
| 48 | + {{ account.name }} |
| 49 | + </template> |
| 50 | + </a-auto-complete> |
55 | 51 | </a-form-item> |
56 | 52 | <a-form-item name="email" ref="email"> |
57 | 53 | <template #label> |
|
121 | 117 | <template #label> |
122 | 118 | <tooltip-label :title="$t('label.name')" :tooltip="apiParams.addUserToProject.username.description"/> |
123 | 119 | </template> |
124 | | - <a-select |
125 | | - show-search |
| 120 | + <a-auto-complete |
126 | 121 | v-model:value="form.username" |
127 | 122 | :placeholder="apiParams.addUserToProject.username.description" |
128 | | - v-focus="true" |
129 | | - :filterOption="false" |
130 | | - @search="fetchUsers" |
| 123 | + :filterOption="filterOption" |
| 124 | + :options="users" |
131 | 125 | > |
132 | 126 | <template v-if="load.users" #notFoundContent> |
133 | 127 | <a-spin size="small" /> |
134 | 128 | </template> |
135 | | - <template v-if="!load.users"> |
136 | | - <a-select-option v-for="user in users" :key="user.username" :value="user.username"> |
137 | | - <span v-if="user.icon"> |
138 | | - <resource-icon :image="user.icon.base64image" size="1x" style="margin-right: 5px"/> |
139 | | - </span> |
140 | | - <block-outlined v-else style="margin-right: 5px" /> |
141 | | - {{ user.firstname + ' ' + user.lastname + " (" + user.username + ")" }} |
142 | | - </a-select-option> |
| 129 | + <template v-if="!load.users" #option="user"> |
| 130 | + <span v-if="user.icon"> |
| 131 | + <resource-icon :image="user.icon.base64image" size="1x" style="margin-right: 5px"/> |
| 132 | + </span> |
| 133 | + <block-outlined v-else style="margin-right: 5px" /> |
| 134 | + {{ user.firstName + ' ' + user.lastName + " (" + user.username + ")" }} |
143 | 135 | </template> |
144 | | - </a-select> |
| 136 | + </a-auto-complete> |
145 | 137 | </a-form-item> |
146 | 138 | <a-form-item name="email" ref="email"> |
147 | 139 | <template #label> |
@@ -254,34 +246,67 @@ export default { |
254 | 246 | this.fetchProjectRoles() |
255 | 247 | } |
256 | 248 | }, |
| 249 | + filterOption (input, option) { |
| 250 | + return ( |
| 251 | + option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0 |
| 252 | + ) |
| 253 | + }, |
257 | 254 | fetchUsers (keyword) { |
258 | 255 | this.load.users = true |
259 | 256 | const params = { listall: true, showicon: true } |
260 | 257 | if (keyword) { |
261 | 258 | params.keyword = keyword |
262 | 259 | } |
263 | 260 | api('listUsers', params).then(response => { |
264 | | - this.users = response.listusersresponse.user ? response.listusersresponse.user : [] |
| 261 | + this.users = this.parseUsers(response?.listusersresponse?.user) |
265 | 262 | }).catch(error => { |
266 | 263 | this.$notifyError(error) |
267 | 264 | }).finally(() => { |
268 | 265 | this.load.users = false |
269 | 266 | }) |
270 | 267 | }, |
| 268 | + parseUsers (users) { |
| 269 | + if (!users) { |
| 270 | + return [] |
| 271 | + } |
| 272 | +
|
| 273 | + return users.map(user => { |
| 274 | + return { |
| 275 | + value: user.username, |
| 276 | + username: user.username, |
| 277 | + firstName: user.firstname, |
| 278 | + lastName: user.lastname, |
| 279 | + icon: user.icon |
| 280 | + } |
| 281 | + }) |
| 282 | + }, |
271 | 283 | fetchAccounts (keyword) { |
272 | 284 | this.load.accounts = true |
273 | 285 | const params = { domainid: this.resource.domainid, showicon: true } |
274 | 286 | if (keyword) { |
275 | 287 | params.keyword = keyword |
276 | 288 | } |
277 | 289 | api('listAccounts', params).then(response => { |
278 | | - this.accounts = response.listaccountsresponse.account || [] |
| 290 | + this.accounts = this.parseAccounts(response?.listaccountsresponse?.account) |
279 | 291 | }).catch(error => { |
280 | 292 | this.$notifyError(error) |
281 | 293 | }).finally(() => { |
282 | 294 | this.load.accounts = false |
283 | 295 | }) |
284 | 296 | }, |
| 297 | + parseAccounts (accounts) { |
| 298 | + if (!accounts) { |
| 299 | + return [] |
| 300 | + } |
| 301 | +
|
| 302 | + return accounts.map(account => { |
| 303 | + return { |
| 304 | + value: account.name, |
| 305 | + name: account.name, |
| 306 | + icon: account.icon |
| 307 | + } |
| 308 | + }) |
| 309 | + }, |
285 | 310 | fetchProjectRoles () { |
286 | 311 | this.load.projectRoles = true |
287 | 312 | api('listProjectRoles', { |
|
0 commit comments