Skip to content
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

Merged
merged 24 commits into from
Jan 21, 2021

Conversation

genereg1
Copy link
Contributor

@genereg1 genereg1 commented Dec 29, 2020

Please provide a link to the associated issue.

#4076

Please provide a brief summary of this pull request.

  • Implement Form Grid Styles into Form Group component
  • Form Field column binding
  • Group Headers

Please check whether the PR fulfills the following requirements

Documentation checklist:

@netlify
Copy link

netlify bot commented Dec 29, 2020

✔️ 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

@genereg1 genereg1 self-assigned this Jan 5, 2021
@genereg1 genereg1 changed the title [WIP] feat: (platform) Form Group enhancement phase 1 feat: (platform) Form Group enhancement phase 1 Jan 6, 2021
@genereg1 genereg1 added the platform platform label Jan 6, 2021
@genereg1 genereg1 changed the title feat: (platform) Form Group enhancement phase 1 feat: (Platform) Form Group enhancement phase 1 Jan 6, 2021
@genereg1 genereg1 requested a review from a team January 11, 2021 09:06
@@ -35,6 +35,9 @@ export abstract class FormField {
* Indicates in which FormZone a form field should be rendered
*/
zone: FormZone;


column: number; // temp type
Copy link
Contributor

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?

Copy link
Contributor

@dimamarksman dimamarksman left a 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

Copy link
Member

@fkolar fkolar left a 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

libs/platform/src/lib/components/form/form-group.ts Outdated Show resolved Hide resolved
@@ -35,6 +35,10 @@ export abstract class FormField {
* Indicates in which FormZone a form field should be rendered
*/
zone: FormZone;
Copy link
Member

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 ?

Copy link
Contributor Author

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>
Copy link
Member

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';
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

libs/platform/src/lib/components/form/form-group.ts Outdated Show resolved Hide resolved
<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">
Copy link
Member

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,
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

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)

Copy link
Contributor Author

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 {
Copy link
Member

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.

Copy link
Contributor Author

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

f.styleClass = `col-sm-${f.columns} col-md-${f.columns} col-lg-${f.columns}`;
merged[current++] = f;
indexR++;
private _setUserLayout(): void {
Copy link
Member

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

Copy link
Contributor Author

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';
Copy link
Member

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

Copy link
Contributor

@JKMarkowski JKMarkowski left a 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

@genereg1 genereg1 force-pushed the feat/form-enhancement-phase-1 branch from 247f8a4 to f13d294 Compare January 16, 2021 10:17
Copy link
Contributor

@valorkin valorkin left a 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">
Copy link
Contributor

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

Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

e2e/wdio/platform/pages/combobox.po.ts Show resolved Hide resolved
<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"
Copy link
Contributor

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 } = {};
Copy link
Contributor

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?

Suggested change
const rows: { [key: number]: FieldColumn } | { [key: number]: FieldGroup } = {};
const rows: { [key: number]: FieldColumn | FieldGroup } = {};


for (const child of this.formChildren) {
if (this._isFieldChild(child)) {
const f = this._getField(child);
Copy link
Contributor

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

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) {
Copy link
Contributor

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

@genereg1 genereg1 force-pushed the feat/form-enhancement-phase-1 branch from 5540013 to 3ab72f3 Compare January 18, 2021 13:44
Copy link
Contributor

@valorkin valorkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@genereg1 genereg1 force-pushed the feat/form-enhancement-phase-1 branch from f412acf to e4d1bbb Compare January 20, 2021 13:49
@genereg1 genereg1 requested a review from fkolar January 20, 2021 16:31
@genereg1 genereg1 merged commit 064955e into main Jan 21, 2021
@genereg1 genereg1 deleted the feat/form-enhancement-phase-1 branch January 21, 2021 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants