-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(1159): refactor the role dropdown to a reusable component, r…
…efs: #1159
- Loading branch information
1 parent
f89407b
commit daf61ae
Showing
3 changed files
with
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue'; | ||
import { ErrorMessage, Field } from 'vee-validate'; | ||
import Dropdown from 'primevue/dropdown'; | ||
import type { FamApplicationRole } from 'fam-app-acsctl-api'; | ||
import type { FamRoleDto } from 'fam-admin-mgmt-api/model'; | ||
const props = defineProps({ | ||
roleId: { type: Number, default: 0 }, | ||
roleOptions: { | ||
type: [Array<FamApplicationRole[]>, Array<FamRoleDto[]>], | ||
default: [], | ||
}, | ||
label: { type: String, default: 'Assign a role to the user' }, | ||
fieldId: { type: String, default: 'roleId' }, | ||
}); | ||
const emit = defineEmits(['change', 'resetVerifiedForestClients']); | ||
const computedRoleId = computed({ | ||
get() { | ||
return props.roleId; | ||
}, | ||
set(newRoleId: Number) { | ||
emit('change', newRoleId); | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div class="form-field"> | ||
<label>{{ props.label }}</label> | ||
<Field | ||
:name="props.fieldId" | ||
aria-label="Role Select" | ||
v-slot="{ field, handleChange, errorMessage }" | ||
v-model="computedRoleId" | ||
> | ||
<Dropdown | ||
:options="roleOptions" | ||
optionLabel="role_name" | ||
optionValue="role_id" | ||
:modelValue="field.value" | ||
placeholder="Choose an option" | ||
class="w-100 custom-height" | ||
style="width: 100% !important" | ||
v-bind="field.value" | ||
@update:modelValue="handleChange" | ||
@change="emit('resetVerifiedForestClients')" | ||
:class="{ | ||
'is-invalid': errorMessage, | ||
}" | ||
/> | ||
<ErrorMessage class="invalid-feedback" :name="props.fieldId" /> | ||
</Field> | ||
</div> | ||
</template> | ||
<style lang="scss" scoped> | ||
label { | ||
margin-bottom: 0px; | ||
} | ||
</style> |