public bool ShouldDisplay(TicketViewModel value)
        {
            ResetValues(value);

            if (SelectedItem == null || SelectedItem.Model.Locked)
            {
                return(false);
            }

            if (SelectedTicket != null && !SelectedItem.Model.Voided && !SelectedItem.Model.Locked)
            {
                var id = SelectedItem.Model.MenuItemId;

                var mi = AppServices.DataAccessService.GetMenuItem(id);
                if (SelectedItem.Model.PortionCount > 1)
                {
                    SelectedItemPortions.AddRange(mi.Portions);
                }
                SelectedItemPropertyGroups.AddRange(mi.PropertyGroups.Where(x => string.IsNullOrEmpty(x.GroupTag)));

                SelectedItemGroupedPropertyItems.AddRange(mi.PropertyGroups.Where(x => !string.IsNullOrEmpty(x.GroupTag) && x.Properties.Count > 1)
                                                          .GroupBy(x => x.GroupTag)
                                                          .Select(x => new MenuItemGroupedPropertyViewModel(SelectedItem, x)));
                RaisePropertyChanged("IsPortionsVisible");
            }
            return(SelectedItemPortions.Count > 1 || SelectedItemPropertyGroups.Count > 0 || SelectedItemGroupedPropertyItems.Count > 0);
        }
        private void OnPropertySelected(MenuItemProperty obj)
        {
            var mig = SelectedItemPropertyGroups.FirstOrDefault(propertyGroup => propertyGroup.Properties.Contains(obj));

            Debug.Assert(mig != null);
            if (_removeModifier)
            {
                if (mig.ForceValue && SelectedItem.Properties.Count(x => x.Model.PropertyGroupId == mig.Id) < 2)
                {
                    InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.SelectionRequired_f, mig.Name));
                }
                else
                {
                    SelectedItem.RemoveProperty(mig, obj);
                }
            }
            else
            {
                SelectedItem.ToggleProperty(mig, obj);
            }
            SelectedTicket.RefreshVisuals();
            SelectedTicket.RecalculateTicket();
            if (_removeModifier)
            {
                OnRemoveModifier("");
            }
            RaisePropertyChanged("IsRemoveModifierButtonVisible");
        }
Exemplo n.º 3
0
 public void CloseView()
 {
     SelectedItem = null;
     SelectedItemPortions.Clear();
     SelectedItemPropertyGroups.Clear();
     SelectedItemGroupedPropertyItems.Clear();
     TicketTags.Clear();
     SelectedTicketTag = null;
 }
Exemplo n.º 4
0
        private void OnPropertySelected(MenuItemPropertyViewModel obj)
        {
            var mig = SelectedItemPropertyGroups.FirstOrDefault(propertyGroup => propertyGroup.Properties.Contains(obj));

            Debug.Assert(mig != null);
            SelectedItem.ToggleProperty(mig.Model, obj.Model);

            foreach (var model in SelectedItemPropertyGroups)
            {
                model.Refresh(SelectedItem.Properties);
            }
        }
 private void ResetValues(TicketViewModel selectedTicket)
 {
     SelectedTicket = null;
     SelectedItem   = null;
     SelectedItemPortions.Clear();
     SelectedItemPropertyGroups.Clear();
     SelectedItemGroupedPropertyItems.Clear();
     Reasons.Clear();
     TicketTags.Clear();
     _showExtraPropertyEditor = false;
     _showTicketNoteEditor    = false;
     _showFreeTagEditor       = false;
     _removeModifier          = false;
     SetSelectedTicket(selectedTicket);
 }
        private void OnCloseCommandExecuted(string obj)
        {
            var unselectedItem = SelectedItemPropertyGroups.FirstOrDefault(x => x.ForceValue && SelectedItem.Properties.Count(y => y.Model.PropertyGroupId == x.Id) == 0);

            if (unselectedItem != null)
            {
                InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.SelectionRequired_f, unselectedItem.Name));
                return;
            }

            _showTicketNoteEditor    = false;
            _showExtraPropertyEditor = false;
            _showFreeTagEditor       = false;
            _removeModifier          = false;
            FreeTag = string.Empty;
            SelectedTicket.ClearSelectedItems();
        }
Exemplo n.º 7
0
        public void Refresh(TicketItemViewModel ticketItem, TicketTagGroup selectedTicketTag)
        {
            HideKeyboard();
            SelectedTicketTag = null;
            SelectedItemPortions.Clear();
            SelectedItemPropertyGroups.Clear();
            SelectedItemGroupedPropertyItems.Clear();
            TicketTags.Clear();

            SelectedItem = ticketItem;

            if (ticketItem != null)
            {
                var mi = AppServices.DataAccessService.GetMenuItem(ticketItem.Model.MenuItemId);
                if (mi.Portions.Count > 1)
                {
                    SelectedItemPortions.AddRange(mi.Portions.Select(x => new MenuItemPortionViewModel(x)));
                }

                SelectedItemGroupedPropertyItems.AddRange(mi.PropertyGroups.Where(x => !string.IsNullOrEmpty(x.GroupTag))
                                                          .GroupBy(x => x.GroupTag)
                                                          .Select(x => new MenuItemGroupedPropertyViewModel(SelectedItem, x)));

                SelectedItemPropertyGroups.AddRange(mi.PropertyGroups
                                                    .Where(x => string.IsNullOrEmpty(x.GroupTag))
                                                    .Select(x => new MenuItemPropertyGroupViewModel(x)));

                foreach (var ticketItemPropertyViewModel in ticketItem.Properties.ToList())
                {
                    var tip = ticketItemPropertyViewModel;
                    var mig = SelectedItemPropertyGroups.Where(x => x.Model.Id == tip.Model.PropertyGroupId).SingleOrDefault();
                    if (mig != null)
                    {
                        mig.Properties.SingleOrDefault(x => x.Name == tip.Model.Name).TicketItemProperty = ticketItemPropertyViewModel.Model;
                    }

                    var sig = SelectedItemGroupedPropertyItems.SelectMany(x => x.Properties).Where(
                        x => x.MenuItemPropertyGroup.Id == tip.Model.PropertyGroupId).FirstOrDefault();
                    if (sig != null)
                    {
                        sig.TicketItemProperty = ticketItemPropertyViewModel.Model;
                    }
                }
            }
            else
            {
                if (selectedTicketTag != null)
                {
                    SelectedTicketTag = selectedTicketTag;

                    if (selectedTicketTag.FreeTagging)
                    {
                        TicketTags.AddRange(Dao.Query <TicketTagGroup>(x => x.Id == selectedTicketTag.Id, x => x.TicketTags).SelectMany(x => x.TicketTags).OrderBy(x => x.Name).Select(x => new TicketTagViewModel(x)));
                    }
                    else
                    {
                        TicketTags.AddRange(selectedTicketTag.TicketTags.Select(x => new TicketTagViewModel(x)));
                    }
                    RaisePropertyChanged("TicketTags");
                }
                else
                {
                    RaisePropertyChanged("TicketNote");
                    ShowKeyboard();
                }
            }

            RaisePropertyChanged("SelectedItem");
            RaisePropertyChanged("IsPortionsVisible");
            RaisePropertyChanged("IsEditorsVisible");
            RaisePropertyChanged("IsTicketNoteVisible");
            RaisePropertyChanged("IsTagEditorVisible");
            RaisePropertyChanged("IsFreeTagEditorVisible");
            RaisePropertyChanged("TagColumnCount");
        }