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