Skip to content
Snippets Groups Projects

Vueify default_membership_role_dropdown and add custom roles

Merged Alex Buijs requested to merge add-custom-roles-to-membership-role-selector into master
Files
4
@@ -14,15 +14,15 @@ export default {
type: Object,
required: true,
},
currentStandardRole: {
type: Number,
required: true,
},
customRoles: {
type: Object,
required: false,
default: () => ({}),
},
currentStandardRole: {
type: Number,
required: true,
},
currentCustomRoleId: {
type: Number,
required: false,
@@ -66,11 +66,11 @@ export default {
},
methods: {
roleToItems(roles, roleType) {
return Object.assign(Object.entries(roles).map(this.roleToItem(roleType)));
return Object.entries(roles).map(this.roleToItem(roleType));
},
currentRole() {
// A custom role takes precedence.
return this.currentCustomRoleId
// A saved custom role takes precedence.
return Object.values(this.customRoles).includes(this.currentCustomRoleId)
? this.itemValue(CUSTOM_ROLE, this.currentCustomRoleId)
: this.itemValue(STANDARD_ROLE, this.currentStandardRole);
},
@@ -92,8 +92,8 @@ export default {
// This is necessary for `DirtySubmitForm` to enable the submit button when selecting a new value.
this.$nextTick(() => {
Object.values(this.$refs).forEach((input) => {
const e = new Event('input', { bubbles: true });
input.dispatchEvent(e);
const event = new Event('input', { bubbles: true });
input.dispatchEvent(event);
});
});
},
@@ -109,12 +109,14 @@ export default {
<div>
<input
ref="standardRoleInput"
data-testid="selected-standard-role"
type="hidden"
name="saml_provider[default_membership_role]"
:value="selectedStandardRoleValue"
/>
<input
ref="customRoleInput"
data-testid="selected-custom-role"
type="hidden"
name="saml_provider[member_role_id]"
:value="selectedCustomRoleValue"
@@ -124,6 +126,7 @@ export default {
block
data-testid="default-membership-role-dropdown"
:items="roles"
:selected="selectedRole"
@select="onSelect"
/>
</div>
Loading