Exemplo n.º 1
0
 public void AssignBacklogItemGroup(BacklogItemViewModel item)
 {
     if (GroupList == null || GroupList.Groups == null || item==null || item.Item == null)
         return;
     item.Group = GroupList.Groups.Where(g => g.GroupUId == item.Item.GroupUId).SingleOrDefault();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Removes the backlog item form the Model, from the View Model collection and from the
        /// services.
        /// </summary>
        /// <param name="itemViewModel">The item view model to be removed.</param>
        private void RemoveBacklogItem(BacklogItemViewModel itemViewModel)
        {
            string shortName = itemViewModel.Item.Name;
            if (shortName == null)
                shortName = String.Empty;
            if (shortName.Length > 15)
                shortName = shortName.Substring(0, 15) + "...";
            string confirmMessage = String.Format(Properties.Resources.Are_you_sure_remove_item, shortName);

            System.Windows.MessageBoxResult ok = dialogs.ShowMessageBox(Properties.Resources.Remove_backlog_item, confirmMessage, System.Windows.MessageBoxButton.YesNo);
            if (ok == System.Windows.MessageBoxResult.No)
                return;

            string backlogitemUId = itemViewModel.Item.BacklogItemUId;

            executor.StartBackgroundTask(
                    () => {
                        backlogService.DeleteBacklogItem(itemViewModel.Item.BacklogItemUId);
                    },
                    () => {
                        ((IEditableCollectionView)backlogViewSource.View).Remove(itemViewModel);
                        itemViewModel.Dispose();
                        OnPropertyChanged("ItemsLeftTotalHours");
                        OnPropertyChanged("ItemsLeftTotalSize");
                        OnPropertyChanged("RequiredVelocity");
                        ((DelegateCommand)PlanAllLateItemsCommand).NotifyCanExecuteChanged();
                        aggregator.Publish<string>(ScrumFactoryEvent.BacklogItemDeleted, backlogitemUId);
                    });
        }
Exemplo n.º 3
0
 /// <summary>
 /// Shows the detail window.
 /// </summary>
 private void ShowDetailWindow(BacklogItemViewModel itemVM)
 {
     if (itemVM.Item == null)
         return;
     FilteredBacklog.MoveCurrentTo(itemVM);
     ShowDetailWindow(itemVM.Item);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates the new backlog item and saves it.
        /// </summary>
        private void CreateNewBacklogItem(BacklogItem newItem)
        {
            // save its
            executor.StartBackgroundTask(
                () => { backlogService.AddBacklogItem(newItem); },
                () => {
                    NewItemName = String.Empty;
                    BacklogItemViewModel vm = new BacklogItemViewModel();
                    vm.Init(backlogService, executor, aggregator, authorizator, Project, newItem);

                    // TO THIS STRANGE CHECK 'CUZ WHEN LIST IS EMPTY COMMITNEW THROWS STRANGE EXCEPTION
                    if (FilteredBacklog.IsEmpty || Items.Count == 0) {
                        Items.Add(vm);
                        backlogViewSource.View.Refresh();
                    }
                    else {
                        ((System.Windows.Data.ListCollectionView)backlogViewSource.View).AddNewItem(vm);
                        ((System.Windows.Data.ListCollectionView)backlogViewSource.View).CommitNew();
                    }
                    vm.NotifyAdded();
                    aggregator.Publish<BacklogItem[]>(ScrumFactoryEvent.BacklogItemsChanged, new BacklogItem[] { newItem });
                });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called when backlog items loaded.
        /// Creates the Items View Model collection and raises publishes the BacklogItemsLoaded event.
        /// </summary>
        /// <param name="items">The items.</param>
        private void OnBacklogItemsLoaded(ICollection<BacklogItem> items)
        {
            if (items == null)
                return;

            List<BacklogItemViewModel> temp = new List<ViewModel.BacklogItemViewModel>();
            foreach (BacklogItem i in items) {
                var itemVm = new BacklogItemViewModel(backlogService, executor, aggregator, authorizator, Project, i, SFConfig);

                itemVm.IgnoreChangeCommands = true; // avoid to trigger ChangeGroup command

                // this should be done at the server - just quick fix
                // NEW SERVER VERSION DOESNT NEED THIS
                if (i != null && i.ItemSizeUId != null && i.Size == null) {
                    var size = ActiveSizes.SingleOrDefault(z => z.ItemSize.ItemSizeUId == i.ItemSizeUId);
                    if (size != null)
                        i.Size = size.ItemSize.Size * i.SizeFactor;
                }
                //------------------------------------------------

                temp.Add(itemVm);
            }

            Items = temp;
            foreach (BacklogItemViewModel item in Items)
                item.IgnoreChangeCommands = false; // now you can change group

            LoadEffectiveHours();

            // load data is over
            IsLoadingData = false;
        }
Exemplo n.º 6
0
        private void AddJob()
        {
            if (String.IsNullOrEmpty(NewTicketName))
                return;

            if (NewTicketProject == null)
                return;

            // create the new item
            BacklogItem newItem = new BacklogItem {
                BacklogItemUId = Guid.NewGuid().ToString(),
                ProjectUId = NewTicketProject.ProjectUId,
                Name = NewTicketName,
                Description = null,
                Status = (short)BacklogItemStatus.ITEM_REQUIRED,
                BusinessPriority = 0,
                OccurrenceConstraint = 1,
                SizeFactor = 1,
                CreateDate = DateTime.Now
            };

            // save its
            executor.StartBackgroundTask(
                () => {

                    // needs to get the project here to get its roles
                    Project project = projectsService.GetProject(newItem.ProjectUId);

                    newItem.Project = project;
                    newItem.SyncPlannedHoursAndRoles(1);

                    ICollection<BacklogItemGroup> groups = backlogService.GetBacklogItemGroups(project.ProjectUId);
                    BacklogItemGroup group = groups.FirstOrDefault(g => g.DefaultGroup == (short)DefaultItemGroups.DEV_GROUP);
                    if (group != null)
                        newItem.GroupUId = group.GroupUId;

                    backlogService.AddBacklogItem(newItem);
                },
                () => {
                    BacklogItemViewModel vm = new BacklogItemViewModel();
                    vm.Init(backlogService, executor, aggregator, authorizator, newTicketProject, newItem);

                    ICollection<BacklogItemViewModel> tickets = ticketsSource.Source as ICollection<BacklogItemViewModel>;
                    tickets.Add(vm);

                    ((IEditableCollectionView)ticketsSource.View).EditItem(vm);
                    ((IEditableCollectionView)ticketsSource.View).CommitEdit();

                    vm.NotifyAdded();

                    NewTicketProject = null;
                    NewTicketName = String.Empty;

                });
        }
 private double _CalcMinZoomFactor(BacklogItemViewModel[] itemsWithHours)
 {
     if (itemsWithHours == null || itemsWithHours.Length == 0)
         return 3;
     decimal? minHours = itemsWithHours.Min(i => i.Item.CurrentTotalHours);
     if (!minHours.HasValue)
         return 3;
     return (double)(14 / minHours.Value);
 }
 private void ShowDetail(BacklogItemViewModel itemVM)
 {
     aggregator.Publish<BacklogItem>(ScrumFactoryEvent.ShowItemDetail, itemVM.Item);
 }
        private void LoadData()
        {
            IsLoadingData = true;
            NeedRefresh = false;

            if (Backlog != null && Backlog.GroupList != null)
                Backlog.GroupList.LoadGroupsIfNotLoadedAsync();

            executor.StartBackgroundTask<ICollection<BacklogItem>>(
                () => {
                    if (Project == null)
                        return null;

                    return this.backlogService.GetCurrentBacklog(Project.ProjectUId, (short)Services.BacklogFiltersMode.PENDING);
                },
                items => {
                    List<BacklogItemViewModel> temp = new List<ViewModel.BacklogItemViewModel>();
                    foreach (BacklogItem i in items) {
                        var itemVm = new BacklogItemViewModel(backlogService, executor, aggregator, authorizator, Project, i, SFConfig);
                        temp.Add(itemVm);
                    }

                    Items = temp;
                    if (calcZoom) {
                        MaxZoomFactor = CalcMaxZoomFactor();
                        ZoomFactor = CalcFitZoomFactor();
                        calcZoom = false;
                    }

                    AssignGroups();

                    // load data is over
                    IsLoadingData = false;
                });
        }
        private void AfterAddSprint(Sprint newSprint, ICollection<BacklogItem> defaultItems)
        {
            Backlog.GroupList.LoadGroupsIfNotLoaded();

            Project.Sprints.Add(newSprint);

            ViewModel.SprintViewModel sprintVM = new ViewModel.SprintViewModel(
                projectsService,
                executor,
                aggregator,
                newSprint,
                Items,
                SFConfig,
                calendar);

            if (defaultItems != null) {
                foreach (BacklogItem item in defaultItems) {
                    BacklogItemViewModel vm = new BacklogItemViewModel(backlogService, executor, aggregator, authorizator, Project, item, SFConfig);

                    Items.Add(vm);
                    vm.NotifyAdded();
                }
            }

            SprintPlans.Add(sprintVM);
            sprintVM.RefreshUI();
            sprintVM.NotifyAdded();

            aggregator.Publish<Sprint>(ScrumFactoryEvent.SprintAdded, newSprint);

            IsLoadingData = false;
        }