-
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): Render TextField and TextArea Field to the Form #…
…26442 * dev (edit content lib): add text area, default value and inputmode/type support * dev (dot edit content field): add comments to new code * dev (dot edit content form): add comment * dev (dot edit content field): change steps from any to 0.1 in decimals * dev (dot edit content lib): create field wrappers for text area and text field * dev (dot edit content): add and clean test cases * dev (edit content mock): remove duplicated code * dev (edit content): address feedback * fix (edit-content-form): styles were off * fix (edit content text area): min height was too high * dev (edit content field): address feedback * dev (mocks): separate fields * dev (edit content field): enhance testing * dev (edit content): general clean up * dev (edit content form): delete todo
- Loading branch information
Showing
22 changed files
with
784 additions
and
402 deletions.
There are no files selected for viewing
34 changes: 16 additions & 18 deletions
34
...t-content/src/lib/components/dot-edit-content-field/dot-edit-content-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,20 +1,18 @@ | ||
<label | ||
[attr.data-testId]="'label-' + field.variable" | ||
[for]="field.variable" | ||
[checkIsRequiredControl]="field.variable" | ||
dotFieldRequired | ||
>{{ field.name }}</label | ||
> | ||
<ng-container [ngSwitch]="field.fieldType"> | ||
<div class="field" *ngSwitchCase="'Text'"> | ||
<label | ||
[attr.data-testId]="'label-' + field.variable" | ||
[for]="field.variable" | ||
[checkIsRequiredControl]="field.variable" | ||
dotFieldRequired | ||
>{{ field.name }}</label | ||
> | ||
<input | ||
[id]="field.variable" | ||
[formControlName]="field.variable" | ||
[attr.data-testId]="'input-' + field.variable" | ||
type="text" | ||
pInputText /> | ||
<small *ngIf="field.hint" [attr.data-testId]="'hint-' + field.variable">{{ | ||
field.hint | ||
}}</small> | ||
</div> | ||
<dot-edit-content-text-field | ||
*ngSwitchCase="fieldTypes.TEXT" | ||
[field]="field" | ||
[attr.data-testId]="'field-' + field.variable"></dot-edit-content-text-field> | ||
<dot-edit-content-text-area | ||
*ngSwitchCase="fieldTypes.TEXTAREA" | ||
[field]="field" | ||
[attr.data-testId]="'field-' + field.variable"></dot-edit-content-text-area> | ||
</ng-container> | ||
<small *ngIf="field.hint" [attr.data-testId]="'hint-' + field.variable">{{ field.hint }}</small> |
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,4 @@ | ||
:host { | ||
display: block; | ||
height: fit-content; | ||
} |
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
17 changes: 17 additions & 0 deletions
17
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Type } from '@angular/core'; | ||
|
||
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' | ||
} | ||
|
||
// 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 | ||
}; |
2 changes: 1 addition & 1 deletion
2
...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
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.