build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
@@ -15,7 +15,6 @@ import { columnTypeData } from '../column-type-data';
|
||||
styleUrls: ['./column-dialog.component.scss']
|
||||
})
|
||||
export class ColumnDialogComponent implements OnInit {
|
||||
|
||||
/** Column Form. */
|
||||
columnForm: UntypedFormGroup;
|
||||
/** Column Type Data */
|
||||
@@ -26,22 +25,53 @@ export class ColumnDialogComponent implements OnInit {
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {any} data Provides the column codes and values for the form (if available).
|
||||
*/
|
||||
constructor(public dialogRef: MatDialogRef<ColumnDialogComponent>,
|
||||
public formBuilder: UntypedFormBuilder,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any) { }
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ColumnDialogComponent>,
|
||||
public formBuilder: UntypedFormBuilder,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates the add column form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.columnForm = this.formBuilder.group({
|
||||
'name': [this.data ? this.data.columnName : '', Validators.required],
|
||||
'type': [{ value: this.data ? (this.data.columnDisplayType === '' ? '' : this.getColumnType(this.data.columnDisplayType)) : '', disabled: this.data.type === 'existing' }, Validators.required],
|
||||
'length': [{ value: this.data ? + this.data.columnLength : '', disabled: this.getColumnType(this.data.columnDisplayType) !== 'String' || this.data.type === 'existing' }, Validators.required],
|
||||
'mandatory': [{ value: this.data.isColumnNullable, disabled: this.data.type === 'existing' }],
|
||||
'unique': [{ value: this.data.isColumnUnique, disabled: this.data.isColumnNullable || this.data.type === 'existing' }],
|
||||
'indexed': [{ value: this.data.isColumnIndexed, disabled: this.data.type === 'existing' }],
|
||||
'code': [{ value: this.data ? this.data.columnCode : '', disabled: this.getColumnType(this.data.columnDisplayType) !== 'Dropdown' || this.data.type === 'existing' }, Validators.required],
|
||||
name: [
|
||||
this.data ? this.data.columnName : '',
|
||||
Validators.required
|
||||
],
|
||||
type: [
|
||||
{
|
||||
value: this.data
|
||||
? this.data.columnDisplayType === ''
|
||||
? ''
|
||||
: this.getColumnType(this.data.columnDisplayType)
|
||||
: '',
|
||||
disabled: this.data.type === 'existing'
|
||||
},
|
||||
Validators.required
|
||||
|
||||
],
|
||||
length: [
|
||||
{
|
||||
value: this.data ? +this.data.columnLength : '',
|
||||
disabled: this.getColumnType(this.data.columnDisplayType) !== 'String' || this.data.type === 'existing'
|
||||
},
|
||||
Validators.required
|
||||
|
||||
],
|
||||
mandatory: [{ value: this.data.isColumnNullable, disabled: this.data.type === 'existing' }],
|
||||
unique: [
|
||||
{ value: this.data.isColumnUnique, disabled: this.data.isColumnNullable || this.data.type === 'existing' }],
|
||||
indexed: [{ value: this.data.isColumnIndexed, disabled: this.data.type === 'existing' }],
|
||||
code: [
|
||||
{
|
||||
value: this.data ? this.data.columnCode : '',
|
||||
disabled: this.getColumnType(this.data.columnDisplayType) !== 'Dropdown' || this.data.type === 'existing'
|
||||
},
|
||||
Validators.required
|
||||
|
||||
]
|
||||
});
|
||||
this.onColumnTypeChanges();
|
||||
}
|
||||
@@ -72,25 +102,24 @@ export class ColumnDialogComponent implements OnInit {
|
||||
* Watches on Column Type field to enable/diable certain fields.
|
||||
*/
|
||||
onColumnTypeChanges() {
|
||||
this.columnForm.get('type').valueChanges
|
||||
.subscribe(type => {
|
||||
switch (type) {
|
||||
case 'String': {
|
||||
this.columnForm.get('length').enable();
|
||||
this.columnForm.get('code').disable();
|
||||
break;
|
||||
}
|
||||
case 'Dropdown': {
|
||||
this.columnForm.get('code').enable();
|
||||
this.columnForm.get('length').disable();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.columnForm.get('code').disable();
|
||||
this.columnForm.get('length').disable();
|
||||
}
|
||||
this.columnForm.get('type').valueChanges.subscribe((type) => {
|
||||
switch (type) {
|
||||
case 'String': {
|
||||
this.columnForm.get('length').enable();
|
||||
this.columnForm.get('code').disable();
|
||||
break;
|
||||
}
|
||||
});
|
||||
case 'Dropdown': {
|
||||
this.columnForm.get('code').enable();
|
||||
this.columnForm.get('length').disable();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.columnForm.get('code').disable();
|
||||
this.columnForm.get('length').disable();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,5 +128,4 @@ export class ColumnDialogComponent implements OnInit {
|
||||
submit() {
|
||||
this.dialogRef.close(this.columnForm.value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user