Inheritance: ShortTextFieldSetting
Esempio n. 1
0
        public override IDictionary<string, FieldMetadata> GetFieldMetadata()
        {
            var fmd = base.GetFieldMetadata();

            fmd[AllowExtraValueName].FieldSetting.Visible = false;
            fmd[AllowMultipleName].FieldSetting.Visible = false;
            fmd[OptionsName].FieldSetting.Visible = false;
            fmd[DisplayChoicesName].FieldSetting.Visible = false;
            fmd[CompulsoryName].FieldSetting.Visible = false;

            var fs = new ChoiceFieldSetting
            {
                Name = DefaultValueName,
                DisplayName = GetTitleString(DefaultValueName),
                Description = GetDescString(DefaultValueName),
                FieldClassName = typeof(ChoiceField).FullName,
                AllowMultiple = false,
                AllowExtraValue = false,
                Options = new List<ChoiceOption>(_options),
                DisplayChoice = Fields.DisplayChoice.DropDown,
                Visible = true
            };

            fmd[DefaultValueName].FieldSetting = fs;

            return fmd;
        }
Esempio n. 2
0
        public override IDictionary <string, FieldMetadata> GetFieldMetadata()
        {
            var fmd = base.GetFieldMetadata();

            fmd[AllowExtraValueName].FieldSetting.Visible = false;
            fmd[AllowMultipleName].FieldSetting.Visible   = false;
            fmd[OptionsName].FieldSetting.Visible         = false;
            fmd[DisplayChoicesName].FieldSetting.Visible  = false;
            fmd[CompulsoryName].FieldSetting.Visible      = false;

            var fs = new ChoiceFieldSetting
            {
                Name            = DefaultValueName,
                DisplayName     = GetTitleString(DefaultValueName),
                Description     = GetDescString(DefaultValueName),
                FieldClassName  = typeof(ChoiceField).FullName,
                AllowMultiple   = false,
                AllowExtraValue = false,
                Options         = new List <ChoiceOption>(_options),
                DisplayChoice   = Fields.DisplayChoice.DropDown,
                Visible         = true
            };

            fmd[DefaultValueName].FieldSetting = fs;

            return(fmd);
        }
Esempio n. 3
0
        public override IDictionary <string, FieldMetadata> GetFieldMetadata()
        {
            var fmd = base.GetFieldMetadata();

            fmd[ShowAsPercentageName].FieldSetting.Visible = false;

            var fs = new ChoiceFieldSetting
            {
                Name            = FormatName,
                DisplayName     = GetTitleString(FormatName),
                Description     = GetDescString(FormatName),
                FieldClassName  = typeof(ChoiceField).FullName,
                AllowMultiple   = false,
                AllowExtraValue = false,
                Options         = (from c in CurrencyTypes.AllKeys
                                   select new ChoiceOption(c, GetCurrencyText(c, CurrencyTypes[c]))).ToList(),
                DisplayChoice = DisplayChoice.DropDown
            };

            fmd.Add(FormatName, new FieldMetadata
            {
                FieldName    = FormatName,
                CanRead      = true,
                CanWrite     = true,
                FieldSetting = fs
            });

            return(fmd);
        }
Esempio n. 4
0
        public override IDictionary <string, FieldMetadata> GetFieldMetadata()
        {
            var fmd = base.GetFieldMetadata();

            var fieldSetting = fmd[ShowAsPercentageName].FieldSetting;

            fieldSetting.VisibleBrowse = FieldVisibility.Hide;
            fieldSetting.VisibleEdit   = FieldVisibility.Hide;
            fieldSetting.VisibleNew    = FieldVisibility.Hide;

            fmd[DigitsName].FieldSetting.DefaultValue = "0";

            var minvalFs = (NumberFieldSetting)fmd[MinValueName].FieldSetting;

            minvalFs.DefaultValue = "0";

            var fs = new ChoiceFieldSetting
            {
                Name            = FormatName,
                DisplayName     = GetTitleString(FormatName),
                Description     = GetDescString(FormatName),
                FieldClassName  = typeof(ChoiceField).FullName,
                AllowMultiple   = false,
                AllowExtraValue = false,
                Options         = GetCurrencyOptions(),
                DisplayChoice   = DisplayChoice.DropDown,
                DefaultValue    = @"[Script:jScript] System.Globalization.CultureInfo.CurrentUICulture.IsNeutralCulture ? System.Globalization.CultureInfo.CreateSpecificCulture(System.Globalization.CultureInfo.CurrentUICulture.Name).Name : System.Globalization.CultureInfo.CurrentUICulture.Name; [/Script]"
            };

            fmd.Add(FormatName, new FieldMetadata
            {
                FieldName    = FormatName,
                CanRead      = true,
                CanWrite     = true,
                FieldSetting = fs
            });

            return(fmd);
        }
Esempio n. 5
0
        public static void ParseOptions(XPathNavigator node, List <ChoiceOption> options, ChoiceFieldSetting fieldSetting, out string enumTypeName)
        {
            options.Clear();
            enumTypeName = string.Empty;

            foreach (XPathNavigator optionElement in node.SelectChildren(XPathNodeType.Element))
            {
                if (optionElement.Name == "Enum")
                {
                    enumTypeName = optionElement.GetAttribute("type", "");
                    var enumType = TypeHandler.GetType(enumTypeName);
                    if (enumType == null)
                    {
                        throw new ContentRegistrationException("Enum");
                    }

                    var resClassName = optionElement.GetAttribute("resourceClass", "");
                    if (string.IsNullOrEmpty(resClassName))
                    {
                        resClassName = CtdResourceClassName;
                    }

                    var names  = Enum.GetNames(enumType);
                    var values = Enum.GetValues(enumType).Cast <int>().ToArray();
                    for (var i = 0; i < names.Length; i++)
                    {
                        var resKey = fieldSetting == null ? string.Empty : fieldSetting.GetResourceKey(names[i]);
                        var text   = string.IsNullOrEmpty(resKey) ? names[i] : SenseNetResourceManager.GetResourceKey(resClassName, resKey);
                        var c      = new ChoiceOption(values[i].ToString(), text);
                        options.Add(c);
                    }
                }
                else
                {
                    var text = optionElement.InnerXml;
                    var key  = optionElement.GetAttribute("value", "");

                    if (text.Length == 0 && key.Length == 0)
                    {
                        key = options.Count.ToString();
                    }
                    if (text.Length == 0)
                    {
                        text = key;
                    }
                    if (key.Length == 0)
                    {
                        key = text;
                    }

                    bool enabled;
                    if (!Boolean.TryParse(optionElement.GetAttribute("enabled", ""), out enabled))
                    {
                        enabled = true;
                    }

                    var selected = false;
                    Boolean.TryParse(optionElement.GetAttribute("selected", ""), out selected);

                    options.Add(new ChoiceOption(key, text, enabled, selected));
                }
            }
        }
Esempio n. 6
0
        public override IDictionary<string, FieldMetadata> GetFieldMetadata()
        {
            var fmd = base.GetFieldMetadata();

            fmd[ShowAsPercentageName].FieldSetting.Visible = false;

            var fs = new ChoiceFieldSetting
                         {
                             Name = FormatName,
                             DisplayName = GetTitleString(FormatName),
                             Description = GetDescString(FormatName),
                             FieldClassName = typeof(ChoiceField).FullName,
                             AllowMultiple = false,
                             AllowExtraValue = false,
                             Options = (from c in CurrencyTypes.AllKeys
                                        select new ChoiceOption(c, GetCurrencyText(c, CurrencyTypes[c]))).ToList(),
                             DisplayChoice = DisplayChoice.DropDown
                         };

            fmd.Add(FormatName, new FieldMetadata
            {
                FieldName = FormatName,
                CanRead = true,
                CanWrite = true,
                FieldSetting = fs
            });

            return fmd;
        }
Esempio n. 7
0
        private static FieldControl CreateDefaultChoiceControl(ChoiceFieldSetting choiceSetting)
        {
            Type controlType = null;
            ChoiceControl control = null;

            if (choiceSetting != null)
            {
                switch (choiceSetting.DisplayChoice)
                {
                    case DisplayChoice.CheckBoxes:
                        controlType = typeof(CheckBoxGroup);
                        break;
                    case DisplayChoice.DropDown:
                        controlType = typeof(DropDown);
                        break;
                    case DisplayChoice.RadioButtons:
                        controlType = typeof(RadioButtonGroup);
                        break;
                    default:
                        controlType = choiceSetting.AllowMultiple == true ? typeof(CheckBoxGroup) : typeof(DropDown);
                        break;
                }

                control = (ChoiceControl)Activator.CreateInstance(controlType);
            }

            return control;
        }