Fingerprints filter for records station computer (#15017)

* add new labels and buttons for records stantion console

* add fingerprint fields for server

* set buttons and updates for fingerPrints filters

* set fingerprints filters

* final set for finger prints filters

* add new trhaslates for station records computer

* some fix for the PR

* refactor server side station record console system

* add message for filters

* add tranlates

* add new ui with several filters

* updetes prints with server side logic

* resolve conflicts with DNA

* resolve conflicts with DNA

* deleted unused variable and rename some fields

* added description for new state

* added select for filter

* set multiplay filters for the console

* added new translates

* add class filters &  fixed issue with reset line edit

* fix dublicate with set the  selectId for option button

* fixed review notes

* fixed review notes forget changet fix name

* add event TextEntered for better usability

* fixed review notes 3

* fixed formating in xaml

* fixed array with _filterTypes

* fixed ui and made it in minimalistic style

* fixed generalstationRecordFilter class, move method

* delete margin after line edit

* fix placeholder for lineEdit

* fix placeholder for lineEdit, the review note

* Revert "fixed generalstationRecordFilter class, move method"

This reverts commit 1b35c6ac44e7dafe9a1f0560eb177152b822f20b.

* impliment short swith in method IsSkippedRecord

* fixed review notes, remaked method IsSkipped and fix casing

* fixed the review note about check null record name
This commit is contained in:
Artjom
2023-04-12 17:27:13 +03:00
committed by GitHub
parent c4fd54eefb
commit d3936b24fe
8 changed files with 223 additions and 24 deletions

View File

@@ -16,6 +16,7 @@ public sealed class GeneralStationRecordConsoleBoundUserInterface : BoundUserInt
_window = new();
_window.OnKeySelected += OnKeySelected;
_window.OnFiltersChanged += OnFiltersChanged;
_window.OnClose += Close;
_window.OpenCentered();
@@ -26,6 +27,13 @@ public sealed class GeneralStationRecordConsoleBoundUserInterface : BoundUserInt
SendMessage(new SelectGeneralStationRecord(key));
}
private void OnFiltersChanged(
GeneralStationRecordFilterType type, string filterValue)
{
GeneralStationRecordsFilterMsg msg = new(type, filterValue);
SendMessage(msg);
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

View File

@@ -1,17 +1,26 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'general-station-record-console-window-title'}"
MinSize="750 500">
<BoxContainer>
<!-- Record listing -->
<BoxContainer Orientation="Vertical" Margin="5 5 5 5" MinWidth="250" VerticalExpand="True">
<Label Name="RecordListingStatus" Visible="False" />
<ScrollContainer VerticalExpand="True">
<ItemList Name="RecordListing" />
</ScrollContainer>
<BoxContainer Orientation="Vertical">
<BoxContainer Margin="5 5 5 10" HorizontalExpand="true" VerticalAlignment="Center">
<OptionButton Name="StationRecordsFilterType" MinWidth="200" Margin="0 0 10 0"/>
<LineEdit Name="StationRecordsFiltersValue"
PlaceHolder="{Loc 'general-station-record-for-filter-line-placeholder'}" HorizontalExpand="True"/>
<Button Name="StationRecordsFilters" Text="{Loc 'general-station-record-console-search-records'}"/>
<Button Name="StationRecordsFiltersReset" Text="{Loc 'general-station-record-console-reset-filters'}"/>
</BoxContainer>
<BoxContainer Orientation="Vertical" Margin="5 5 5 5">
<Label Name="RecordContainerStatus" Visible="False" Text="{Loc 'general-station-record-console-select-record-info'}"/>
<BoxContainer Name="RecordContainer" Orientation="Vertical" />
<BoxContainer VerticalExpand="True">
<!-- Record listing -->
<BoxContainer Orientation="Vertical" Margin="5" MinWidth="250" MaxWidth="250">
<Label Name="RecordListingStatus" Visible="False" />
<ScrollContainer VerticalExpand="True">
<ItemList Name="RecordListing" />
</ScrollContainer>
</BoxContainer>
<BoxContainer Orientation="Vertical" Margin="5">
<Label Name="RecordContainerStatus" Visible="False" Text="{Loc 'general-station-record-console-select-record-info'}"/>
<BoxContainer Name="RecordContainer" Orientation="Vertical" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
</DefaultWindow>

View File

@@ -12,12 +12,24 @@ namespace Content.Client.StationRecords;
public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow
{
public Action<StationRecordKey?>? OnKeySelected;
public Action<GeneralStationRecordFilterType, string>? OnFiltersChanged;
private bool _isPopulating;
private GeneralStationRecordFilterType _currentFilterType;
public GeneralStationRecordConsoleWindow()
{
RobustXamlLoader.Load(this);
_currentFilterType = GeneralStationRecordFilterType.Name;
foreach (var item in Enum.GetValues<GeneralStationRecordFilterType>())
{
StationRecordsFilterType.AddItem(GetTypeFilterLocals(item), (int)item);
}
RecordListing.OnItemSelected += args =>
{
if (_isPopulating || RecordListing[args.ItemIndex].Metadata is not StationRecordKey cast)
@@ -33,20 +45,66 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow
if (!_isPopulating)
OnKeySelected?.Invoke(null);
};
StationRecordsFilterType.OnItemSelected += eventArgs =>
{
var type = (GeneralStationRecordFilterType)eventArgs.Id;
if (_currentFilterType != type)
{
_currentFilterType = type;
FilterListingOfRecords();
}
};
StationRecordsFiltersValue.OnTextEntered += args =>
{
FilterListingOfRecords(args.Text);
};
StationRecordsFilters.OnPressed += _ =>
{
FilterListingOfRecords(StationRecordsFiltersValue.Text);
};
StationRecordsFiltersReset.OnPressed += _ =>
{
StationRecordsFiltersValue.Text = "";
FilterListingOfRecords();
};
}
public void UpdateState(GeneralStationRecordConsoleState state)
{
if (state.Filter != null)
{
if (state.Filter.Type != _currentFilterType)
{
_currentFilterType = state.Filter.Type;
}
if (state.Filter.Value != StationRecordsFiltersValue.Text)
{
StationRecordsFiltersValue.Text = state.Filter.Value;
}
}
StationRecordsFilterType.SelectId((int)_currentFilterType);
if (state.RecordListing == null)
{
RecordListingStatus.Visible = true;
RecordListing.Visible = false;
RecordListingStatus.Text = Loc.GetString("general-station-record-console-empty-state");
RecordContainer.Visible = false;
RecordContainerStatus.Visible = false;
return;
}
RecordListingStatus.Visible = false;
RecordListing.Visible = true;
RecordContainer.Visible = true;
PopulateRecordListing(state.RecordListing!, state.SelectedKey);
RecordContainerStatus.Visible = state.Record == null;
@@ -65,18 +123,17 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow
RecordContainer.RemoveAllChildren();
}
}
private void PopulateRecordListing(Dictionary<StationRecordKey, string> listing, StationRecordKey? selected)
{
RecordListing.Clear();
RecordListing.ClearSelected();
_isPopulating = true;
foreach (var (key, name) in listing)
{
var item = RecordListing.AddItem(name);
item.Metadata = key;
if (selected != null && key.ID == selected.Value.ID)
{
item.Selected = true;
@@ -131,4 +188,17 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow
RecordContainer.AddChild(control);
}
}
private void FilterListingOfRecords(string text = "")
{
if (!_isPopulating)
{
OnFiltersChanged?.Invoke(_currentFilterType, text);
}
}
private string GetTypeFilterLocals(GeneralStationRecordFilterType type)
{
return Loc.GetString($"general-station-record-{type.ToString().ToLower()}-filter");
}
}