-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New UI for the InputEditor and add MultiCombobox
- Loading branch information
1 parent
71a4c6d
commit 29e3eed
Showing
8 changed files
with
359 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!------------------------------------------------------------------------------ | ||
// Copyright (c) 2023 RHEA System S.A. | ||
// | ||
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Nabil Abbar | ||
// | ||
// This file is part of COMET WEB Community Edition | ||
// The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 | ||
// Annex A and Annex C. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
-------------------------------------------------------------------------------> | ||
@typeparam TItem | ||
|
||
<DxComboBox TValue="TItem" | ||
TData="TItem" | ||
Data="@this.Data" | ||
ValueChanged="@this.ItemSelected" | ||
Enabled="@this.Enabled" | ||
CssClass="w-100"> | ||
<ItemTemplate> | ||
<div class="multi-combo-item-template"> | ||
@if (this.ShowCheckBoxes) | ||
{ | ||
var isSelected = this.Values.Contains(context); | ||
<DxCheckBox Checked="@isSelected"></DxCheckBox> | ||
} | ||
|
||
@if (this.RowTemplate != null) | ||
{ | ||
@this.RowTemplate(context) | ||
} | ||
else | ||
{ | ||
<span>@context.ToString()</span> | ||
} | ||
</div> | ||
</ItemTemplate> | ||
|
||
<EditBoxTemplate> | ||
@if(this.Values.Count <= 2) | ||
{ | ||
<div class="chips-container"> | ||
@foreach(var value in this.Values) | ||
{ | ||
<button class="chip" @onclick="@(() => this.ItemSelected(value))"> | ||
@if (this.RowTemplate != null) | ||
{ | ||
@this.RowTemplate(value) | ||
} | ||
else | ||
{ | ||
@value | ||
} | ||
</button> | ||
} | ||
</div> | ||
} | ||
else | ||
{ | ||
<div>@(this.Values.Count) items are selected</div> | ||
} | ||
</EditBoxTemplate> | ||
</DxComboBox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// ----------------------------------------------------------------------------------- | ||
// <copyright file="MultiComboBox.razor.cs" company="RHEA System S.A."> | ||
// Copyright (c) 2023 RHEA System S.A. | ||
// | ||
// Authors: Sam Gerené, Jaime Bernar | ||
// | ||
// This file is part of AIDA | ||
// European Space Agency Community License – v2.4 Permissive (Type 3) | ||
// See LICENSE file for details | ||
// | ||
// </copyright> | ||
// ----------------------------------------------------------------------------------- | ||
|
||
namespace COMET.Web.Common.Components | ||
{ | ||
using Microsoft.AspNetCore.Components; | ||
|
||
/// <summary> | ||
/// Support class for the multicombobox component | ||
/// </summary> | ||
public partial class MultiComboBox<TItem> | ||
{ | ||
/// <summary> | ||
/// Gets or sets if the checkboxes for the selected items should be drawn | ||
/// </summary> | ||
[Parameter] | ||
public bool ShowCheckBoxes { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the item template for the selected items | ||
/// </summary> | ||
[Parameter] | ||
public RenderFragment<TItem> RowTemplate { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the data of the combobox | ||
/// </summary> | ||
[Parameter] | ||
public IEnumerable<TItem> Data { get; set; } = Enumerable.Empty<TItem>(); | ||
|
||
/// <summary> | ||
/// Gets or sets if the component should show all the fields as readonly | ||
/// </summary> | ||
[Parameter] | ||
public bool Enabled { get; set; } = true; | ||
|
||
/// <summary> | ||
/// Gets or sets the value of the selected items | ||
/// </summary> | ||
[Parameter] | ||
public List<TItem> Values { get; set; } = new(); | ||
|
||
/// <summary> | ||
/// Gets or sets the callback used to update the component value | ||
/// </summary> | ||
[Parameter] | ||
public EventCallback<List<TItem>> ValuesChanged { get; set; } | ||
|
||
/// <summary> | ||
/// Handler for when the value of the component has changed | ||
/// </summary> | ||
/// <param name="newValue">the new value</param> | ||
/// <returns>an asynchronous operation</returns> | ||
private async Task ItemSelected(TItem newValue) | ||
{ | ||
if(this.Values.Contains(newValue)) | ||
{ | ||
this.Values.Remove(newValue); | ||
} | ||
else | ||
{ | ||
this.Values.Add(newValue); | ||
} | ||
|
||
await this.ValuesChanged.InvokeAsync(this.Values); | ||
} | ||
} | ||
} |
Oops, something went wrong.