Exemplo n.º 1
0
 public ItemSelector(Config config, FieldConfig fieldConfig)
     : base(config)
 {
     this.FieldConfig = fieldConfig;
     this.InitializeRelation();
     this.Initialize();
 }
Exemplo n.º 2
0
        internal static ILayout GetLayout(string dataType, Config config, FieldConfig fieldConfig)
        {
            string vtype = string.Empty;

            if (Shorts.Contains(dataType) || Integers.Contains(dataType) || Longs.Contains(dataType))
            {
                vtype = "int";

                if (dataType.EndsWith("_strict"))
                {
                    vtype = "int-strict";
                }
                if (dataType.EndsWith("_strict2"))
                {
                    vtype = "int-strict2";
                }

                return new TextBox(config, fieldConfig, vtype);
            }

            if (Decimals.Contains(dataType))
            {
                vtype = "dec";

                if (dataType.EndsWith("_strict"))
                {
                    vtype = "dec-strict";
                }
                if (dataType.EndsWith("_strict2"))
                {
                    vtype = "dec-strict2";
                }

                return new TextBox(config, fieldConfig, vtype);
            }

            if (Bools.Contains(dataType))
            {
                return new Radios(config, fieldConfig);
            }

            if (Dates.Contains(dataType))
            {
                return new TextBox(config, fieldConfig, "date");
            }

            return Files.Contains(dataType)
                ? new TextBox(config, fieldConfig, "file")
                : new TextBox(config, fieldConfig);
        }
Exemplo n.º 3
0
        public static IEnumerable<FieldConfig> GetFields(DataTable defaultValues, Config config,
            bool editing)
        {
            using (
                DataTable table = TableHelper.GetTable(config.TableSchema, config.Table, config.Exclude))
            {

                Collection<FieldConfig> fields = new Collection<FieldConfig>();

                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        // ReSharper disable once UseObjectOrCollectionInitializer
                        FieldConfig fieldConfig = new FieldConfig();

                        fieldConfig.ColumnName = Conversion.TryCastString(row["column_name"]);
                        fieldConfig.ColumnNameLocalized =
                            ScrudLocalizationHelper.GetResourceString(config.ResourceAssembly,
                                ConfigBuilder.GetResourceClassName(config), fieldConfig.ColumnName);
                        fieldConfig.DefaultValue = Conversion.TryCastString(row["column_default"]);
                        fieldConfig.IsSerial = fieldConfig.DefaultValue.StartsWith("nextval",
                            StringComparison.OrdinalIgnoreCase);
                        fieldConfig.IsNullable = Conversion.TryCastBoolean(row["is_nullable"]);
                        fieldConfig.DataType = Conversion.TryCastString(row["data_type"]);
                        fieldConfig.Domain = Conversion.TryCastString(row["domain_name"]);
                        fieldConfig.MaxLength = Conversion.TryCastInteger(row["character_maximum_length"]);

                        fieldConfig.ParentTableSchema = Conversion.TryCastString(row["references_schema"]);
                        fieldConfig.ParentTable = Conversion.TryCastString(row["references_table"]);
                        fieldConfig.ParentTableColumn = Conversion.TryCastString(row["references_field"]);

                        if (defaultValues.Rows.Count.Equals(1))
                        {
                            fieldConfig.DefaultValue =
                                Conversion.TryCastString(defaultValues.Rows[0][fieldConfig.ColumnName]);
                        }

                        if (editing)
                        {
                            if (!string.IsNullOrWhiteSpace(config.ExcludeEdit))
                            {
                                if (
                                    config.ExcludeEdit.Split(',')
                                        .Any(
                                            column =>
                                                column.Trim()
                                                    .ToUpperInvariant()
                                                    .Equals(fieldConfig.ColumnName.ToUpperInvariant())))
                                {
                                    fieldConfig.IsDisabled = true;
                                }
                            }
                        }

                        fields.Add(fieldConfig);
                    }
                }

                return fields;
            }
        }
Exemplo n.º 4
0
 internal Field(Config config, FieldConfig fieldConfig)
     : base(config)
 {
     this.FieldConfig = fieldConfig;
 }
Exemplo n.º 5
0
 public TextBox(Config config, FieldConfig fieldConfig, string validationType = "")
     : base(config)
 {
     this.FieldConfig    = fieldConfig;
     this.ValidationType = validationType;
 }
Exemplo n.º 6
0
 public Select(Config config, FieldConfig fieldConfig)
     : base(config)
 {
     this.FieldConfig = fieldConfig;
 }
Exemplo n.º 7
0
 public FormField(Config config, FieldConfig fieldConfig, string control)
     : base(config)
 {
     this.FieldConfig = fieldConfig;
     this.Control = control;
 }
Exemplo n.º 8
0
 public FormField(Config config, FieldConfig fieldConfig, string control) : base(config)
 {
     this.FieldConfig = fieldConfig;
     this.Control     = control;
 }
Exemplo n.º 9
0
 public Radios(Config config, FieldConfig fieldConfig)
     : base(config)
 {
     this.FieldConfig = fieldConfig;
 }
Exemplo n.º 10
0
 internal Field(Config config, FieldConfig fieldConfig)
     : base(config)
 {
     this.FieldConfig = fieldConfig;
 }
Exemplo n.º 11
0
 public TextBox(Config config, FieldConfig fieldConfig, string validationType = "")
     : base(config)
 {
     this.FieldConfig = fieldConfig;
     this.ValidationType = validationType;
 }
Exemplo n.º 12
0
 public Select(Config config, FieldConfig fieldConfig)
     : base(config)
 {
     this.FieldConfig = fieldConfig;
 }
Exemplo n.º 13
0
 public Radios(Config config, FieldConfig fieldConfig)
     : base(config)
 {
     this.FieldConfig = fieldConfig;
 }