-
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.
Browse files
Browse the repository at this point in the history
### Proposed Changes * Convert from dialog to sidebar the selection of categories in edit contentlet category-field ### Checklist - [x] Tests - [x] Translations - [ ] Security Implications Contemplated (add notes if applicable) ### Additional Info ** any additional useful context or info ** https://github.com/dotCMS/core/assets/1909643/5e9db5a3-8bb3-4b89-a105-31091d8cd191 --------- Co-authored-by: Freddy Montes <[email protected]>
- Loading branch information
Showing
16 changed files
with
3,553 additions
and
3,500 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
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> |
41 changes: 41 additions & 0 deletions
41
...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,41 @@ | ||
@use "variables" as *; | ||
|
||
.category-field__header { | ||
align-items: center; | ||
flex-wrap: wrap; | ||
gap: $spacing-0; | ||
padding: $spacing-1 $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>(); | ||
} |
35 changes: 19 additions & 16 deletions
35
...lib/fields/dot-edit-content-category-field/dot-edit-content-category-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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
@if (values.length) { | ||
<div class="dot-category-field__categories" data-testId="category-chip-list"> | ||
@for (category of values; track category.id) { | ||
<p-chip | ||
[pTooltip]="category.value" | ||
[removable]="true" | ||
[label]="category.value" | ||
tooltipPosition="top" | ||
styleClass="p-chip-sm" /> | ||
} | ||
</div> | ||
<div class="dot-category-field__categories" data-testId="category-chip-list"> | ||
@for (category of values; track category.id) { | ||
<p-chip | ||
[pTooltip]="category.value" | ||
[removable]="true" | ||
[label]="category.value" | ||
tooltipPosition="top" | ||
styleClass="p-chip-sm" /> | ||
} | ||
</div> | ||
} | ||
|
||
<div class="dot-category-field__select"> | ||
<p-button | ||
(onClick)="showCategories()" | ||
[label]="'edit.content.category-field.show-categories-dialog' | dm" | ||
data-testId="show-dialog-btn" | ||
icon="pi pi-pencil" | ||
styleClass="p-button-sm p-button-text p-button-secondary" /> | ||
<button | ||
(click)="showCategoriesSidebar()" | ||
[disabled]="disableSelectCategoriesButton()" | ||
[label]="'edit.content.category-field.button.show-categories' | dm" | ||
class="p-button-sm p-button-text p-button-secondary" | ||
data-testId="show-sidebar-btn" | ||
pButton></button> | ||
</div> | ||
|
||
<ng-container dotDynamic></ng-container> |
Oops, something went wrong.