Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | export class DynamicInput<T>{ |
| 2 | |
| 3 | id: string; |
| 4 | name: string; |
| 5 | type: string; |
| 6 | description: string; |
| 7 | value: T; |
| 8 | prompt: any; |
| 9 | maxLength: number; |
| 10 | minLength: number; |
| 11 | isVisible: boolean; |
| 12 | isRequired: boolean; |
| 13 | isEnabled: boolean; |
| 14 | isReadOnly: boolean; |
| 15 | |
| 16 | |
| 17 | constructor(options: { |
| 18 | id?: string, |
| 19 | name?: string, |
| 20 | type: string, |
| 21 | description?: string, |
| 22 | value?: T, |
| 23 | prompt?: any, |
| 24 | maxLength?: number, |
| 25 | minLength?: number, |
| 26 | isVisible?: boolean, |
| 27 | isRequired?: boolean, |
| 28 | isEnabled?: boolean, |
| 29 | isReadOnly?: boolean, |
| 30 | }) { |
| 31 | this.id = options.id; |
| 32 | this.name = options.name || ''; |
| 33 | this.type = options.type; |
| 34 | this.description = options.description || ''; |
| 35 | this.value = options.value; |
| 36 | this.prompt = options.prompt; |
| 37 | this.maxLength = options.maxLength; |
| 38 | this.minLength = options.minLength; |
| 39 | this.isVisible = options.isVisible == false? options.isVisible: true; |
| 40 | this.isEnabled = options.isEnabled == false? options.isEnabled: true; |
| 41 | this.isRequired = options.isRequired == null? false: options.isRequired; |
| 42 | this.isReadOnly = options.isReadOnly == null? false: options.isReadOnly; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export class DynamicNumber extends DynamicInput<number> { |
| 47 | |
| 48 | max: number; |
| 49 | min: number; |
| 50 | |
| 51 | constructor(options: { |
| 52 | id?: string, |
| 53 | name?: string, |
| 54 | type: string, |
| 55 | description?: string, |
| 56 | value?: number, |
| 57 | prompt?: any, |
| 58 | maxLength?: number, |
| 59 | minLength?: number, |
| 60 | isVisible?: boolean, |
| 61 | isRequired?: boolean, |
| 62 | isEnabled?: boolean, |
| 63 | isReadOnly?: boolean, |
| 64 | max?: number, |
| 65 | min?: number |
| 66 | }){ |
| 67 | super(options); |
| 68 | this.max = options.max; |
| 69 | this.min = options.min; |
| 70 | } |
| 71 | |
| 72 | } |
| 73 | |
| 74 | export class DynamicSelect extends DynamicInput<any> { |
| 75 | optionList: any[]; |
| 76 | |
| 77 | constructor(options: { |
| 78 | id?: string, |
| 79 | name?: string, |
| 80 | type: string, |
| 81 | description?: string, |
| 82 | value?: any, |
| 83 | prompt?: any, |
| 84 | maxLength?: number, |
| 85 | minLength?: number, |
| 86 | isVisible?: boolean, |
| 87 | isRequired?: boolean, |
| 88 | isEnabled?: boolean, |
| 89 | isReadOnly?: boolean, |
| 90 | optionList?: any[] |
| 91 | }) { |
| 92 | super(options); |
| 93 | this.optionList = options.optionList || []; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | export class DynamicMultiSelect extends DynamicSelect { |
| 98 | selectedItems: any[]; |
| 99 | settings: any; |
| 100 | |
| 101 | constructor(options: { |
| 102 | id?: string, |
| 103 | name?: string, |
| 104 | type: string, |
| 105 | description?: string, |
| 106 | value?: any, |
| 107 | prompt?: any, |
| 108 | maxLength?: number, |
| 109 | minLength?: number, |
| 110 | isVisible?: boolean, |
| 111 | isRequired?: boolean, |
| 112 | isEnabled?: boolean, |
| 113 | isReadOnly?: boolean, |
| 114 | settings?: any, |
| 115 | optionList?: any[], |
| 116 | selectedItems?: any[] |
| 117 | }) { |
| 118 | super(options); |
| 119 | this.settings = options.settings || {}; |
| 120 | this.selectedItems = options.selectedItems || []; |
| 121 | } |
| 122 | } |
| 123 | |