// ---------[ UI FUNCTIONALITY ]--------- /// <summary>Sets the value of the input field based on the value in the RequestFilter.</summary> public virtual void UpdateInputField(RequestFilter requestFilter) { string filterValue = string.Empty; List <IRequestFieldFilter> fieldFilterList; if (requestFilter != null && requestFilter.fieldFilterMap.TryGetValue(ModIO.API.GetAllModsFilterFields.fullTextSearch, out fieldFilterList) && fieldFilterList != null && fieldFilterList.Count > 0) { IRequestFieldFilter fieldFilter = fieldFilterList[0]; switch (fieldFilter.filterMethod) { case FieldFilterMethod.Equal: { filterValue = ((EqualToFilter <string>)fieldFilter).filterValue; } break; case FieldFilterMethod.LikeString: { filterValue = ((StringLikeFilter)fieldFilter).likeValue; } break; } } this.UpdateInputField(filterValue); }
// ---------[ UI FUNCTIONALITY ]--------- /// <summary>Displays the tags for a given RequestFilter.</summary> public void DisplayInArrayFilterTags(RequestFilter filter) { List <IRequestFieldFilter> tagsFilterList = null; if (filter != null) { filter.fieldFilterMap.TryGetValue(ModIO.API.GetAllModsFilterFields.tags, out tagsFilterList); } string[] tags = null; if (tagsFilterList != null) { MatchesArrayFilter <string> tagsFilter = null; for (int i = 0; i < tagsFilterList.Count && tagsFilter == null; ++i) { IRequestFieldFilter f = tagsFilterList[i]; if (f.filterMethod == FieldFilterMethod.EquivalentCollection) { tagsFilter = f as MatchesArrayFilter <string>; } } if (tagsFilter != null) { tags = tagsFilter.filterValue; } } this.container.DisplayTags(tags); }
public void AddFieldFilter(string fieldName, IRequestFieldFilter filter) { List <IRequestFieldFilter> list = null; this.fieldFilterMap.TryGetValue(fieldName, out list); if (list == null) { list = new List <IRequestFieldFilter>(); this.fieldFilterMap[fieldName] = list; } list.Add(filter); }
public void AddFieldFilter(string fieldName, IRequestFieldFilter filter) { Debug.Assert(this.fieldFilterMap != null); // early out if (string.IsNullOrEmpty(fieldName) || filter == null || filter.filterValue == null) { Debug.LogWarning("[mod.io] Attempted to add an invalid field filter to the request filter." + "\nfieldName=\"" + (fieldName == null ? "NULL" : fieldName) + "\"" + "\nfilter=" + (filter == null ? "NULL" : filter.GetType().ToString()) + (filter == null ? string.Empty : "\nfilterValue=" + (filter.filterValue == null ? "NULL" : filter.filterValue.ToString())) ); return; } List <IRequestFieldFilter> list = null; this.fieldFilterMap.TryGetValue(fieldName, out list); if (list == null) { list = new List <IRequestFieldFilter>(); this.fieldFilterMap[fieldName] = list; } // remove duplicate from list for (int i = 0; i < list.Count; ++i) { if (list[i] != null && list[i].filterMethod == filter.filterMethod) { list.RemoveAt(i); break; } } list.Add(filter); }
// ---------[ FUNCTIONALITY ]--------- /// <summary>Displays the date live selection based on the RequestFilter data.</summary> public void DisplayDateLiveOption(RequestFilter filter) { if (filter == null) { return; } // get filter value List <IRequestFieldFilter> dateLiveFilterList = null; if (filter != null) { filter.fieldFilterMap.TryGetValue(ModIO.API.GetAllModsFilterFields.dateLive, out dateLiveFilterList); } int dateLiveUntil = -1; if (dateLiveFilterList != null) { IRequestFieldFilter <int> dateLiveFilter = null; for (int i = 0; i < dateLiveFilterList.Count && dateLiveFilter == null; ++i) { IRequestFieldFilter f = dateLiveFilterList[i]; if (f.filterMethod == FieldFilterMethod.GreaterThan || f.filterMethod == FieldFilterMethod.Minimum) { dateLiveFilter = f as IRequestFieldFilter <int>; } } if (dateLiveFilter != null) { dateLiveUntil = dateLiveFilter.filterValue; } } // set value int optionIndex = this.dropdown.value; if (dateLiveUntil < 0) { for (int i = 0; i < this.options.Length; ++i) { if (this.options[i].filterPeriodSeconds < 0) { optionIndex = i; break; } } } else { int filterPeriod = dateLiveUntil - ServerTimeStamp.Now; int optionDifference = int.MaxValue; for (int i = 0; i < this.options.Length; ++i) { OptionData option = this.options[i]; if (option.filterPeriodSeconds < 0) { continue; } int minOptionPeriod = option.filterPeriodSeconds - option.filterRoundingSeconds; int filterDifference = filterPeriod - minOptionPeriod; if (filterDifference >= 0 && filterDifference < optionDifference) { optionIndex = i; optionDifference = filterDifference; } } } this.dropdown.value = optionIndex; }