-
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) Radio button group component Implementation #2122
Conversation
Check the deploy log for errors here: https://app.netlify.com/sites/fundamental-ngx/deploys Built with commit 9c75c8b https://app.netlify.com/sites/fundamental-ngx/deploys/5e611220b993cb00071e4cca |
Deploy preview for fundamental-ngx ready! Built with commit 8b85427 |
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 dont use capital names for folder/package structure /Forms/
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 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
.
<fd-radio-button | ||
fd-form-control | ||
name="name" | ||
[value]="None" |
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.
Is "None" a string value? If so, this will not work unless the string is placed in single quotes, like this:
[value]="'None'"
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.
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" |
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.
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 {} |
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 think we agreed to preface all our module names with Platform
. Please change the name from FdpFormModule
to PlatformModule
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.
@KevinOkamoto Are you sure its Platform? I just told him its Fdp and I can pull out the thread.
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.
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".
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.
it should not be plurar forms
it should be form
* custom label that is shown in the options. | ||
*/ | ||
|
||
export type stateType = 'valid' | 'invalid' | 'warning' | 'default' | 'information'; |
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.
Constant should start with capital letter
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.
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'; |
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.
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 ?
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.
Similar as above for statetype
. states are already defined in the core. can we use it?
state: stateType = 'default'; | ||
|
||
@Input() | ||
get isInline(): boolean { |
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.
You should add some documentation for this.
libs/platform/src/lib/components/Forms/radio-group/radio-group.component.ts
Outdated
Show resolved
Hide resolved
7f3a2bc
to
b80b87d
Compare
button.inputElement.nativeElement.checked = true; | ||
this._selected = button; | ||
} | ||
// button.onChange.Pipe(takeUntil(this.destroy$)).subscribe(ev => this._selectedRadioButtonChanged(ev)); |
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.
@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(); |
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.
@fkolar ,as content is not initialised. I am not able to update names for content Radio buttons. please suggest
7e7a664
to
d12cf97
Compare
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. |
@@ -0,0 +1,22 @@ | |||
<ng-template #renderer> | |||
<ng-container *ngTemplateOutlet="radio"></ng-container> |
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 have commented this before on slack, this is not addressed.
- 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'; |
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.
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 { |
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.
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 { |
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 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..
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 had not pushed changes for Radio button group. Now i have pushed.
yes slack is not a good place for comments.
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.
Fiori has Radio button Group, we need to maintain the same naming convention everywhere it is used.
e32d04c
to
d2ace33
Compare
export class RadioButtonComponent extends BaseInput { | ||
/** Setting default value for mandatory field id */ | ||
@Input() | ||
id: string = `radio-id-${uniqueId++}`; |
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.
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; |
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.
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; |
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.
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 } |
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.
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++}`; |
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.
The same as my comment for radiobutton
* Type of Radio buttons. | ||
*/ | ||
@Input() | ||
state: stateType = 'default'; |
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.
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
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.
if we do like this then it will diverse from fiori specification. and QA may raise more questions.
libs/platform/src/lib/components/form/radio-group/radio-group.component.ts
Show resolved
Hide resolved
* values of radio buttons. type will be of SelectItem or String | ||
*/ | ||
@Input() | ||
list: Array<SelectItem | string>; |
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.
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 @@ | |||
/** |
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 though that this one is under:
https://github.com/SAP/fundamental-ngx/blob/master/libs/platform/src/lib/domain/data-model.ts
You have moved this?
e262962
to
fcc1020
Compare
templateUrl: './radio-group.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class GroupRadioButtonComponent extends CollectionBaseInput implements AfterViewInit { |
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.
Rename to RadioGroupComponent
exports: [GroupRadioButtonComponent], | ||
declarations: [GroupRadioButtonComponent] | ||
}) | ||
export class FdpRadioButtonGroupModule {} |
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.
Rename to PlatformRadioGroupModule
5a17474
to
cb54644
Compare
libs/platform/src/lib/components/form/radio-group/radio-group.component.ts
Show resolved
Hide resolved
imports: [CommonModule, FdFormModule, RadioModule, FormsModule, ReactiveFormsModule], | ||
exports: [RadioButtonComponent], | ||
declarations: [RadioButtonComponent] | ||
}) |
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 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; | ||
} |
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.
Who or what will be setting a state in case of RB?
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.
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".
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.
have removed state input and getting it from Status of BaseInput.
8ba1486
to
585f8d1
Compare
@SAP/fundamental-denoland-team check you check? |
naming changes name changes in test cases radio module removed removed unnecesary detectchanges
585f8d1
to
8b85427
Compare
No change needed for 0.16.0 release. so merging it. |
@DeepakSap14 you should have checked with us before merging |
@droshev "@SAP/fundamental-denoland-team" , was asked for review. i waited for 1 day for any comments. then i merged. |
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
https://github.com/SAP/fundamental-ngx/blob/master/CONTRIBUTING.md
Documentation checklist:
README.md