Skip to content

Commit

Permalink
use canAddNewOption prop on EditGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
jxjj committed Sep 23, 2024
1 parent 475f91d commit 81ef19e
Showing 1 changed file with 5 additions and 67 deletions.
72 changes: 5 additions & 67 deletions resources/js/components/EditGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,9 @@
placeholder="Select..."
label="Group Type"
:showLabel="false"
>
<template #afterOptions="{ query }">
<ButtonComponent
@click="
addGroupTypeOption({
label: query,
})
"
>Add New Group Type</ButtonComponent
>
</template>
</ComboBox>
:canAddNewOptions="true"
@addNewOption="groupTypes.push($event)"
/>
</div>

<div class="form-group tw-col-span-2">
Expand Down Expand Up @@ -301,22 +292,11 @@
id="roles"
v-model="newRole"
:options="filteredRoles"
:canAddNewOption="true"
label="Role"
:showLabel="false"
:canAddNewOption="true"
@addNewOption="(newOption) => roles.push(newOption)"
>
<template #afterOptions="{ query }">
<ButtonComponent
@click="
addRoleOption({
label: query,
})
"
>Add New Role</ButtonComponent
>
</template>
</ComboBox>
/>
</div>
<div class="col-sm-3">
<button
Expand Down Expand Up @@ -495,48 +475,6 @@ export default {
});
},
methods: {
addGroupTypeOption({ label }) {
const newOption = {
id: null,
label,
secondaryLabel: "",
};
// check if it already exists
const existingGroup = this.groupTypes.find(
(groupType) => groupType.label === newOption.label,
);
if (existingGroup) {
this.localGroup.group_type = existingGroup;
return;
}
// set the group type to the new group type
this.groupTypes.push(newOption);
this.localGroup.group_type = newOption;
},
addRoleOption({ label }) {
const newOption = {
id: null,
label,
};
// check if it already exists
const existingRole = this.roles.find(
(role) => role.label === newOption.label,
);
if (existingRole) {
this.newRole = existingRole;
return;
}
// set the role to the new role
this.roles.push(newOption);
this.newRole = newOption;
},
isValidUrl,
isValidDeptId(str) {
if (!str) return true;
Expand Down

0 comments on commit 81ef19e

Please sign in to comment.