Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(page-dynamic-search): melhora o disclaimer para campos booleanos #1636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,42 @@ describe('PoPageDynamicSearchComponent:', () => {
expect(component['setDisclaimers'](filters)).toEqual(result);
});

it('getFilterValueToDisclaimer: should return true if field type is PoDynamicFieldType.Boolean', () => {
const field = { type: PoDynamicFieldType.Boolean, property: '1', label: 'boolean' };
const value = true;

const result = component['getFilterValueToDisclaimer'](field, value);

expect(result).toBe(true);
});

it('getFilterValueToDisclaimer: should return yes if field type is PoDynamicFieldType.Boolean', () => {
const field = { type: PoDynamicFieldType.Boolean, property: '1', label: 'boolean', booleanTrue: 'Yes' };
const value = true;

const result = component['getFilterValueToDisclaimer'](field, value);

expect(result).toBe('Yes');
});

it('getFilterValueToDisclaimer: should return false if field type is PoDynamicFieldType.Boolean', () => {
const field = { type: PoDynamicFieldType.Boolean, property: '1', label: 'boolean' };
const value = false;

const result = component['getFilterValueToDisclaimer'](field, value);

expect(result).toBe(false);
});

it('getFilterValueToDisclaimer: should return no if field type is PoDynamicFieldType.Boolean', () => {
const field = { type: PoDynamicFieldType.Boolean, property: '1', label: 'boolean', booleanFalse: 'No' };
const value = false;

const result = component['getFilterValueToDisclaimer'](field, value);

expect(result).toBe('No');
});

it('getFilterValueToDisclaimer: should return formated date if field type is PoDynamicFieldType.Date', () => {
const field = { type: PoDynamicFieldType.Date, property: '1', label: 'date' };
const value = '2020-08-12';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export class PoPageDynamicSearchComponent extends PoPageDynamicSearchBaseCompone
}

private getFilterValueToDisclaimer(field: any, value: any, optionsServiceObjectsList?: Array<PoComboOption>) {
if (field.type === PoDynamicFieldType.Boolean) {
value = value ? field.booleanTrue || value : field.booleanFalse || value;
}

if (field.optionsService && optionsServiceObjectsList) {
return this.optionsServiceDisclaimerLabel(value, optionsServiceObjectsList);
}
Expand Down