This commit is contained in:
MeysamMoghaddam
2025-10-13 21:36:05 +03:30
parent a10d1c05c7
commit 39b82ed3bc
5 changed files with 33 additions and 9 deletions

View File

@@ -35,7 +35,9 @@
@if (_isExpanded && _currentUser?.Children?.Any() == true) @if (_isExpanded && _currentUser?.Children?.Any() == true)
{ {
<OrganizationChartLevel Nodes="_currentUser.Children" Level="1" /> <CascadingValue Value="this">
<OrganizationChartLevel Nodes="_currentUser.Children" Level="1" />
</CascadingValue>
} }
</div> </div>
</div> </div>

View File

@@ -50,6 +50,14 @@ public partial class OrganizationChart
LastName = "رضایی", LastName = "رضایی",
PersonalPurchase = 950000, PersonalPurchase = 950000,
TeamPurchase = 2100000 TeamPurchase = 2100000
},
new UserNode
{
Id = 8,
FirstName = "فرزاد",
LastName = "رضایی",
PersonalPurchase = 950000,
TeamPurchase = 2100000
} }
} }
}, },
@@ -80,6 +88,14 @@ public partial class OrganizationChart
LastName = "رضایی", LastName = "رضایی",
PersonalPurchase = 1350000, PersonalPurchase = 1350000,
TeamPurchase = 4100000 TeamPurchase = 4100000
},
new UserNode
{
Id = 7,
FirstName = "آرش",
LastName = "رضایی",
PersonalPurchase = 1350000,
TeamPurchase = 4100000
} }
} }
}, },

View File

@@ -13,11 +13,6 @@
.org-node { .org-node {
position: relative; position: relative;
margin: 20px 0;
}
.root-node {
margin-bottom: 40px;
} }
.child-node { .child-node {

View File

@@ -7,7 +7,7 @@ public partial class OrganizationChartLevel
[Parameter] public List<UserNode>? Nodes { get; set; } [Parameter] public List<UserNode>? Nodes { get; set; }
[Parameter] public int Level { get; set; } = 1; [Parameter] public int Level { get; set; } = 1;
[CascadingParameter] private OrganizationChart ParentChart { get; set; } = default!; [CascadingParameter] private OrganizationChart? ParentChart { get; set; }
private Size GetAvatarSize(int level) private Size GetAvatarSize(int level)
{ {
@@ -21,7 +21,18 @@ public partial class OrganizationChartLevel
private void ToggleNodeExpand(long userId) private void ToggleNodeExpand(long userId)
{ {
ParentChart?.ToggleNodeExpand(userId); if (ParentChart != null)
{
ParentChart.ToggleNodeExpand(userId);
}
}
private void SafeToggleNodeExpand(long userId)
{
if (ParentChart != null)
{
ParentChart.ToggleNodeExpand(userId);
}
} }
public class UserNode public class UserNode

View File

@@ -4,7 +4,7 @@
justify-content: center; justify-content: center;
flex-wrap: wrap; flex-wrap: wrap;
position: relative; position: relative;
margin-top: 40px; margin-top: 80px;
} }
.org-level::before { .org-level::before {