Created
October 22, 2020 02:52
-
-
Save J-Graham/b694dbaaef4144c4cefa39683cdb1601 to your computer and use it in GitHub Desktop.
Customer Form Group Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CustomerDynamicControls { | |
formGroup: string; | |
statuses: ICustomerStatus[]; | |
sources: ICustomerSource[]; | |
Form: IExpandableObject; | |
View: IExpandableObject; | |
constructor(private customer?: ICustomer, additionalParameters?: ICustomerDynamicControlsParameters) { | |
this.formGroup = additionalParameters && additionalParameters.formGroup || 'Customer'; | |
this.statuses = additionalParameters && additionalParameters.statuses || undefined; | |
this.sources = additionalParameters && additionalParameters.sources || undefined; | |
this.Form = { | |
Name: new DynamicField({ | |
formGroup: this.formGroup, | |
label: 'Name', | |
name: 'Name', | |
options: null, | |
type: new DynamicFieldType({ | |
fieldType: DynamicFieldTypes.Input, | |
inputType: null, | |
scale: null, | |
}), | |
validation: [ Validators.required, Validators.maxLength(50) ], | |
validators: { 'required': true, 'maxlength': 50 }, | |
value: this.customer && this.customer.hasOwnProperty('Name') && this.customer.Name !== null ? this.customer.Name.toString() : '', | |
}), | |
SourceId: new DynamicField({ | |
formGroup: this.formGroup, | |
label: 'Source', | |
name: 'SourceId', | |
options: this.sources, | |
type: new DynamicFieldType({ | |
fieldType: DynamicFieldTypes.Select, | |
inputType: null, | |
scale: null, | |
}), | |
validation: [ noZeroRequiredValidator ], | |
validators: { 'required': true }, | |
value: this.customer && this.customer.SourceId || null, | |
}), | |
StatusId: new DynamicField({ | |
formGroup: this.formGroup, | |
label: 'Status', | |
name: 'StatusId', | |
options: this.statuses, | |
type: new DynamicFieldType({ | |
fieldType: DynamicFieldTypes.Select, | |
inputType: null, | |
scale: null, | |
}), | |
validation: [ noZeroRequiredValidator ], | |
validators: { 'required': true }, | |
value: this.customer && this.customer.StatusId || null, | |
}), | |
}; | |
this.View = { | |
Name: new DynamicLabel( | |
'Name', | |
this.customer && this.customer.hasOwnProperty('Name') && this.customer.Name !== null ? this.customer.Name.toString() : '', | |
new DynamicFieldType({ | |
fieldType: DynamicFieldTypes.Input, | |
inputType: null, | |
scale: null, | |
}), | |
), | |
SourceId: new DynamicLabel( | |
'Source', | |
getMetaItemValue(this.sources, this.customer && this.customer.hasOwnProperty('SourceId') && this.customer.SourceId !== null ? this.customer.SourceId : null), | |
new DynamicFieldType({ | |
fieldType: DynamicFieldTypes.Select, | |
inputType: null, | |
scale: null, | |
}), | |
), | |
StatusId: new DynamicLabel( | |
'Status', | |
getMetaItemValue(this.statuses, this.customer && this.customer.hasOwnProperty('StatusId') && this.customer.StatusId !== null ? this.customer.StatusId : null), | |
new DynamicFieldType({ | |
fieldType: DynamicFieldTypes.Select, | |
inputType: null, | |
scale: null, | |
}), | |
), | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment