private void RedisplayPage(UPPageModelController modelController, bool showErrors) { if (modelController == null) { modelController = this.currentModelController; } this.finalSaveCalled = false; List <IIdentifier> changedIdentifiers = new List <IIdentifier>(); foreach (UPMElement actionElement in this.RightNaviagtionBarItems) { if (actionElement is UPMOrganizerAction) { ((UPMOrganizerAction)actionElement).Enabled = true; changedIdentifiers.Add(actionElement.Identifier); } else if (actionElement is UPMOrganizerActionGroup) { ((UPMOrganizerActionGroup)actionElement).Enabled = true; changedIdentifiers.Add(actionElement.Identifier); } } this.ModelControllerDelegate.ModelControllerDidChange(this, this.TopLevelElement, this.TopLevelElement, changedIdentifiers, null); if (showErrors && modelController is SerialEntryPageModelController) { ((SerialEntryPageModelController)modelController).PositionsWithError(); } else if (modelController is EditPageModelController) { modelController.ModelControllerDelegate.ModelControllerDidChange(modelController, modelController.TopLevelElement, modelController.TopLevelElement, null, null); } }
/// <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> /// Performed when the model controller view will disappear. /// </summary> /// <param name="pageModelController">The page model controller.</param> public override void PageModelControllerViewWillDisappear(UPPageModelController pageModelController) { if (this.disappearingOrganizer) { return; } if (pageModelController is SerialEntryPageModelController) { ((SerialEntryPageModelController)pageModelController).SaveChangedPosition(null); } else if (pageModelController is EditPageModelController) { } this.currentModelController = null; }
/// <summary> /// Adds Subview pages to UPMOrganizer /// </summary> /// <param name="expandHeader"> /// <see cref="UPConfigHeader"/> configuration object /// </param> /// <param name="detailOrganizer"> /// <see cref="UPMOrganizer"/> to add pages to /// </param> /// <param name="overviewPage"> /// <see cref="Page"/> object to update LableText /// </param> private void UPMOrganizerAddPages(UPConfigHeader expandHeader, UPMOrganizer detailOrganizer, Page overviewPage) { var additionalParameters = new Dictionary <string, object> { { nameof(VirtualInfoAreaId), VirtualInfoAreaId } }; if (expandHeader.SubViews != null) { foreach (UPConfigHeaderSubView subView in expandHeader.SubViews) { if (subView.Options == "#") { overviewPage.LabelText = subView.Label; continue; } UPPageModelController pageModelController = PageForViewReference( subView.ViewReference?.ViewReferenceWith(additionalParameters).ViewReferenceWith(RecordIdentification)); if (pageModelController != null) { pageModelController.Page.Parent = detailOrganizer; pageModelController.Page.Invalid = true; pageModelController.Page.LabelText = subView.Label; AddPageModelController(pageModelController); if (pageModelController is UPWebContentPageModelController) { var webContentPageModelController = (UPWebContentPageModelController)pageModelController; if (webContentPageModelController.AllowsXMLExport) { var exportXMLAction = new UPMOrganizerAction(StringIdentifier.IdentifierWithStringId("action.exportXML")) { LabelText = "Export XML" }; AddOrganizerHeaderActionItem(exportXMLAction); } } detailOrganizer.AddPage(pageModelController.Page); } } } }
/// <summary> /// Observes the value for key path of object change context. /// </summary> /// <param name="keyPath">The key path.</param> /// <param name="theObject">The object.</param> /// <param name="change">The change.</param> /// <param name="context">The context.</param> public void ObserveValueForKeyPathOfObjectChangeContext(string keyPath, object theObject, Dictionary <string, object> change, object context) { if (keyPath == "hasRunningChangeRequests") { SerialEntryPageModelController modelController = (SerialEntryPageModelController)theObject; this.PageModelControllerSetContextValueForKey(modelController, modelController.ChangeRequestError, "organizerError"); if (modelController.ChangeRequestError != null && !this.closeOnErrors) { this.isSaving = false; if (this.organizerDealsWithSaveErrors) { this.Organizer.Status = null; modelController.Page.Status = null; modelController.Page.Invalid = true; this.RedisplayPage(null, true); } else if (this.CloseOrganizerDelegate != null) { this._modelControllerToRedraw = modelController; } if (this.organizerDealsWithSaveErrors || this.CloseOrganizerDelegate != null) { this.organizerDealsWithSaveErrors = false; if (modelController.SerialEntry.ConflictHandling) { this.currentModelController = modelController; this.RedisplayPage(null, true); return; } else { this.serialEntryPageModelController = modelController; //UIAlertView alertview = new UIAlertView(LocalizationKeys.upTextYouMadeChanges, LocalizationKeys.upTextProcessSerialEntrySaveErrors, this, LocalizationKeys.upTextOK, LocalizationKeys.upTextBasicDiscardChanges, null); //this.isErrorSaveDialog = true; //alertview.Show(); } return; } } foreach (UPPageModelController pageModelController in this.PageModelControllers) { var controller = pageModelController as SerialEntryWebContentModelController; if (controller != null) { controller.Page.Invalid = true; controller.ShouldWaitForPendingChanges = modelController.HasRunningChangeRequests; } } if (this.isSaving && !modelController.HasRunningChangeRequests) { this.organizerDealsWithSaveErrors = false; this.waitForSerialEntrySave = false; this.isSaving = false; if (!this.waitForSave) { if (this.CloseOrganizerDelegate != null) { UPMCloseOrganizerDelegate del = this.CloseOrganizerDelegate; this.CloseOrganizerDelegate = null; del.UpOrganizerModelControllerAllowedClosingOrganizer(this); } else { this.HandleChangeManager(); this.HandleSaved(); } } } } }
/// <summary> /// Performed when the model controller view will appear. /// </summary> /// <param name="pageModelController">The page model controller.</param> public override void PageModelControllerViewWillAppear(UPPageModelController pageModelController) { this.currentModelController = pageModelController; }