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

dotCMS/core#25901 Unable to reuse content inside the variants #26450

Merged
merged 3 commits into from Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -234,4 +234,15 @@ describe('DotPaletteComponent', () => {

expect(store.setAllowedContent).toHaveBeenCalledWith(allowedContent);
});

it('should change view and load data when the lang change.', async () => {
comp.languageId = '2';

fixture.detectChanges();
await fixture.whenStable();

expect(store.setLanguageId).toHaveBeenCalledWith('2');
expect(store.switchView).toHaveBeenCalled();
expect(store.getContenttypesData).toHaveBeenCalled();
});
});
@@ -1,7 +1,7 @@
import { Observable } from 'rxjs';

import { animate, AnimationEvent, state, style, transition, trigger } from '@angular/animations';
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { Component, Input, ViewChild } from '@angular/core';

import { LazyLoadEvent } from 'primeng/api';

Expand Down Expand Up @@ -32,23 +32,22 @@ import { DotPaletteState, DotPaletteStore } from './store/dot-palette.store';
])
]
})
export class DotPaletteComponent implements OnInit {
export class DotPaletteComponent {
@Input() set allowedContent(items: string[]) {
this.store.setAllowedContent(items);
}
@Input() languageId: string;
@Input() set languageId(languageId: string) {
this.store.setLanguageId(languageId);
this.store.switchView();
this.store.getContenttypesData();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can unify this in one updater because here you are updating the state 3 times and triggering changes 3 times.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch thanks. done, at least a couple less.

}
vm$: Observable<DotPaletteState> = this.store.vm$;

@ViewChild('contentlets') contentlets: DotPaletteContentletsComponent;
@ViewChild('contentTypes') contentTypes: DotPaletteContentTypeComponent;

constructor(private store: DotPaletteStore) {}

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

/**
* Sets value on store to show/hide components on the UI
*
Expand Down