Skip to content

Commit

Permalink
WEB-4225 add batch size class if multi contact section
Browse files Browse the repository at this point in the history
  • Loading branch information
thomlamb committed Feb 17, 2025
1 parent caf5835 commit 6d853d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/imio/smartweb/core/contents/sections/contact/view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
<metal:macro use-macro="context/@@sections_macros/section_edition" />
<div class="container section-container section-contact"
id=""
tal:define="batch view/contacts | nothing"
tal:define="batch view/contacts | nothing;
number_of_contacts view/get_number_of_contacts"
tal:attributes="id string:container-section-${context/id}"
i18n:domain="imio.smartweb">
<div class="number_of_contacts"></div>
<metal:macro use-macro="context/@@sections_macros/section_title" />
<div class="row"
<div tal:attributes="class string:row nb-contact-by-line-${context/nb_contact_by_line} number-of-contacts-${number_of_contacts}"
tal:repeat="items batch">
<tal:block tal:content="structure python:context.__dict__" />
<tal:loop tal:repeat="item items">
<metal:macro use-macro="context/@@contact_macros/contact_body"
tal:define="section_view nocall:view;
Expand Down
9 changes: 9 additions & 0 deletions src/imio/smartweb/core/contents/sections/contact/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
class ContactView(HashableJsonSectionView):
"""Contact Section view"""

def get_number_of_contacts(self):
"""
Returns the number of related contacts.
"""
related_contacts = self.context.related_contacts # Assurez-vous que 'related_contacts' est une liste
if related_contacts:
return len(related_contacts)
return 0

def contacts(self):
# Firstly, try to get contact from the container view
container_view = queryMultiAdapter(
Expand Down

0 comments on commit 6d853d6

Please sign in to comment.