Skip to content

Commit

Permalink
More SQ comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander van Delft committed Jan 6, 2025
1 parent 14990c0 commit fe557d0
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ else
@dataItem.ElementName <span>
<button class="starion-pill" title="Owning Domain Of Expertise: @dataItem.OwnerShortName">@dataItem.OwnerShortName</button>
</span>
@foreach (var category in @dataItem.ElementBase.GetAllCategories())
@foreach (var categoryShortName in @dataItem.ElementBase.GetAllCategories().Select(x => x.ShortName))
{
<span>
<button class="starion-pill" style="background-color:aliceblue !important;" title="Category: @category.ShortName">@category.ShortName</button>
<button class="starion-pill" style="background-color:aliceblue !important;" title="Category: @categoryShortName">@categoryShortName</button>
</span>
}
</div>
Expand All @@ -92,10 +92,10 @@ else
@dataItem.ElementName <span>
<button class="starion-pill" title="Owning Domain Of Expertise: @dataItem.OwnerShortName">@dataItem.OwnerShortName</button>
</span>
@foreach (var category in @dataItem.ElementBase.GetAllCategories())
@foreach (var categoryShortName in @dataItem.ElementBase.GetAllCategories().Select(x => x.ShortName))
{
<span>
<button class="starion-pill" style="background-color:aliceblue !important;" title="Category: @category.ShortName">@category.ShortName</button>
<button class="starion-pill" style="background-color:aliceblue !important;" title="Category: @categoryShortName">@categoryShortName</button>
</span>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@ public partial class ElementDefinitionTree
/// Use the <paramref name="firstRender" /> parameter to ensure that initialization work is only performed
/// once.
/// </remarks>
protected override async Task OnAfterRenderAsync(bool firstRender)
protected override Task OnAfterRenderAsync(bool firstRender)
{
if (this.ViewModel.Iteration != this.InitialIteration)
{
this.InitialIteration = this.ViewModel.Iteration;
}

return Task.CompletedTask;
}

/// <summary>
Expand Down
46 changes: 25 additions & 21 deletions COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@
<ElementDefinitionTree
@ref="this.SourceTree"
InitialIteration="@this.ViewModel.CurrentThing"
SelectionChanged="model => {
if (model != null)
SelectionChanged="model =>
{
this.TargetTree.ClearSelection();
}
this.OnElementSelected(model);}"
if (model != null)
{
this.TargetTree.ClearSelection();
}
this.OnElementSelected(model);
}"
AllowDrag="true"
AllowDrop="true"
OnCalculateDropIsAllowed="@(async x => await this.SetDropIsAllowed(x))"
OnDragEnter="@(async x => await this.OnDragEnter(x))"
OnDragLeave="@(async x => await this.OnDragLeave(x))"
OnDragStart="@(async x => await this.OnDragStart(x))"
OnDragEnd="@(async x => await this.OnDragEnd(x))"
OnDrop="@(async x => await this.OnDrop(x))"
AllowNodeDrag="(tree, model) => model is ElementDefinitionTreeTreeRowViewModel"
OnCalculateDropIsAllowed="@(async x => await this.SetDropIsAllowedAsync(x))"
OnDragEnter="@(async x => await this.OnDragEnterAsync(x))"
OnDragLeave="@(async x => await this.OnDragLeaveAsync())"
OnDragStart="@(async x => await this.OnDragStartAsync(x))"
OnDragEnd="@(async x => await this.OnDragEndAsync())"
OnDrop="@(async x => await this.OnDropAsync(x))"
AllowNodeDrag="(_, model) => model is ElementDefinitionTreeTreeRowViewModel"
IsModelSelectionEnabled="true">
</ElementDefinitionTree>
</div>
Expand All @@ -56,21 +58,23 @@
<ElementDefinitionTree
@ref="this.TargetTree"
InitialIteration="@this.ViewModel.CurrentThing"
SelectionChanged="model => {
SelectionChanged="model =>
{
if (model != null)
{
this.SourceTree.ClearSelection();
}
this.OnElementSelected(model);}"
this.OnElementSelected(model);
}"
AllowDrag="true"
AllowDrop="true"
OnCalculateDropIsAllowed="@(async x => await this.SetDropIsAllowed(x))"
OnDragEnter="@(async x => await this.OnDragEnter(x))"
OnDragLeave="@(async x => await this.OnDragLeave(x))"
OnDragStart="@(async x => await this.OnDragStart(x))"
OnDragEnd="@(async x => await this.OnDragEnd(x))"
OnDrop="@(async x => await this.OnDrop(x))"
AllowNodeDrag="(tree, model) => model is ElementDefinitionTreeTreeRowViewModel"
OnCalculateDropIsAllowed="@(async x => await this.SetDropIsAllowedAsync(x))"
OnDragEnter="@(async x => await this.OnDragEnterAsync(x))"
OnDragLeave="@(async x => await this.OnDragLeaveAsync())"
OnDragStart="@(async x => await this.OnDragStartAsync(x))"
OnDragEnd="@(async x => await this.OnDragEndAsync())"
OnDrop="@(async x => await this.OnDropAsync(x))"
AllowNodeDrag="(_, model) => model is ElementDefinitionTreeTreeRowViewModel"
IsModelSelectionEnabled="false">
</ElementDefinitionTree>
</div>
Expand Down
78 changes: 37 additions & 41 deletions COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ namespace COMETwebapp.Components.MultiModelEditor
using COMETwebapp.ViewModels.Components.ModelEditor.Rows;
using COMETwebapp.ViewModels.Components.MultiModelEditor.Rows;

using DevExpress.Blazor;

using ReactiveUI;

/// <summary>
Expand Down Expand Up @@ -99,7 +97,7 @@ private void OnElementSelected(ElementBaseTreeRowViewModel elementRowViewModel)
/// </summary>
/// <param name="nodeData">A <see cref="Tuple"/> that contains the specific <see cref="ElementDefinitionTree"/> and the specific node (<see cref="ElementBaseTreeRowViewModel"/>)</param>
/// <returns>an awaitable <see cref="Task"/></returns>
private Task OnDragStart((ElementDefinitionTree, ElementBaseTreeRowViewModel) nodeData)
private Task OnDragStartAsync((ElementDefinitionTree, ElementBaseTreeRowViewModel) nodeData)
{
this.DragObject = nodeData;
return Task.CompletedTask;
Expand All @@ -108,9 +106,8 @@ private Task OnDragStart((ElementDefinitionTree, ElementBaseTreeRowViewModel) no
/// <summary>
/// Is executed when dragging has been ended for a specific node (<see cref="ElementBaseTreeRowViewModel"/>) in a specific <see cref="ElementDefinitionTree"/>
/// </summary>
/// <param name="nodeData">A <see cref="Tuple"/> that contains the specific <see cref="ElementDefinitionTree"/> and the specific node (<see cref="ElementBaseTreeRowViewModel"/>)</param>
/// <returns>an awaitable <see cref="Task"/></returns>
private Task OnDragEnd((ElementDefinitionTree, ElementBaseTreeRowViewModel) nodeData)
private Task OnDragEndAsync()
{
this.DragObject = (null, null);
return Task.CompletedTask;
Expand All @@ -121,7 +118,7 @@ private Task OnDragEnd((ElementDefinitionTree, ElementBaseTreeRowViewModel) node
/// </summary>
/// <param name="nodeData">A <see cref="Tuple"/> that contains the specific <see cref="ElementDefinitionTree"/> and the specific node (<see cref="ElementBaseTreeRowViewModel"/>)</param>
/// <returns>an awaitable <see cref="Task"/></returns>
private async Task OnDrop((ElementDefinitionTree, ElementBaseTreeRowViewModel) nodeData)
private async Task OnDropAsync((ElementDefinitionTree, ElementBaseTreeRowViewModel) nodeData)
{
this.ErrorMessage = string.Empty;

Expand Down Expand Up @@ -160,7 +157,7 @@ private async Task OnDrop((ElementDefinitionTree, ElementBaseTreeRowViewModel) n
/// </summary>
/// <param name="elementData">A <see cref="Tuple"/> that contains the specific <see cref="ElementDefinitionTree"/> and the specific element (<see cref="object"/>)</param>
/// <returns>an awaitable <see cref="Task"/></returns>
private Task OnDragEnter((ElementDefinitionTree, object) elementData)
private Task OnDragEnterAsync((ElementDefinitionTree, object) elementData)
{
this.DragOverObject = elementData;
return Task.CompletedTask;
Expand All @@ -169,9 +166,8 @@ private Task OnDragEnter((ElementDefinitionTree, object) elementData)
/// <summary>
/// Is executed when a dragged node (<see cref="ElementBaseTreeRowViewModel"/>) leaves a previously hovered over specific element (<see cref="object"/>) in a specific <see cref="ElementDefinitionTree"/>
/// </summary>
/// <param name="elementData">A <see cref="Tuple"/> that contains the specific <see cref="ElementDefinitionTree"/> and the specific element (<see cref="object"/>)</param>
/// <returns>an awaitable <see cref="Task"/></returns>
private Task OnDragLeave((ElementDefinitionTree, object) elementData)
private Task OnDragLeaveAsync()
{
this.DragOverObject = (null, null);
return Task.CompletedTask;
Expand All @@ -182,7 +178,7 @@ private Task OnDragLeave((ElementDefinitionTree, object) elementData)
/// </summary>
/// <param name="elementDefinitionTree">The <see cref="ElementDefinitionTree"/> to calculate this for</param>
/// <returns>an awaitable <see cref="Task"/></returns>
private Task SetDropIsAllowed(ElementDefinitionTree elementDefinitionTree)
private Task SetDropIsAllowedAsync(ElementDefinitionTree elementDefinitionTree)
{
elementDefinitionTree.AllowNodeDrop = this.CalculateDropIsAllowed(elementDefinitionTree);
return Task.CompletedTask;
Expand All @@ -198,46 +194,46 @@ private bool CalculateDropIsAllowed(ElementDefinitionTree elementDefinitionTree)
var dragOverObject = this.DragOverObject;
var dragObject = this.DragObject;

if (elementDefinitionTree.AllowDrop)
if (!elementDefinitionTree.AllowDrop)
{
return false;
}

if (dragObject == (null, null))
{
return false;
}

if (dragOverObject == dragObject)
{
return false;
}

if (dragOverObject.Item2 is ElementDefinitionTreeTreeRowViewModel dragOverVm)
{
if (dragObject != (null, null))
if (dragObject.Item2 is not ElementDefinitionTreeTreeRowViewModel dragVm)
{
if (dragOverObject == dragObject)
{
return false;
}

if (dragOverObject.Item2 is ElementDefinitionTreeTreeRowViewModel dragOverVm)
{
if (dragObject.Item2 is ElementDefinitionTreeTreeRowViewModel dragVm)
{
if (dragOverVm.ElementBase == dragVm.ElementBase)
{
return false;
}

if (dragOverVm.ElementBase.GetContainerOfType<Iteration>() == dragVm.ElementBase.GetContainerOfType<Iteration>())
{
return true;
}

return false;
}

return false;
}

if (dragOverObject.Item1 == elementDefinitionTree)
{
return true;
}
return false;
}

if (dragOverVm.ElementBase == dragVm.ElementBase)
{
return false;
}

if (dragOverVm.ElementBase.GetContainerOfType<Iteration>() == dragVm.ElementBase.GetContainerOfType<Iteration>())
{
return true;
}

return false;
}

if (dragOverObject.Item1 == elementDefinitionTree)
{
return true;
}

return false;
}
}
Expand Down

0 comments on commit fe557d0

Please sign in to comment.