Skip to content

Commit 6cc07f4

Browse files
authored
1 parent 2c8bfac commit 6cc07f4

File tree

11 files changed

+150
-18
lines changed

11 files changed

+150
-18
lines changed

core-web/libs/dotcms-scss/angular/dotcms-theme/components/_datatable.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@
182182
box-shadow: inset 0 -2px 0 0 $color-palette-primary-100;
183183
}
184184

185-
.p-datatable.p-datatable-hoverable-rows .p-datatable-tbody > tr:not(.p-highlight):hover {
185+
.p-datatable.p-datatable-hoverable-rows
186+
.p-datatable-tbody
187+
> tr:not(.p-highlight):not(.no-highlight):hover {
186188
background: $color-palette-primary-100;
187189
color: $text-color-hover;
188190
transition: background-color ease-in $basic-speed;

core-web/libs/dotcms-scss/angular/dotcms-theme/components/_table.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ $dot-table-cell-height: 1.25rem;
7272
}
7373

7474
&:first-child {
75-
padding-left: $spacing-3;
75+
padding-left: $spacing-4;
7676
}
7777

7878
&:last-child {
79-
padding-right: $spacing-3;
79+
padding-right: $spacing-4;
8080
}
8181

8282
.error-message {
@@ -174,11 +174,11 @@ $dot-table-cell-height: 1.25rem;
174174
}
175175

176176
&:first-child {
177-
padding-left: $spacing-3;
177+
padding-left: $spacing-4;
178178
}
179179

180180
&:last-child {
181-
padding-right: $spacing-3;
181+
padding-right: $spacing-4;
182182
}
183183

184184
.container-thumbnail {

core-web/libs/dotcms-scss/shared/_colors.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ $color-palette-gray-700: var(--gray-700);
8080
$color-palette-gray-800: var(--gray-800);
8181
$color-palette-gray-900: var(--gray-900);
8282

83+
// Surface
84+
$color-palette-surface-500: var(--surface-500);
85+
$color-palette-surface-900: var(--surface-900);
86+
8387
$color-palette-gray-shade: $color-palette-gray-300;
8488
$color-palette-gray: $color-palette-gray-500;
8589
$color-palette-gray-tint: rgba($color-palette-gray, 0.1);
@@ -463,4 +467,7 @@ $success: $color-accessible-text-green;
463467
--gray-700: #6c7389;
464468
--gray-800: #515667;
465469
--gray-900: #3d404d;
470+
471+
--surface-500: #9e9e9e;
472+
--surface-900: #212121;
466473
}

core-web/libs/portlets/dot-content-drive/portlet/src/lib/dot-content-drive-shell/dot-content-drive-shell.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dot-content-drive-toolbar {
3131
.tree-selector {
3232
background-color: lightblue;
3333
grid-area: tree;
34-
34+
overflow: hidden;
3535
border-right: 1px solid $color-palette-gray-400;
3636
width: 0;
3737

core-web/libs/portlets/dot-content-drive/portlet/src/lib/store/dot-content-drive.store.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@ describe('DotContentDriveStore', () => {
234234
store.setFilters({ contentType: 'Blog' });
235235
expect(store.filters()).toEqual({ contentType: 'Blog' });
236236
});
237+
238+
it('should update filters and reset pagination offset', () => {
239+
store.setPagination({ limit: 10, offset: 10 });
240+
expect(store.pagination()).toEqual({ limit: 10, offset: 10 });
241+
242+
store.setFilters({ contentType: 'Blog' });
243+
expect(store.pagination()).toEqual({ limit: 10, offset: 0 });
244+
expect(store.filters()).toEqual({ contentType: 'Blog' });
245+
});
237246
});
238247

239248
describe('setPagination', () => {

core-web/libs/portlets/dot-content-drive/portlet/src/lib/store/dot-content-drive.store.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,13 @@ export const DotContentDriveStore = signalStore(
119119
patchState(store, { status });
120120
},
121121
setFilters(filters: Record<string, string>) {
122-
patchState(store, { filters: { ...store.filters(), ...filters } });
122+
patchState(store, {
123+
filters: { ...store.filters(), ...filters },
124+
pagination: {
125+
...store.pagination(),
126+
offset: 0
127+
}
128+
});
123129
},
124130
setPagination(pagination: DotContentDrivePagination) {
125131
patchState(store, { pagination });

core-web/libs/portlets/dot-content-drive/ui/src/lib/dot-folder-list-view/dot-folder-list-view.component.html

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<p-table
22
[value]="$items()"
33
[tableStyle]="{ width: '100%' }"
4-
dataKey="identifier"
5-
[paginator]="true"
6-
[rows]="20"
7-
[rowsPerPageOptions]="[20, 40, 60]"
4+
[paginator]="$showPagination()"
5+
[rows]="MIN_ROWS_PER_PAGE"
6+
[rowsPerPageOptions]="rowsPerPageOptions"
87
[totalRecords]="$totalItems()"
98
[lazy]="true"
9+
[scrollable]="true"
10+
[styleClass]="$styleClass()"
11+
[(selection)]="selectedItems"
12+
(selectionChange)="onSelectionChange()"
1013
(onPage)="onPage($event)"
14+
(onSort)="onSort($event)"
15+
dataKey="identifier"
1116
sortMode="single"
12-
[(selection)]="selectedItems"
1317
selectionMode="multiple"
14-
(selectionChange)="onSelectionChange()"
15-
styleClass="dotTable"
1618
sortField="modDate"
1719
data-testId="table"
18-
(onSort)="onSort($event)">
20+
scrollHeight="flex">
1921
<ng-template pTemplate="header">
2022
<tr data-testId="header-row">
2123
<th style="width: 2.5rem"><p-tableHeaderCheckbox data-testId="header-checkbox" /></th>
@@ -76,4 +78,23 @@
7678
</tr>
7779
}
7880
</ng-template>
81+
<ng-template pTemplate="emptymessage">
82+
<tr class="no-highlight">
83+
<td colspan="7" class="empty-state">
84+
<div class="empty-state-content">
85+
<div class="empty-state-icon">
86+
<i class="pi pi-folder-open"></i>
87+
</div>
88+
<div class="empty-state-message">
89+
<h3 class="empty-state-title">
90+
{{ 'content.drive.empty.state.title' | dm }}
91+
</h3>
92+
<p class="empty-state-description">
93+
{{ 'content.drive.empty.state.description' | dm }}
94+
</p>
95+
</div>
96+
</div>
97+
</td>
98+
</tr>
99+
</ng-template>
79100
</p-table>

core-web/libs/portlets/dot-content-drive/ui/src/lib/dot-folder-list-view/dot-folder-list-view.component.scss

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:host {
44
width: 100%;
55
max-height: 100%;
6-
overflow-y: auto;
6+
min-height: 0;
77

88
::ng-deep {
99
p-table {
@@ -14,6 +14,14 @@
1414
}
1515
}
1616
}
17+
18+
p-table {
19+
.p-datatable.empty-table {
20+
table {
21+
height: 100%;
22+
}
23+
}
24+
}
1725
}
1826
}
1927

@@ -24,3 +32,52 @@
2432
gap: $spacing-3;
2533
width: 100%;
2634
}
35+
36+
.empty-state {
37+
padding: $spacing-6 $spacing-4;
38+
text-align: center;
39+
border: none;
40+
41+
.empty-state-content {
42+
display: flex;
43+
flex-direction: column;
44+
align-items: center;
45+
gap: $spacing-4;
46+
max-width: 400px;
47+
margin: 0 auto;
48+
}
49+
50+
.empty-state-icon {
51+
display: flex;
52+
align-items: center;
53+
justify-content: center;
54+
width: 5rem;
55+
height: 5rem;
56+
border-radius: 50%;
57+
58+
i {
59+
color: $color-palette-surface-500;
60+
font-size: 5.75rem;
61+
}
62+
}
63+
64+
.empty-state-message {
65+
display: flex;
66+
flex-direction: column;
67+
}
68+
69+
.empty-state-title {
70+
margin: 0;
71+
font-size: $font-size-lmd;
72+
font-weight: $font-weight-medium-bold;
73+
text-align: center;
74+
color: $color-palette-gray-800;
75+
}
76+
77+
.empty-state-description {
78+
margin: 0;
79+
color: $black;
80+
font-size: $font-size-md;
81+
line-height: 1.5;
82+
}
83+
}

core-web/libs/portlets/dot-content-drive/ui/src/lib/dot-folder-list-view/dot-folder-list-view.component.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ describe('DotFolderListViewComponent', () => {
130130
});
131131
});
132132

133+
describe('Styles and Pagination', () => {
134+
it('should have empty-table class when items list is empty', () => {
135+
spectator.setInput('items', []);
136+
spectator.setInput('totalItems', 0);
137+
spectator.detectChanges();
138+
139+
const tableDebugEl = spectator.debugElement.query(By.css('[data-testId="table"]'));
140+
expect(tableDebugEl.attributes['ng-reflect-style-class']).toContain('empty-table');
141+
});
142+
143+
it('should not show pagination when there are 20 or fewer total items', () => {
144+
spectator.setInput('totalItems', 20);
145+
spectator.detectChanges();
146+
147+
const tableDebugEl = spectator.debugElement.query(By.css('[data-testId="table"]'));
148+
expect(tableDebugEl.attributes['ng-reflect-paginator']).toBe('false');
149+
});
150+
});
151+
133152
describe('Loading', () => {
134153
it('should show the loading row', () => {
135154
spectator.setInput('items', mockItems);

core-web/libs/portlets/dot-content-drive/ui/src/lib/dot-folder-list-view/dot-folder-list-view.component.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
ChangeDetectionStrategy,
33
Component,
4+
computed,
45
CUSTOM_ELEMENTS_SCHEMA,
56
input,
67
output
@@ -40,8 +41,16 @@ export class DotFolderListViewComponent {
4041
paginate = output<LazyLoadEvent>();
4142
sort = output<SortEvent>();
4243

43-
readonly HEADER_COLUMNS = HEADER_COLUMNS;
44-
readonly SKELETON_SPAN = HEADER_COLUMNS.length + 1;
44+
readonly MIN_ROWS_PER_PAGE = 20;
45+
protected readonly rowsPerPageOptions = [this.MIN_ROWS_PER_PAGE, 40, 60];
46+
protected readonly HEADER_COLUMNS = HEADER_COLUMNS;
47+
protected readonly SKELETON_SPAN = HEADER_COLUMNS.length + 1;
48+
protected readonly $showPagination = computed(
49+
() => this.$totalItems() > this.MIN_ROWS_PER_PAGE
50+
);
51+
protected readonly $styleClass = computed(() =>
52+
this.$items().length === 0 ? 'dotTable empty-table' : 'dotTable'
53+
);
4554

4655
// Model for the table selection
4756
selectedItems: DotContentDriveItem[] = [];

0 commit comments

Comments
 (0)