Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredo-dotcms committed Jan 27, 2022
1 parent 2005bfa commit da3326a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ const storeMock = jasmine.createSpyObj(
'DotPaletteStore',
[
'getContentletsData',
'filter',
'languageId',
'viewContentlet',
'setFilter',
'setLanguageId',
'setViewContentlet',
'setLoading',
'setLoaded',
'loadContentTypes',
Expand Down Expand Up @@ -153,8 +153,8 @@ describe('DotPaletteComponent', () => {

const wrapper = fixture.debugElement.query(By.css('[data-testid="wrapper"]'));
expect(wrapper.nativeElement.style.transform).toEqual('translateX(0%)');
expect(store.viewContentlet).toHaveBeenCalledWith('contentlet:in');
expect(store.filter).toHaveBeenCalledWith('');
expect(store.setViewContentlet).toHaveBeenCalledWith('contentlet:in');
expect(store.setFilter).toHaveBeenCalledWith('');
expect(store.loadContentlets).toHaveBeenCalledWith('Blog');
expect(contentContentletsComp.componentInstance.totalRecords).toBe(20);
expect(contentContentletsComp.componentInstance.items).toEqual([contentletProductDataMock]);
Expand All @@ -169,7 +169,7 @@ describe('DotPaletteComponent', () => {
fixture.detectChanges();
await fixture.whenStable();

expect(store.viewContentlet).toHaveBeenCalledWith('contentlet:out');
expect(store.setViewContentlet).toHaveBeenCalledWith('contentlet:out');
});

it('should set value on store on filtering event', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class DotPaletteComponent implements OnInit {
constructor(private store: DotPaletteStore) {}

ngOnInit(): void {
this.store.languageId(this.languageId);
this.store.setLanguageId(this.languageId);
}

/**
Expand All @@ -57,8 +57,8 @@ export class DotPaletteComponent implements OnInit {
switchView(variableName?: string): void {
const viewContentlet = variableName ? 'contentlet:in' : 'contentlet:out';

this.store.viewContentlet(viewContentlet);
this.store.filter('');
this.store.setViewContentlet(viewContentlet);
this.store.setFilter('');
this.store.loadContentlets(variableName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ describe('DotPaletteStore', () => {
});

it('should update filter', () => {
dotPaletteStore.filter('test');
dotPaletteStore.setFilter('test');
dotPaletteStore.state$.subscribe((data) => {
expect(data.filter).toEqual('test');
});
});

it('should update languageId', () => {
dotPaletteStore.languageId('1');
dotPaletteStore.setLanguageId('1');
dotPaletteStore.state$.subscribe((data) => {
expect(data.languageId).toEqual('1');
});
});

it('should update viewContentlet', () => {
dotPaletteStore.viewContentlet('in');
dotPaletteStore.setViewContentlet('in');
dotPaletteStore.state$.subscribe((data) => {
expect(data.viewContentlet).toEqual('in');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export class DotPaletteStore extends ComponentStore<DotPaletteState> {
.subscribe((data: DotCMSContentlet[] | DotCMSContentType[]) => {
data.forEach((item) => (item.contentType = item.variable = 'FORM'));
this.setLoaded();
this.contentlets(data);
this.totalRecords(this.paginationService.totalRecords);
this.setContentlets(data);
this.setTotalRecords(this.paginationService.totalRecords);
});
} else {
let langId: string;
Expand All @@ -87,8 +87,8 @@ export class DotPaletteStore extends ComponentStore<DotPaletteState> {
.pipe(take(1))
.subscribe((response: ESContent) => {
this.setLoaded();
this.totalRecords(response.resultsSize);
this.contentlets(response.jsonObjectView.contentlets);
this.setTotalRecords(response.resultsSize);
this.setContentlets(response.jsonObjectView.contentlets);
});
}
}
Expand Down Expand Up @@ -144,31 +144,31 @@ export class DotPaletteStore extends ComponentStore<DotPaletteState> {
);

// UPDATERS
private readonly contentlets = this.updater(
private readonly setContentlets = this.updater(
(state: DotPaletteState, data: DotCMSContentlet[] | DotCMSContentType[]) => {
return { ...state, contentlets: data };
}
);

private readonly contentTypes = this.updater(
private readonly setContentTypes = this.updater(
(state: DotPaletteState, data: DotCMSContentType[]) => {
return { ...state, contentTypes: data };
}
);

private readonly totalRecords = this.updater((state: DotPaletteState, data: number) => {
private readonly setTotalRecords = this.updater((state: DotPaletteState, data: number) => {
return { ...state, totalRecords: data };
});

readonly filter = this.updater((state: DotPaletteState, data: string) => {
readonly setFilter = this.updater((state: DotPaletteState, data: string) => {
return { ...state, filter: data };
});

readonly languageId = this.updater((state: DotPaletteState, data: string) => {
readonly setLanguageId = this.updater((state: DotPaletteState, data: string) => {
return { ...state, languageId: data };
});

readonly viewContentlet = this.updater((state: DotPaletteState, data: string) => {
readonly setViewContentlet = this.updater((state: DotPaletteState, data: string) => {
return { ...state, viewContentlet: data };
});

Expand All @@ -190,15 +190,15 @@ export class DotPaletteStore extends ComponentStore<DotPaletteState> {
readonly loadContentTypes = this.effect((data$: Observable<DotCMSContentType[]>) => {
return data$.pipe(
map((data) => {
this.contentTypes(data);
this.setContentTypes(data);
})
);
});

readonly filterContentlets = this.effect((filterValue$: Observable<string>) => {
return filterValue$.pipe(
map((value: string) => {
this.filter(value);
this.setFilter(value);

if (this.isFormContentType) {
this.paginationService.searchParam = 'variable';
Expand Down

0 comments on commit da3326a

Please sign in to comment.