/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { ListControl editControl; bool useDescription = configurationValues != null && configurationValues.ContainsKey(DISPLAY_DESCRIPTION) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean(); int? definedTypeId = configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY) ? configurationValues[DEFINED_TYPE_KEY].Value.AsIntegerOrNull() : null; if (definedTypeId.HasValue) { var definedType = DefinedTypeCache.Get(definedTypeId.Value); } if (configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean()) { if (configurationValues != null && configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean()) { editControl = new DefinedValuesPickerEnhanced { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; } else { editControl = new DefinedValuesPicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; } } else { editControl = new DefinedValuePicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; if (configurationValues != null && configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean()) { (( DefinedValuePicker )editControl).EnhanceForLongLists = true; } } if (editControl is IDefinedValuePicker) { (editControl as IDefinedValuePicker).IncludeInactive = configurationValues.GetValueOrNull(INCLUDE_INACTIVE_KEY).AsBooleanOrNull() ?? false; } if (definedTypeId.HasValue) { return(editControl); } return(null); }
/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { Control editControl; bool useDescription = configurationValues != null && configurationValues.ContainsKey(DISPLAY_DESCRIPTION) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean(); int? definedTypeId = configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY) ? configurationValues[DEFINED_TYPE_KEY].Value.AsIntegerOrNull() : null; int repeatColumns = (configurationValues != null && configurationValues.ContainsKey(REPEAT_COLUMNS_KEY) ? configurationValues[REPEAT_COLUMNS_KEY].Value.AsIntegerOrNull() : null) ?? 4; bool allowAdd = configurationValues != null && configurationValues.ContainsKey(ALLOW_ADDING_NEW_VALUES_KEY) ? configurationValues[ALLOW_ADDING_NEW_VALUES_KEY].Value.AsBoolean() : false; bool enhanceForLongLists = configurationValues != null && configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean(); bool allowMultiple = configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean(); if (allowMultiple) { if (allowAdd) { editControl = new DefinedValuePickerWithAddMultipleSelect { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId, RepeatColumns = repeatColumns, IsAllowAddDefinedValue = allowAdd, EnhanceForLongLists = enhanceForLongLists }; } else { if (enhanceForLongLists) { editControl = new DefinedValuesPickerEnhanced { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId }; } else { editControl = new DefinedValuesPicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId, RepeatColumns = repeatColumns }; } } } else { //TODO: The add versions of the controls are not working with AttributeValuesContainer, so keep the old ones for now if (allowAdd) { editControl = new DefinedValuePickerWithAddSingleSelect { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId, IsAllowAddDefinedValue = allowAdd, EnhanceForLongLists = enhanceForLongLists }; } else { editControl = new DefinedValuePicker { ID = id, DisplayDescriptions = useDescription, DefinedTypeId = definedTypeId, EnhanceForLongLists = enhanceForLongLists }; } } if (editControl is IDefinedValuePicker) { (editControl as IDefinedValuePicker).IncludeInactive = configurationValues.GetValueOrNull(INCLUDE_INACTIVE_KEY).AsBooleanOrNull() ?? false; } if (definedTypeId.HasValue) { return(editControl); } return(null); }