-
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.
feat(edit-content) change from dialog to sidebar #28764
- Loading branch information
Showing
11 changed files
with
278 additions
and
149 deletions.
There are no files selected for viewing
18 changes: 0 additions & 18 deletions
18
...-edit-content-category-field-dialog/dot-edit-content-category-field-dialog.component.html
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...-edit-content-category-field-dialog/dot-edit-content-category-field-dialog.component.scss
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
...it-content-category-field-dialog/dot-edit-content-category-field-dialog.component.spec.ts
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
...ot-edit-content-category-field-dialog/dot-edit-content-category-field-dialog.component.ts
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
...dit-content-category-field-sidebar/dot-edit-content-category-field-sidebar.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,38 @@ | ||
<p-sidebar | ||
(onHide)="this.closedSidebar.emit()" | ||
[(visible)]="visible" | ||
[showCloseIcon]="false" | ||
#sidebar | ||
data-testId="sidebar" | ||
position="right" | ||
styleClass="w-9"> | ||
<ng-template pTemplate="header"> | ||
<div class="flex flex-row category-field__header"> | ||
<button | ||
(click)="sidebar.close($event)" | ||
class="p-button-rounded p-button-text" | ||
data-testId="back-btn" | ||
icon="pi pi-angle-left" | ||
pButton></button> | ||
<div class="category-field__header-title" data-testId="sidebar-title"> | ||
{{ 'edit.content.category-field.sidebar.header.select-categories' | dm }} | ||
</div> | ||
</div> | ||
</ng-template> | ||
|
||
<div class="category-field__content h-full w-full"> | ||
<div class="category-field__left-pane flex flex-column"> | ||
<div class="category-field__search">Input Search</div> | ||
<div class="flex-grow-1 category-field__categories">Categories</div> | ||
</div> | ||
|
||
<div class="category-field__right-pane flex flex-column"> | ||
<div class="category-field__selected-categories-list flex-1">Selected Categories</div> | ||
<div class="category-field__actions flex justify-content-end"> | ||
<button class="p-button p-button-link" data-testId="clear_all-btn" pButton> | ||
{{ 'edit.content.category-field.button.clear-all' | dm }} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</p-sidebar> |
43 changes: 43 additions & 0 deletions
43
...dit-content-category-field-sidebar/dot-edit-content-category-field-sidebar.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,43 @@ | ||
@use "variables" as *; | ||
|
||
.category-field__header { | ||
height: 60px; | ||
align-items: center; | ||
flex-wrap: wrap; | ||
gap: $spacing-0; | ||
padding: 0 $spacing-4; | ||
} | ||
|
||
.category-field__header-title { | ||
font-size: $font-size-lg; | ||
font-weight: $font-weight-medium-bold; | ||
margin: 0; | ||
} | ||
|
||
.category-field__content { | ||
display: grid; | ||
grid-template-columns: 2fr 1fr; | ||
margin: auto; | ||
background-color: $color-palette-gray-300; | ||
padding: $spacing-4; | ||
gap: $spacing-1; | ||
} | ||
|
||
.category-field__left-pane, | ||
.category-field__right-pane { | ||
gap: $spacing-1; | ||
} | ||
|
||
.category-field__search, | ||
.category-field__categories, | ||
.category-field__right-pane { | ||
border: $field-border-size solid $color-palette-gray-400; | ||
border-radius: $border-radius-md; | ||
background-color: $white; | ||
|
||
padding: $spacing-3; | ||
} | ||
|
||
:host ::ng-deep .p-sidebar-content { | ||
padding: 0; | ||
} |
47 changes: 47 additions & 0 deletions
47
...-content-category-field-sidebar/dot-edit-content-category-field-sidebar.component.spec.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 { expect, it } from '@jest/globals'; | ||
import { byTestId, createComponentFactory, Spectator } from '@ngneat/spectator'; | ||
import { mockProvider } from '@ngneat/spectator/jest'; | ||
|
||
import { DotMessageService } from '@dotcms/data-access'; | ||
|
||
import { DotEditContentCategoryFieldSidebarComponent } from './dot-edit-content-category-field-sidebar.component'; | ||
|
||
describe('DotEditContentCategoryFieldSidebarComponent', () => { | ||
let spectator: Spectator<DotEditContentCategoryFieldSidebarComponent>; | ||
|
||
const createComponent = createComponentFactory({ | ||
component: DotEditContentCategoryFieldSidebarComponent, | ||
providers: [mockProvider(DotMessageService)] | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createComponent(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
it('should have `visible` property by default `true`', () => { | ||
expect(spectator.component.visible).toBe(true); | ||
}); | ||
|
||
it('should have a sidebar', () => { | ||
expect(spectator.query(byTestId('sidebar'))).not.toBeNull(); | ||
}); | ||
|
||
it('should have a clear all button', () => { | ||
expect(spectator.query(byTestId('clear_all-btn'))).not.toBeNull(); | ||
}); | ||
|
||
it('should close the sidebar when you click back', () => { | ||
const closedSidebarSpy = jest.spyOn(spectator.component.closedSidebar, 'emit'); | ||
const cancelBtn = spectator.query(byTestId('back-btn')); | ||
expect(cancelBtn).not.toBeNull(); | ||
|
||
expect(closedSidebarSpy).not.toHaveBeenCalled(); | ||
|
||
spectator.click(cancelBtn); | ||
expect(closedSidebarSpy).toHaveBeenCalled(); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
...-edit-content-category-field-sidebar/dot-edit-content-category-field-sidebar.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,33 @@ | ||
import { ChangeDetectionStrategy, Component, EventEmitter } from '@angular/core'; | ||
|
||
import { ButtonModule } from 'primeng/button'; | ||
import { DialogModule } from 'primeng/dialog'; | ||
import { SidebarModule } from 'primeng/sidebar'; | ||
|
||
import { DotMessagePipe } from '@dotcms/ui'; | ||
|
||
/** | ||
* Component for the sidebar that appears when editing content category field. | ||
*/ | ||
@Component({ | ||
selector: 'dot-edit-content-category-field-sidebar', | ||
standalone: true, | ||
imports: [DialogModule, ButtonModule, DotMessagePipe, SidebarModule], | ||
templateUrl: './dot-edit-content-category-field-sidebar.component.html', | ||
styleUrl: './dot-edit-content-category-field-sidebar.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class DotEditContentCategoryFieldSidebarComponent { | ||
/** | ||
* Indicates whether the sidebar is visible or not. | ||
* | ||
*/ | ||
visible = true; | ||
|
||
/** | ||
* The event is fired whenever the sidebar is closed either by hitting 'Escape', | ||
* clicking on the overlay, or on the back button. | ||
* | ||
*/ | ||
closedSidebar = new EventEmitter<void>(); | ||
} |
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
Oops, something went wrong.