Skip to content

Commit

Permalink
Remove SortName and have it calculate based on name
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Oct 16, 2023
1 parent 9fff863 commit 9ac1aca
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Shoko.Commons
2 changes: 0 additions & 2 deletions Shoko.Desktop/Forms/MoveSeries.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@

<TextBlock Grid.Row="0" Grid.Column="0" FontWeight="Bold" Margin="5,0,5,0" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=GroupName}"/>
<TextBox Grid.Row="0" Grid.Column="1" MinWidth="300" Margin="5,0,0,5" Text="" Name="txtGroupName"/>
<TextBlock Grid.Row="1" Grid.Column="0" FontWeight="Bold" Margin="5,0,5,0" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=SortName}"/>
<TextBox Grid.Row="1" Grid.Column="1" MinWidth="300" Margin="5,0,0,5" Text="" Name="txtGroupSortName"/>
</Grid>
</StackPanel>

Expand Down
2 changes: 0 additions & 2 deletions Shoko.Desktop/Forms/MoveSeries.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ void btnOK_Click(object sender, RoutedEventArgs e)

VM_AnimeGroup_User grp = new VM_AnimeGroup_User();
grp.GroupName = txtGroupName.Text.Trim();
grp.SortName = txtGroupName.Text.Trim();
grp.AnimeGroupParentID = null;
grp.Description = "";
grp.IsFave = 0;
Expand Down Expand Up @@ -199,7 +198,6 @@ public void Init(VM_AnimeSeries_User series)
Series = series;

txtGroupName.Text = Series.SeriesName;
txtGroupSortName.Text = Series.SeriesName;
}

void txtGroupSearch_TextChanged(object sender, TextChangedEventArgs e)
Expand Down
3 changes: 0 additions & 3 deletions Shoko.Desktop/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,6 @@ public void CommandBinding_Edit(object sender, ExecutedRoutedEventArgs e)
GroupName = grp.GroupName,
IsFave = grp.IsFave,
Description = grp.Description,
SortName = grp.SortName
};
}

Expand Down Expand Up @@ -1868,7 +1867,6 @@ public void CommandBinding_Save(object sender, ExecutedRoutedEventArgs e)
if (obj.GetType() == typeof(VM_AnimeGroup_User))
{
VM_AnimeGroup_User grp = (VM_AnimeGroup_User)obj;
grp.SortName = grp.SortName ?? grp.GroupName;
bool isnew = grp.AnimeGroupID==0;
if (grp.Validate())
{
Expand Down Expand Up @@ -2050,7 +2048,6 @@ public void CommandBinding_Cancel(object sender, ExecutedRoutedEventArgs e)

//grp.AnimeGroupParentID = groupBeforeChanges.AnimeGroupParentID;
grp.Description = groupBeforeChanges.Description;
grp.SortName = groupBeforeChanges.SortName;

VM_MainListHelper.Instance.ViewGroups.Refresh();
EnableDisableGroupControls(true);
Expand Down
9 changes: 0 additions & 9 deletions Shoko.Desktop/UserControls/AnimeGroupControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,6 @@
</Button>
</StackPanel>

<!-- Sort Name -->
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,0,0,5">
<TextBlock FontWeight="Bold" Margin="0,0,5,0" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=SortName}"/>
<TextBlock Text="{Binding Path=SortName}" Name="tbGroupSortName"
Visibility="{Binding Path=IsReadOnly, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBox MinWidth="200" Text="{Binding Path=SortName}" Name="txtGroupSortName"
Visibility="{Binding Path=IsBeingEdited, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</StackPanel>

<!-- Rating -->
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,0,0,5">
<usercontrols:VisualRating Rating="{Binding Path=AniDBRating}" VerticalAlignment="Center">
Expand Down
1 change: 0 additions & 1 deletion Shoko.Desktop/UserControls/AnimeSeries.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@ void btnEditSeriesFinish_Click(object sender, RoutedEventArgs e)
if (thisGrp != null)
{
thisGrp.GroupName = ser.GroupName;
thisGrp.SortName = ser.SeriesName;
thisGrp.Save();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Shoko.Desktop/UserControls/UserAdminControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
</Grid.RowDefinitions>

<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" FontWeight="Bold" Margin="0,10,15,0" Text="{Resx Key=User_Username, ResxName=Shoko.Commons.Properties.Resources}"/>
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" MinWidth="200" Margin="0,10,0,0" Text="{Binding Path=SortName}" x:Name="txtUsername"/>
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" MinWidth="200" Margin="0,10,0,0" x:Name="txtUsername"/>
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" FontWeight="Bold" Margin="0,5,15,0" Text="{Resx Key=User_IsAdmin, ResxName=Shoko.Commons.Properties.Resources}"/>
<CheckBox Grid.Row="1" Grid.Column="1" x:Name="chkIsAdmin" VerticalAlignment="Center" />

Expand All @@ -129,7 +129,7 @@
<CheckBox Grid.Row="4" Grid.Column="1" x:Name="chkEditSettings" VerticalAlignment="Center" />

<TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" FontWeight="Bold" Margin="0,6,15,1" Text="{Resx Key=User_Hide_Tags, ResxName=Shoko.Commons.Properties.Resources}"/>
<TextBox Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="300" Margin="0,5,0,0" Text="{Binding Path=SortName}" x:Name="txtTags"/>
<TextBox Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="300" Margin="0,5,0,0" x:Name="txtTags"/>


<ListBox x:Name="lbTags" Grid.Row="6" Grid.Column="1" BorderThickness="1" BorderBrush="LightGray" Background="White" Margin="0,0,5,5" Height="130"
Expand Down
25 changes: 5 additions & 20 deletions Shoko.Desktop/ViewModel/Server/VM_AnimeGroup_User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Windows;
using System.Xml.Serialization;
using Newtonsoft.Json;
using Shoko.Commons.Extensions;
using Shoko.Commons.Notification;
using Shoko.Desktop.Utilities;
using Shoko.Models.Enums;
Expand Down Expand Up @@ -191,11 +192,7 @@ public bool IsBeingEdited
}


public new string SortName
{
get { return base.SortName; }
set { this.SetField(()=>base.SortName,(r)=> base.SortName = r, value); }
}
public new string SortName => GroupName.ToSortName();

public new string Description
{
Expand Down Expand Up @@ -698,7 +695,6 @@ public void Populate(CL_AnimeGroup_User contract)
// editable members
GroupName = contract.GroupName;
IsFave = contract.IsFave;
SortName = contract.SortName;
DefaultAnimeSeriesID = contract.DefaultAnimeSeriesID;
Description = contract.Description;

Expand All @@ -715,7 +711,6 @@ public CL_AnimeGroup_Save_Request ToRequest()
IsManuallyNamed = IsManuallyNamed,
GroupName = GroupName,
IsFave = IsFave,
SortName = SortName,
Description = Description
};
}
Expand Down Expand Up @@ -893,19 +888,9 @@ private static void GetAnimeSeriesRecursive(VM_AnimeGroup_User grp, ref List<VM_
*/
public bool Validate()
{
if (string.IsNullOrEmpty(GroupName))
{
MessageBox.Show(Shoko.Commons.Properties.Resources.Anime_GroupName);
return false;
}

if (string.IsNullOrEmpty(SortName))
{
MessageBox.Show(Shoko.Commons.Properties.Resources.Anime_SortName);
return false;
}

return true;
if (!string.IsNullOrEmpty(GroupName)) return true;
MessageBox.Show(Shoko.Commons.Properties.Resources.Anime_GroupName);
return false;
}


Expand Down
2 changes: 1 addition & 1 deletion Shoko.Desktop/ViewModel/Server/VM_AnimeSeries_User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void NotifyPropertyChanged(string propname)
public DateTime? Stat_AirDate_Max => AniDBAnime?.AniDBAnime?.AirDate;

[JsonIgnore, XmlIgnore]
public string SortName => SeriesName;
public string SortName => SeriesName.ToSortName();

[JsonIgnore, XmlIgnore]
public string DateTimeCreatedAsString => DateTimeCreated.ToString("dd MMM yyyy - HH:mm", Commons.Culture.Global);
Expand Down
2 changes: 1 addition & 1 deletion Shoko.Desktop/ViewModel/Server/VM_GroupFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public string SortName
return split[1] + part2;
}
}
return GroupFilterName;
return GroupFilterName.ToSortName();
}
}

Expand Down

0 comments on commit 9ac1aca

Please sign in to comment.