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) Radio button group component Implementation #2122

Merged
merged 4 commits into from
Apr 16, 2020

Conversation

DeepakSap14
Copy link
Contributor

@DeepakSap14 DeepakSap14 commented Mar 5, 2020

Please provide a link to the associated issue.

#2121

https://github.com/SAP/fundamental-ngx/wiki/Platform:-RadioGroup-Technical-Design

Please provide a brief summary of this pull request.

Implementation of Radio Button Group component, which Groups many radio buttons with simple template signature.

Please check whether the PR fulfills the following requirements

Documentation checklist:

@netlify
Copy link

netlify bot commented Mar 5, 2020

@netlify
Copy link

netlify bot commented Mar 5, 2020

Deploy preview for fundamental-ngx ready!

Built with commit 8b85427

https://deploy-preview-2122--fundamental-ngx.netlify.com

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.

We dont use capital names for folder/package structure /Forms/

Copy link
Member

@KevinOkamoto KevinOkamoto left a comment

Choose a reason for hiding this comment

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

I see you've placed the new forms code in the directory libs/platform/src/lib/components/Forms. Directory names shouldn't be capitalized. Please lower-case the directory name: libs/platform/src/lib/components/forms.

libs/platform/src/lib/components/Forms/fdp-form.module.ts Outdated Show resolved Hide resolved
<fd-radio-button
fd-form-control
name="name"
[value]="None"
Copy link
Member

Choose a reason for hiding this comment

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

Is "None" a string value? If so, this will not work unless the string is placed in single quotes, like this:

[value]="'None'"

Copy link
Member

Choose a reason for hiding this comment

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

you dont use to use it this way. [value]="None" must even fail the compilation no? you are using binding syntax.
Also whey are u using directive fd-form-control ?

<div fd-form-item *ngIf="hasNoValue">
<fd-radio-button
fd-form-control
name="name"
Copy link
Member

Choose a reason for hiding this comment

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

Are we hard-coding "name" to the string 'name'? I think you want property binding here:

[name]="name"

entryComponents: [RadioGroupComponent],
exports: [RadioGroupComponent]
})
export class FdpFormModule {}
Copy link
Member

Choose a reason for hiding this comment

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

I think we agreed to preface all our module names with Platform. Please change the name from FdpFormModule to PlatformModule

Copy link
Member

Choose a reason for hiding this comment

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

@KevinOkamoto Are you sure its Platform? I just told him its Fdp and I can pull out the thread.

Copy link
Member

Choose a reason for hiding this comment

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

Ah my bad - I guess we earlier decided on "Fdp". However all the other modules in the platform library are prefaced with "Platform", so instead of changing the names of the other modules which have already been published, let's name it "PlatformFormModule", so that we have consistent naming in our library, and from this point forward all platform modules will be prefaced with "Platform".

@KevinOkamoto
Copy link
Member

I checkout your branch, and tried running the documentation app, and saw these errors in the console:

Screen Shot 2020-03-05 at 7 59 59 AM

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.

it should not be plurar forms it should be form

libs/platform/src/lib/components/Forms/form-control.ts Outdated Show resolved Hide resolved
libs/platform/src/lib/components/Forms/public_api.ts Outdated Show resolved Hide resolved
* custom label that is shown in the options.
*/

export type stateType = 'valid' | 'invalid' | 'warning' | 'default' | 'information';
Copy link
Member

Choose a reason for hiding this comment

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

Constant should start with capital letter

Copy link
Member

Choose a reason for hiding this comment

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

also I saw similar constant in the core, we can simply use it, we dont need to redefine it here

import { BaseInput } from '../base.input';
import { SelectItem } from '../data-model';

export type stateType = 'valid' | 'invalid' | 'warning' | 'default' | 'information';
Copy link
Member

Choose a reason for hiding this comment

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

Does state type applies to all of the components ? if yes then you dont want to duplicate the declaration in here. (I think I saw in some other file ). This relates to other comments I had above. Before jumping into this, let;'s think of all the common properties for Inputs.

State, Compact|Cozy -> Is there anything else ?

Copy link
Member

Choose a reason for hiding this comment

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

Similar as above for statetype. states are already defined in the core. can we use it?

state: stateType = 'default';

@Input()
get isInline(): boolean {
Copy link
Member

Choose a reason for hiding this comment

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

You should add some documentation for this.

@DeepakSap14 DeepakSap14 changed the title feat: (platform) Radio button group component Implementation feat: [WIP] (platform) Radio button group component Implementation Mar 10, 2020
@DeepakSap14 DeepakSap14 changed the title feat: [WIP] (platform) Radio button group component Implementation [WIP]feat: (platform) Radio button group component Implementation Mar 10, 2020
@DeepakSap14 DeepakSap14 changed the title [WIP]feat: (platform) Radio button group component Implementation [WIP] feat: (platform) Radio button group component Implementation Mar 10, 2020
button.inputElement.nativeElement.checked = true;
this._selected = button;
}
// button.onChange.Pipe(takeUntil(this.destroy$)).subscribe(ev => this._selectedRadioButtonChanged(ev));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fkolar , Radio button have not exposed change event. By using Onchange function i am not able to get button change event. please suggest here.

set name(value: string) {
if (this.name !== value) {
this._name = value;
this._updateRadioButtonNames();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fkolar ,as content is not initialised. I am not able to update names for content Radio buttons. please suggest

@InnaAtanasova InnaAtanasova requested a review from a team March 18, 2020 16:53
@InnaAtanasova InnaAtanasova added the platform platform label Mar 18, 2020
@InnaAtanasova InnaAtanasova added this to In progress in Development via automation Mar 18, 2020
@InnaAtanasova InnaAtanasova added this to the Sprint 34 - Głogów milestone Mar 18, 2020
@fkolar
Copy link
Member

fkolar commented Mar 24, 2020

Since I was commenting on this mostly in the slack, have you addressed all the comments before I starts looking at this ? Also you might want to squash your commits. when you giving this out for a review..

@DeepakSap14
Copy link
Contributor Author

Since I was commenting on this mostly in the slack, have you addressed all the comments before I starts looking at this ? Also you might want to squash your commits. when you giving this out for a review..

i will take one more day to push the changes. i will let you know, if i push changes.
from next time i will squash the commits.

Development automation moved this from In progress to Review in progress Mar 29, 2020
@@ -0,0 +1,22 @@
<ng-template #renderer>
<ng-container *ngTemplateOutlet="radio"></ng-container>
Copy link
Member

Choose a reason for hiding this comment

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

I have commented this before on slack, this is not addressed.

  1. I was asking, why do you need this ng-template radio and extra ng-container?

@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
Copy link
Member

Choose a reason for hiding this comment

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

Remove this file as there are not tests and issue and it will be tested as part of RB Group

  • Can you move Radio under RadioGroup? I know logically in case of CheckBox, it makes sense to have it as extra folder, but I dont see a usecase somebody will be using fdp-radio on its own (they could use fd-radio), but our added value is RB Group.

changeDetection: ChangeDetectionStrategy.OnPush,
providers: [{ provide: FormFieldControl, useExisting: PlatformRadioButtonComponent, multi: true }]
})
export class PlatformRadioButtonComponent implements ControlValueAccessor {
Copy link
Member

Choose a reason for hiding this comment

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

Once again, you havent addressed thing that I said before. You asked me to comment things in slack and I have added comment for this.

Check e.g. RB implementation for radio button in material design, and comment I said in slack

export class PlatformRadioButtonComponent implements ControlValueAccessor {
/** name of radio button, will be set from radio button group name */
@Input()
get name(): any {
Copy link
Member

Choose a reason for hiding this comment

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

I am finishing my review as the same applies for name, its not addressed, Please come back when you address all, or at least you raise question.

I don't feel like copying over all what I said... Please next time, dont ask for input on slack..

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 had not pushed changes for Radio button group. Now i have pushed.
yes slack is not a good place for comments.

@DeepakSap14 DeepakSap14 requested a review from sKudum March 30, 2020 09:46
Copy link
Contributor

@sKudum sKudum left a comment

Choose a reason for hiding this comment

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

Fiori has Radio button Group, we need to maintain the same naming convention everywhere it is used.

@DeepakSap14 DeepakSap14 changed the title [WIP] feat: (platform) Radio button group component Implementation feat: (platform) Radio button group component Implementation Mar 30, 2020
export class RadioButtonComponent extends BaseInput {
/** Setting default value for mandatory field id */
@Input()
id: string = `radio-id-${uniqueId++}`;
Copy link
Member

Choose a reason for hiding this comment

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

You dont need to redefine @input for values which are in parent, if you need re-assign values, just do this in constructor. the same goes for name


/** Access radio button child elemen passed as content of radio button group*/
@ViewChild(CoreRadioButtonComponent, { static: false })
coreRadioButton: CoreRadioButtonComponent;
Copy link
Member

Choose a reason for hiding this comment

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

make it private if you are not using it outside

* Value for the radio-group. Should equal the value of the selected radio button if there is
* a corresponding radio button with a matching value.
*/
protected _value: any = null;
Copy link
Member

Choose a reason for hiding this comment

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

you can make this private, I dont think you expect somebody will inhert radio

<ng-container
*ngTemplateOutlet="
radio?.renderer;
context: { name: name, value: radio.value, size: size, state: state, disabled: disabled }
Copy link
Member

Choose a reason for hiding this comment

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

You can disable who RadioGroup or you can disable individual RB within th e group. I think here you want to pass radio.disabed from application.

Or even better, when you set disabled to true on Group Level and its clear you want to disable all, but if it will have default value false on the group level you want read from RB definition.

disabled: disabled ||radio.disabled Does this make sense ?

as for the other attributes I guess size should be one 1, you dont dont even need to test it, it needs to have size set on the GROUP level

export class GroupRadioButtonComponent extends CollectionBaseInput implements AfterViewInit {
/** uniqly generated, if value not provided for id */
@Input()
id: string = `radio-group-${nextUniqueId++}`;
Copy link
Member

Choose a reason for hiding this comment

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

The same as my comment for radiobutton

* Type of Radio buttons.
*/
@Input()
state: stateType = 'default';
Copy link
Member

@fkolar fkolar Mar 31, 2020

Choose a reason for hiding this comment

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

Dont we have state on BaseInput Level? or formControl level?

There is something called

export type Status = 'error' | 'warning' | void;

Where void is your default. We selected states which make sense . so you could remove state as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we do like this then it will diverse from fiori specification. and QA may raise more questions.

* values of radio buttons. type will be of SelectItem or String
*/
@Input()
list: Array<SelectItem | string>;
Copy link
Member

Choose a reason for hiding this comment

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

What I mean by this list list: Array<SelectItem | string>; in relation to CollectionBaseInput so to move this @Input into this parent, so we can use the same for CheckboxGroup.
Since its CollectionBaseInput, it will have this ist: Array<SelectItem | string>;.

So you could remove it from here..

@@ -0,0 +1,33 @@
/**
Copy link
Member

Choose a reason for hiding this comment

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

@DeepakSap14 DeepakSap14 force-pushed the RadioButtonGroup branch 2 times, most recently from e262962 to fcc1020 Compare April 6, 2020 05:05
templateUrl: './radio-group.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class GroupRadioButtonComponent extends CollectionBaseInput implements AfterViewInit {
Copy link
Member

Choose a reason for hiding this comment

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

Rename to RadioGroupComponent

exports: [GroupRadioButtonComponent],
declarations: [GroupRadioButtonComponent]
})
export class FdpRadioButtonGroupModule {}
Copy link
Member

Choose a reason for hiding this comment

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

Rename to PlatformRadioGroupModule

imports: [CommonModule, FdFormModule, RadioModule, FormsModule, ReactiveFormsModule],
exports: [RadioButtonComponent],
declarations: [RadioButtonComponent]
})
Copy link
Member

Choose a reason for hiding this comment

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

We said that we dont need this module, radio will be part of RadioGroup. Unless it make sense to use this on its own. What do you think?

@Input()
get state(): Status | stateType {
return this._state;
}
Copy link
Member

Choose a reason for hiding this comment

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

Who or what will be setting a state in case of RB?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changing the style for Error, which is _status in baseInput, It needs to be passed to Radio button. so i am doing [state]="status" in "radio-group.component.html".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

have removed state input and getting it from Status of BaseInput.

@DeepakSap14 DeepakSap14 force-pushed the RadioButtonGroup branch 2 times, most recently from 8ba1486 to 585f8d1 Compare April 11, 2020 10:04
@DeepakSap14 DeepakSap14 linked an issue Apr 14, 2020 that may be closed by this pull request
Development automation moved this from Review in progress to Reviewer approved Apr 14, 2020
@fkolar
Copy link
Member

fkolar commented Apr 14, 2020

@SAP/fundamental-denoland-team check you check?

@DeepakSap14
Copy link
Contributor Author

No change needed for 0.16.0 release. so merging it.

@DeepakSap14 DeepakSap14 merged commit cd2c26c into master Apr 16, 2020
Development automation moved this from Reviewer approved to Done Apr 16, 2020
@DeepakSap14 DeepakSap14 deleted the RadioButtonGroup branch April 16, 2020 06:12
@droshev
Copy link
Contributor

droshev commented Apr 17, 2020

@DeepakSap14 you should have checked with us before merging

@DeepakSap14
Copy link
Contributor Author

@droshev "@SAP/fundamental-denoland-team" , was asked for review. i waited for 1 day for any comments. then i merged.
Is any review pending, i will create separate PR, if it is needed.

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.

feat: (platform) Radio button group component Implementation
7 participants