return $this->group_name;
}
+ /**
+ * Get parents as an array
+ *
+ * @return array
+ */
+ public function getParents(): array
+ {
+ $parents = [];
+ $group = $this;
+ while ($group = $group->getParentGroup()) {
+ $parents[] = $group->getName();
+ }
+ return $parents;
+ }
+
+
/**
* Get the indented short name of the group " >> bar"
*
/**
* Get parent group
*
- * @return Group
+ * @return Group|null
*/
public function getParentGroup()
{
}
} while ($group = $group->getParentGroup());
- //@phpstan-ignore-next-line
return true;
}
<div class="ui stackable pointing inverted menu tabbed">
<div class="item header">
- <i class="users cog icon" aria-hidden="true"></i>
- {{ group.getFullName() }} :
+ <div class="ui breadcrumb">
+ {% for parent in group.parents %}
+ <span class="section">{{ parent }}</span>
+ <i class="right angle icon divider"></i>
+ {% endfor %}
+ <span class="section active">{{ group.getName() }}</span>
+ </div>
</div>
<a href="{{ url_for('groups', {'id': group.getId()}) }}?tab=group_information" class="item{{ tab == 'group_information' ? ' active' }}" data-tab="group_information">{{ _T("Information") }}</a>
- <a href="{{ url_for('groups', {'id': group.getId()}) }}?tab=group_managers" class="item{{ tab == 'group_managers' ? ' active' }}" data-tab="group_managers">{{ _T("Managers") }} ({{ managers|length }})</a>
- <a href="{{ url_for('groups', {'id': group.getId()}) }}?tab=group_members" class="item{{ tab == 'group_members' ? ' active' }}" data-tab="group_members">{{ _T("Members") }} ({{ members|length }})</a>
+ <a href="{{ url_for('groups', {'id': group.getId()}) }}?tab=group_managers" class="item{{ tab == 'group_managers' ? ' active' }}" data-tab="group_managers"><i class="user shield icon" aria-hidden="true"></i>{{ _T("Managers") }} ({{ managers|length }})</a>
+ <a href="{{ url_for('groups', {'id': group.getId()}) }}?tab=group_members" class="item{{ tab == 'group_members' ? ' active' }}" data-tab="group_members"><i class="user icon" aria-hidden="true"></i>{{ _T("Members") }} ({{ members|length }})</a>
</div>
<form class="ui form" action="{{ url_for("doEditGroup", {"id": group.getId()}) }}" method="post" enctype="multipart/form-data" id="group_form">
<div class="ui{{ tab == 'group_information' ? ' active' }} tab segment" data-tab="group_information">
{% endif %}
{% else %}
<tr>
- <td colspan="2">
+ <td colspan="{% if login.isSuperAdmin() %}3{% else %}2{% endif %}">
{% if person_mode == 'members' %}
{{ _T("No member attached") }}
{% else %}
{% set can_export = login.isGroupManager() and preferences.pref_bool_groupsmanagers_exports or login.isAdmin() or login.isStaff() %}
-{% macro group_item(login, group, opened, selected) %}
- <div class="{% if group.getGroups()|length > 0 %}title{% if group.getName() in opened %} active{% endif %}{% else %}nochild{% endif %}">
+{% macro group_item(login, group, parents, selected) %}
+ <div class="{% if group.getGroups()|length > 0 %}title{% if group.getName() in parents %} active{% endif %}{% else %}nochild{% endif %}">
<i class="{% if group.getGroups()|length > 0 %}dropdown{% else %}empty{% endif %} icon" aria-hidden="true"></i>
<a class="ui{% if group.getName() == selected %} primary{% endif %}{% if not login.isGroupManager(group.getId()) %} disabled{% endif %} label" href="{% if login.isGroupManager(group.getId()) %}{{ url_for("groups", {"id": group.getId()}) }}{% else %}#{% endif %}">
{{ group.getName() }}
</a>
</div>
{% if group.getGroups()|length > 0 %}
- <div class="content{% if group.getName() in opened %} active{% endif %}">
+ <div class="content{% if group.getName() in parents %} active{% endif %}">
<div class="accordion">
{% for child_group in group.getGroups() %}
- {{ _self.group_item(login, child_group, opened, selected) }}
+ {{ _self.group_item(login, child_group, parents, selected) }}
{% endfor %}
</div>
</div>
{% endmacro %}
{% block content %}
- {% set opened = group.getFullName()|split(' / ') %}
- {% set selected = opened|last %}
+ {% set parents = group.getParents() %}
+ {% set selected = group.getName() %}
<div class="ui stackable grid">
<div class="three wide column">
{% if group.getId() %}
<div class="ui attached accordion-styled scrolling segment loader_selector">
<div class="ui tree accordion">
{% for group in groups_root %}
- {{ _self.group_item(login, group, opened, selected) }}
+ {{ _self.group_item(login, group, parents, selected) }}
{% endfor %}
</div>
</div>
$children = $group->getGroups();
$this->assertCount(1, $children);
$this->assertSame('Another child group', $children[0]->getName());
+
+ $group = new \Galette\Entity\Group($child_id_2);
+ $this->assertSame(['A parent group'], $group->getParents());
+
+ $group = new \Galette\Entity\Group();
+ $group->setName('A second level child group');
+ $group->setParentGroup($child_id_2);
+ $this->assertTrue($group->store());
+ $child_id_3 = $group->getId();
+ $this->assertSame($child_id_2, $group->getParentGroup()->getId());
+
+ $group = new \Galette\Entity\Group($child_id_3);
+ $this->assertSame(['Another child group', 'A parent group'], $group->getParents());
+ $this->assertTrue($group->detach());
}
/**