private UPMEditField CreateDependEditField(IIdentifier participantIdentifier, UPCatalog catalog, UPMGroup editGroup) { UPCRMField field = null; if (catalog == this.ParticipantsControl.RequirementCatalog) { field = this.ParticipantsControl.RequirementField; } else if (catalog == this.ParticipantsControl.AcceptanceCatalog) { field = this.ParticipantsControl.AcceptanceField; } var editField = new UPMParticipantCatalogEditField(StringIdentifier.IdentifierWithStringId( field != null ? $"dependField_{participantIdentifier}_{field.InfoAreaId}_{field.FieldId}" : $"dependField_{participantIdentifier}_(null)_0")) { GroupModelController = this, Group = editGroup }; if (catalog != null) { var possibleValues = catalog.Values; List <string> explicitKeyOrder; var possibleValuesAsString = catalog.TextValuesForFieldValues(false); var configStore = ConfigurationUnitStore.DefaultStore; var acceptanceCatalogAttributes = configStore.CatalogAttributesForInfoAreaIdFieldId(field.InfoAreaId, field.FieldId); foreach (var catalogValue in possibleValues) { var possibleValue = new UPMCatalogPossibleValue { TitleLabelField = new UPMStringField(StringIdentifier.IdentifierWithStringId("x")) { StringValue = catalogValue.Text } }; var configCatalogValueAttributes = acceptanceCatalogAttributes.ValuesByCode.ValueOrDefault(catalogValue.CodeKey.ToInt()); if (configCatalogValueAttributes != null) { var colorString = configCatalogValueAttributes.ColorKey; if (!string.IsNullOrEmpty(colorString)) { possibleValue.IndicatorColor = AureaColor.ColorWithString(colorString); } possibleValue.ImageString = configCatalogValueAttributes.ImageName; } possibleValue.Key = catalogValue.CodeKey; editField.AddPossibleValue(possibleValue); } if (string.IsNullOrEmpty(possibleValuesAsString.ValueOrDefault("0"))) { editField.NullValueKey = "0"; } if (acceptanceCatalogAttributes != null && !ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("FixedCatalog.SortByAttributeFilter")) { explicitKeyOrder = this.ExplicitKeyOrderByCatalogAttributeCodeOrder(acceptanceCatalogAttributes, catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false)); } else if (ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("FixedCatalog.SortByCode")) { explicitKeyOrder = catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false); } else { explicitKeyOrder = catalog.ExplicitKeyOrderEmptyValueIncludeHidden(false, false); } if (explicitKeyOrder != null) { editField.ExplicitKeyOrder = explicitKeyOrder; } editField.ContinuousUpdate = true; editField.DisplayValues = possibleValuesAsString.Values.ToList(); } return(editField); }
UPMEditField CreateDependEditFieldWithParticipantIdentifierCatalogEditGroup(UPMIdentifier participantIdentifier, UPCatalog catalog, UPMGroup editGroup) { UPCRMField field; if (catalog == this.ParticipantsControl.RequirementCatalog) { field = this.ParticipantsControl.RequirementField; } else if (catalog == this.ParticipantsControl.AcceptanceCatalog) { field = this.ParticipantsControl.AcceptanceField; } UPMParticipantCatalogEditField editField = new UPMParticipantCatalogEditField(UPMStringIdentifier.IdentifierWithStringId(NSString.StringWithFormat("dependField_%@_%@_%ld", participantIdentifier.Description, field.InfoAreaId, (long)field.FieldId))); editField.GroupModelController = this; editField.Group = editGroup; if (catalog != null) { ArrayList possibleValues = catalog.Values; ArrayList explicitKeyOrder; NSDictionary possibleValuesAsString = catalog ? catalog.TextValuesForFieldValues() : null; UPConfigurationUnitStore configStore = UPConfigurationUnitStore.DefaultStore(); UPConfigCatalogAttributes acceptanceCatalogAttributes = configStore.CatalogAttributesForInfoAreaIdFieldId(field.InfoAreaId, field.FieldId); possibleValues.EnumerateObjectsUsingBlock(delegate(object obj, uint idx, bool stop) { UPMCatalogPossibleValue possibleValue = new UPMCatalogPossibleValue(); UPMStringField valueField = new UPMStringField(UPMStringIdentifier.IdentifierWithStringId("x")); UPCatalogValue catalogValue = (UPCatalogValue)obj; valueField.StringValue = catalogValue.Text; possibleValue.TitleLabelField = valueField; UPConfigCatalogValueAttributes configCatalogValueAttributes = acceptanceCatalogAttributes.ValuesByCode().ObjectForKey(NSNumber.NumberWithInt(catalogValue.CodeKey.IntValue)); if (configCatalogValueAttributes) { string colorString = configCatalogValueAttributes.ColorKey(); if (colorString) { possibleValue.IndicatorColor = UPColor.ColorWithString(colorString); } possibleValue.ImageString = configCatalogValueAttributes.ImageName(); } editField.AddPossibleValueForKey(possibleValue, catalogValue.CodeKey); }); if (((string)possibleValuesAsString.ObjectForKey("0")).Length == 0) { editField.NullValueKey = "0"; } if (catalog != null && acceptanceCatalogAttributes != null && !UPConfigurationUnitStore.DefaultStore().ConfigValueIsSet("FixedCatalog.SortByAttributeFilter")) { explicitKeyOrder = this.ExplicitKeyOrderByCatalogAttributeCodeOrder(acceptanceCatalogAttributes, catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false)); } else if (catalog != null && UPConfigurationUnitStore.DefaultStore().ConfigValueIsSet("FixedCatalog.SortByCode")) { explicitKeyOrder = catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false); } else { explicitKeyOrder = catalog.ExplicitKeyOrderEmptyValueIncludeHidden(false, false); } if (explicitKeyOrder != null) { editField.ExplicitKeyOrder = explicitKeyOrder; } editField.ContinuousUpdate = true; } return(editField); }