/// <summary>
        /// Create the controller for reinflating the collapsed block; or return null if not possible
        /// </summary>
        /// <param name="collapseRequested">The handler that will be used for the re-expanded block</param>
        public BlockController Reinflate(Action <BlockController> blockGotFocusHandler, Action <BlockController, bool> collapseRequested)
        {
            if (OriginalControllerType == typeof(ExtBoxController))
            {
                var inflateData = Data as ExtBoxController.CollapseData;
                var c           = new ExtBoxController(inflateData.RowId, blockGotFocusHandler, collapseRequested, true);
                return(c);
            }
            if (OriginalControllerType == typeof(ExtPersonController))
            {
                var inflateData = Data as ExtPersonController.CollapseData;
                var c           = new ExtPersonController(inflateData.RowId, blockGotFocusHandler, collapseRequested, false);
                return(c);
            }
            if (OriginalControllerType == typeof(TodayController))
            {
                var inflateData = Data as TodayController.CollapseData;
                var c           = new TodayController(inflateData.IsToday, blockGotFocusHandler, collapseRequested);
                return(c);
            }
            if (OriginalControllerType == typeof(BoxSearchController))
            {
                var inflateData = Data as BoxSearchController.CollapseData;
                var c           = new BoxSearchController(blockGotFocusHandler, collapseRequested, inflateData.DoneMode);
                c.VM.TermCri           = inflateData.TermCri;
                c.VM.DoneSinceCri.Date = inflateData.DoneSinceCri;
                c.VM.IncludeDetailsCri = inflateData.IncludeDetailsCri;
                c.SearchRequested();
                return(c);
            }
            if (OriginalControllerType == typeof(PersonSearchController))
            {
                var inflateData = Data as PersonSearchController.CollapseData;
                var c           = new PersonSearchController(blockGotFocusHandler, collapseRequested);
                c.VM.TermCri           = inflateData.TermCri;
                c.VM.IncludeDetailsCri = inflateData.IncludeDetailsCri;
                c.VM.CatIdCri          = inflateData.CatIdCri;
                c.SearchRequested();
                return(c);
            }
            if (OriginalControllerType == typeof(AgendaController))
            {
                var c = new AgendaController(blockGotFocusHandler, collapseRequested, 15); //the 15 gets fixed by caller
                return(c);
            }
            if (OriginalControllerType == typeof(CalendarController))
            {
                var c = new CalendarController(blockGotFocusHandler, collapseRequested);
                return(c);
            }
            if (OriginalControllerType == typeof(SubjectController))
            {
                var c = new SubjectController(blockGotFocusHandler, collapseRequested);
                return(c);
            }

            return(null);
        }
Exemplo n.º 2
0
        public void ActivateFor(ExtBoxController block)
        {
            //cancel if not saved
            if (block.VM.Persistent.Box.RowId == 0)
            {
                UIGlobals.Do.ShowTimedMessge("Save before creating links");
                return;
            }

            Source          = block;
            VM.IsActive     = true;
            VM.Instructions = "Use this to link/relink/unlink this item. Open another task, note, or person to see all options.";
            VM.Items.Clear();
            var box = block.VM.Persistent;

            //convert ExtBox.Links to VM items
            foreach (var link in box.Links)
            {
                //don't show child boxes - there could be many of them and there is a lot of complexity with the ui, since the child
                //box could be open with unsaved changes
                if (link.Link == LinkType.FromBoxToChildBox)
                {
                    continue;
                }

                var item = new RecordLinkVM.ItemVM
                {
                    IsSticky   = true,
                    ButtonText = "Unlink",
                    Command    = new LinkInstruction
                    {
                        FromId        = box.Box.RowId,
                        IsRemove      = true,
                        Link          = link.Link,
                        ToId          = link.OtherId,
                        ToDescription = link.Description
                    }
                };
                if (link.Link == LinkType.FromBoxToParentBox)
                {
                    item.Description = $"'{box.Box.Title}' is a sub-item of {link.Description}";
                }
                else
                {
                    item.Description = $"'{box.Box.Title}' is linked to {link.Description}";
                }
                VM.Items.Add(item);
            }
        }