various code quality fixes (#5792)

* various code quality fixes

* reduce duplicated code

* add safety check
This commit is contained in:
Denys Vuika
2020-06-18 17:57:46 +01:00
committed by GitHub
parent dc2060fe49
commit e9350bd297
54 changed files with 96 additions and 154 deletions

View File

@@ -98,7 +98,7 @@ export abstract class FormBaseComponent {
}
hasForm(): boolean {
return this.form ? true : false;
return !!this.form;
}
isTitleEnabled(): boolean {

View File

@@ -53,19 +53,19 @@
}
hasPreviewStatus(): boolean {
return this.previewStatus === 'supported' ? true : false;
return this.previewStatus === 'supported';
}
isTypeImage(): boolean {
return this.simpleType === 'image' ? true : false;
return this.simpleType === 'image';
}
isTypePdf(): boolean {
return this.simpleType === 'pdf' ? true : false;
return this.simpleType === 'pdf';
}
isTypeDoc(): boolean {
return this.simpleType === 'word' || this.simpleType === 'content' ? true : false;
return this.simpleType === 'word' || this.simpleType === 'content';
}
isThumbnailReady(): boolean {

View File

@@ -27,8 +27,8 @@ export class ErrorMessageModel {
this.attributes = new Map();
}
isActive() {
return this.message ? true : false;
isActive(): boolean {
return !!this.message;
}
getAttributesAsJsonObj() {

View File

@@ -80,7 +80,7 @@ export class RequiredFieldValidator implements FormFieldValidator {
}
if (field.type === FormFieldTypes.BOOLEAN) {
return field.value ? true : false;
return !!field.value;
}
if (field.value === null || field.value === undefined || field.value === '') {

View File

@@ -221,7 +221,7 @@ export class FormFieldModel extends FormWidgetModel {
}
private isTypeaheadFieldType(type: string): boolean {
return type === 'typeahead' ? true : false;
return type === 'typeahead';
}
private getFieldNameWithLabel(name: string): string {
@@ -419,11 +419,7 @@ export class FormFieldModel extends FormWidgetModel {
* @param type
*/
isInvalidFieldType(type: string) {
if (type === 'container') {
return true;
} else {
return false;
}
return type === 'container';
}
getOptionName(): string {

View File

@@ -154,7 +154,7 @@ export class FormModel {
}
}
this.isValid = errorsField.length > 0 ? false : true;
this.isValid = errorsField.length <= 0;
if (this.formService) {
validateFormEvent.isValid = this.isValid;

View File

@@ -110,7 +110,7 @@ export class DropdownWidgetComponent extends WidgetComponent implements OnInit {
}
isReadOnlyType(): boolean {
return this.field.type === 'readonly' ? true : false;
return this.field.type === 'readonly';
}
}

View File

@@ -180,7 +180,7 @@ export class DynamicTableModel extends FormWidgetModel {
}
if (column.type === 'Boolean') {
return rowValue ? true : false;
return !!rowValue;
}
if (column.type === 'Date') {

View File

@@ -59,8 +59,8 @@ export class WidgetComponent implements AfterViewInit {
constructor(public formService?: FormService) {
}
hasField() {
return this.field ? true : false;
hasField(): boolean {
return !!this.field;
}
// Note for developers:
@@ -73,7 +73,7 @@ export class WidgetComponent implements AfterViewInit {
}
isValid(): boolean {
return this.field.validationSummary ? true : false;
return !!this.field.validationSummary;
}
hasValue(): boolean {