Skip to content

Commit 7c17708

Browse files
committed
Fix some user selects showing selected value as undefined if user was not on the first page
1 parent 301ae29 commit 7c17708

File tree

16 files changed

+112
-72
lines changed

16 files changed

+112
-72
lines changed

client/web/admin/src/components/Authclient/CSelectUser.vue

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:get-option-label="getOptionLabel"
66
:get-option-key="getOptionKey"
77
:value="user.value"
8+
:filterable="false"
89
@search="search"
910
@input="updateRunAs"
1011
/>

client/web/admin/src/components/CRolePicker.vue

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
:get-option-key="r => r.value"
1010
:get-option-label="r => getRoleLabel(r)"
1111
:placeholder="$t('admin:picker.role.placeholder')"
12+
:filterable="false"
1213
@search="search"
1314
@input="updateValue($event)"
1415
/>

client/web/admin/src/components/Permissions/CPermissionList.vue

+28-11
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,12 @@
218218
class="mb-0"
219219
>
220220
<c-input-select
221-
key="roleID"
222221
v-model="add.roleID"
223222
:data-test-id="`select-${add.mode}-roles`"
224223
:options="availableRoles"
225224
:get-option-key="getOptionRoleKey"
226-
:multiple="add.mode === 'eval'"
227225
label="name"
226+
:multiple="add.mode === 'eval'"
228227
:disabled="add.mode === 'eval' && !!add.userID"
229228
:placeholder="$t('ui.add.role.placeholder')"
230229
/>
@@ -237,15 +236,13 @@
237236
class="mt-3 mb-0"
238237
>
239238
<c-input-select
240-
key="userID"
241239
v-model="add.userID"
242240
:data-test-id="`select-${add.mode}-users`"
243241
:disabled="!!add.roleID.length"
244-
:get-option-key="getOptionUserKey"
245242
:options="userOptions"
246243
:get-option-label="getUserLabel"
247-
label="name"
248244
:placeholder="$t('ui.add.user.placeholder')"
245+
:filterable="false"
249246
@search="searchUsers"
250247
/>
251248
</b-form-group>
@@ -328,6 +325,8 @@ export default {
328325
329326
newRole: null,
330327
permissionChanges: [],
328+
329+
fetchedUsers: {},
331330
}
332331
},
333332
@@ -380,6 +379,10 @@ export default {
380379
this.searchUsers('', () => {})
381380
},
382381
382+
beforeDestroy () {
383+
this.setDefaultValues()
384+
},
385+
383386
methods: {
384387
checkRule (ID, res, op, access) {
385388
const key = `${op}@${res}`
@@ -426,15 +429,23 @@ export default {
426429
427430
this.$SystemAPI.userList({ query, limit: 15 })
428431
.then(({ set }) => {
429-
this.userOptions = set.map(m => Object.freeze(m))
432+
this.userOptions = set.reduce((acc, { userID, name, username, email }) => {
433+
if (!this.fetchedUsers[userID]) {
434+
this.fetchedUsers[userID] = name || username || email || `<@${userID}>`
435+
}
436+
437+
acc.push(userID)
438+
439+
return acc
440+
}, [])
430441
})
431442
.finally(() => {
432443
loading(false)
433444
})
434445
},
435446
436-
getUserLabel ({ userID, email, name, username }) {
437-
return name || username || email || `<@${userID}>`
447+
getUserLabel (userID) {
448+
return this.fetchedUsers[userID]
438449
},
439450
440451
getTranslation (resource, operation = '') {
@@ -461,7 +472,7 @@ export default {
461472
},
462473
463474
onAdd () {
464-
this.$emit('add', this.add)
475+
this.$emit('add', { ...this.add, userID: { userID: this.add.userID, name: this.fetchedUsers[this.add.userID] } })
465476
this.add = {
466477
mode: 'edit',
467478
roleID: [],
@@ -477,8 +488,14 @@ export default {
477488
return roleID
478489
},
479490
480-
getOptionUserKey ({ userID }) {
481-
return userID
491+
setDefaultValues () {
492+
this.add = {}
493+
this.modeOptions = []
494+
this.userOptions = []
495+
this.evaluatedPermissions = undefined
496+
this.newRole = null
497+
this.permissionChanges = []
498+
this.fetchedUsers = {}
482499
},
483500
},
484501
}

client/web/admin/src/components/Role/CRoleEditorMembers.vue

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
:get-option-key="u => u.value"
2222
:get-option-label="u => getUserLabel(u)"
2323
:placeholder="$t('admin:picker.member.placeholder')"
24+
:filterable="false"
2425
@search="search"
2526
@input="updateValue($event)"
2627
/>

client/web/admin/src/mixins/permissionHelpers.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ export default {
146146

147147
if (mode === 'edit') {
148148
const { roleID, name } = add.roleID || {}
149+
const ID = `edit-${roleID}`
150+
151+
if (this.roles.some(r => r.ID === ID)) {
152+
this.loaded.roles = true
153+
return
154+
}
149155

150156
this.readPermissions({ roleID, name: [name] })
151157
.finally(() => {
@@ -157,14 +163,20 @@ export default {
157163
let name = ''
158164

159165
if (userID) {
160-
const { name: uname, username, email, handle } = userID
161-
name = [uname || username || email || handle || userID || '']
166+
name = [userID.name]
162167
userID = userID.userID
163168
} else {
164169
name = roleID.map(({ name }) => name)
165170
roleID = roleID.map(({ roleID }) => roleID)
166171
}
167172

173+
const ID = userID ? `eval-${userID}` : `eval-${roleID.join('-')}`
174+
175+
if (this.roles.some(r => r.ID === ID)) {
176+
this.loaded.roles = true
177+
return
178+
}
179+
168180
this.evaluatePermissions({ name, roleID, userID })
169181
.finally(() => {
170182
setIncludedRoles(this.roles)

client/web/compose/src/components/Namespaces/Reminders/Edit.vue

+31-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div
3-
class="d-flex flex-column h-100"
3+
class="d-flex flex-column h-100 p-3"
44
>
55
<b-form
66
v-if="reminder"
@@ -69,11 +69,9 @@
6969
data-test-id="select-assignee"
7070
:options="assignees"
7171
:get-option-label="getUserLabel"
72-
:get-option-key="getOptionKey"
7372
:loading="processingUsers"
7473
:placeholder="$t('field.kind.user.suggestionPlaceholder')"
75-
:reduce="user => user.userID"
76-
option-value="userID"
74+
:filterable="false"
7775
@search="searchUsers"
7876
/>
7977
</b-form-group>
@@ -167,12 +165,6 @@ export default {
167165
default: () => ({}),
168166
},
169167
170-
users: {
171-
type: Array,
172-
required: true,
173-
default: () => [],
174-
},
175-
176168
disableSave: {
177169
type: Boolean,
178170
default: false,
@@ -190,7 +182,11 @@ export default {
190182
191183
// Do this, so we don't edit the original object
192184
reminder: undefined,
193-
assignees: [{ userID: this.$auth.user.userID }],
185+
assignees: [this.$auth.user.userID],
186+
187+
fetchedUsers: {
188+
[this.$auth.user.userID]: this.$t('reminder.edit.assigneePlaceholder'),
189+
},
194190
}
195191
},
196192
@@ -207,28 +203,41 @@ export default {
207203
deep: true,
208204
handler (edit) {
209205
this.reminder = new system.Reminder(edit)
210-
this.searchUsers()
206+
this.fetchUsers()
211207
},
212208
},
213209
},
214210
215211
methods: {
216212
searchUsers: _.debounce(function (query) {
213+
this.fetchUsers(query)
214+
}, 300),
215+
216+
fetchUsers (query) {
217217
this.processingUsers = true
218218
219-
this.$SystemAPI.userList({ query, limit: 15 }).then(({ set = [] }) => {
220-
this.assignees = set
219+
return this.$SystemAPI.userList({ query, limit: 15 }).then(({ set = [] }) => {
220+
this.assignees = [this.$auth.user.userID]
221+
set.forEach(({ userID, name, username, email }) => {
222+
if (!this.fetchedUsers[userID]) {
223+
this.fetchedUsers[userID] = name || username || email || `<@${userID}>`
224+
}
225+
226+
if (userID === this.$auth.user.userID) {
227+
return
228+
}
229+
230+
this.assignees.push(userID)
231+
}, [])
221232
}).finally(() => {
222-
this.processingUsers = false
233+
setTimeout(() => {
234+
this.processingUsers = false
235+
}, 300)
223236
})
224-
}, 300),
225-
226-
getUserLabel ({ userID, email, name, username }) {
227-
if (userID === this.$auth.user.userID) {
228-
return this.$t('reminder.edit.assigneePlaceholder')
229-
}
237+
},
230238
231-
return name || username || email || `<@${userID}>`
239+
getUserLabel (userID) {
240+
return this.fetchedUsers[userID]
232241
},
233242
234243
getOptionKey ({ userID }) {

client/web/compose/src/components/Namespaces/Reminders/List.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div
33
class="d-flex flex-column h-100"
44
>
5-
<div class="flex-fill overflow-auto px-2">
5+
<div class="d-flex flex-column flex-fill gap-2 overflow-auto p-3">
66
<div
77
v-for="(r, i) in sortedReminders"
88
:key="r.reminderID"
@@ -11,7 +11,7 @@
1111
<hr v-if="r.dismissedAt && sortedReminders[i - 1] ? !sortedReminders[i - 1].dismissedAt : false ">
1212

1313
<div
14-
class="border card shadow-sm my-2 p-1"
14+
class="border card shadow-sm p-1"
1515
>
1616
<div
1717
class="d-flex flex-row flex-nowrap align-items-center"

client/web/compose/src/components/Namespaces/Reminders/index.vue

-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<edit
1313
v-else
1414
:edit="edit"
15-
:users="users"
1615
:disable-save="disableSave"
1716
:processing-save="processingSave"
1817
class="flex-fill"
@@ -26,7 +25,6 @@
2625
<script>
2726
import List from './List'
2827
import Edit from './Edit'
29-
import { mapGetters } from 'vuex'
3028
import { system, NoID } from '@cortezaproject/corteza-js'
3129
3230
export default {
@@ -44,12 +42,6 @@ export default {
4442
}
4543
},
4644
47-
computed: {
48-
...mapGetters({
49-
users: 'user/set',
50-
}),
51-
},
52-
5345
mounted () {
5446
this.fetchReminders()
5547
// @todo remove this, when sockets get implemented

client/web/compose/src/components/PageBlocks/Navigation/NavTypes/ComposePage.vue

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
label-class="text-primary"
2121
>
2222
<c-input-select
23-
key="pageID"
2423
v-model="options.item.pageID"
2524
:placeholder="$t('navigation.none')"
2625
:options="pageList"

client/web/reporter/src/components/Common/ColumnSelector.vue

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
22
<c-input-select
3-
key="name"
43
:value="value"
54
:options="columns"
65
:get-option-label="getColumnLabel"

client/web/workflow/src/components/Configurator/Function.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@
122122
>
123123
<c-input-select
124124
v-if="a.target === 'workflow'"
125-
key="workflowID"
126125
v-model="a.value"
127126
:options="workflowOptions"
128127
:get-option-label="getWorkflowLabel"
129128
:get-option-key="getWorkflowKey"
130129
:reduce="wf => a.type === 'ID' ? wf.workflowID : wf.handle"
131130
:placeholder="$t('steps:function.configurator.search-workflow')"
131+
:filterable="false"
132132
@input="$root.$emit('change-detected')"
133133
@search="searchWorkflows"
134134
/>

client/web/workflow/src/components/Configurator/Workflow.vue

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
:get-option-key="getOptionKey"
5757
:value="user.value"
5858
:placeholder="$t('run-as.placeholder')"
59+
:filterable="false"
5960
@search="search"
6061
@input="updateRunAs"
6162
/>

0 commit comments

Comments
 (0)