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

feat:User CRUD #35

Merged
merged 9 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/components/MainNavigationDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ import {
mdiNoteOutline,
mdiTag,
mdiOfficeBuilding,
mdiViewGrid
mdiViewGrid,
mdiAccountGroup
} from '@mdi/js'

export default {
Expand Down Expand Up @@ -190,6 +191,17 @@ export default {
// title: 'Teams'
// }
]
},
{
header: 'Admin section',
items: [
{
can: ['read', 'users'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

admin section will still be shown to a standard user in this case.
I believe admin section should be shown to only manager and sys admin
Related to #43

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making a note that we also want this nav section to be hidden when you "drill down" into an Org. And we want to change the name Admin Section => Admin

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

admin section will still be shown to standard users (in addition to managers and admins) but perhaps that is our intent

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we discussed today, @ergjustin will make this can -> canCreate

icon: mdiAccountGroup,
title: 'Users',
to: '/users'
}
]
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/UserAccountEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<v-card-text>
<ValidationProvider
v-slot="{ errors }"
name="name"
name="preferred name"
rules="required|max:100"
>
<v-text-field
v-model="name"
:error-messages="errors"
label="Name"
label="Preferred Name"
required
></v-text-field>
</ValidationProvider>
Expand Down
150 changes: 150 additions & 0 deletions src/components/UserDetail.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<template>
<v-row>
<v-col>
<v-row>
<v-col>
<v-card>
<v-container fluid>
<v-row>
<v-col>
<ValidationProvider
v-slot="{ errors }"
name="email"
rules="required|email"
>
<v-text-field
v-model.trim="value.email"
:error-messages="errors"
:readonly="!editing"
label="Email"
required
></v-text-field>
</ValidationProvider>

<ValidationProvider
v-slot="{ errors }"
name="preferred name"
rules="required|min:1|max:100"
>
<v-text-field
v-model.trim="value.name"
:error-messages="errors"
:readonly="!editing"
label="Preferred name"
required
></v-text-field>
</ValidationProvider>

<ValidationProvider v-slot="{ errors }" name="full_name">
<v-text-field
v-model.trim="value.full_name"
:error-messages="errors"
:readonly="!editing"
label="Full name"
></v-text-field>
</ValidationProvider>

<ValidationProvider
v-if="create"
v-slot="{ errors }"
name="password"
rules="required|min:10|max:100"
vid="password"
>
<v-text-field
v-model.trim="value.password"
:error-messages="errors"
:readonly="!editing"
label="Password"
required
type="password"
></v-text-field>
</ValidationProvider>

<ValidationProvider
v-if="create"
v-slot="{ errors }"
name="confirmation"
rules="required|confirmed:password"
>
<v-text-field
v-model="value.password_confirm"
:error-messages="errors"
label="Password confirmation"
required
type="password"
></v-text-field>
</ValidationProvider>

<ValidationProvider
v-slot="{ errors }"
name="roles"
rules="required"
>
<v-select
v-model="value.roles"
class="pt-3"
:items="roles"
:error-messages="errors"
chips
deletable-chips
dense
label="Roles"
hide-details
small-chips
variant="solo"
:readonly="!editing"
></v-select>
</ValidationProvider>
</v-col>
</v-row>

<standard-options :editing="editing" :value="value" as="users" />

<standard-audit v-if="!editing" :value="value" />

<standard-identifier v-if="!editing" :value="value" />
</v-container>
</v-card>
</v-col>
</v-row>
</v-col>
</v-row>
</template>

<script>
import { ValidationProvider } from 'vee-validate'
import StandardAudit from '@/components/StandardAudit'
import StandardIdentifier from '@/components/StandardIdentifier'
import StandardOptions from '@/components/StandardOptions'

export default {
components: {
StandardAudit,
StandardIdentifier,
StandardOptions,
ValidationProvider
},

props: {
editing: { default: false, type: Boolean },
value: { type: Object, required: true },
create: { default: false, type: Boolean }
},

computed: {
roles() {
const roles = ['user', 'manager']
if (
this.$cannotPatch('users', {
_id: this.value._id
})
) {
return roles.filter(role => role === this.value.roles)
}

return roles
}
}
}
</script>
4 changes: 2 additions & 2 deletions src/components/UserPasswordEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ValidationProvider
v-slot="{ errors }"
name="current password"
rules="required|min:6|max:100"
rules="required|min:10|max:100"
>
<v-text-field
v-model="current_password"
Expand All @@ -22,7 +22,7 @@
<ValidationProvider
v-slot="{ errors }"
name="new password"
rules="required|min:6|max:100"
rules="required|min:10|max:100"
vid="new_password"
>
<v-text-field
Expand Down
Loading