Skip to content

Commit

Permalink
fix: some regressions in departments and members management
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Dec 9, 2024
1 parent 45fc355 commit 2ab6748
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion ui/src/components/add-department-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const editDepartment = ref({ ...emptyDepartment })
watch(menu, () => {
if (!menu.value) return
editDepartmentMenu.value = { ...emptyDepartment }
editDepartment.value = { ...emptyDepartment }
createForm.value?.reset()
})
Expand Down
5 changes: 3 additions & 2 deletions ui/src/components/add-member-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
/>
</v-form>
<v-alert
:value="!!link"
v-if="!!link"
type="warning"
variant="outlined"
>
Expand All @@ -107,7 +107,8 @@
</v-btn>
<v-btn
:disabled="disableInvite || !invitation || !invitation.email || !invitation.role"
color="warning"
color="primary"
variant="flat"
@click="confirmInvitation()"
>
{{ $t('common.confirmOk') }}
Expand Down
27 changes: 12 additions & 15 deletions ui/src/components/delete-department-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
:disabled="!members || !!members.count || patchOrganization.loading.value"
color="warning"
variant="flat"
@click="confirmDelete"
@click="confirmDelete.execute()"
>
{{ $t('common.confirmOk') }}
</v-btn>
Expand All @@ -74,28 +74,25 @@ const { patchOrganization } = useStore()
const { t } = useI18n()
const menu = ref(false)
const members = ref<any>()
watch(menu, async () => {
if (!menu.value) {
members.value = null
fetchMembers.data.value = null
return
}
fetchMembers()
fetchMembers.refresh()
})
const fetchMembers = withUiNotif(async () => {
members.value = await $fetch(`organizations/${orga.id}/members`, {
query: {
params: {
size: 0,
department: department.id
}
}
})
})
const fetchMembers = useFetch<{ count: number, results: any[] }>(
() => `${$apiPath}/organizations/${orga.id}/members`,
{
query: computed(() => ({ size: 0, department: department.id })),
watch: false,
}
)
const members = computed(() => fetchMembers.data.value)
const confirmDelete = withUiNotif(async () => {
const confirmDelete = useAsyncAction(async () => {
menu.value = false
const departments = (orga.departments ?? []).filter(d => d.id !== department.id)
await patchOrganization.execute(orga.id, { departments }, t('common.modificationOk'))
Expand Down
16 changes: 7 additions & 9 deletions ui/src/components/edit-department-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
<v-btn
:title="$t('pages.organization.editDepartment', {departmentLabel})"
variant="text"
icon
:icon="mdiPencil"
v-bind="props"
>
<v-icon :icon="mdiPencil" />
</v-btn>
/>
</template>

<v-card
v-if="editDepartment"
data-iframe-height
width="500"
:width="500"
>
<v-card-title>
{{ $t('pages.organization.confirmEditDepartmentTitle', {name: department.name, departmentLabel}) }}
Expand All @@ -26,11 +24,12 @@
<p>{{ $t('common.id') }} = {{ department.id }}</p>
<load-avatar
v-if="orga && $uiConfig.avatars.orgs"
ref="loadAvatar"
ref="avatar"
:owner="{type: 'organization', id: orga.id, department: department.id}"
:disabled="$uiConfig.readonly"
:hide-validate="true"
/>

<v-text-field
v-model="editDepartment.name"
:label="$t('common.name')"
Expand Down Expand Up @@ -74,7 +73,7 @@ const { t } = useI18n()
const menu = ref(false)
const editDepartment = ref<Department>()
const loadAvatar = ref<typeof import('./load-avatar.vue')['default']>()
const avatar = ref<typeof import('./load-avatar.vue')['default']>()
watch(menu, () => {
if (!menu.value) return
Expand All @@ -85,10 +84,9 @@ const confirmEdit = withUiNotif(async () => {
menu.value = false
const departments = (orga.departments ?? []).map(d => d.id === editDepartment.value?.id ? editDepartment.value : d)
await patchOrganization.execute(orga.id, { departments }, t('common.modificationOk'))
await loadAvatar.value?.validate()
await avatar.value?.validate()
emit('change')
})
</script>

<style lang="css" scoped>
Expand Down
40 changes: 21 additions & 19 deletions ui/src/components/organization-departments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,27 @@

<v-list-item-title>{{ department.name }}</v-list-item-title>

<v-list-item-action v-if="writableDepartments">
<edit-department-menu
:orga="orga"
:department="department"
:department-label="departmentLabel"
@change="$emit('change');refreshDepartment(department)"
/>
</v-list-item-action>
<v-list-item-action
v-if="writableDepartments"
class="ml-0"
>
<delete-department-menu
:orga="orga"
:department="department"
:department-label="departmentLabel"
@change="$emit('change')"
/>
</v-list-item-action>
<template #append>
<v-list-item-action v-if="writableDepartments">
<edit-department-menu
:orga="orga"
:department="department"
:department-label="departmentLabel"
@change="$emit('change');refreshDepartment(department)"
/>
</v-list-item-action>
<v-list-item-action
v-if="writableDepartments"
class="ml-0"
>
<delete-department-menu
:orga="orga"
:department="department"
:department-label="departmentLabel"
@change="$emit('change')"
/>
</v-list-item-action>
</template>
</v-list-item>
<v-divider
v-if="i + 1 < currentPage.length"
Expand Down

0 comments on commit 2ab6748

Please sign in to comment.