Пример #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);
        }
Пример #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);
        }
Пример #3
0
        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);
        }
Пример #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;
        }
Пример #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;
        }
Пример #6
0
 public static SchemaItem HasClass(this SchemaItem item, string className)
 {
     item.ClassName = className;
     return(item);
 }
Пример #7
0
 public static SchemaItem Select(this SchemaItem item, string key, Options options, params Validator[] validators)
 => item.Select(key, String.Empty, options, validators);
Пример #8
0
 public static SchemaItem Datepicker(this SchemaItem item, string key, params Validator[] validators)
 => item.Datepicker(key, String.Empty, validators);
Пример #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);
        }
Пример #10
0
 public static SchemaItem Checkbox(this SchemaItem item, string key, params Validator[] validators)
 => item.Checkbox(key, String.Empty, validators);
Пример #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);
        }
Пример #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);
Пример #13
0
 public static SchemaItem Text(this SchemaItem item, string key, params Validator[] validators)
 => item.Text(key, String.Empty, validators);
Пример #14
0
 // Finish building and return to Schema!
 public static Schema Build(this SchemaItem item) => item.Schema;