-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(edit-content): UI with mock data #30515
- Loading branch information
Showing
12 changed files
with
464 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...p-field/components/dot-select-existing-content/dot-select-existing-content.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
@let rowsPerPage = 25; | ||
@let data = store.data(); | ||
|
||
<p-dialog | ||
[header]="'dot.file.field.dialog.import.from.url.header' | dm" | ||
[modal]="true" | ||
|
||
[(visible)]="$visible" | ||
dataKey="id" | ||
appendTo="body"> | ||
<p-table | ||
#datatable | ||
[value]="data" | ||
selectionMode="multiple" | ||
[(selection)]="$selectedItems" | ||
[loading]="store.isLoading()" | ||
[paginator]="false" | ||
[rows]="rowsPerPage" | ||
styleClass="p-datatable-sm"> | ||
<ng-template pTemplate="caption"> | ||
<div class="flex w-full"> | ||
<p-iconField iconPosition="left"> | ||
<p-inputIcon styleClass="pi pi-search" /> | ||
<input | ||
#searchInput | ||
pInputText | ||
type="search" | ||
[placeholder]=" | ||
'dot.file.field.dialog.select.existing.file.table.search' | dm | ||
" | ||
(input)="datatable.filterGlobal(searchInput.value, 'contains')" /> | ||
</p-iconField> | ||
</div> | ||
</ng-template> | ||
<ng-template pTemplate="header" styleClass="relative"> | ||
<tr class="existing-content__table_header"> | ||
<th style="width: 4rem"><p-tableHeaderCheckbox /></th> | ||
<th pSortableColumn="title"> | ||
Title | ||
<p-sortIcon field="title" /> | ||
</th> | ||
<th pSortableColumn="step"> | ||
Step | ||
<p-sortIcon field="step" /> | ||
</th> | ||
<th pSortableColumn="description"> | ||
Description | ||
<p-sortIcon field="description" /> | ||
</th> | ||
<th pSortableColumn="lastUpdate"> | ||
Last Update | ||
<p-sortIcon field="lastUpdate" /> | ||
</th> | ||
<th>Menu</th> | ||
</tr> | ||
</ng-template> | ||
<ng-template pTemplate="emptymessage"> | ||
<tr> | ||
<td colspan="6"> | ||
<div class="flex p-2 gap-2 justify-content-center"> | ||
<p class="text-500">Relate content by clicking on the Plus Button</p> | ||
</div> | ||
</td> | ||
</tr> | ||
</ng-template> | ||
<ng-template pTemplate="body" let-item> | ||
<tr> | ||
<td> | ||
<p-tableCheckbox [value]="item" /> | ||
</td> | ||
<td class="max-w-12rem"> | ||
<p class="truncate-text">{{ item.title }}</p> | ||
</td> | ||
<td>{{ item.step }}</td> | ||
<td class="max-w-12rem"> | ||
<p class="truncate-text">{{ item.description }}</p> | ||
</td> | ||
<td>{{ item.lastUpdate }}</td> | ||
<td> | ||
<i class="pi pi-ellipsis-v"></i> | ||
</td> | ||
</tr> | ||
</ng-template> | ||
</p-table> | ||
<ng-template pTemplate="footer"> | ||
<p-button label="Cancel" (onClick)="closeDialog()" [text]="true" severity="secondary" /> | ||
<p-button label="Save" [outlined]="true" severity="secondary" /> | ||
</ng-template> | ||
</p-dialog> |
20 changes: 20 additions & 0 deletions
20
...p-field/components/dot-select-existing-content/dot-select-existing-content.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@use "variables" as *; | ||
|
||
::ng-deep { | ||
p-table { | ||
.p-datatable { | ||
border: 1px solid $color-palette-gray-300; | ||
border-radius: $border-radius-md; | ||
.p-datatable-header { | ||
background-color: $color-palette-gray-100; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.existing-content__table_header { | ||
th { | ||
font-weight: $font-weight-bold; | ||
background-color: $color-palette-gray-100; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...hip-field/components/dot-select-existing-content/dot-select-existing-content.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { ChangeDetectionStrategy, Component, inject, model } from '@angular/core'; | ||
|
||
import { ButtonModule } from 'primeng/button'; | ||
import { DialogModule } from 'primeng/dialog'; | ||
import { IconFieldModule } from 'primeng/iconfield'; | ||
import { InputIconModule } from 'primeng/inputicon'; | ||
import { InputTextModule } from 'primeng/inputtext'; | ||
import { MenuModule } from 'primeng/menu'; | ||
import { TableModule } from 'primeng/table'; | ||
|
||
import { DotMessagePipe } from '@dotcms/ui'; | ||
|
||
import { Content, ExistingContentStore } from './store/existing-content.store'; | ||
|
||
@Component({ | ||
selector: 'dot-select-existing-content', | ||
standalone: true, | ||
imports: [ | ||
TableModule, | ||
ButtonModule, | ||
MenuModule, | ||
DotMessagePipe, | ||
DialogModule, | ||
IconFieldModule, | ||
InputIconModule, | ||
InputTextModule | ||
], | ||
templateUrl: './dot-select-existing-content.component.html', | ||
styleUrls: ['./dot-select-existing-content.component.scss'], | ||
providers: [ExistingContentStore], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class DotSelectExistingContentComponent { | ||
/** | ||
* A readonly instance of the ExistingContentStore injected into the component. | ||
* This store is used to manage the state and actions related to the existing content. | ||
*/ | ||
readonly store = inject(ExistingContentStore); | ||
|
||
$visible = model(false, { alias: 'visible' }); | ||
|
||
$selectedItems = model<Content[]>([]); | ||
|
||
closeDialog() { | ||
this.$visible.set(false); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...relationship-field/components/dot-select-existing-content/store/existing-content.store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { faker } from '@faker-js/faker'; | ||
import { | ||
patchState, | ||
signalStore, | ||
withComputed, | ||
withHooks, | ||
withMethods, | ||
withState | ||
} from '@ngrx/signals'; | ||
|
||
import { computed } from '@angular/core'; | ||
|
||
import { ComponentStatus } from '@dotcms/dotcms-models'; | ||
|
||
export interface Content { | ||
id: string; | ||
title: string; | ||
step: string; | ||
description: string; | ||
lastUpdate: string; | ||
} | ||
|
||
export interface ExistingContentState { | ||
data: Content[]; | ||
status: ComponentStatus; | ||
} | ||
|
||
const initialState: ExistingContentState = { | ||
data: [], | ||
status: ComponentStatus.INIT | ||
}; | ||
|
||
export const ExistingContentStore = signalStore( | ||
withState(initialState), | ||
withComputed((state) => ({ | ||
isLoading: computed(() => state.status() === ComponentStatus.LOADING) | ||
})), | ||
withMethods((store) => ({ | ||
loadContent() { | ||
const mockData = Array.from({ length: 100 }, () => ({ | ||
id: faker.string.uuid(), | ||
title: faker.lorem.sentence(), | ||
step: faker.helpers.arrayElement(['Draft', 'Published', 'Archived']), | ||
description: faker.lorem.paragraph(), | ||
lastUpdate: faker.date.recent().toISOString() | ||
})); | ||
patchState(store, { | ||
data: mockData | ||
}); | ||
} | ||
})), | ||
withHooks({ | ||
onInit: (store) => { | ||
store.loadContent(); | ||
} | ||
}) | ||
); |
35 changes: 35 additions & 0 deletions
35
...ds/dot-edit-content-relationship-field/dot-edit-content-relationship-field.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<p-table [value]="store.data()" styleClass="p-datatable-lg"> | ||
<ng-template pTemplate="header" styleClass="relative"> | ||
<p-menu #menu [model]="$menuItems()" [popup]="true" appendTo="body" /> | ||
<p-button | ||
(onClick)="menu.toggle($event)" | ||
class="add-item-btn" | ||
[size]="'small'" | ||
icon="pi pi-plus" | ||
[text]="true" /> | ||
<tr class="relationship-field__table_header"> | ||
<th>Title</th> | ||
<th>Language</th> | ||
<th>State</th> | ||
</tr> | ||
</ng-template> | ||
<ng-template pTemplate="emptymessage"> | ||
<tr> | ||
<td colspan="3"> | ||
<div class="flex p-2 gap-2 justify-content-center"> | ||
<i class="pi pi-folder-open"></i> | ||
<p class="text-500">Relate content by clicking on the Plus Button</p> | ||
</div> | ||
</td> | ||
</tr> | ||
</ng-template> | ||
<ng-template pTemplate="body" let-item> | ||
<tr> | ||
<td>{{ item.title }}</td> | ||
<td>{{ item.language }}</td> | ||
<td>{{ item.state }}</td> | ||
</tr> | ||
</ng-template> | ||
</p-table> | ||
|
||
<dot-select-existing-content [(visible)]="$showExistingContentDialog" /> |
24 changes: 24 additions & 0 deletions
24
...ds/dot-edit-content-relationship-field/dot-edit-content-relationship-field.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@use "variables" as *; | ||
|
||
::ng-deep { | ||
p-table { | ||
.p-datatable { | ||
border: 1px solid $color-palette-gray-300; | ||
border-radius: $border-radius-md; | ||
.p-datatable-header { | ||
background-color: $color-palette-gray-100; | ||
} | ||
} | ||
} | ||
} | ||
.add-item-btn { | ||
position: absolute; | ||
top: 0.4rem; | ||
right: 0.4rem; | ||
} | ||
.relationship-field__table_header { | ||
th { | ||
font-weight: $font-weight-bold; | ||
background-color: $color-palette-gray-100; | ||
} | ||
} |
Oops, something went wrong.