Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show role members on initial fetch #1296

Merged
merged 1 commit into from Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions client/web/admin/src/components/CRolePicker.vue
Expand Up @@ -32,13 +32,11 @@
>
<b-col>{{ getRoleLabel(role) }}</b-col>
<b-col class="text-right">
<b-button
<c-input-confirm
data-test-id="button-remove-role"
variant="link"
@click="removeRole(role)"
>
<font-awesome-icon :icon="['far', 'trash-alt']" />
</b-button>
no-prompt
@confirmed="removeRole(role)"
/>
</b-col>
</b-row>
</b-container>
Expand All @@ -48,14 +46,16 @@
<script>
import { debounce } from 'lodash'
import { VueSelect } from 'vue-select'

import { components } from '@cortezaproject/corteza-vue/'
const { CInputConfirm } = components
function roleSorter (a, b) {
return `${a.name} ${a.handle} ${a.roleID}`.localeCompare(`${b.name} ${b.handle} ${b.roleID}`)
}

export default {
components: {
VueSelect,
CInputConfirm,
},

props: {
Expand Down
33 changes: 13 additions & 20 deletions client/web/admin/src/components/Role/CRoleEditorMembers.vue
Expand Up @@ -36,14 +36,11 @@
>
<td>{{ getUserLabel(user) }}</td>
<td class="text-right">
<b-button
<c-input-confirm
data-test-id="button-remove-member"
variant="link"
class="text-danger pr-0"
@click="removeMember(user.userID)"
>
{{ $t('remove') }}
</b-button>
no-prompt
@confirmed="removeMember(user.userID)"
/>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -72,6 +69,8 @@
import { debounce } from 'lodash'
import { VueSelect } from 'vue-select'
import CSubmitButton from 'corteza-webapp-admin/src/components/CSubmitButton'
import { components } from '@cortezaproject/corteza-vue/'
const { CInputConfirm } = components

export default {
i18nOptions: {
Expand All @@ -82,6 +81,7 @@ export default {
components: {
CSubmitButton,
VueSelect,
CInputConfirm,
},

props: {
Expand Down Expand Up @@ -132,7 +132,6 @@ export default {

mounted () {
this.fetchUsers()
this.fetchMembers()
},

methods: {
Expand Down Expand Up @@ -172,24 +171,18 @@ export default {
},

fetchUsers () {
this.$SystemAPI.userList({ query: this.filter })
this.$SystemAPI.userList({ query: this.filter, limit: 25 })
.then(({ set: items = [] }) => {
this.users = items

if (!this.filter) {
const userIDs = this.members.map(({ userID }) => userID)
this.memberUsers = items.filter(({ userID }) => userIDs.includes(userID))
}
})
.catch(this.toastErrorHandler(this.$t('notification:user.fetch.error')))
},

fetchMembers () {
const userID = this.members.map(({ userID }) => userID)
if (userID.length > 0) {
this.$SystemAPI.userList({ query: this.filter, userID })
.then(({ set: items = [] }) => {
this.memberUsers = items
})
.catch(this.toastErrorHandler(this.$t('notification:user.fetch.error')))
}
},

search: debounce(function (query = '') {
if (query !== this.filter) {
this.filter = query
Expand Down
3 changes: 2 additions & 1 deletion client/web/admin/src/views/System/Role/Editor.vue
Expand Up @@ -108,7 +108,7 @@ export default {
initialRoleState: undefined,
isContext: false,

roleMembers: [],
roleMembers: undefined,

info: {
processing: false,
Expand Down Expand Up @@ -166,6 +166,7 @@ export default {
this.role = new system.Role()
this.initialRoleState = this.role.clone()
this.isContext = false
this.roleMembers = undefined
}
},
},
Expand Down