Skip to content

Commit

Permalink
Fix Skip Export: BOOLEAN Custom Field Type (new integrations) (#475)
Browse files Browse the repository at this point in the history
Skip Export
  • Loading branch information
anishfyle authored Jan 30, 2024
1 parent 22dfc45 commit 11630a6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/core/models/si/misc/skip-export.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function constructPayload1(valueField: {
operator: valueField.operator1,
values:
valueField.condition1.type === 'DATE' ||
valueField.operator1 === 'isnull' || valueField.condition1.field_name === 'report_title'
valueField.operator1 === 'isnull' || valueField.condition1.field_name === 'report_title' || valueField.condition1.type === 'BOOLEAN'
? valueField.value1
: valueOption1,
rank: 1,
Expand All @@ -45,7 +45,7 @@ export function constructPayload2(valueField: {
operator: valueField.operator2,
values:
valueField.condition2.type === 'DATE' ||
valueField.operator2 === 'isnull' || valueField.condition2.field_name === 'report_title'
valueField.operator2 === 'isnull' || valueField.condition2.field_name === 'report_title' || valueField.condition2.type === 'BOOLEAN'
? valueField.value2
: valueOption2,
rank: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<p-chips [addOnBlur]="true" styleClass="tw-w-[296px]" [(ngModel)]="valueOption1" formControlName="value1" separator="," placeholder="Enter Value"></p-chips>
<small class="chip-hint"><br>Separate your values with a comma or enter key.</small>
</div>
<div class="tw-w-296-px" *ngIf="showBooleanField1()">
<p-dropdown appendTo="body" formControlName="value1" placeholder="Select Value" [options]="customCheckBoxValueOptions">
</p-dropdown>
</div>
</div>

<div *ngIf="showAdditionalCondition" class="tw-pb-24-px">
Expand Down Expand Up @@ -105,6 +109,10 @@
<div *ngIf="showDateField2()" class="tw-w-296-px">
<p-calendar formControlName="value2" [readonlyInput]="true" placeholder="Select Date"></p-calendar>
</div>
<div class="tw-w-296-px" *ngIf="showBooleanField2()">
<p-dropdown appendTo="body" formControlName="value2" placeholder="Select Value" [options]="customCheckBoxValueOptions">
</p-dropdown>
</div>
<svg-icon-sprite src="bin" width="24px" height="24px" class="tw-text-sub-text-color delete-icon" [pTooltip]="'Remove Condition'" (click)="remCondition()"></svg-icon-sprite>
</div>
<div class=" tw-text-mandatory-field-color" *ngIf="checkValidationCondition()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ export class SkipExportComponent implements OnInit {

valueOption2: any[] = [];

customCheckBoxValueOptions: { label: string; value: string; }[] = [
{
label: 'Yes',
value: 'true'
},
{
label: 'No',
value: 'false'
}
];

constructor(
private formBuilder: FormBuilder,
private advancedSettingsService: SiAdvancedSettingService
Expand Down Expand Up @@ -166,7 +177,7 @@ export class SkipExportComponent implements OnInit {
getFieldValue(value: any, condition: ConditionField, rank: number) {
if (condition.type === 'DATE') {
return new Date(value[0]);
} else if (condition.field_name === 'report_title') {
} else if (condition.field_name === 'report_title' || condition.type === 'BOOLEAN') {
return value[0];
}
if (rank === 1) {
Expand Down Expand Up @@ -271,6 +282,10 @@ export class SkipExportComponent implements OnInit {
return this.skipExportForm.value?.condition1?.type==='DATE' && (this.skipExportForm.value.operator1 !== 'is_empty' || this.skipExportForm.value.operator1 !== 'is_not_empty');
}

showBooleanField1() {
return this.skipExportForm.value?.condition1?.type==='BOOLEAN';
}

showInputField2() {
return this.skipExportForm.value?.condition2?.field_name && this.skipExportForm.value?.condition2?.field_name === 'report_title' && (this.skipExportForm.value.operator2 !== 'is_empty' || this.skipExportForm.value.operator2 !== 'is_not_empty');
}
Expand All @@ -283,6 +298,10 @@ export class SkipExportComponent implements OnInit {
return this.skipExportForm.value?.condition2?.type==='DATE' && (this.skipExportForm.value.operator2 !== 'is_empty' || this.skipExportForm.value.operator2 !== 'is_not_empty');
}

showBooleanField2() {
return this.skipExportForm.value?.condition2?.type==='BOOLEAN';
}

saveSkipExportFields() {
if (!this.skipExportForm.valid) {
return;
Expand Down Expand Up @@ -392,7 +411,19 @@ export class SkipExportComponent implements OnInit {
}

setCustomOperatorOptions(rank: number, type: string) {
if (type !== 'SELECT') {
if (type === 'BOOLEAN') {
const customCheckBoxOperatorOptions: { label: string; value: string; }[] = [
{
label: 'Is',
value: 'exact'
}
];
if (rank === 1) {
this.operatorFieldOptions1 = customCheckBoxOperatorOptions;
} else if (rank === 2) {
this.operatorFieldOptions2 = customCheckBoxOperatorOptions;
}
} else if (type !== 'SELECT') {
if (rank === 1) {
this.operatorFieldOptions1 = this.customOperatorOptions;
} else if (rank === 2) {
Expand Down

0 comments on commit 11630a6

Please sign in to comment.