Skip to content

Commit

Permalink
chore(edit-content): apply format
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobytes committed Jan 8, 2025
1 parent a152bac commit b38704b
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 113 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Beware while using this type, since we have a [key: string]: any; it can be used to store any kind of data and you can write wrong properties and it will not fail

import { DotLanguage } from "./dot-language.model";
import { DotLanguage } from './dot-language.model';

// Maybe we need to refactor this to a generic type that extends from unknown when missing the generic type
export interface DotCMSContentlet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
}
</th>
<th scope="col" class="max-w-12rem" [pSortableColumn]="'title'">
<span class="capitalize">{{ 'dot.file.relationship.dialog.table.title' | dm }}</span>
<span class="capitalize">
{{ 'dot.file.relationship.dialog.table.title' | dm }}
</span>
<p-sortIcon [field]="'title'" />
</th>
@for (column of columns; track $index) {
Expand All @@ -78,13 +80,19 @@
</th>
}
<th scope="col" class="max-w-12rem" [pSortableColumn]="'language'">
<span class="capitalize">{{ 'dot.file.relationship.dialog.table.language' | dm }}</span>
<span class="capitalize">
{{ 'dot.file.relationship.dialog.table.language' | dm }}
</span>
</th>
<th scope="col" class="max-w-12rem" [pSortableColumn]="'state'">
<span class="capitalize">{{ 'dot.file.relationship.dialog.table.state' | dm }}</span>
<span class="capitalize">
{{ 'dot.file.relationship.dialog.table.state' | dm }}
</span>
</th>
<th scope="col" class="max-w-12rem" [pSortableColumn]="'modDate'">
<span class="capitalize">{{ 'dot.file.relationship.dialog.table.last.modified' | dm }}</span>
<span class="capitalize">
{{ 'dot.file.relationship.dialog.table.last.modified' | dm }}
</span>
<p-sortIcon [field]="'modDate'" />
</th>
</tr>
Expand All @@ -111,7 +119,9 @@
</td>
<td class="max-w-12rem">
@let status = item | contentletStatus;
<p-chip [styleClass]="'p-chip-sm ' + status.classes" [label]="status.label" />
<p-chip
[styleClass]="'p-chip-sm ' + status.classes"
[label]="status.label" />
</td>
<td class="max-w-12rem">
<p class="truncate-text">{{ item.modDate | date: 'longDate' }}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const mockContentletDefaults = {
};

const mockData: DotCMSContentlet[] = [
{
{
...mockContentletDefaults,
inode: '1',
identifier: 'id-1',
Expand All @@ -52,7 +52,7 @@ const mockData: DotCMSContentlet[] = [
host: 'demo.dotcms.com',
stInode: 'st-1'
},
{
{
...mockContentletDefaults,
inode: '2',
identifier: 'id-2',
Expand All @@ -75,7 +75,7 @@ const mockData: DotCMSContentlet[] = [
host: 'demo.dotcms.com',
stInode: 'st-2'
},
{
{
...mockContentletDefaults,
inode: '3',
identifier: 'id-3',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ export class DotSelectExistingContentComponent implements OnInit {
});

constructor() {
effect(() => {
this.$selectedItems.set(this.store.selectedItems());
}, {
allowSignalWrites: true
});
effect(
() => {
this.$selectedItems.set(this.store.selectedItems());
},
{
allowSignalWrites: true
}
);
}

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { tap, switchMap, filter } from 'rxjs/operators';

import { ComponentStatus, DotCMSContentlet } from '@dotcms/dotcms-models';
import { Column } from '@dotcms/edit-content/fields/dot-edit-content-relationship-field/models/column.model';
import {
SelectionMode
} from '@dotcms/edit-content/fields/dot-edit-content-relationship-field/models/relationship.models';
import { SelectionMode } from '@dotcms/edit-content/fields/dot-edit-content-relationship-field/models/relationship.models';
import { RelationshipFieldService } from '@dotcms/edit-content/fields/dot-edit-content-relationship-field/services/relationship-field.service';

export interface ExistingContentState {
Expand Down Expand Up @@ -67,7 +65,7 @@ export const ExistingContentStore = signalStore(
const data = state.data();
const currentItemsIds = state.currentItemsIds();

return data.filter((item) => currentItemsIds.includes(item.inode));;
return data.filter((item) => currentItemsIds.includes(item.inode));
})
})),
withMethods((store) => {
Expand Down Expand Up @@ -96,7 +94,7 @@ export const ExistingContentStore = signalStore(
}
}),
filter(({ contentTypeId }) => !!contentTypeId),
switchMap(({ contentTypeId, currentItemsIds }) =>
switchMap(({ contentTypeId, currentItemsIds }) =>
relationshipFieldService.getColumnsAndContent(contentTypeId).pipe(
tapResponse({
next: ([columns, data]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { HeaderComponent } from './components/header/header.component';
import { PaginationComponent } from './components/pagination/pagination.component';
import { RelationshipFieldStore } from './store/relationship-field.store';


@Component({
selector: 'dot-edit-content-relationship-field',
standalone: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ describe('RelationshipFieldService', () => {

const contentTypeId = '123';

const expectedColumns = mockFields.map((field) => ({ field: field.variable, header: field.name }));
const expectedColumns = mockFields.map((field) => ({
field: field.variable,
header: field.name
}));

spectator.service.getColumns(contentTypeId).subscribe((columns) => {
expect(dotFieldService.getFields).toHaveBeenCalledWith(
Expand Down Expand Up @@ -249,14 +252,24 @@ describe('RelationshipFieldService', () => {
title: 'Test Content 1',
field: 'Field 1',
description: 'Description 1',
language: { id: 1, language: 'English', isoCode: 'en', languageCode: 'en-US' }
language: {
id: 1,
language: 'English',
isoCode: 'en',
languageCode: 'en-US'
}
});
expect(item1).toEqual({
identifier: '456',
title: 'Test Content 2',
field: 'Field 2',
description: 'Description 2',
language: { id: 2, language: 'Spanish', isoCode: 'es', languageCode: 'es-ES' }
language: {
id: 2,
language: 'Spanish',
isoCode: 'es',
languageCode: 'es-ES'
}
});

// Verify service calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { forkJoin, Observable } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';


import { catchError, map, pluck } from 'rxjs/operators';

import {
Expand Down Expand Up @@ -47,9 +46,7 @@ export class RelationshipFieldService {
* @param contentTypeId The content type ID
* @returns Observable of [Column[], RelationshipFieldItem[]]
*/
getColumnsAndContent(
contentTypeId: string
): Observable<[Column[], DotCMSContentlet[]] | null> {
getColumnsAndContent(contentTypeId: string): Observable<[Column[], DotCMSContentlet[]] | null> {
return forkJoin([
this.getColumns(contentTypeId),
this.getContent(contentTypeId),
Expand Down Expand Up @@ -84,7 +81,7 @@ export class RelationshipFieldService {
return this.#dotLanguagesService.get().pipe(
map((languages) =>
languages.reduce((acc, lang) => {
acc[lang.id] = {...lang};
acc[lang.id] = { ...lang };

return acc;
}, {})
Expand All @@ -99,8 +96,8 @@ export class RelationshipFieldService {
*/
#buildColumns(columns: DotCMSContentTypeField[]): Column[] {
return columns
.filter((column) => column.variable && column.name)
.map((column) => ({
.filter((column) => column.variable && column.name)
.map((column) => ({
field: column.variable,
header: column.name
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('RelationshipFieldStore', () => {
let store: InstanceType<typeof RelationshipFieldStore>;

const mockData: DotCMSContentlet[] = [
{
{
id: '1',
title: 'Content 1',
language: '1',
Expand Down Expand Up @@ -40,7 +40,7 @@ describe('RelationshipFieldStore', () => {
stInode: 'test',
titleImage: null
},
{
{
id: '2',
title: 'Content 2',
language: '1',
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('RelationshipFieldStore', () => {
stInode: 'test',
titleImage: null
},
{
{
id: '3',
title: 'Content 3',
language: '1',
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('RelationshipFieldStore', () => {
describe('State Management', () => {
describe('initialize', () => {
it('should set single selection mode for ONE_TO_ONE relationship', () => {
store.initialize({
store.initialize({
cardinality: 2,
contentlet: mockContentlet,
variable: 'relationship_field'
Expand All @@ -177,7 +177,7 @@ describe('RelationshipFieldStore', () => {
});

it('should set multiple selection mode for other relationship types', () => {
store.initialize({
store.initialize({
cardinality: 0,
contentlet: mockContentlet,
variable: 'relationship_field'
Expand All @@ -186,7 +186,7 @@ describe('RelationshipFieldStore', () => {
});

it('should initialize data from contentlet', () => {
store.initialize({
store.initialize({
cardinality: 0,
contentlet: mockContentlet,
variable: 'relationship_field'
Expand Down Expand Up @@ -214,7 +214,7 @@ describe('RelationshipFieldStore', () => {
store.setData(mockData);
store.deleteItem('inode1');
expect(store.data().length).toBe(2);
expect(store.data().find(item => item.inode === 'inode1')).toBeUndefined();
expect(store.data().find((item) => item.inode === 'inode1')).toBeUndefined();
});
});

Expand Down Expand Up @@ -254,7 +254,7 @@ describe('RelationshipFieldStore', () => {

describe('isDisabledCreateNewContent', () => {
beforeEach(() => {
store.initialize({
store.initialize({
cardinality: 2,
contentlet: mockContentlet,
variable: 'relationship_field'
Expand All @@ -272,7 +272,7 @@ describe('RelationshipFieldStore', () => {
});

it('should not disable for multiple mode regardless of items', () => {
store.initialize({
store.initialize({
cardinality: 0,
contentlet: mockContentlet,
variable: 'relationship_field'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export function getRelationshipFromContentlet({
if (!contentlet || !variable) {
return [];
}


const relationship = contentlet[variable] || [];

Expand Down
Loading

0 comments on commit b38704b

Please sign in to comment.