-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: (Platform) Form Group enhancement phase 1 #4213
Conversation
✔️ Deploy preview for fundamental-ngx ready! 🔨 Explore the source changes: d7677c5 🔍 Inspect the deploy logs: https://app.netlify.com/sites/fundamental-ngx/deploys/6008498221e4bc0007f0f756 😎 Browse the preview: https://deploy-preview-4213--fundamental-ngx.netlify.app |
@@ -35,6 +35,9 @@ export abstract class FormField { | |||
* Indicates in which FormZone a form field should be rendered | |||
*/ | |||
zone: FormZone; | |||
|
|||
|
|||
column: number; // temp type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add describing comment there?
libs/platform/src/lib/components/form/form-group/form-field-group/form-field-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-field-group/form-field-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-field-group/form-field-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-field/form-field.component.html
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-field-group/form-field-group.component.ts
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-field/form-field.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments
libs/platform/src/lib/components/form/form-group/form-field-group/form-field-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-field/form-field.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Outdated
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allot was already commented also by dima, let's address all these changes and do another iteration
@@ -35,6 +35,10 @@ export abstract class FormField { | |||
* Indicates in which FormZone a form field should be rendered | |||
*/ | |||
zone: FormZone; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need FormZone? Do we even have zones In new design?
The same goes to fluid. do we have such functionality now ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not need more. Removed
@@ -3,20 +3,22 @@ | |||
</ng-template> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we need this section anymore.. forceRender
import { Subject } from 'rxjs'; | ||
import { coerceBooleanProperty } from '@angular/cdk/coercion'; | ||
|
||
import { FormField } from '../form-field'; | ||
import { FormGroupContainer } from '../form-group'; | ||
import { LabelLayout, HintPlacement, FormZone } from '../form-options'; | ||
import { FormZone, HintPlacement, LabelLayout } from '../form-options'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I already commented in form-field.ts do we need formZones. Is this in new Design? We have columns instead no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
<h1 class="fd-form-group__header-text">{{ row.value.label }}</h1> | ||
</div> | ||
|
||
<ng-container *ngFor="let r of (row.value.label ? row.value.fields: row.value) | keyvalue; trackBy: trackByFieldName"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should maintain existing functionality for nested.
But FormGroup has FormFields or FormFieldsGroup
FormFieldGroup supports fields.
I would not complicate this now,
public name: string, | ||
public rank: number, | ||
public name?: string, | ||
public rank?: number, | ||
public renderer?: TemplateRef<any>, | ||
public columns: number = 6, | ||
public isFluid: boolean = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this fluid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
} | ||
} | ||
return; | ||
} | ||
} | ||
|
||
export class GroupField { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GroupField was that as internal structure to keep fields with some additional metadata used for rendering. How our FiledGroup fits (the heading we have)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Children of FormFieldGroup
wrapped GroupField
as well. The heading stored separately
for (let i = 0; i <= Math.abs(zLeft.length - zRight.length); i++) { | ||
const zone = toEven[0].zone; | ||
toEven.push(new GroupField(zone, `${zone}-${i}`, toEven.length + 1, null, 6)); | ||
private _setUserSpecifiedLayout(groupField?: GroupField): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to also validate highest column numbers with our layout pattern.
So will not have XL2, but you will try to place column into number 4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so we need to validate this case. At now if a form has 2 columns and a field will try bind to the 4th column, it will set at the last available column
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Show resolved
Hide resolved
f.styleClass = `col-sm-${f.columns} col-md-${f.columns} col-lg-${f.columns}`; | ||
merged[current++] = f; | ||
indexR++; | ||
private _setUserLayout(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you have the validation? that your columnLayout is using smaller numbers than your column? We should also throw exception in dev mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added separate method
@@ -294,9 +283,13 @@ export class FormFieldComponent implements FormField, AfterContentInit, AfterVie | |||
* Add FormField to FormGroup | |||
*/ | |||
private addToFormGroup(): void { | |||
if (!this.formGroupContainer) { | |||
// prevent adding wrapped fields into field group into form group container | |||
const isFieldGroup = this._elementRef.nativeElement.parentElement.tagName.toLowerCase() === 'fdp-form-field-group'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we are using this long dotted path, can some of this be NULL?
This might not with metaUI (the rule engine)
where we wrap these things with extra tag so it coudl like like:
<from-group>
<meta-ui-tag-that generantes bellow code>
<form-group-field>
<meta-ui-tag-that generantes bellow code>
` <form-field>
So I would try to lookup closest element instead direct parent
libs/platform/src/lib/components/form/form-group/form-field/form-field.component.ts
Outdated
Show resolved
Hide resolved
5704095
to
829bd4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All my comments have been resolved
829bd4e
to
583ecc7
Compare
247f8a4
to
f13d294
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm to me in general, but there are several minor comments
please drop empty file apps/docs/src/app/platform/component-docs/platform-forms/platform-form-container/platform-form-container-header/platform-form-container-header.component.scss
@@ -1,16 +1,16 @@ | |||
<h3>Binary Checkbox in Template Driven Form</h3> | |||
<fdp-form-group [multiLayout]="true" [noLabelLayout]="false"> | |||
<fdp-form-field [id]="'yellow'" [label]="'Yellow'" [noLabelLayout]="true" zone="zLeft" rank="4" [editable]="true"> | |||
<fdp-form-field [id]="'yellow'" [label]="'Yellow'" [noLabelLayout]="true" rank="4" [editable]="true"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't use unnecessary []
bindings and if you see one please remove them (could be done via regexp replace)
it's not only hurts performance for no good reason, but additionally consumers of our lib should not do it too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relative to all modified files, please ;)
rank="1" | ||
[placeholder]="'Field placeholder text'" | ||
placeholder="Field placeholder text" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
<div class="fd-form-group fd-col__form-group fd-col" [ngClass]="xlCol"> | ||
<div class="fd-form-item fd-row__form-item fd-row"> | ||
<div | ||
*ngFor="let f of r.value; trackBy: trackByFieldName" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f or r.value
, no idea what this means. please use a bit more descriptive names for variables
if (!this.bZone) { | ||
this.bZone = []; | ||
private _updateFieldByColumn(): void { | ||
const rows: { [key: number]: FieldColumn } | { [key: number]: FieldGroup } = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not it will be easier? or this doesn't work?
const rows: { [key: number]: FieldColumn } | { [key: number]: FieldGroup } = {}; | |
const rows: { [key: number]: FieldColumn | FieldGroup } = {}; |
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Show resolved
Hide resolved
|
||
for (const child of this.formChildren) { | ||
if (this._isFieldChild(child)) { | ||
const f = this._getField(child); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f
? please use more readable variable names
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Show resolved
Hide resolved
libs/platform/src/lib/components/form/form-group/form-group.component.ts
Show resolved
Hide resolved
this._getColumnNumbers(); | ||
if (isNaN(this.xlColumnsNumber) || isNaN(this.lgColumnsNumber) || isNaN(this.mdColumnsNumber)) { | ||
throw new Error('Input a valid number for columns'); | ||
} else if (this.xlColumnsNumber > 12 || this.lgColumnsNumber > 12 || this.mdColumnsNumber > 12) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for else if
when you have throw
or return
in if
block
5540013
to
3ab72f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…ies in components
f412acf
to
e4d1bbb
Compare
Please provide a link to the associated issue.
#4076
Please provide a brief summary of this pull request.
Please check whether the PR fulfills the following requirements
https://github.com/SAP/fundamental-ngx/blob/main/CONTRIBUTING.md
https://github.com/SAP/fundamental-ngx/wiki/PR-Review-Checklist
Documentation checklist:
README.md