fix: only show edit button on first section

This commit is contained in:
Shariq Ansari 2025-01-02 18:28:44 +05:30
parent b00cf4bb95
commit 7c81607877

View File

@ -14,7 +14,7 @@
:opened="section.opened" :opened="section.opened"
> >
<template v-if="!preview" #actions> <template v-if="!preview" #actions>
<div v-if="section.contacts" class="pr-2"> <div v-if="section.name == 'contacts_section'" class="pr-2">
<Link <Link
value="" value=""
doctype="Contact" doctype="Contact"
@ -41,9 +41,7 @@
</Link> </Link>
</div> </div>
<Button <Button
v-else-if=" v-else-if="section.showEditButton"
((!section.contacts && i == 1) || i == 0) && isManager()
"
variant="ghost" variant="ghost"
class="w-7 mr-2" class="w-7 mr-2"
@click="showSidePanelModal = true" @click="showSidePanelModal = true"
@ -389,7 +387,10 @@ const showSidePanelModal = ref(false)
const _sections = computed(() => { const _sections = computed(() => {
if (!props.sections?.length) return [] if (!props.sections?.length) return []
let editButtonAdded = false
return props.sections.map((section) => { return props.sections.map((section) => {
let isContactSection = section.name == 'contacts_section'
if (section.columns?.length) { if (section.columns?.length) {
section.columns[0].fields = section.columns[0].fields.map((field) => { section.columns[0].fields = section.columns[0].fields.map((field) => {
let df = field?.all_properties || {} let df = field?.all_properties || {}
@ -412,9 +413,20 @@ const _sections = computed(() => {
return _field return _field
}) })
} }
section.showEditButton = !(
!isManager() ||
isContactSection ||
editButtonAdded
)
if (section.showEditButton) {
editButtonAdded = true
}
section.visible = section.visible =
section.name == 'contacts_section' || isContactSection ||
section.columns?.[0].fields.filter((f) => f.visible).length section.columns?.[0].fields.filter((f) => f.visible).length
return section return section
}) })
}) })