public FiltersListView(IJiraToolWindowNavigatorViewModel parent, IIssueService issueService) { InitializeComponent(); this._viewModel = new FilterListViewModel(parent, issueService); this.DataContext = this._viewModel; }
public void NoFilters_State_Changed_If_ProjectList_Is_Empty() { this._mockFilterList.Object.Clear(); this._viewModel = new FilterListViewModel(_mockJiraToolWindowNavigatorViewModel.Object, this._mockIssueService.Object); Assert.AreEqual(this._viewModel.FilterList.Count, 0); Assert.IsTrue(this._viewModel.NoFilters); }
public MainPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator, SettingsHelper settingsHelper, SettingsViewModel settingsViewModel, SettingsPaneViewModel settingsPaneViewModel, FilterListViewModel filterListViewModel, ListFilterViewModel listFilterViewModel, TorrentWindowViewModel torrentWindowViewModel, ErrorTracker errorTracker) { _errorTracker = errorTracker; _uriQueue = new List<string>(); _torrentsQueue = new List<TorrentFileData>(); _settingsHelper = settingsHelper; _eventAggregator = eventAggregator; _navigationService = navigationService; FilterList = filterListViewModel; ListFilter = listFilterViewModel; SettingsPane = settingsPaneViewModel; Settings = settingsViewModel; TorrentWindow = torrentWindowViewModel; backingTorrents = new ObservableCollection<TorrentViewModel>(); Torrents = new ListCollectionView(backingTorrents); SelectedItems = new ObservableCollection<TorrentViewModel>(); ChangeOrder(settingsHelper.GetSetting<bool>(SettingType.OrderByQueue)); Torrents.Filter = ListFilter.GetFilter(Filter.All); ClearCommand = new DelegateCommand(() => ClearSelection()); SelectAllCommand = new DelegateCommand(() => SelectAll()); ForceStartCommand = new DelegateCommand(() => ChangeTorrentState(StateType.ForceStart)); PauseCommand = new DelegateCommand(() => ChangeTorrentState(StateType.Stop)); StartCommand = new DelegateCommand(() => ChangeTorrentState(StateType.Start)); VerifyCommand = new DelegateCommand(() => ChangeTorrentState(StateType.Verify)); ShowAddTorrentCommand = new DelegateCommand(() => TorrentWindow.Open(Purpose.Add, Server.DefaultDownloadLocation)); ShowMoveTorrentsCommand = new DelegateCommand(() => TorrentWindow.Open(Purpose.Move, Server.DefaultDownloadLocation, SelectedItems)); ShowConfirmDeleteCommand = new DelegateCommand(() => TorrentWindow.Open(Purpose.Delete, Server.DefaultDownloadLocation, SelectedItems)); _eventAggregator.GetEvent<AddTorrent>().Subscribe(AddTorrents); _eventAggregator.GetEvent<DeleteTorrents>().Subscribe(Delete); _eventAggregator.GetEvent<MoveTorrents>().Subscribe(MoveTorrents); _eventAggregator.GetEvent<SearchChanged>().Subscribe(query => Torrents.Refresh()); _eventAggregator.GetEvent<SearchCleared>().Subscribe(_ => Torrents.Refresh()); _eventAggregator.GetEvent<PriorityChanged>().Subscribe(PriorityChanged); _eventAggregator.GetEvent<WantedChanged>().Subscribe(WantedChanged); _eventAggregator.GetEvent<FilterChanged>().Subscribe(FilterChanged); _eventAggregator.GetEvent<OrderByQueueSettingChanged>().Subscribe(orderByQueue => ChangeOrder(orderByQueue)); _eventAggregator.GetEvent<FileActivated>().Subscribe(FileActivated); _eventAggregator.GetEvent<URIActivated>().Subscribe(URIActivated); _eventAggregator.GetEvent<ServerLoaded>().Subscribe(ProcessQueues); SelectedItems.CollectionChanged += (s, e) => { SelectionChange(); }; }
public void Initialize() { this._mockJiraToolWindowNavigatorViewModel = new Mock <IJiraToolWindowNavigatorViewModel>(); this._mockFilterList = new Mock <FilterList>(); this._mockFilter = new Mock <Filter>(); this._mockIssueService = new Mock <IIssueService>(); this._mockIssueService.Setup(mock => mock.GetAllFiltersAsync()).Returns(Task.FromResult(this._mockFilterList.Object)); Add_Filters(); this._viewModel = new FilterListViewModel(_mockJiraToolWindowNavigatorViewModel.Object, this._mockIssueService.Object); }
private static AlignmentFilter PromptDbInfo() { IUIVisualizer uiVisualizer = ViewModel.ServiceProvider.Resolve <IUIVisualizer>(); Debug.Assert(uiVisualizer != null); var savedConnections = AlignmentFilter.Load(SAVED_CONNECTION_FILE); using (var cvm = new FilterListViewModel(savedConnections)) { try { if (savedConnections.Count > 0) { if (uiVisualizer.ShowDialog(RCADDI_SELECT_EXISTING_CONNECTION_UI, cvm) == true) { return(cvm.SelectedFilter.Filter); } } else { var vm = new FilterViewModel(); if (uiVisualizer.ShowDialog(RCADRI_CREATE_CONNECTION_UI, vm) == true) { cvm.Filters.Add(vm); cvm.SelectedFilter = vm; return(vm.Filter); } } return(null); } finally { AlignmentFilter.Save(SAVED_CONNECTION_FILE, cvm.Filters .Where(vm => vm.ShouldSerialize) .Select(vm => vm.Filter)); } } }
public void CancelingUdpDefaultFilterOnSearchFirstLoadLoadsTheSearchWithNoFilter() { const string NewFilterDefinition = @"{ ""FilterGuid"": ""3732f424-216c-4fab-a2dc-a50c405512c3"", ""TimeStamp"": ""09/20/2013 15:05:08"", ""Version"": ""100.1"", ""Body"": { ""ColumnName"": ""Notes_f"", ""Operator"": ""IsEqualTo"", ""Value"": ""%{\""Type\"":\""Udp\"",\""DisplayName\"":\""Value for Notes:\"",\""SystemName\"":\""Notes_f\"",\""DefaultValue\"":\""\""}%"", ""MemberType"": ""System.String"" } }"; var udpFilter = new FilterViewModel(FilterType.UserFilter) { Name = "UdpFilter", OriginalFilterDefinitions = NewFilterDefinition }; var vm = new FilterListViewModel { QuickFilterToolbarVM = new Lazy<QuickFilterToolbarViewModel>() }; vm.SelectedFilter = null; vm.SearchViewModel = GetNewSearchListVm(); Mock.Arrange(() => vm.SearchViewModel.AppliedFilter).Returns(() => null); Mock.Arrange(() => vm.SearchViewModel.ProcessSystemName).Returns("ProcessSystemName"); var filterPreprocessor = new FilterPreprocessor(); var udpValuesViewModel = new UdpValuesViewModel(); filterPreprocessor.UDPValuesViewModel = new Lazy<UdpValuesViewModel>(() => udpValuesViewModel); var popupBuilderMock = Mock.Create<PopupBuilder>(Behavior.CallOriginal); Mock.Arrange(() => popupBuilderMock.SetCustomViewModel(Arg.IsAny<INotificationViewModel>())).Returns(popupBuilderMock); Mock.Arrange(() => popupBuilderMock.SetIsModal(Arg.AnyBool)).Returns(popupBuilderMock); Mock.Arrange(() => popupBuilderMock.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoInstead<Action, Func<bool>>((ok, cancel) => cancel()); var popupFactoryMock = Mock.Create<PopupFactory>(Behavior.Loose); Mock.Arrange(() => popupFactoryMock.Popup()).Returns(popupBuilderMock); filterPreprocessor.ThePopupFactory = new Lazy<PopupFactory>(() => popupFactoryMock); vm.FilterPreprocessor = new Lazy<IFilterPreprocessor>(() => filterPreprocessor); var dynamicTypeManager = Mock.Create<IDynamicTypeManager>(Behavior.CallOriginal); Mock.Arrange(() => dynamicTypeManager.GetFilterInfoType(Arg.AnyString)).Returns(() => null); Mock.Arrange(() => vm.TheDynamicTypeManager).Returns(new Lazy<IDynamicTypeManager>(() => dynamicTypeManager)); Mock.Arrange(() => vm.SearchViewModel.RefreshSearchList(Arg.IsAny<MobileObservableCollection<IFilterDescriptor>>())).DoNothing(); Mock.Arrange(() => vm.SearchViewModel.IsItemsLoaded).Returns(false); vm.ApplyFilter(udpFilter); Assert.IsNull(vm.SelectedFilter); Assert.IsNull(vm.AppliedFilter); }
public void UdpQuickFilterSettingsReviewAndCancelingApplyingPreservePreviewslyApplyiedFilter() { const string PredifinedFilterDefinition = @"{ ""FilterGuid"": ""3732f424-216c-4fab-a2dc-a50c405512c3"", ""TimeStamp"": ""09/20/2013 15:05:08"", ""Version"": ""100.1"", ""Body"": { ""ColumnName"": ""Notes_f"", ""Operator"": ""IsEqualTo"", ""Value"": ""%{\""Type\"":\""Udp\"",\""DisplayName\"":\""Value for Notes:\"",\""SystemName\"":\""Notes_f\"",\""DefaultValue\"":\""\""}%"", ""MemberType"": ""System.String"" } }"; const string NewFilterDefinition = @"{ ""FilterGuid"": ""3732f424-216c-4fab-a2dc-a50c405512c3"", ""TimeStamp"": ""09/20/2013 15:05:08"", ""Version"": ""100.1"", ""Body"": { ""ColumnName"": ""Notes_f"", ""Operator"": ""IsEqualTo"", ""Value"": ""%{\""Type\"":\""Udp\"",\""DisplayName\"":\""Value for Notes:\"",\""SystemName\"":\""Notes_f\"",\""DefaultValue\"":\""\""}%"", ""MemberType"": ""System.String"" } }"; var predefinedFilter = new FilterViewModel(FilterType.UserFilter) { Name = "PreviouslySelectedFilter", OriginalFilterDefinitions = PredifinedFilterDefinition }; var newFilter = new FilterViewModel(FilterType.UserFilter) { Name = "NewFilter_______________", OriginalFilterDefinitions = NewFilterDefinition }; var vm = new FilterListViewModel { QuickFilterToolbarVM = new Lazy<QuickFilterToolbarViewModel>() }; vm.SelectedFilter = predefinedFilter; vm.SearchViewModel = GetNewSearchListVm(); vm.SearchViewModel.AppliedFilter = predefinedFilter; Mock.Arrange(() => vm.SearchViewModel.ProcessSystemName).Returns("ProcessSystemName"); Mock.Arrange(() => vm.SearchViewModel.IsItemsLoaded).Returns(true); Mock.Arrange(() => vm.SearchViewModel.SetIsBusy(false)).DoNothing(); var filterPreprocessor = new FilterPreprocessor(); var udpValuesViewModel = new UdpValuesViewModel(); filterPreprocessor.UDPValuesViewModel = new Lazy<UdpValuesViewModel>(() => udpValuesViewModel); var popupBuilderMock = Mock.Create<PopupBuilder>(Behavior.CallOriginal); Mock.Arrange(() => popupBuilderMock.SetCustomViewModel(Arg.IsAny<INotificationViewModel>())).Returns(popupBuilderMock); Mock.Arrange(() => popupBuilderMock.SetIsModal(Arg.AnyBool)).Returns(popupBuilderMock); Mock.Arrange(() => popupBuilderMock.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoInstead<Action, Func<bool>>((ok, cancel) => cancel()).InSequence(); var popupFactoryMock = Mock.Create<PopupFactory>(Behavior.Loose); Mock.Arrange(() => popupFactoryMock.Popup()).Returns(popupBuilderMock); filterPreprocessor.ThePopupFactory = new Lazy<PopupFactory>(() => popupFactoryMock); vm.FilterPreprocessor = new Lazy<IFilterPreprocessor>(() => filterPreprocessor); vm.ApplyFilter(newFilter); Assert.AreEqual(predefinedFilter.Name, vm.SelectedFilter.Name); /* Mock.Arrange(() => popupBuilderMock.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoInstead<Action, Func<bool>>((ok, cancel) => ok()).InSequence(); vm.ApplyFilter(newFilter); Assert.AreEqual(newFilter.Name, vm.SelectedFilter.Name); */ }
public void ApplyingSortingPreserveFilteringGottenFrom_MCR_ShowSearchReferenced() { var vm = GetNewSearchListVm(); Mock.Arrange(() => vm.ProcessSystemName).Returns("processName"); Mock.Arrange(() => vm.FilterString).Returns("filterString"); Mock.Arrange(() => vm.SortDescriptors).Returns(new SortList()); Mock.Arrange(() => vm.GroupColumn).Returns("groupColumn"); Mock.Arrange(() => vm.Columns).Returns(new ColumnCollection()); var quickFilterToolbarViewModel = new QuickFilterToolbarViewModel(); vm.QuickFilterToolbarVM = new Lazy<QuickFilterToolbarViewModel>(); Mock.Arrange(() => quickFilterToolbarViewModel.RefreshQuickFilters()).Returns(TaskHelper.GetEmptyTask); Mock.Arrange(() => vm.QuickFilterToolbarVM.Value).Returns(quickFilterToolbarViewModel); var filterListVM = new FilterListViewModel(); Mock.Arrange(() => vm.FilterListVM).Returns(filterListVM); var filterDescriptor = new FilterDescriptor(); Mock.Arrange(() => filterDescriptor.ToJSON()).Returns("expected"); var filterList = new MobileObservableCollection<IFilterDescriptor> { filterDescriptor }; Mock.NonPublic.Arrange(vm, "AddMandatoryFilter", ArgExpr.IsAny<MobileObservableCollection<IFilterDescriptor>>()).DoNothing(); Mock.Arrange(() => vm.TheFetchSearchListService.Refresh( Arg.AnyString, Arg.AnyInt, Arg.AnyInt, Arg.IsAny<SortList>(), Arg.AnyString, Arg.IsAny<ColumnCollection>(), Arg.IsAny<MobileObservableCollection<IFilterDescriptor>>(), Arg.AnyString, Arg.IsAny<Action<DataPortalResult<IInfoList>>>())).DoNothing(); vm.RefreshSearchList(filterList); Assert.AreEqual("expected", vm.AppliedFilter.TempFilterDefinitions); }
private string GetFilter() { string sitetype = Request["sitetype"]; string siteGUID = Request["SiteGuid"]; string searchWords = Request["SearchWords"]; int tileId = int.Parse(Request["tileId"]); //if (tileId == 0) //{ // TileManager tm = new TileManager(); // if (sitetype.ToLower() == "selfservice") // { // tileId = SystemDefinedTile.SelfService_AllBIModels.SystemDefinedTileId; // } // else // { // tileId = SystemDefinedTile.MyReports_AllReports.SystemDefinedTileId; // } //} string logonUser = Session["UserName"] == null ? "" : Session["UserName"].ToString(); bool isCurrentSiteAdmin = logonUser == "" ? false : service.GetUserAdminTeams(logonUser).Count() > 0; using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { IReportRepository report_repository = new ReportRepository(context); IUserRepository user_repository = new UserRepository(context); ITeamRepository team_repository = new TeamRepository(context); ICategoryRepository category_repository = new CategoryRepository(context); ITagRepository tag_repository = new TeamTagRepository(context); ITileRepository tile_repository = new TileRepository(context); ITileQueryLogicRepository tile_query_repository = new TileQueryLogicRepository(context); EditReportService sa = new EditReportService(report_repository, user_repository, team_repository, category_repository, tag_repository, tile_repository, tile_query_repository); FilterListViewModel filterList = new FilterListViewModel(); #region query filter data int DataCount = 0; ICollection <Statistics> ls = null; switch (sitetype.ToLower()) { case "teamsite": ls = sa.GetTeamSiteReportsStatistics(tileId, logonUser, siteGUID, isCurrentSiteAdmin); break; case "reportcatalog": break; //case "myreport": // ls = sa.GetMyReportsStatistics(tileId, logonUser, teamSiteGuidUnderControl); // break; //case "selfservice": // ls = sa.GetSelfServiceStatistics(tileId, logonUser, teamSiteGuidUnderControl); // break; //case "searchreport": // ls = sa.GetSearchReportsStatistics(logonUser, teamSiteGuidUnderControl, searchWords, out DataCount); // break; default: break; } #endregion filterList.DataCount = DataCount; #region Get Statistics business moel foreach (Statistics l in ls) { FilterEntityViewModel filterEty = new FilterEntityViewModel(); filterEty.FilterType = l.Name; foreach (AttributeValue attr in l.Values) { Application.MainBoundedContect.ViewModel.Filters.FilterItem item = new Application.MainBoundedContect.ViewModel.Filters.FilterItem(); item.Name = attr.Name; if (l.Name == "Owner") { item.Value = attr.GUID.ToString(); } else { item.Value = attr.Value.ToString(); } item.Count = attr.Count; item.ParentValue = attr.ParentValue; filterEty.FilterItemList.Add(item); } if (!filterEty.FilterType.Equals("Category")) { filterEty.FilterItemList.OrderByDescending(c => c.Count).ThenBy(n => n.Value); } filterList.FilterList.Add(filterEty); } JavaScriptSerializer jss = new JavaScriptSerializer(); #endregion return(jss.Serialize(filterList)); } }
public FilterListView(FilterListViewModel viewModel) { InitializeComponent(); ViewModelBinder.Bind(viewModel, this); }