/// <summary> /// Gets the answers. /// </summary> /// <value> /// The answers. /// </value> public List <IQuestionnaireAnswerOption> Answers() { if (!this.answersInitialized && this.answers == null) { if (!string.IsNullOrEmpty(this.InfoAreaId) && this.FieldId >= 0) { if (this.FieldInfo.IsCatalogField) { UPCatalog catalog = UPCRMDataStore.DefaultStore.CatalogForCrmField(this.Field); if (!catalog.IsDependent) { Dictionary <string, string> values = catalog.TextValuesForFieldValues(false); if (values.Count > 0) { this.answers = UPQuestionnaireAnswer.AnswersFromCatalogValueDictionary(values); } if (this.multiple && !this.Questionnaire.Manager.MultipleAnswersForCatalogs) { this.multiple = false; } } } } this.answersInitialized = true; if (this.answers?.Count > 0) { this.answerDictionary = new Dictionary <string, IQuestionnaireAnswerOption>(); foreach (IQuestionnaireAnswerOption answerOption in this.answers) { if (answerOption.AnswerId != null) { this.answerDictionary[answerOption.AnswerId] = answerOption; } } } else { this.multiple = false; } } return(this.answers); }
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); }