From e0b5efccd8cdd7df39e7e7f861057aa3e8681fac Mon Sep 17 00:00:00 2001 From: Nicolas Molina Monroy Date: Fri, 3 Jan 2025 17:38:25 -0400 Subject: [PATCH] chore(edit-content): apply format to relationships (#31048) ### Parent Issue #31040 ### Proposed Changes This pull request introduces a new enumeration `DotContentletDepths` to manage the depth of contentlets and updates various components to utilize this enumeration. The changes include updates to type definitions, imports, and method calls to incorporate the new `DotContentletDepths` enum. ### Introduction of `DotContentletDepths` Enumeration: * Added `DotContentletDepths` enum to define the depth levels of contentlets in `dot-contentlet.model.ts`. ### Updates to Import Statements: * Updated import statements to include `DotContentletDepths` in `dot-edit-content-form.component.spec.ts`, `edit-content.store.ts`, `content.feature.ts`, `dot-edit-content-relationship-field.component.ts`, `dot-edit-content.service.spec.ts`, and `dot-edit-content.service.ts`. [[1]](diffhunk://#diff-ba170b6ba64e637bbeea8b08f81a725fc7de75cfb94e910ab35148aa4c377ec5L29-R29) [[2]](diffhunk://#diff-ed3e9ecca632a2f217989f35608b4eedd1576950bda10c74f8598e83a4703016L6-R6) [[3]](diffhunk://#diff-45e4158706adbaf57599a885340534ed77401e3c69ea593dd9b377ffacc36958R32) [[4]](diffhunk://#diff-479af3558b758325f127c8f7abe07cf9da59524f145b758f7c298e82a8e9cbadR15) [[5]](diffhunk://#diff-ee2c6ce1c6a997f7b2b87106dbc020dba9d7f42fcdc29caebe547f6963e7caabL13-R13) ### Updates to Method Calls: * Modified `initializeExistingContent` method calls to include the `depth` parameter in `dot-edit-content-form.component.spec.ts` and `edit-content.store.ts`. [[1]](diffhunk://#diff-ba170b6ba64e637bbeea8b08f81a725fc7de75cfb94e910ab35148aa4c377ec5L125-R128) [[2]](diffhunk://#diff-ba170b6ba64e637bbeea8b08f81a725fc7de75cfb94e910ab35148aa4c377ec5L203-R209) [[3]](diffhunk://#diff-ba170b6ba64e637bbeea8b08f81a725fc7de75cfb94e910ab35148aa4c377ec5L296-R305) [[4]](diffhunk://#diff-ba170b6ba64e637bbeea8b08f81a725fc7de75cfb94e910ab35148aa4c377ec5L310-R322) [[5]](diffhunk://#diff-ba170b6ba64e637bbeea8b08f81a725fc7de75cfb94e910ab35148aa4c377ec5L323-R338) [[6]](diffhunk://#diff-ba170b6ba64e637bbeea8b08f81a725fc7de75cfb94e910ab35148aa4c377ec5L337-R355) [[7]](diffhunk://#diff-ed3e9ecca632a2f217989f35608b4eedd1576950bda10c74f8598e83a4703016L49-R49) ### Enhancements to Relationship Field Store: * Added a new test file `relationship-field.store.spec.ts` to validate the functionality of `RelationshipFieldStore`. * Enhanced `relationship-field.store.ts` by adding computed properties for pagination, disabling create new content button, and formatting relationships. Removed unnecessary hooks and methods. [[1]](diffhunk://#diff-a2c980da63c75c9dc2cd899475beab89cb79492b1dc0819574fc380e856e7ed1L5-L15) [[2]](diffhunk://#diff-a2c980da63c75c9dc2cd899475beab89cb79492b1dc0819574fc380e856e7ed1R50-R58) [[3]](diffhunk://#diff-a2c980da63c75c9dc2cd899475beab89cb79492b1dc0819574fc380e856e7ed1R68-R76) [[4]](diffhunk://#diff-a2c980da63c75c9dc2cd899475beab89cb79492b1dc0819574fc380e856e7ed1L118-L124) [[5]](diffhunk://#diff-a2c980da63c75c9dc2cd899475beab89cb79492b1dc0819574fc380e856e7ed1L151-L155) ### Service Method Updates: * Updated `dot-edit-content.service.spec.ts` to include a test for getting content by id and depth. ### Checklist - [x] Tests - [x] Translations - [x] Security Implications Contemplated (add notes if applicable) --- .../src/lib/dot-contentlet.model.ts | 30 ++++ .../dot-edit-content-form.component.spec.ts | 32 +++- .../upload-file/upload-file.service.ts | 2 +- ...it-content-relationship-field.component.ts | 8 + .../store/relationship-field.store.spec.ts | 153 ++++++++++++++++++ .../store/relationship-field.store.ts | 42 +++-- .../services/dot-edit-content.service.spec.ts | 13 +- .../lib/services/dot-edit-content.service.ts | 26 ++- .../src/lib/store/edit-content.store.ts | 4 +- .../src/lib/store/features/content.feature.ts | 7 +- .../store/features/locales.feature.spec.ts | 5 +- .../src/lib/store/features/locales.feature.ts | 5 +- 12 files changed, 280 insertions(+), 47 deletions(-) create mode 100644 core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.spec.ts diff --git a/core-web/libs/dotcms-models/src/lib/dot-contentlet.model.ts b/core-web/libs/dotcms-models/src/lib/dot-contentlet.model.ts index 77939313c4f8..38a918b3e029 100644 --- a/core-web/libs/dotcms-models/src/lib/dot-contentlet.model.ts +++ b/core-web/libs/dotcms-models/src/lib/dot-contentlet.model.ts @@ -48,3 +48,33 @@ export interface DotContentletPermissions { PUBLISH?: string[]; CAN_ADD_CHILDREN?: string[]; } + +/** + * The depth of the contentlet. + * + * @enum {string} + * @property {string} ZERO - Without relationships + * @property {string} ONE - Retrieve the id of relationships + * @property {string} TWO - Retrieve relationships + * @property {string} THREE - Retrieve relationships with their relationships + */ +export enum DotContentletDepths { + /** + * Without relationships + */ + ZERO = '0', + /** + * Retrieve the id of relationships + */ + ONE = '1', + /** + * Retrieve relationships + */ + TWO = '2', + /** + * Retrieve relationships with their relationships + */ + THREE = '3' +} + +export type DotContentletDepth = `${DotContentletDepths}`; diff --git a/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts b/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts index 03ab4b8e7383..5e5fda6257b3 100644 --- a/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts +++ b/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts @@ -26,7 +26,7 @@ import { DotWorkflowsActionsService, DotWorkflowService } from '@dotcms/data-access'; -import { DotCMSWorkflowAction } from '@dotcms/dotcms-models'; +import { DotCMSWorkflowAction, DotContentletDepths } from '@dotcms/dotcms-models'; import { DotWorkflowActionsComponent } from '@dotcms/ui'; import { DotFormatDateServiceMock, @@ -122,7 +122,10 @@ describe('DotFormComponent', () => { ); dotWorkflowService.getWorkflowStatus.mockReturnValue(of(MOCK_WORKFLOW_STATUS)); - store.initializeExistingContent(MOCK_CONTENTLET_1_OR_2_TABS.inode); // called with the inode of the contentlet + store.initializeExistingContent({ + inode: MOCK_CONTENTLET_1_OR_2_TABS.inode, + depth: DotContentletDepths.ONE + }); // called with the inode of the contentlet spectator.detectChanges(); }); @@ -200,7 +203,10 @@ describe('DotFormComponent', () => { ); dotWorkflowService.getWorkflowStatus.mockReturnValue(of(MOCK_WORKFLOW_STATUS)); - store.initializeExistingContent(MOCK_CONTENTLET_1_OR_2_TABS.inode); // called with the inode of the contentlet + store.initializeExistingContent({ + inode: MOCK_CONTENTLET_1_OR_2_TABS.inode, + depth: DotContentletDepths.ONE + }); // called with the inode of the contentlet spectator.detectChanges(); }); @@ -293,7 +299,10 @@ describe('DotFormComponent', () => { ); dotWorkflowService.getWorkflowStatus.mockReturnValue(of(MOCK_WORKFLOW_STATUS)); - store.initializeExistingContent(MOCK_CONTENTLET_1_OR_2_TABS.inode); + store.initializeExistingContent({ + inode: MOCK_CONTENTLET_1_OR_2_TABS.inode, + depth: DotContentletDepths.ONE + }); spectator.detectChanges(); }); @@ -307,7 +316,10 @@ describe('DotFormComponent', () => { workflowActionsService.getWorkFlowActions.mockReturnValue( of(MOCK_SINGLE_WORKFLOW_ACTIONS) // Single workflow actions trigger the show ); - store.initializeExistingContent('inode'); + store.initializeExistingContent({ + inode: 'inode', + depth: DotContentletDepths.ONE + }); spectator.detectChanges(); const workflowActions = spectator.query(DotWorkflowActionsComponent); @@ -320,7 +332,10 @@ describe('DotFormComponent', () => { of(MOCK_MULTIPLE_WORKFLOW_ACTIONS) // Multiple workflow actions trigger the hide ); - store.initializeExistingContent('inode'); + store.initializeExistingContent({ + inode: 'inode', + depth: DotContentletDepths.ONE + }); spectator.detectChanges(); const workflowActions = spectator.query(DotWorkflowActionsComponent); @@ -334,7 +349,10 @@ describe('DotFormComponent', () => { workflowActionsService.getWorkFlowActions.mockReturnValue( of(MOCK_SINGLE_WORKFLOW_ACTIONS) ); - store.initializeExistingContent('inode'); + store.initializeExistingContent({ + inode: 'inode', + depth: DotContentletDepths.ONE + }); spectator.detectChanges(); const workflowActions = spectator.query(DotWorkflowActionsComponent); diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/services/upload-file/upload-file.service.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/services/upload-file/upload-file.service.ts index e8cd7c65e588..91d722a6969a 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/services/upload-file/upload-file.service.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/services/upload-file/upload-file.service.ts @@ -130,7 +130,7 @@ export class DotFileFieldUploadService { */ getContentById(identifier: string) { return this.#contentService - .getContentById(identifier) + .getContentById({ id: identifier }) .pipe(switchMap((contentlet) => this.#addContent(contentlet))); } diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/dot-edit-content-relationship-field.component.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/dot-edit-content-relationship-field.component.ts index 34cb07e40867..9995c8a76c2d 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/dot-edit-content-relationship-field.component.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/dot-edit-content-relationship-field.component.ts @@ -142,6 +142,14 @@ export class DotEditContentRelationshipFieldComponent implements ControlValueAcc allowSignalWrites: true } ); + + effect(() => { + if (this.onChange && this.onTouched) { + const value = this.store.formattedRelationship(); + this.onChange(value); + this.onTouched(); + } + }); } /** diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.spec.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.spec.ts new file mode 100644 index 000000000000..1b55434b4ef9 --- /dev/null +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.spec.ts @@ -0,0 +1,153 @@ +import { TestBed } from '@angular/core/testing'; + +import { ComponentStatus } from '@dotcms/dotcms-models'; + +import { RelationshipFieldStore } from './relationship-field.store'; + +import { RelationshipFieldItem } from '../models/relationship.models'; + +describe('RelationshipFieldStore', () => { + let store: InstanceType; + + const mockData: RelationshipFieldItem[] = [ + { id: '1', title: 'Content 1', language: '1', modDate: new Date().toISOString() }, + { id: '2', title: 'Content 2', language: '1', modDate: new Date().toISOString() }, + { id: '3', title: 'Content 3', language: '1', modDate: new Date().toISOString() } + ]; + + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [RelationshipFieldStore] + }); + + store = TestBed.inject(RelationshipFieldStore); + }); + + it('should be created', () => { + expect(store).toBeTruthy(); + }); + + describe('Initial State', () => { + it('should have correct initial state', () => { + expect(store.data()).toEqual([]); + expect(store.status()).toBe(ComponentStatus.INIT); + expect(store.selectionMode()).toBeNull(); + expect(store.pagination()).toEqual({ + offset: 0, + currentPage: 1, + rowsPerPage: 6 + }); + }); + }); + + describe('State Management', () => { + describe('setData', () => { + it('should set data correctly', () => { + store.setData(mockData); + expect(store.data()).toEqual(mockData); + }); + }); + + describe('setCardinality', () => { + it('should set single selection mode for ONE_TO_ONE relationship', () => { + store.setCardinality(2); // ONE_TO_ONE cardinality + expect(store.selectionMode()).toBe('single'); + }); + + it('should set multiple selection mode for other relationship types', () => { + store.setCardinality(0); // ONE_TO_MANY cardinality + expect(store.selectionMode()).toBe('multiple'); + }); + + it('should throw error for invalid cardinality', () => { + expect(() => store.setCardinality(999)).toThrow('Invalid relationship type'); + }); + }); + + describe('addData', () => { + it('should add new unique data to existing data', () => { + const initialData = [mockData[0]]; + const newData = [mockData[1], mockData[2]]; + + store.setData(initialData); + store.addData(newData); + + expect(store.data()).toEqual([...initialData, ...newData]); + }); + + it('should not add duplicate data', () => { + const initialData = [mockData[0]]; + const newData = [mockData[0], mockData[1]]; + + store.setData(initialData); + store.addData(newData); + + expect(store.data()).toEqual([mockData[0], mockData[1]]); + }); + }); + + describe('pagination', () => { + it('should handle next page correctly', () => { + store.nextPage(); + expect(store.pagination()).toEqual({ + offset: 6, + currentPage: 2, + rowsPerPage: 6 + }); + }); + + it('should handle previous page correctly', () => { + store.nextPage(); + store.previousPage(); + expect(store.pagination()).toEqual({ + offset: 0, + currentPage: 1, + rowsPerPage: 6 + }); + }); + }); + }); + + describe('Computed Properties', () => { + describe('totalPages', () => { + it('should compute total pages correctly', () => { + store.setData(mockData); + expect(store.totalPages()).toBe(1); + }); + + it('should handle empty data', () => { + expect(store.totalPages()).toBe(0); + }); + }); + + describe('isDisabledCreateNewContent', () => { + it('should disable for single mode with one item', () => { + store.setCardinality(2); // ONE_TO_ONE + store.setData([mockData[0]]); + expect(store.isDisabledCreateNewContent()).toBe(true); + }); + + it('should not disable for single mode with no items', () => { + store.setCardinality(2); // ONE_TO_ONE + expect(store.isDisabledCreateNewContent()).toBe(false); + }); + + it('should not disable for multiple mode regardless of items', () => { + store.setCardinality(0); // ONE_TO_MANY + store.setData(mockData); + expect(store.isDisabledCreateNewContent()).toBe(false); + }); + }); + + describe('formattedRelationship', () => { + it('should format relationship IDs correctly', () => { + store.setData(mockData); + expect(store.formattedRelationship()).toBe('1,2,3'); + }); + + it('should handle empty data', () => { + expect(store.formattedRelationship()).toBe(''); + }); + }); + }); +}); diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.ts index 235a47ce602f..9d25daf886e0 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.ts @@ -1,18 +1,7 @@ -import { - patchState, - signalStore, - withComputed, - withHooks, - withMethods, - withState -} from '@ngrx/signals'; -import { rxMethod } from '@ngrx/signals/rxjs-interop'; -import { pipe } from 'rxjs'; +import { patchState, signalStore, withComputed, withMethods, withState } from '@ngrx/signals'; import { computed } from '@angular/core'; -import { tap } from 'rxjs/operators'; - import { ComponentStatus } from '@dotcms/dotcms-models'; import { RELATIONSHIP_OPTIONS } from '../dot-edit-content-relationship-field.constants'; @@ -52,7 +41,15 @@ export const RelationshipFieldStore = signalStore( { providedIn: 'root' }, withState(initialState), withComputed((state) => ({ + /** + * Computes the total number of pages based on the number of items and the rows per page. + * @returns {number} The total number of pages. + */ totalPages: computed(() => Math.ceil(state.data().length / state.pagination().rowsPerPage)), + /** + * Checks if the create new content button is disabled based on the selection mode and the number of items. + * @returns {boolean} True if the button is disabled, false otherwise. + */ isDisabledCreateNewContent: computed(() => { const totalItems = state.data().length; const selectionMode = state.selectionMode(); @@ -62,6 +59,15 @@ export const RelationshipFieldStore = signalStore( } return false; + }), + /** + * Formats the relationship field data into a string of IDs. + * @returns {string} A string of IDs separated by commas. + */ + formattedRelationship: computed(() => { + const data = state.data(); + + return data.map((item) => item.id).join(','); }) })), withMethods((store) => { @@ -115,13 +121,6 @@ export const RelationshipFieldStore = signalStore( data: store.data().filter((item) => item.id !== id) }); }, - /** - * Loads the data for the relationship field by fetching content from the service. - * It updates the state with the loaded data and sets the status to LOADED. - */ - loadData: rxMethod( - pipe(tap(() => patchState(store, { status: ComponentStatus.LOADED }))) - ), /** * Advances the pagination to the next page and updates the state accordingly. */ @@ -147,10 +146,5 @@ export const RelationshipFieldStore = signalStore( }); } }; - }), - withHooks({ - onInit: (store) => { - store.loadData(); - } }) ); diff --git a/core-web/libs/edit-content/src/lib/services/dot-edit-content.service.spec.ts b/core-web/libs/edit-content/src/lib/services/dot-edit-content.service.spec.ts index f25163144817..830cad1b5880 100644 --- a/core-web/libs/edit-content/src/lib/services/dot-edit-content.service.spec.ts +++ b/core-web/libs/edit-content/src/lib/services/dot-edit-content.service.spec.ts @@ -12,6 +12,7 @@ import { DotSiteService, DotWorkflowActionsFireService } from '@dotcms/data-access'; +import { DotContentletDepths } from '@dotcms/dotcms-models'; import { DotEditContentService } from './dot-edit-content.service'; @@ -44,16 +45,24 @@ describe('DotEditContentService', () => { describe('Endpoints', () => { it('should get content by id', () => { const ID = '1'; - spectator.service.getContentById(ID).subscribe(); + spectator.service.getContentById({ id: ID }).subscribe(); spectator.expectOne(`${CONTENT_API_ENDPOINT}/${ID}`, HttpMethod.GET); }); it('should get content by id and language', () => { const ID = '1'; - spectator.service.getContentById(ID, 1).subscribe(); + spectator.service.getContentById({ id: ID, languageId: 1 }).subscribe(); spectator.expectOne(`${CONTENT_API_ENDPOINT}/${ID}?language=1`, HttpMethod.GET); }); + it('should get content by id and depth', () => { + const ID = '1'; + const DEPTH = DotContentletDepths.TWO; + spectator.service.getContentById({ id: ID, depth: DEPTH }).subscribe(); + + spectator.expectOne(`${CONTENT_API_ENDPOINT}/${ID}?depth=${DEPTH}`, HttpMethod.GET); + }); + it('should get tags', () => { const NAME = 'test'; spectator.service.getTags(NAME).subscribe(); diff --git a/core-web/libs/edit-content/src/lib/services/dot-edit-content.service.ts b/core-web/libs/edit-content/src/lib/services/dot-edit-content.service.ts index d9c0512307c8..a8562be2443d 100644 --- a/core-web/libs/edit-content/src/lib/services/dot-edit-content.service.ts +++ b/core-web/libs/edit-content/src/lib/services/dot-edit-content.service.ts @@ -10,7 +10,7 @@ import { DotSiteService, DotWorkflowActionsFireService } from '@dotcms/data-access'; -import { DotCMSContentType, DotCMSContentlet } from '@dotcms/dotcms-models'; +import { DotCMSContentType, DotCMSContentlet, DotContentletDepth } from '@dotcms/dotcms-models'; import { CustomTreeNode, @@ -31,14 +31,28 @@ export class DotEditContentService { * * @param {string} id - The ID of the content to retrieve. * @param {number} [languageId] - Optional language ID to filter the content. + * @param {DotContentletDepth} [depth] - Optional depth to filter the content. * @returns {Observable} An observable of the DotCMSContentlet object. */ - getContentById(id: string, languageId?: number): Observable { - const params = languageId - ? new HttpParams().set('language', languageId.toString()) - : new HttpParams(); + getContentById(params: { + id: string; + languageId?: number; + depth?: DotContentletDepth; + }): Observable { + const { id, languageId, depth } = params; + let httpParams = new HttpParams(); - return this.#http.get(`/api/v1/content/${id}`, { params }).pipe(pluck('entity')); + if (languageId) { + httpParams = httpParams.set('language', languageId.toString()); + } + + if (depth) { + httpParams = httpParams.set('depth', depth); + } + + return this.#http + .get(`/api/v1/content/${id}`, { params: httpParams }) + .pipe(pluck('entity')); } /** diff --git a/core-web/libs/edit-content/src/lib/store/edit-content.store.ts b/core-web/libs/edit-content/src/lib/store/edit-content.store.ts index 6dacaedfee31..25b0789ce80d 100644 --- a/core-web/libs/edit-content/src/lib/store/edit-content.store.ts +++ b/core-web/libs/edit-content/src/lib/store/edit-content.store.ts @@ -3,7 +3,7 @@ import { signalStore, withHooks, withState } from '@ngrx/signals'; import { inject } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ComponentStatus } from '@dotcms/dotcms-models'; +import { ComponentStatus, DotContentletDepths } from '@dotcms/dotcms-models'; import { withContent } from './features/content.feature'; import { withForm } from './features/form.feature'; @@ -46,7 +46,7 @@ export const DotEditContentStore = signalStore( // TODO: refactor this when we will use EditContent as sidebar if (inode) { - store.initializeExistingContent(inode); + store.initializeExistingContent({ inode, depth: DotContentletDepths.TWO }); } else if (contentType) { store.initializeNewContent(contentType); } diff --git a/core-web/libs/edit-content/src/lib/store/features/content.feature.ts b/core-web/libs/edit-content/src/lib/store/features/content.feature.ts index 85507cd078bd..c20ff78345bb 100644 --- a/core-web/libs/edit-content/src/lib/store/features/content.feature.ts +++ b/core-web/libs/edit-content/src/lib/store/features/content.feature.ts @@ -29,6 +29,7 @@ import { DotCMSContentType, DotCMSWorkflow, DotCMSWorkflowAction, + DotContentletDepth, FeaturedFlags, WorkflowStep } from '@dotcms/dotcms-models'; @@ -233,12 +234,12 @@ export function withContent() { * @returns {Observable} An observable that emits the content's inode when initialization is complete * @throws Will redirect to /c/content and show error if initialization fails */ - initializeExistingContent: rxMethod( + initializeExistingContent: rxMethod<{ inode: string; depth: DotContentletDepth }>( pipe( - switchMap((inode: string) => { + switchMap(({ inode, depth }) => { patchState(store, { state: ComponentStatus.LOADING }); - return dotEditContentService.getContentById(inode).pipe( + return dotEditContentService.getContentById({ id: inode, depth }).pipe( switchMap((contentlet) => { const { contentType } = contentlet; diff --git a/core-web/libs/edit-content/src/lib/store/features/locales.feature.spec.ts b/core-web/libs/edit-content/src/lib/store/features/locales.feature.spec.ts index 0871efbf4219..ee9b1aafd61a 100644 --- a/core-web/libs/edit-content/src/lib/store/features/locales.feature.spec.ts +++ b/core-web/libs/edit-content/src/lib/store/features/locales.feature.spec.ts @@ -127,7 +127,10 @@ describe('LocalesFeature', () => { store.switchLocale(MOCK_LANGUAGES[1]); tick(); - expect(dotEditContentService.getContentById).toHaveBeenCalledWith('123', 2); + expect(dotEditContentService.getContentById).toHaveBeenCalledWith({ + id: '123', + languageId: 2 + }); expect(router.navigate).toHaveBeenCalledWith(['/content', '456'], { replaceUrl: true, diff --git a/core-web/libs/edit-content/src/lib/store/features/locales.feature.ts b/core-web/libs/edit-content/src/lib/store/features/locales.feature.ts index a8f4bf733ff8..f8497ac26f2b 100644 --- a/core-web/libs/edit-content/src/lib/store/features/locales.feature.ts +++ b/core-web/libs/edit-content/src/lib/store/features/locales.feature.ts @@ -191,7 +191,10 @@ export function withLocales() { */ if (locale.translated) { return dotEditContentService - .getContentById(store.currentIdentifier(), locale.id) + .getContentById({ + id: store.currentIdentifier(), + languageId: locale.id + }) .pipe( tapResponse({ next: (contentlet) => {