Basic search outline config UI implemented.

This commit is contained in:
2021-08-17 02:59:01 -05:00
parent 8a1e5aca15
commit c6b8ca523b
25 changed files with 1047 additions and 520 deletions

View File

@@ -11,53 +11,45 @@ namespace Props.Models.Search
{
public int Id { get; set; }
[Required]
public string ApplicationUserId { get; set; }
public int SearchOutlinePreferencesId { get; set; }
[Required]
public virtual ApplicationUser ApplicationUser { get; set; }
public virtual SearchOutlinePreferences SearchOutlinePreferences { get; set; }
[Required]
public string Name { get; set; } = "Default";
public Filters Filters { get; set; } = new Filters();
public string Name { get; set; }
public Filters Filters { get; set; }
[Required]
public ShopsDisabled Enabled { get; set; } = new ShopsDisabled();
public ShopSelector DisabledShops { get; set; }
public sealed class ShopsDisabled : HashSet<string>
public sealed class ShopSelector : HashSet<string>
{
public int TotalShops { get; set; }
public bool this[string name]
{
get
{
return !this.Contains(name);
return this.Contains(name);
}
set
{
if (value == false && TotalShops - Count <= 1) return;
if (value)
{
this.Remove(name);
this.Add(name);
}
else
{
this.Add(name);
this.Remove(name);
}
}
}
public ShopsDisabled Copy()
public ShopSelector()
{
ShopsDisabled copy = new ShopsDisabled();
copy.Union(this);
return copy;
}
public bool IsShopToggleable(string shop)
public ShopSelector(IEnumerable<string> disabledShops) : base(disabledShops)
{
return (!Contains(shop) && TotalShops - Count > 1) || Contains(shop);
}
}
@@ -70,27 +62,27 @@ namespace Props.Models.Search
SearchOutline other = (SearchOutline)obj;
return
Id == other.Id &&
Name.Equals(other.Name) &&
Filters.Equals(other.Filters) &&
Enabled.Equals(other.Enabled);
DisabledShops.Equals(other.DisabledShops);
}
public override int GetHashCode()
{
return HashCode.Combine(Id, Name);
return HashCode.Combine(Id, Name, Filters, DisabledShops);
}
public SearchOutline()
{
this.Name = "Default";
this.Filters = new Filters();
this.Enabled = new ShopsDisabled();
this.DisabledShops = new ShopSelector();
}
public SearchOutline(string name, Filters filters, ShopsDisabled disabled)
public SearchOutline(string name, Filters filters, ShopSelector disabled)
{
this.Name = name;
this.Filters = filters;
this.Enabled = disabled;
this.DisabledShops = disabled;
}
}
}