Basic search outline config UI implemented.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,7 +21,6 @@ namespace Props.Models
|
||||
[Required]
|
||||
public IList<Category> Order { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ProfileName { get; set; }
|
||||
|
||||
public ResultsPreferences()
|
||||
|
@@ -16,22 +16,19 @@ namespace Props.Models.User
|
||||
public virtual ApplicationUser ApplicationUser { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual ISet<SearchOutline> SearchOutlines { get; set; }
|
||||
public virtual IList<SearchOutline> SearchOutlines { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual SearchOutline ActiveSearchOutline { get; set; }
|
||||
public string NameOfLastUsed { get; set; }
|
||||
|
||||
public SearchOutlinePreferences()
|
||||
{
|
||||
SearchOutlines = new HashSet<SearchOutline>();
|
||||
ActiveSearchOutline = new SearchOutline();
|
||||
SearchOutlines.Add(ActiveSearchOutline);
|
||||
SearchOutlines = new List<SearchOutline>();
|
||||
}
|
||||
|
||||
public SearchOutlinePreferences(ISet<SearchOutline> searchOutlines, SearchOutline activeSearchOutline)
|
||||
public SearchOutlinePreferences(List<SearchOutline> searchOutlines, string nameOfLastUsed)
|
||||
{
|
||||
this.SearchOutlines = searchOutlines;
|
||||
this.ActiveSearchOutline = activeSearchOutline;
|
||||
this.NameOfLastUsed = nameOfLastUsed;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user