-
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): Edit Content: Render Radio and Select Field to th…
…e Form #26448 * Added Select and Radio fields. Added basic tests on both components. Changed formData structure and architecture * Added validation to set, in case dont have value or defaultValue, the first option as value in select and radio field * Added enum to DataType * Added tests. Changed mocks. * Working on PR Suggestions. Commit before merge * Added merge with master. Added Typing to forms on Select and Radio button. Added more test cases * Pair programming select tests * Changed tests. Changed language of mocks. Moved folders to shared/ * Replaced shared folder with models content * Changed and added test to RadioButton field * Changed name on util => function * Working on DotEditContentForm tests * Solved test on DotEditContentForm * Pair programming tests for dot-edit-content * Added more tests. Reduced html on radio field. Casting values on init form --------- Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>
- Loading branch information
1 parent
8d50af3
commit b103c86
Showing
22 changed files
with
962 additions
and
76 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
10 changes: 8 additions & 2 deletions
10
core-web/libs/edit-content/src/lib/components/dot-edit-content-field/utils.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 |
---|---|---|
@@ -1,17 +1,23 @@ | ||
import { Type } from '@angular/core'; | ||
|
||
import { DotEditContentRadioFieldComponent } from '../../fields/dot-edit-content-radio-field/dot-edit-content-radio-field.component'; | ||
import { DotEditContentSelectFieldComponent } from '../../fields/dot-edit-content-select-field/dot-edit-content-select-field.component'; | ||
import { DotEditContentTextAreaComponent } from '../../fields/dot-edit-content-text-area/dot-edit-content-text-area.component'; | ||
import { DotEditContentTextFieldComponent } from '../../fields/dot-edit-content-text-field/dot-edit-content-text-field.component'; | ||
|
||
// Map to match the field type to component selector | ||
export enum FIELD_TYPES { | ||
TEXT = 'Text', | ||
TEXTAREA = 'Textarea' | ||
TEXTAREA = 'Textarea', | ||
SELECT = 'Select', | ||
RADIO = 'Radio' | ||
} | ||
|
||
// This holds the mapping between the field type and the component that should be used to render it. | ||
export const FIELD_TYPES_COMPONENTS: Record<FIELD_TYPES, Type<unknown>> = { | ||
// We had to use unknown because components have different types. | ||
[FIELD_TYPES.TEXT]: DotEditContentTextFieldComponent, | ||
[FIELD_TYPES.TEXTAREA]: DotEditContentTextAreaComponent | ||
[FIELD_TYPES.TEXTAREA]: DotEditContentTextAreaComponent, | ||
[FIELD_TYPES.SELECT]: DotEditContentSelectFieldComponent, | ||
[FIELD_TYPES.RADIO]: DotEditContentRadioFieldComponent | ||
}; |
13 changes: 7 additions & 6 deletions
13
...dit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.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,16 +1,17 @@ | ||
<form class="p-fluid edit-content-form" *ngIf="form" [formGroup]="form"> | ||
<ng-container *ngFor="let row of formData"> | ||
<div class="row"> | ||
<div class="column" *ngFor="let column of row.columns"> | ||
<form class="p-fluid" *ngIf="form" [formGroup]="form"> | ||
<ng-container *ngFor="let row of formData.layout"> | ||
<div class="row" data-testId="row"> | ||
<div class="column" *ngFor="let column of row.columns" data-testId="column"> | ||
<dot-edit-content-field | ||
*ngFor="let field of column.fields" | ||
[field]="field"></dot-edit-content-field> | ||
[field]="field" | ||
data-testId="field" /> | ||
</div> | ||
</div> | ||
</ng-container> | ||
</form> | ||
|
||
<aside> | ||
<p-button [label]="'Save' | dm" (click)="saveContenlet()" data-testId="button-save"></p-button> | ||
<pre><code>{{form.value | json}}</code></pre> | ||
<pre><code>{{form?.value | json}}</code></pre> | ||
</aside> |
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
4 changes: 2 additions & 2 deletions
4
core-web/libs/edit-content/src/lib/feature/edit-content/edit-content.layout.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
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.