Esempio n. 1
0
        public static SchemaItem TextArea(this SchemaItem item, string key, string label, int rows = 4, params Validator[] validators)
        {
            ApplyProperties(item, key, label, SchemaItemType.Textarea, validators);
            item.TextareaRows = rows;

            return(item);
        }
Esempio n. 2
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);
        }
        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);
        }
Esempio n. 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;
        }
Esempio n. 5
0
 public static SchemaItem HasClass(this SchemaItem item, string className)
 {
     item.ClassName = className;
     return(item);
 }
Esempio n. 6
0
 public static SchemaItem Select(this SchemaItem item, string key, Options options, params Validator[] validators)
 => item.Select(key, String.Empty, options, validators);
Esempio n. 7
0
 public static SchemaItem Datepicker(this SchemaItem item, string key, params Validator[] validators)
 => item.Datepicker(key, String.Empty, validators);
Esempio n. 8
0
        public static SchemaItem Datepicker(this SchemaItem item, string key, string label, params Validator[] validators)
        {
            ApplyProperties(item, key, label, SchemaItemType.Datepicker, validators);

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

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