Skip to content

Commit

Permalink
Remove projects dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimeatstariongroup committed Sep 19, 2023
1 parent 798fb6d commit 63d3dd9
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 97 deletions.
5 changes: 1 addition & 4 deletions COMET.Web.Common/COMET.Web.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<!--<PackageReference Include="CDP4ServicesDal-CE" Version="24.1.0" />-->
<PackageReference Include="CDP4ServicesDal-CE" Version="24.1.0" />
<PackageReference Include="DevExpress.Blazor" Version="23.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="7.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.4" />
Expand All @@ -53,7 +53,4 @@
<ItemGroup>
<Folder Include="ViewModels\Components\BookEditor\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\COMET-SDK-Community-Edition\CDP4ServicesDal\CDP4ServicesDal.csproj" />
</ItemGroup>
</Project>
12 changes: 0 additions & 12 deletions COMETwebapp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{
.github\workflows\publish-docker-container.yml = .github\workflows\publish-docker-container.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CDP4Common", "..\COMET-SDK-Community-Edition\CDP4Common\CDP4Common.csproj", "{3BB827A8-4C73-4746-A898-50E09C5A6237}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CDP4ServicesDal", "..\COMET-SDK-Community-Edition\CDP4ServicesDal\CDP4ServicesDal.csproj", "{F1DE6907-1F53-43BB-95D0-8344C63D3F8D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -59,14 +55,6 @@ Global
{C1BEF589-7A99-4B95-A036-471259115495}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1BEF589-7A99-4B95-A036-471259115495}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1BEF589-7A99-4B95-A036-471259115495}.Release|Any CPU.Build.0 = Release|Any CPU
{3BB827A8-4C73-4746-A898-50E09C5A6237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3BB827A8-4C73-4746-A898-50E09C5A6237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BB827A8-4C73-4746-A898-50E09C5A6237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BB827A8-4C73-4746-A898-50E09C5A6237}.Release|Any CPU.Build.0 = Release|Any CPU
{F1DE6907-1F53-43BB-95D0-8344C63D3F8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1DE6907-1F53-43BB-95D0-8344C63D3F8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1DE6907-1F53-43BB-95D0-8344C63D3F8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1DE6907-1F53-43BB-95D0-8344C63D3F8D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 1 addition & 3 deletions COMETwebapp/Components/BookEditor/BookEditorBody.razor
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
Items="@this.ViewModel.AvailableBooks.Items.ToList()"
@bind-SelectedValue="@this.ViewModel.SelectedBook"
OnCreateNewItemClick="@(() => this.ViewModel.IsOnBookCreation = true)"
LinesOnRight="true"
HorizontalLineHalfWidth="true"
DrawLeftLines="false"
IsCollapsed="@this.IsBooksColumnCollapsed"
CollapseButtonIconClass="no-display"
CssClass="book-nodes">
Expand Down Expand Up @@ -97,7 +96,6 @@
<BookEditorColumn TItem="Note" HeaderHexColor="#eb6075" HeaderTitle="Notes"
Items="@this.ViewModel.SelectedPage?.Note.ToList()"
OnCreateNewItemClick="@(() => this.ViewModel.IsOnNoteCreation = true)"
HorizontalLineHalfWidth="true"
OnCollapseClicked="@(() => this.IsPageColumnCollapsed = !this.IsPageColumnCollapsed)"
CollapseButtonIconClass="@(this.IsPageColumnCollapsed ? "icon-arrow-right" : "icon-arrow-left")">
<ContentTemplate>
Expand Down
92 changes: 54 additions & 38 deletions COMETwebapp/Components/BookEditor/BookEditorColumn.razor
Original file line number Diff line number Diff line change
Expand Up @@ -36,52 +36,68 @@
<div class="column-content">
@if (this.Items != null && this.Items.Any())
{
<Virtualize TItem="@TItem" Items="@this.Items" Context="item">
@{
var isSelected = item.Equals(this.SelectedValue);
var conditionalClass = isSelected ? "selected" : "";
var firstClass = item.Equals(this.Items.First()) && this.Items.Count > 1 ? "first" : "";
var lastClass = item.Equals(this.Items.Last()) && this.Items.Count > 1 ? "last" : "";
<div class="column-scroll-content" @onscroll="@(this.OnScroll)">

var fullWidthClass = this.HorizontalLineHalfWidth ? "" : "full-width";
var rightSideClass = this.LinesOnRight ? "right-side" : "";
<Virtualize TItem="@TItem" Items="@this.Items" Context="item">
@{
var isSelected = item.Equals(this.SelectedValue);
var isFirst = item.Equals(this.Items.First()) && this.Items.Count > 1;
var isLast = item.Equals(this.Items.Last()) && this.Items.Count > 1;
var conditionalClass = isSelected ? "selected" : "";
var firstClass = isFirst ? "first" : "";
var lastClass = isLast ? "last" : "";

var index = this.Items.IndexOf(item);
var index = this.Items.IndexOf(item);

<div class="node-inner-content @this.CssClass">
@if (!this.LinesOnRight)
{
<hr class="horizontal-line @firstClass @lastClass @fullWidthClass @rightSideClass"/>
<hr class="vertical-line @firstClass @lastClass @rightSideClass"/>
}
<button @onclick="@(async () => { await this.OnSelectedValueChanged(item, index); })" class="book-button @conditionalClass">
@if (this.ContentTemplate != null)
<div class="node-inner-content @this.CssClass">
@if (this.DrawLeftLines)
{
@this.ContentTemplate(item)
<hr class="horizontal-line @firstClass @lastClass" />
<hr class="vertical-line @firstClass @lastClass" />

// var points = this.GenerateLeftPathPoints(isFirst, isLast);
// <svg class="svg-path">
// <polyline points="@points.horizontalPath"
// style="fill:none;stroke:#CCC;stroke-width:2"
// stroke-dasharray="8,3" />
// <polyline points="@points.verticalPath"
// style="fill:none;stroke:#CCC;stroke-width:2"
// stroke-dasharray="8,3" />
// </svg>
}
else

<button @onclick="@(async () => { await this.OnSelectedValueChanged(item, index); })" class="book-button @conditionalClass">
@if (this.ContentTemplate != null)
{
@this.ContentTemplate(item)
}
else
{
@item.ToString()
}
</button>

@if (isSelected)
{
@item.ToString()
<div class="edit-node-container">
<button class="icon icon-arrow-up"></button>
<button class="icon icon-arrow-down"></button>
<button class="icon icon-edit"></button>
<button class="icon icon-trash"></button>
</div>
}
</button>
</div>
}
</Virtualize>

</div>

@if (isSelected)
{
<div class="edit-node-container">
<button class="icon icon-arrow-up"></button>
<button class="icon icon-arrow-down"></button>
<button class="icon icon-edit"></button>
<button class="icon icon-trash"></button>
</div>
}
</div>
}
</Virtualize>
<svg class="svg-path">
<polyline points="@this.GeneratePathPoints()"
style="fill:none;stroke:#CCC;stroke-width:2"
stroke-dasharray="8,3" />
</svg>
}
<svg class="svg-path">
<polyline points="@this.GeneratePathPoints()"
style="fill:none;stroke:#CCC;stroke-width:2"
stroke-dasharray="8,3" />
</svg>
</div>
</div>
67 changes: 45 additions & 22 deletions COMETwebapp/Components/BookEditor/BookEditorColumn.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

namespace COMETwebapp.Components.BookEditor
{
using CDP4JsonSerializer.JsonConverter;

using COMETwebapp.Services.Interoperability;

using DynamicData;

using Microsoft.AspNetCore.Components;

/// <summary>
Expand All @@ -48,17 +48,11 @@ public partial class BookEditorColumn<TItem>
public string CollapseButtonIconClass { get; set; }

/// <summary>
/// Gets or sets if the lines should be drawn in the right side
/// </summary>
[Parameter]
public bool LinesOnRight { get; set; }

/// <summary>
/// Gets or sets if the first horizontal line should be the half width
/// Gets or sets if the lines should be drawn in the left side or not drawn at all
/// </summary>
[Parameter]
public bool HorizontalLineHalfWidth { get; set; }

public bool DrawLeftLines { get; set; } = true;
/// <summary>
/// Gets or sets the title of the header
/// </summary>
Expand Down Expand Up @@ -119,24 +113,29 @@ public partial class BookEditorColumn<TItem>

[Parameter]
public string CssClass { get; set; }

/// <summary>
/// Hanlder for when the selected value changes
/// </summary>
/// <param name="item">the item selected</param>
/// <param name="itemIndex">the index of the item selected</param>
/// <returns>an asynchronous operation</returns>
private async Task OnSelectedValueChanged(TItem item, int itemIndex)
{
try
{
this.firstItemSizeAndPosition = await this.DomDataService.GetElementSizeAndPosition(0, this.CssClass);
this.sizeAndPosition = await this.DomDataService.GetElementSizeAndPosition(itemIndex, this.CssClass);
await this.SelectedValueChanged.InvokeAsync(item);
}
catch (Exception ex)
{
this.firstItemSizeAndPosition = await this.DomDataService.GetElementSizeAndPosition(0, this.CssClass, false);
this.sizeAndPosition = await this.DomDataService.GetElementSizeAndPosition(itemIndex, this.CssClass, true);
await this.SelectedValueChanged.InvokeAsync(item);
}

}
/// <summary>
/// Callback method called from JS when an element performs scroll
/// </summary>
/// <returns></returns>
public async Task OnScroll()
{
var itemIndex = this.Items.IndexOf(this.SelectedValue);
this.sizeAndPosition = await this.DomDataService.GetElementSizeAndPosition(itemIndex, this.CssClass, true);
await this.InvokeAsync(this.StateHasChanged);
}

/// <summary>
Expand All @@ -149,7 +148,7 @@ private string GeneratePathPoints()
{
return string.Empty;
}

var left = this.sizeAndPosition[0];
var top = this.sizeAndPosition[1];
var width = this.sizeAndPosition[2];
Expand All @@ -168,5 +167,29 @@ private string GeneratePathPoints()

return $"{x1},{y1},{x2},{y2},{x3},{y3},{x4},{y4}";
}

private (string verticalPath, string horizontalPath) GenerateLeftPathPoints(bool isFirst, bool isLast)
{
if (this.sizeAndPosition.Length < 4 || this.firstItemSizeAndPosition.Length < 4)
{
return (string.Empty, string.Empty);
}

var top = this.sizeAndPosition[1];
var width = this.sizeAndPosition[2];
var height = this.sizeAndPosition[3];

var x1 = (int)(width*0.1);
var y1 = (int)(top);
var x2 = (int)(width*0.1);
var y2 = (int)(top + height);

var x3 = (int)(width*0.0);
var y3 = (int)(top + height / 2.0f);
var x4 = (int)(width*0.2);
var y4 = (int)(top + height / 2.0f);

return ($"{x1},{y1},{x2},{y2}",$"{x3},{y3},{x4},{y4}");
}
}
}
29 changes: 26 additions & 3 deletions COMETwebapp/Components/BookEditor/BookEditorColumn.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
flex-direction: column;
max-height: 85vh;
border: 0px dashed #555;
padding: 5% 0%;
padding: 2.5% 0%;
transition: all 1s;
box-shadow: 0px 0px 4px rgba(0,0,0,0.2);
}
Expand Down Expand Up @@ -48,7 +48,6 @@
.column-content {
width: 100%;
height: 100%;
overflow-y: auto;
display: flex;
flex-direction: column;
align-items: center;
Expand All @@ -57,6 +56,16 @@
position: relative;
}

.column-scroll-content {
width: 100%;
height: 100%;
overflow-y: auto;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
}

.node-inner-content {
position: relative;
width: 100%;
Expand All @@ -78,7 +87,7 @@
z-index: 1;
}

.book-button:hover, .section-button:hover, .page-button:hover, .note-button:hover {
.book-button:hover {
box-shadow: 0px 0px 0px 2px rgba(0,0,0,0.2);
}

Expand Down Expand Up @@ -136,6 +145,20 @@
left: 50%;
}

.horizontal-line.first-slice {
display:none;
width: 50%;
left: 0%;
border-top: 2px dashed red;
}

.horizontal-line.first.first-slice {
display:block;
width: 20%;
left: 0%;
border-top: 2px dashed red;
}

.edit-node-container{
display: flex;
flex-direction: column;
Expand Down
6 changes: 3 additions & 3 deletions COMETwebapp/Services/Interoperability/DomDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

namespace COMETwebapp.Services.Interoperability
{
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;

/// <summary>
Expand All @@ -45,10 +44,11 @@ public DomDataService(IJSRuntime jsRuntime) : base(jsRuntime)
/// </summary>
/// <param name="elementIndex">the index of the element to search</param>
/// <param name="cssSelector">the selector to use to select the items</param>
/// <param name="useScroll">If the scroll must be taken into account for the calculations</param>
/// <returns>the size and position</returns>
public async Task<float[]> GetElementSizeAndPosition(int elementIndex, string cssSelector)
public async Task<float[]> GetElementSizeAndPosition(int elementIndex, string cssSelector, bool useScroll)
{
return await this.JsRuntime.InvokeAsync<float[]>("GetElementSizeAndPosition", elementIndex, cssSelector);
return await this.JsRuntime.InvokeAsync<float[]>("GetElementSizeAndPosition", elementIndex, cssSelector, useScroll);
}
}
}
5 changes: 2 additions & 3 deletions COMETwebapp/Services/Interoperability/IDomDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

namespace COMETwebapp.Services.Interoperability
{
using Microsoft.AspNetCore.Components;

/// <summary>
/// The service used to retrieve several data from the DOM
/// </summary>
Expand All @@ -36,7 +34,8 @@ public interface IDomDataService
/// </summary>
/// <param name="elementIndex">the index of the element to search</param>
/// <param name="cssSelector">the selector to use to select the items</param>
/// <param name="useScroll">If the scroll must be taken into account for the calculations</param>
/// <returns>the size and position</returns>
Task<float[]> GetElementSizeAndPosition(int elementIndex, string cssSelector);
Task<float[]> GetElementSizeAndPosition(int elementIndex, string cssSelector, bool useScroll);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ protected override async Task OnIterationChanged()
}

this.ResetDataToCreate();
this.CreateFakeData();
//this.CreateFakeData();
this.IsLoading = false;
}

Expand Down
Loading

0 comments on commit 63d3dd9

Please sign in to comment.