-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(users): add update user role feature
- Loading branch information
1 parent
9575896
commit daa25d1
Showing
13 changed files
with
231 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
text-align: center; | ||
} | ||
|
||
&__close-btn { | ||
&__btn-close { | ||
margin-right: $spacing-unit/2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/components/specific/users/user-card/user-card-update-form/UserCardUpdateForm.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.user-card-update-form { | ||
display: flex; | ||
align-items: center; | ||
gap: $spacing-unit/2; | ||
width: 100%; | ||
height: 100%; | ||
|
||
&__input { | ||
flex-grow: 1; | ||
display: flex; | ||
justify-content: center; | ||
gap: $spacing-unit * 2; | ||
} | ||
|
||
&__btn-close { | ||
margin-right: $spacing-unit/2; | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
src/components/specific/users/user-card/user-card-update-form/UserCardUpdateForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<div class="user-card-update-form"> | ||
<span class="user-card-update-form__input"> | ||
<template v-if="project"> | ||
<BIMDataRadio name="role" text="Guest" :value="25" v-model="role" /> | ||
</template> | ||
<BIMDataRadio name="role" text="User" :value="50" v-model="role" /> | ||
<BIMDataRadio name="role" text="Admin" :value="100" v-model="role" /> | ||
</span> | ||
<BIMDataButton | ||
data-test="btn-submit-update" | ||
class="user-card-update-form__btn-submit" | ||
width="80px" | ||
color="primary" | ||
fill | ||
radius | ||
@click="submit" | ||
> | ||
{{ $t("UserCardUpdateForm.submitButtonText") }} | ||
</BIMDataButton> | ||
<BIMDataButton | ||
data-test="btn-close-update" | ||
class="user-card-update-form__btn-close" | ||
color="default" | ||
ghost | ||
rounded | ||
icon | ||
@click="close" | ||
> | ||
<BIMDataIcon name="close" size="xxs" /> | ||
</BIMDataButton> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { inject, ref } from "vue"; | ||
import { useProjects } from "@/state/projects"; | ||
import { useSpaces } from "@/state/spaces"; | ||
export default { | ||
props: { | ||
user: { | ||
type: Object, | ||
required: true | ||
}, | ||
space: { | ||
type: Object, | ||
default: null | ||
}, | ||
project: { | ||
type: Object, | ||
default: null | ||
} | ||
}, | ||
emits: ["close"], | ||
setup(props, { emit }) { | ||
const { updateSpaceUser } = useSpaces(); | ||
const { updateProjectUser } = useProjects(); | ||
const loading = inject("loading", false); | ||
const role = ref( | ||
props.project ? props.user.projectRole : props.user.cloudRole | ||
); | ||
const submit = async () => { | ||
try { | ||
loading.value = true; | ||
if (props.project) { | ||
await updateProjectUser(props.project, { | ||
...props.user, | ||
projectRole: role.value, | ||
role: role.value | ||
}); | ||
} else if (props.space) { | ||
await updateSpaceUser(props.space, { | ||
...props.user, | ||
cloudRole: role.value, | ||
role: role.value | ||
}); | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
} finally { | ||
loading.value = false; | ||
} | ||
close(); | ||
}; | ||
const close = () => { | ||
emit("close"); | ||
}; | ||
return { | ||
// Reference | ||
role, | ||
// Methods | ||
close, | ||
submit | ||
}; | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss" src="./UserCardUpdateForm.scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.