Skip to content

Commit

Permalink
before details components
Browse files Browse the repository at this point in the history
  • Loading branch information
joao4all committed Apr 4, 2024
1 parent 0d32944 commit 6621c6d
Show file tree
Hide file tree
Showing 15 changed files with 657 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ Copyright (c) 2023-2024 RHEA System S.A.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
------------------------------------------------------------------------------->
@using COMETwebapp.ViewModels.Components.SiteDirectory.Rows
@using CDP4Common.SiteDirectoryData
@inherits COMETwebapp.Components.Common.SelectedDataItemBase<CDP4Common.SiteDirectoryData.EngineeringModelSetup, COMETwebapp.ViewModels.Components.SiteDirectory.Rows.EngineeringModelRowViewModel>
@inherits SelectedDataItemBase<EngineeringModelSetup, EngineeringModelRowViewModel>

<LoadingComponent IsVisible="@(this.ViewModel.IsLoading)">
<div style="display: flex; justify-content: space-between;">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!------------------------------------------------------------------------------
Copyright (c) 2023-2024 RHEA System S.A.
Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
This file is part of CDP4-COMET WEB Community Edition
The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
------------------------------------------------------------------------------->
@inherits DisposableComponent

<DxFormLayout CssClass="w-100 overflow-auto max-height-50vh">
<DxFormLayoutItem Caption="Shortname:" ColSpanMd="10">
<DxTextBox @bind-Text="@(this.ViewModel.Thing.ShortName)"/>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Name:" ColSpanMd="10">
<DxTextBox @bind-Text="@(this.ViewModel.Thing.Name)"/>
</DxFormLayoutItem>

@foreach (var permission in this.ViewModel.Thing.ParticipantPermission.OrderBy(x => x.ObjectClass.ToString()))
{
<DxFormLayoutItem Caption="@(permission.ObjectClass.ToString())"
ColSpanMd="12">
<DxComboBox Data="@this.ViewModel.ParticipantAccessKinds"
@bind-Value="@permission.AccessRight"
CssClass="cw-480"
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto"/>
</DxFormLayoutItem>
}
</DxFormLayout>

<DxPopup @bind-Visible="@(this.ViewModel.IsOnDeprecationMode)" HeaderText="Please confirm" Width="auto" CloseOnOutsideClick="false">
@(this.ViewModel.PopupDialog)
<div class="dxbl-grid-confirm-dialog-buttons">
<DxButton Text="Cancel " RenderStyle="ButtonRenderStyle.Success" Click="@(this.ViewModel.OnCancelPopupButtonClick)"/>
<DxButton Text="Confirm" RenderStyle="ButtonRenderStyle.Danger" Click="@(this.ViewModel.OnConfirmPopupButtonClick)"/>
</div>
</DxPopup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ParticipantRoleDetails.razor.cs" company="RHEA System S.A.">
// Copyright (c) 2023-2024 RHEA System S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
//
// This file is part of CDP4-COMET WEB Community Edition
// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Components.SiteDirectory.Roles
{
using COMET.Web.Common.Components;

using COMETwebapp.ViewModels.Components.SiteDirectory.Roles;

using Microsoft.AspNetCore.Components;

/// <summary>
/// Support class for the <see cref="ParticipantRoleDetails"/>
/// </summary>
public partial class ParticipantRoleDetails : DisposableComponent
{
/// <summary>
/// The <see cref="IParticipantRolesTableViewModel" /> for this component
/// </summary>
[Parameter]
public IParticipantRolesTableViewModel ViewModel { get; set; }

/// <summary>
/// Gets or sets the value to check if the deprecatable option should be shown
/// </summary>
[Parameter]
public bool ShowDeprecatableOption { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!------------------------------------------------------------------------------
Copyright (c) 2023-2024 RHEA System S.A.
Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
This file is part of CDP4-COMET WEB Community Edition
The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
------------------------------------------------------------------------------->
@inherits SelectedDeprecatableDataItemBase<ParticipantRole, ParticipantRoleRowViewModel>

<LoadingComponent IsVisible="@(this.ViewModel.IsLoading)">
<div style="display: flex; justify-content: space-between;">
<DxGrid @ref="this.Grid"
Data="this.ViewModel.Rows.Items"
ColumnResizeMode="GridColumnResizeMode.ColumnsContainer"
ShowSearchBox="true"
SearchBoxNullText="Search for a participant role..."
AllowSelectRowByClick="true"
SelectedDataItemChanged="@(row => this.OnSelectedDataItemChanged((ParticipantRoleRowViewModel)row))"
PopupEditFormCssClass="pw-800"
PopupEditFormHeaderText="Participant Role"
CustomizeElement="DisableDeprecatedThing"
CustomizeEditModel="this.CustomizeEditThing"
EditMode="GridEditMode.PopupEditForm"
EditModelSaving="@(() => this.OnEditThingSaving())"
PageSize="20"
PagerNavigationMode="PagerNavigationMode.Auto"
PageSizeSelectorVisible="true"
PageSizeSelectorItems="@(new[] { 20, 35, 50 })"
PageSizeSelectorAllRowsItemVisible="true"
CssClass="d-inline">
<Columns>
<DxGridDataColumn FieldName="@nameof(ParticipantRoleRowViewModel.Name)" MinWidth="150"/>
<DxGridDataColumn FieldName="@nameof(ParticipantRoleRowViewModel.ShortName)" MinWidth="80" />
<DxGridDataColumn FieldName="@nameof(ParticipantRoleRowViewModel.IsDeprecated)" MinWidth="80" Visible="false"/>
<DxGridCommandColumn Width="200px" EditButtonVisible="false" DeleteButtonVisible="false">
<HeaderTemplate>
<DxButton Id="addParticipantRoleButton" Text="Add Participant Role" IconCssClass="oi oi-plus" Click="() => this.Grid.StartEditNewRowAsync()"/>
</HeaderTemplate>
</DxGridCommandColumn>
</Columns>

<EditFormTemplate Context="EditFormContext">
<DxFormLayout CssClass="w-100">
<DxFormLayoutTabPages>

<DxFormLayoutTabPage Caption="Basic">
<DxFormLayoutItem Caption="Shortname:" ColSpanMd="10">
<DxTextBox @bind-Text="@(this.ViewModel.Thing.ShortName)"/>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Name:" ColSpanMd="10">
<DxTextBox @bind-Text="@(this.ViewModel.Thing.Name)"/>
</DxFormLayoutItem>
</DxFormLayoutTabPage>

<DxFormLayoutTabPage Caption="Permissions" CssClass="overflow-auto max-height-50vh">
@foreach (var permission in this.ViewModel.Thing.ParticipantPermission.OrderBy(x => x.ObjectClass.ToString()))
{
<DxFormLayoutItem Caption="@(permission.ObjectClass.ToString())"
ColSpanMd="12">
<DxComboBox Data="@this.ViewModel.ParticipantAccessKinds"
@bind-Value="@permission.AccessRight"
CssClass="cw-480"
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto"/>
</DxFormLayoutItem>
}
</DxFormLayoutTabPage>

</DxFormLayoutTabPages>
</DxFormLayout>
<ValidationSummary/>
</EditFormTemplate>

<CustomValidators>
<FluentValidationValidator/>
</CustomValidators>

</DxGrid>
</div>
<div class="pb-3"></div>
</LoadingComponent>

<DxPopup @bind-Visible="@(this.ViewModel.IsOnDeprecationMode)" HeaderText="Please confirm" Width="auto" CloseOnOutsideClick="false">
@(this.ViewModel.PopupDialog)
<div class="dxbl-grid-confirm-dialog-buttons">
<DxButton Text="Cancel " RenderStyle="ButtonRenderStyle.Success" Click="@(this.ViewModel.OnCancelPopupButtonClick)"/>
<DxButton Text="Confirm" RenderStyle="ButtonRenderStyle.Danger" Click="@(this.ViewModel.OnConfirmPopupButtonClick)"/>
</div>
</DxPopup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ParticipantRolesTable.razor.cs" company="RHEA System S.A.">
// Copyright (c) 2023-2024 RHEA System S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
//
// This file is part of CDP4-COMET WEB Community Edition
// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Components.SiteDirectory.Roles
{
using CDP4Common.SiteDirectoryData;

using COMETwebapp.Components.Common;
using COMETwebapp.ViewModels.Components.SiteDirectory.Roles;
using COMETwebapp.ViewModels.Components.SiteDirectory.Rows;

using DevExpress.Blazor;

using Microsoft.AspNetCore.Components;

/// <summary>
/// Support class for the <see cref="ParticipantRolesTable"/>
/// </summary>
public partial class ParticipantRolesTable : SelectedDeprecatableDataItemBase<ParticipantRole, ParticipantRoleRowViewModel>
{
/// <summary>
/// The <see cref="IParticipantRolesTableViewModel" /> for this component
/// </summary>
[Inject]
public IParticipantRolesTableViewModel ViewModel { get; set; }

/// <summary>
/// Method invoked when the component is ready to start, having received its
/// initial parameters from its parent in the render tree.
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
this.Initialize(this.ViewModel);
}

/// <summary>
/// Method that is invoked when the edit/add thing form is being saved
/// </summary>
/// <returns>A <see cref="Task" /></returns>
protected override async Task OnEditThingSaving()
{
await this.ViewModel.CreateOrEditParticipantRole(this.ShouldCreateThing);
}

/// <summary>
/// Method invoked when creating a new thing
/// </summary>
/// <param name="e">A <see cref="GridCustomizeEditModelEventArgs" /></param>
protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
{
base.CustomizeEditThing(e);

var dataItem = (ParticipantRoleRowViewModel)e.DataItem;
this.ShouldCreateThing = e.IsNew;

if (dataItem == null)
{
this.ViewModel.Thing = new ParticipantRole();
e.EditModel = this.ViewModel.Thing;
return;
}

this.ViewModel.Thing = dataItem.Thing.Clone(false);
e.EditModel = this.ViewModel.Thing;
}

/// <summary>
/// Metgid invoked everytime a row is selected
/// </summary>
/// <param name="row">The selected row</param>
private void OnSelectedDataItemChanged(ParticipantRoleRowViewModel row)
{
// do something
}

/// <summary>
/// Sets the selected values for the <see cref="Participant"/> creation and submits the form
/// </summary>
/// <returns>A <see cref="Task"/></returns>
private async Task SetSelectedValuesAndSubmit()

Check warning on line 102 in COMETwebapp/Components/SiteDirectory/Roles/ParticipantRolesTable.razor.cs

View workflow job for this annotation

GitHub Actions / Build

Remove the unused private method 'SetSelectedValuesAndSubmit'. (https://rules.sonarsource.com/csharp/RSPEC-1144)
{
await this.Grid.SaveChangesAsync();
}
}
}
3 changes: 3 additions & 0 deletions COMETwebapp/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace COMETwebapp.Extensions
using COMETwebapp.ViewModels.Components.ReferenceData.ParameterTypes;
using COMETwebapp.ViewModels.Components.SiteDirectory.EngineeringModels;
using COMETwebapp.ViewModels.Components.SiteDirectory.Organizations;
using COMETwebapp.ViewModels.Components.SiteDirectory.Roles;
using COMETwebapp.ViewModels.Components.SubscriptionDashboard;
using COMETwebapp.ViewModels.Components.SystemRepresentation;
using COMETwebapp.ViewModels.Components.UserManagement;
Expand Down Expand Up @@ -100,6 +101,8 @@ public static void RegisterViewModels(this IServiceCollection serviceCollection)
serviceCollection.AddTransient<IOrganizationalParticipantsTableViewModel, OrganizationalParticipantsTableViewModel>();
serviceCollection.AddTransient<IIterationsTableViewModel, IterationsTableViewModel>();
serviceCollection.AddTransient<IActiveDomainsTableViewModel, ActiveDomainsTableViewModel>();
serviceCollection.AddTransient<IParticipantRolesTableViewModel, ParticipantRolesTableViewModel>();
serviceCollection.AddTransient<IPersonRolesTableViewModel, PersonRolesTableViewModel>();
}
}
}
2 changes: 2 additions & 0 deletions COMETwebapp/Pages/SiteDirectory/DirectoryPage.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace COMETwebapp.Pages.SiteDirectory
{
using COMETwebapp.Components.SiteDirectory;
using COMETwebapp.Components.SiteDirectory.EngineeringModel;
using COMETwebapp.Components.SiteDirectory.Roles;

using DevExpress.Blazor;

Expand All @@ -49,6 +50,7 @@ public partial class DirectoryPage
{typeof(EngineeringModelsTable), "Models"},
{typeof(DomainsOfExpertiseTable), "Domains"},
{typeof(OrganizationsTable), "Organizations"},
{typeof(ParticipantRolesTable), "Roles"},
};

/// <summary>
Expand Down
Loading

0 comments on commit 6621c6d

Please sign in to comment.