Skip to content

Commit

Permalink
fix(containers): Filtered Rows and Columns in variables list (#26196)
Browse files Browse the repository at this point in the history
* Filtered Rows and Columns in variables list

* Added enum to FilteredTypes, added test case on FilteredTypes
  • Loading branch information
KevinDavilaDotCMS committed Sep 25, 2023
1 parent 71ad1f3 commit 7357e72
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Expand Up @@ -51,6 +51,7 @@ import {
import { DotRouterService } from '@services/dot-router/dot-router.service';

import { DotAddVariableComponent } from './dot-add-variable.component';
import { FilteredFieldTypes } from './dot-add-variable.models';

@Component({
selector: 'dot-form-dialog',
Expand Down Expand Up @@ -252,5 +253,14 @@ describe('DotAddVariableComponent', () => {
);
expect(dialogRef.close).toHaveBeenCalled();
});

it('should be a variable list without FielteredTypes', () => {
const fieldTypes = fixture.nativeElement.querySelectorAll('small');
fieldTypes.forEach((field) => {
const content = field.textContent.trim();
expect(content).not.toEqual(FilteredFieldTypes.Column);
expect(content).not.toEqual(FilteredFieldTypes.Row);
});
});
});
});
Expand Up @@ -2,16 +2,30 @@ import { Component, OnInit } from '@angular/core';

import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';

import { map } from 'rxjs/operators';

import { DotAddVariableStore } from '@dotcms/app/portlets/dot-containers/dot-container-create/dot-container-code/dot-add-variable/store/dot-add-variable.store';

import { FilteredFieldTypes } from './dot-add-variable.models';

@Component({
selector: 'dot-add-variable',
templateUrl: './dot-add-variable.component.html',
styleUrls: ['./dot-add-variable.component.scss'],
providers: [DotAddVariableStore]
})
export class DotAddVariableComponent implements OnInit {
vm$ = this.store.vm$;
vm$ = this.store.vm$.pipe(
map((res) => {
const variables = res.variables.filter(
(variable) =>
variable.fieldType !== FilteredFieldTypes.Column &&
variable.fieldType !== FilteredFieldTypes.Row
);

return { variables };
})
);

constructor(
private store: DotAddVariableStore,
Expand Down
@@ -0,0 +1,4 @@
export enum FilteredFieldTypes {
Column = 'Column',
Row = 'Row'
}

0 comments on commit 7357e72

Please sign in to comment.