Skip to content

Commit

Permalink
feat(edit-content) fix comments #28658
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra committed Jun 5, 2024
1 parent 6cd8a77 commit 10da22a
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
@use "variables" as *;

:host {
display: block;
display: flex;
flex-direction: column;
height: fit-content;
margin-bottom: 0;
gap: $spacing-1;

label {
margin: 0;
}

small {
margin-top: $spacing-1;
display: block;
margin: 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
(click)="dialogRef.close()"
data-testId="cancel-btn"
pButton>
Cancel
{{ 'edit.content.category-field.cancel' | dm }}
</button>
<button class="p-button" data-testId="apply-btn">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
@use "variables" as *;

:host {
display: block;
height: 100%;

.category-field__dialog {
display: grid;
grid-template-columns: 2fr 1fr;
max-width: 1200px;
margin: auto;
}
.category-field__dialog {
display: grid;
grid-template-columns: 2fr 1fr;
margin: auto;
}

.category-field__left-pane,
.category-field__right-pane {
padding: $spacing-3;
gap: $spacing-3;
}
.category-field__left-pane,
.category-field__right-pane {
padding: $spacing-3;
gap: $spacing-3;
}

.category-field__left-pane {
background-color: $color-palette-gray-300;
}
.category-field__left-pane {
background-color: $color-palette-gray-300;
}

.category-field__selected-categories {
border: $field-border-size solid $color-palette-gray-400;
border-radius: $border-radius-sm;
padding: $spacing-3;
}
.category-field__selected-categories {
border: $field-border-size solid $color-palette-gray-400;
border-radius: $border-radius-sm;
padding: $spacing-3;
}

.category-field__actions {
gap: $spacing-1;
}
.category-field__actions {
gap: $spacing-1;
}

::ng-deep .category-field__dialog .p-dialog-content {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<div class="dot-category-field__wrapper" [ngClass]="{ 'has-categories': values.length }">
@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>
@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__select">
<p-button
[label]="'edit.content.category-field.show-categories-dialog' | dm"
(onClick)="showCategories()"
data-testId="show-dialog-btn"
icon="pi pi-pencil"
styleClass="p-button-sm p-button-text p-button-secondary" />
</div>
<div class="dot-category-field__select">
<p-button
[label]="'edit.content.category-field.show-categories-dialog' | dm"
(onClick)="showCategories()"
data-testId="show-dialog-btn"
icon="pi pi-pencil"
styleClass="p-button-sm p-button-text p-button-secondary" />
</div>
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
@use "variables" as *;

.dot-category-field__wrapper {
.dot-category-field__categories,
.dot-category-field__select {
border: $field-border-size solid $color-palette-gray-400;
display: flex;
flex-wrap: wrap;
align-items: center;
:host {
&.dot-category-field__container--has-categories .dot-category-field__select {
border-radius: 0 0 $border-radius-md $border-radius-md;
}

.dot-category-field__categories {
padding: $spacing-1;
gap: $spacing-1;
border-radius: $border-radius-md $border-radius-md 0 0;
&.dot-category-field__container--has-categories .dot-category-field__categories {
border-bottom: none;
}
}

.dot-category-field__select {
height: $field-height-md;
border-radius: $border-radius-md;
padding: 0 $spacing-0;
justify-content: flex-end;
}
.dot-category-field__categories,
.dot-category-field__select {
border: $field-border-size solid $color-palette-gray-400;
display: flex;
flex-wrap: wrap;
align-items: center;
}

&.has-categories {
.dot-category-field__select {
border-radius: 0 0 $border-radius-md $border-radius-md;
}
.dot-category-field__categories {
padding: $spacing-1;
gap: $spacing-1;
border-radius: $border-radius-md $border-radius-md 0 0;
}

.dot-category-field__categories {
border-bottom: none;
}
}
.dot-category-field__select {
height: $field-height-md;
border-radius: $border-radius-md;
padding: 0 $spacing-0;
justify-content: flex-end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import { DotMessagePipe } from '@dotcms/ui';

import { DotEditContentCategoryFieldDialogComponent } from './components/dot-edit-content-category-field-dialog/dot-edit-content-category-field-dialog.component';

/**
* Component for editing content category field.
*
* @class
* @name DotEditContentCategoryFieldComponent
*/
@Component({
selector: 'dot-edit-content-category-field',
standalone: true,
Expand All @@ -34,10 +40,23 @@ import { DotEditContentCategoryFieldDialogComponent } from './components/dot-edi
useFactory: () => inject(ControlContainer, { skipSelf: true })
}
],
providers: [DialogService]
providers: [DialogService],
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
host: {
'[class.dot-category-field__container--has-categories]': 'hasCategories()',
'[class.dot-category-field__container]': '!hasCategories()'
}
})
export class DotEditContentCategoryFieldComponent {
/**
* The `field` variable is of type `DotCMSContentTypeField` and is a required input.
*
* @name field
* @description The variable represents a field of a DotCMS content type.
*/
field = input.required<DotCMSContentTypeField>();

// TODO: Replace with the content of the selected categories
// values = [];
values = [
{ id: 1, value: 'Streetwear' },
Expand All @@ -52,10 +71,22 @@ export class DotEditContentCategoryFieldComponent {
{ id: 2, value: 'Kids' },
{ id: 2, value: 'Kids streetwear' }
];

#dialogService = inject(DialogService);

showCategories() {
/**
* Checks if the object has categories.
* @returns {boolean} - True if the object has categories, false otherwise.
*/
hasCategories(): boolean {
return this.values.length > 0;
}

/**
* Open the "DotEditContentCategoryFieldDialogComponent" dialog to show categories.
*
* @returns {void}
*/
showCategories(): void {
this.#dialogService.open(DotEditContentCategoryFieldDialogComponent, {
showHeader: false,
styleClass: 'category-field__dialog',
Expand Down

0 comments on commit 10da22a

Please sign in to comment.