Esempio n. 1
0
        /// <summary>
        /// Adds the remaining page model controller.
        /// </summary>
        public void AddRemainingPageModelController()
        {
            this.created = true;
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            UPConfigHeader          editHeader  = configStore.HeaderByNameFromGroup(this.IsNew ? "New" : "Update", this.ExpandConfig.HeaderGroupName) ??
                                                  configStore.HeaderByNameFromGroup("Edit", this.ExpandConfig.HeaderGroupName);

            if (editHeader != null && editHeader.SubViews.Count != 0)
            {
                Page rootPage = this.PageModelControllers[0].Page;
                if (string.IsNullOrEmpty(rootPage.LabelText) && !string.IsNullOrEmpty(editHeader.Label))
                {
                    this.PageModelControllers[0].Page.LabelText = editHeader.Label;
                }

                foreach (UPConfigHeaderSubView subView in editHeader.SubViews)
                {
                    ViewReference pageViewReference = this.CopyFieldDictionary != null
                        ? subView.ViewReference.ViewReferenceWith(new Dictionary <string, object> {
                        { "copyFields", this.CopyFieldDictionary }
                    })
                        : subView.ViewReference;

                    UPPageModelController pageModelController = pageViewReference.ViewName == "RecordView"
                        ? new EditPageModelController(pageViewReference.ViewReferenceWith(this.RecordIdentification))
                        : this.PageForViewReference(pageViewReference.ViewReferenceWith(this.RecordIdentification));

                    if (pageModelController != null)
                    {
                        if (pageModelController is SerialEntryPageModelController)
                        {
                            //pageModelController.AddObserverForKeyPathOptionsContext(this, "hasRunningChangeRequests", NSKeyValueObservingOptionNew, null);
                        }

                        pageModelController.Page.Invalid   = true;
                        pageModelController.Page.LabelText = subView.Label;
                        pageModelController.Delegate       = this;
                        this.AddPageModelController(pageModelController);
                        this.Organizer.AddPage(pageModelController.Page);

                        if (pageModelController is UPWebContentPageModelController)
                        {
                            if (((UPWebContentPageModelController)pageModelController).AllowsXMLExport)
                            {
                                UPMOrganizerAction exportXMLAction = new UPMOrganizerAction(StringIdentifier.IdentifierWithStringId("action.exportXML"));
                                //exportXMLAction.SetTargetAction(pageModelController, ExportXML);
                                exportXMLAction.LabelText = "Export XML";
                                this.AddOrganizerHeaderActionItem(exportXMLAction);
                            }
                        }
                    }
                }
            }
        }
        /// <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);
        }
Esempio n. 3
0
        private void RefreshTableCaption()
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            var    crmStore         = UPCRMDataStore.DefaultStore;
            string tableCaptionName = this.ExpandConfig.TableCaptionName;

            if (string.IsNullOrEmpty(tableCaptionName))
            {
                tableCaptionName = this.InfoAreaId;
            }

            UPConfigTableCaption tableCaption = configStore.TableCaptionByName(tableCaptionName);
            string recordTableCaption         = tableCaption?.TableCaptionForRecordIdentification(this.RecordIdentification);

            if (string.IsNullOrEmpty(recordTableCaption) && !crmStore.RecordExistsOffline(this.RecordIdentification))
            {
                this.Organizer.TitleText = configStore.BasicTextByIndex(4);
                tableCaption?.RequestTableCaptionForRecordIdentification(this.RecordIdentification, this);
            }
            else
            {
                this.Organizer.TitleText = recordTableCaption;
            }

            string subTitleText = null;

            if (!string.IsNullOrEmpty(this.ExpandConfig.HeaderGroupName))
            {
                UPConfigHeader header = configStore.HeaderByNameFromGroup("Expand", this.ExpandConfig.HeaderGroupName);
                subTitleText = header?.Label;
            }

            if (string.IsNullOrEmpty(subTitleText))
            {
                InfoArea infoAreaConfig = configStore.InfoAreaConfigById(this.InfoAreaId);
                subTitleText = infoAreaConfig.SingularName;
                if (string.IsNullOrEmpty(subTitleText))
                {
                    subTitleText = crmStore.TableInfoForInfoArea(this.InfoAreaId).Label;
                }
            }

            this.Organizer.SubtitleText = subTitleText;
            this.InformAboutDidChangeTopLevelElement(this.Organizer, this.Organizer, null, UPChangeHints.ChangeHintsWithHint("TableCaptionChanged"));
        }