/// <summary>
        /// Computes EditRecordViewReference from <see cref="FieldControl"/>
        /// </summary>
        /// <param name="listFieldControl">
        /// <see cref="FieldControl"/> object
        /// </param>
        /// <param name="configStore">
        /// <see cref="IConfigurationUnitStore"/>
        /// </param>
        /// <returns>
        /// EditRecordViewReference value to be set
        /// </returns>
        private ViewReference GetEditRecordViewReference(FieldControl listFieldControl, IConfigurationUnitStore configStore)
        {
            var viewReference = (ViewReference)null;
            var editAction    = listFieldControl.ValueForAttribute(AttributeCalendarEditAction);

            if (editAction == ActionNone)
            {
                viewReference = null;
            }
            else if (!string.IsNullOrWhiteSpace(editAction))
            {
                if (editAction.StartsWith(ActionPrefixButton))
                {
                    viewReference = configStore.ButtonByName(editAction.Substring(ButtonNameStartingIndex)).ViewReference;
                }
                else if (editAction.StartsWith(ActionPrefixMenu))
                {
                    viewReference = configStore.MenuByName(editAction.Substring(MenuNameStartingIndex)).ViewReference;
                }
                else
                {
                    viewReference = configStore.ButtonByName(editAction).ViewReference;
                }
            }
            else
            {
                var expand = configStore.ExpandByName(InfoAreaId);
                var header = configStore.HeaderByNameFromGroup(HeaderExpand, expand.HeaderGroupName);

                if (header?.ButtonNames != null)
                {
                    foreach (var button in header.ButtonNames)
                    {
                        if (button.StartsWith(Edit))
                        {
                            viewReference = configStore.ButtonByName(button).ViewReference;
                            var isSwitchToEdit = false;
                            if (viewReference.ParameterDictionary().ContainsKey(Action))
                            {
                                isSwitchToEdit = ((string)viewReference.ParameterDictionary()[Action]).StartsWith(SwitchToEdit);
                            }

                            if (viewReference.ViewName == ViewOrganizerAction && isSwitchToEdit)
                            {
                                viewReference = configStore.MenuByName(MenuEditRecord).ViewReference;
                            }

                            if (viewReference != null)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            return(viewReference);
        }
        /// <summary>
        /// The buttons for result row.
        /// </summary>
        /// <param name="row">
        /// The row.
        /// </param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public List <UPConfigButton> ButtonsForResultRow(UPCRMResultRow row)
        {
            UPConfigQueryTable matchingTable = this.QueryTableForResultRow(row);

            if (matchingTable != null)
            {
                List <UPConfigButton> matchingButtons = new List <UPConfigButton>();

                UPConfigQueryCondition propertyCondition = matchingTable.PropertyConditions[@"Action"];

                if (propertyCondition != null)
                {
                    IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

                    foreach (string menuName in propertyCondition.FieldValues)
                    {
                        Menu menu = configStore.MenuByName(menuName);
                        if (menu != null)
                        {
                            UPConfigButton button = new UPConfigButton(
                                menu.DisplayName,
                                menu.ImageName,
                                menu.ViewReference);
                            matchingButtons.Add(button);
                        }
                        else if (menuName.StartsWith(@"Button:"))
                        {
                            UPConfigButton button = configStore.ButtonByName(menuName.Substring(7));
                            if (button != null)
                            {
                                matchingButtons.Add(button);
                            }
                        }
                    }
                }

                propertyCondition = matchingTable.PropertyConditions.ValueOrDefault("ButtonAction");

                if (propertyCondition != null)
                {
                    foreach (string buttonName in propertyCondition.FieldValues)
                    {
                        UPConfigButton button = ConfigurationUnitStore.DefaultStore.ButtonByName(buttonName);

                        if (button != null)
                        {
                            matchingButtons.Add(button);
                        }
                    }
                }

                return(matchingButtons.Count > 0 ? matchingButtons : null);
            }

            return(null);
        }
        /// <summary>
        /// Sets ShowRecordViewReferece
        /// </summary>
        /// <param name="listFieldControl">
        /// <see cref="FieldControl"/>
        /// </param>
        /// <param name="configStore">
        /// <see cref="IConfigurationUnitStore"/>
        /// </param>
        private void SetShowRecordViewReference(FieldControl listFieldControl, IConfigurationUnitStore configStore)
        {
            var showAction = listFieldControl.ValueForAttribute(AttributeCalendarShowAction);

            if (showAction == ActionNone)
            {
                ShowRecordViewReference = null;
            }
            else if (!string.IsNullOrWhiteSpace(showAction))
            {
                if (showAction.StartsWith(ActionPrefixButton))
                {
                    ShowRecordViewReference = configStore.ButtonByName(showAction.Substring(7)).ViewReference;
                }
                else if (showAction.StartsWith(ActionPrefixMenu))
                {
                    ShowRecordViewReference = configStore.MenuByName(showAction.Substring(5)).ViewReference;
                }
                else
                {
                    ShowRecordViewReference = configStore.ButtonByName(showAction).ViewReference;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QuestionnaireEditPageModelController"/> class.
        /// </summary>
        /// <param name="viewReference">The view reference.</param>
        public QuestionnaireEditPageModelController(ViewReference viewReference)
            : base(viewReference)
        {
            this.RecordIdentification = this.ViewReference.ContextValueForKey("RecordId");
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            string configValue = this.ViewReference.ContextValueForKey("ConfirmButtonName");

            if (!string.IsNullOrEmpty(configValue))
            {
                this.ConfirmationButton = configStore.ButtonByName(configValue);
            }

            configValue = this.ViewReference.ContextValueForKey("ConfirmedFilterName");
            if (!string.IsNullOrEmpty(configValue))
            {
                this.ConfirmedFilter = configStore.FilterByName(configValue);
            }

            this.Readonly      = this.ViewReference.ContextValueIsSet("ReadOnly") || this.ViewReference.ContextValueIsSet("QuestionnaireReadOnly");
            this.Survey        = new UPSurvey(this.ViewReference, this.RecordIdentification, this);
            this.PortfolioMode = this.ViewReference.ContextValueIsSet("Portfolio");
            this.BuildPage();
        }
Esempio n. 5
0
        private void HandleSaved()
        {
            this.disappearingOrganizer = true;
            var savedActionName = !string.IsNullOrEmpty(this.finishActionName) ? this.finishActionName : this.ViewReference.ContextValueForKey("SavedAction");

            if (!string.IsNullOrEmpty(savedActionName))
            {
                if (this.ConflictHandlingMode)
                {
                    savedActionName = string.Empty;
                }
                else
                {
                    foreach (UPPageModelController pageModelController in this.PageModelControllers)
                    {
                        if (pageModelController is SerialEntryPageModelController &&
                            ((SerialEntryPageModelController)pageModelController).RightsFilterRevocation)
                        {
                            savedActionName = string.Empty;
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(savedActionName))
            {
                IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                if (savedActionName.StartsWith("Button:"))
                {
                    UPConfigButton button = configStore.ButtonByName(savedActionName.Substring(7));
                    this.SaveViewReference = button.ViewReference;
                }
                else if (savedActionName.StartsWith("Menu:"))
                {
                    Menu menu = configStore.MenuByName(savedActionName.Substring(5));
                    this.SaveViewReference = menu.ViewReference;
                }
                else if (savedActionName == "Return")
                {
                    this.PopToPrevious = true;
                }
                else
                {
                    Menu menu = configStore.MenuByName(savedActionName);
                    this.SaveViewReference = menu.ViewReference;
                }

                this.ExecuteSavedActionWithRecordIdentification((string)this.PageModelControllerContextValueForKey(null, "RootRecordIdentification"), false);
            }
            else
            {
                if (this.PopToRootOnSave)
                {
                    this.ModelControllerDelegate.PopToRootContentViewController();
                }
                else
                {
                    this.PopToPreviousContentViewController();
                }
            }
        }