コード例 #1
0
        public override void Prepare(string parameter)
        {
            Name.Accept(parameter);

            navigationFromStartTimeEntryViewModelStopwatch = stopwatchProvider.Get(MeasuredOperation.OpenCreateProjectViewFromStartTimeEntryView);
            stopwatchProvider.Remove(MeasuredOperation.OpenCreateProjectViewFromStartTimeEntryView);
        }
コード例 #2
0
        public override async Task Initialize()
        {
            await base.Initialize();

            navigationFromMainViewModelStopwatch = stopwatchProvider.Get(MeasuredOperation.OpenSettingsView);
            stopwatchProvider.Remove(MeasuredOperation.OpenStartView);
        }
コード例 #3
0
        public override async Task Initialize()
        {
            await base.Initialize();

            navigationFromEditTimeEntryViewModelStopwatch = stopwatchProvider.Get(MeasuredOperation.OpenSelectProjectFromEditView);
            stopwatchProvider.Remove(MeasuredOperation.OpenSelectProjectFromEditView);

            var workspaces = await interactorFactory.GetAllWorkspaces().Execute();

            shouldShowProjectCreationSuggestion = workspaces.Any(ws => ws.IsEligibleForProjectCreation());
            allWorkspaces = workspaces.ToList();
            UseGrouping   = allWorkspaces.Count > 1;

            dataSource.Projects
            .GetAll()
            .Select(projects => projects.Any())
            .Subscribe(hasProjects => IsEmpty = !hasProjects);

            infoSubject.AsObservable()
            .StartWith(Text)
            .Select(text => text.SplitToQueryWords())
            .ObserveOn(schedulerProvider.BackgroundScheduler)
            .SelectMany(query => interactorFactory.GetProjectsAutocompleteSuggestions(query).Execute())
            .SubscribeOn(schedulerProvider.MainScheduler)
            .Select(suggestions => suggestions.Cast <ProjectSuggestion>())
            .Select(setSelectedProject)
            .Subscribe(onSuggestions);
        }
コード例 #4
0
        public override async Task Initialize()
        {
            await base.Initialize();

            navigationFromEditTimeEntryViewModelStopwatch = stopwatchProvider.Get(MeasuredOperation.OpenSelectProjectFromEditView);
            stopwatchProvider.Remove(MeasuredOperation.OpenSelectProjectFromEditView);

            var workspaces = await interactorFactory.GetAllWorkspaces().Execute();

            projectCreationSuggestionsAreEnabled = workspaces.Any(ws => ws.IsEligibleForProjectCreation());
            UseGrouping = workspaces.Count() > 1;

            FilterText.Subscribe(async text =>
            {
                var suggestions = interactorFactory.GetProjectsAutocompleteSuggestions(text.SplitToQueryWords()).Execute().SelectMany(x => x).ToEnumerable()
                                  .Cast <ProjectSuggestion>()
                                  .Select(setSelectedProject);

                var collectionSections = suggestions
                                         .GroupBy(project => project.WorkspaceId)
                                         .Select(grouping => grouping.OrderBy(projectSuggestion => projectSuggestion.ProjectName))
                                         .OrderBy(grouping => grouping.First().WorkspaceName)
                                         .Select(grouping => collectionSection(grouping, prependNoProject: string.IsNullOrEmpty(text)))
                                         .ToList();

                if (shouldSuggestCreation(text))
                {
                    var createEntitySuggestion = new CreateEntitySuggestion(Resources.CreateProject, text);
                    var section = new SectionModel <string, AutocompleteSuggestion>(null, new[] { createEntitySuggestion });
                    collectionSections.Insert(0, section);
                }

                if (collectionSections.None())
                {
                    var workspace           = await interactorFactory.GetWorkspaceById(workspaceId).Execute();
                    var noProjectSuggestion = ProjectSuggestion.NoProject(workspace.Id, workspace.Name);
                    collectionSections.Add(
                        new SectionModel <string, AutocompleteSuggestion>(null, new[] { noProjectSuggestion })
                        );
                }

                suggestionsSubject.OnNext(collectionSections);
            });
        }
コード例 #5
0
        public override async Task Initialize()
        {
            navigationFromStartTimeEntryViewModelStopwatch = stopwatchProvider.Get(MeasuredOperation.OpenCreateProjectViewFromStartTimeEntryView);
            stopwatchProvider.Remove(MeasuredOperation.OpenCreateProjectViewFromStartTimeEntryView);

            var defaultWorkspace = await interactorFactory.GetDefaultWorkspace()
                                   .TrackException <InvalidOperationException, IThreadSafeWorkspace>("EditProjectViewModel.Initialize")
                                   .Execute();

            var allWorkspaces = await interactorFactory.GetAllWorkspaces().Execute();

            var workspace = defaultWorkspace.IsEligibleForProjectCreation()
                ? defaultWorkspace
                : allWorkspaces.First(ws => ws.IsEligibleForProjectCreation());

            areCustomColorsEnabled = await interactorFactory.AreCustomColorsEnabledForWorkspace(workspace.Id).Execute();

            workspaceId   = initialWorkspaceId = workspace.Id;
            WorkspaceName = workspace.Name;

            await setupNameAlreadyTakenError();
        }