Exemple #1
0
        public static SchemaItem Select(this SchemaItem item, string key, string label, Options options, params Validator[] validators)
        {
            ApplyProperties(item, key, label, SchemaItemType.Select, validators);
            item.Options = options;

            return(item);
        }
Exemple #2
0
        public static SchemaItem TextArea(this SchemaItem item, string key, string label, int rows = 4, int maxRows = 4, params Validator[] validators)
        {
            ApplyProperties(item, key, label, SchemaItemType.Textarea, validators);
            item.TextareaRows    = rows;
            item.TextareaMaxRows = maxRows;

            return(item);
        }
        public static Schema WithItem(this Schema schema, SchemaItem item)
        {
            item.Key.ThrowIfEmpty(nameof(item.Key));
            if (string.IsNullOrEmpty(item.Label))
            {
                item.Label = item.Key.Humanize(LetterCasing.Title);
            }

            schema.AddItem(item);
            return(schema);
        }
Exemple #4
0
        private static void ApplyProperties(SchemaItem item, string key, string label, SchemaItemType type, params Validator[] validators)
        {
            key.ThrowIfEmpty(nameof(label));
            if (string.IsNullOrEmpty(label))
            {
                label = key.Humanize(LetterCasing.Title);
            }

            item.Type       = type;
            item.Key        = key;
            item.Label      = label;
            item.Validators = validators;
        }
Exemple #5
0
        public void AddItem(SchemaItem item)
        {
            var existing = Items.FirstOrDefault(i => i.Key == item.Key);

            if (existing == null)
            {
                items.Add(item);
            }
            else
            {
                existing = item;
            }
            item.Schema = this;
        }
Exemple #6
0
 public static SchemaItem HasClass(this SchemaItem item, string className)
 {
     item.ClassName = className;
     return(item);
 }
Exemple #7
0
 public static SchemaItem Select(this SchemaItem item, string key, Options options, params Validator[] validators)
 => item.Select(key, String.Empty, options, validators);
Exemple #8
0
 public static SchemaItem Datepicker(this SchemaItem item, string key, params Validator[] validators)
 => item.Datepicker(key, String.Empty, validators);
Exemple #9
0
        public static SchemaItem Datepicker(this SchemaItem item, string key, string label, params Validator[] validators)
        {
            ApplyProperties(item, key, label, SchemaItemType.Datepicker, validators);

            return(item);
        }
Exemple #10
0
 public static SchemaItem Checkbox(this SchemaItem item, string key, params Validator[] validators)
 => item.Checkbox(key, String.Empty, validators);
Exemple #11
0
        public static SchemaItem Checkbox(this SchemaItem item, string key, string label, params Validator[] validators)
        {
            ApplyProperties(item, key, label, SchemaItemType.Checkbox, validators);

            return(item);
        }
Exemple #12
0
 public static SchemaItem TextArea(this SchemaItem item, string key, int rows = 4, int maxRows = 4, params Validator[] validators)
 => item.TextArea(key, String.Empty, rows, maxRows, validators);
Exemple #13
0
 public static SchemaItem Text(this SchemaItem item, string key, params Validator[] validators)
 => item.Text(key, String.Empty, validators);
Exemple #14
0
 // Finish building and return to Schema!
 public static Schema Build(this SchemaItem item) => item.Schema;