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(module:all): simplify boolean attributes usage #459

Merged
merged 1 commit into from
Dec 5, 2017
Merged

feat(module:all): simplify boolean attributes usage #459

merged 1 commit into from
Dec 5, 2017

Conversation

trotyl
Copy link
Contributor

@trotyl trotyl commented Oct 20, 2017

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: closes #458, closes #648.

(There will be a different PR for #460)

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

buttonDebugElement.nativeElement.click();
expect(testComponent.isLoading).toBe(true);
setTimeout(_ => {
Copy link
Contributor Author

@trotyl trotyl Oct 20, 2017

Choose a reason for hiding this comment

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

This is failing randomly in my local machine, fixed now. (Likely it wasn't working at all in sync function)

Copy link
Contributor

Choose a reason for hiding this comment

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

tick is fine

@@ -40,7 +40,12 @@ export class NzButtonComponent implements AfterContentInit {

@Input()
set nzGhost(value: boolean) {
this._ghost = value;
const ghost = value as boolean | ''
Copy link
Contributor Author

@trotyl trotyl Oct 20, 2017

Choose a reason for hiding this comment

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

This way it will not change the property type, user still get boolean value when access via API. (getter & setter must have same type)

@Input() nzMode = 'year';
@Input() nzFullScreen = true;
@Input() nzShowHeader = true;
@Input() nzDisabledDate: Function;

@Input()
get nzValue(): Date {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Input() should always on setter rather than getter, same below.

}

@Input()
@HostBinding('class.ant-card-no-hovering')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Theoretically @HostBinding() should on getter, but TypeScript requires all decorators on same part.

@@ -67,15 +68,24 @@ import { NzDropDownComponent } from './nz-dropdown.component';
})

export class NzDropDownButtonComponent extends NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() nzDisable = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is a breaking bug fix, using nzDisable instead of nzDisabled is just a typo, but should be mentioned in change log.

@NG-ZORRO NG-ZORRO deleted a comment from coveralls Nov 30, 2017
@NG-ZORRO NG-ZORRO deleted a comment from coveralls Nov 30, 2017
@NG-ZORRO NG-ZORRO deleted a comment from coveralls Nov 30, 2017
@vthinkxie
Copy link
Member

should it be merged now or later?

@trotyl
Copy link
Contributor Author

trotyl commented Nov 30, 2017

Later, still working on it... 😃

@trotyl trotyl changed the title [WIP] feat(module:TODO): simplify boolean attributes [WIP] feat(module:all): simplify boolean attributes usage Nov 30, 2017
}

@ViewChild('ref')
_ref;

@HostBinding('class.ant-spin-nested-loading')
private get isNested() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HostBinding() cannot use private since it's accessed by external class.

@NG-ZORRO NG-ZORRO deleted a comment from coveralls Dec 1, 2017
@NG-ZORRO NG-ZORRO deleted a comment from coveralls Dec 1, 2017
@NG-ZORRO NG-ZORRO deleted a comment from coveralls Dec 1, 2017
@NG-ZORRO NG-ZORRO deleted a comment from coveralls Dec 1, 2017
@NG-ZORRO NG-ZORRO deleted a comment from coveralls Dec 1, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 41.451% when pulling 5773f28 on trotyl:boolean-attribute into 68163a4 on NG-ZORRO:master.

@NG-ZORRO NG-ZORRO deleted a comment from coveralls Dec 1, 2017
@NG-ZORRO NG-ZORRO deleted a comment from coveralls Dec 1, 2017
@trotyl trotyl changed the title [WIP] feat(module:all): simplify boolean attributes usage feat(module:all): simplify boolean attributes usage Dec 1, 2017
@trotyl
Copy link
Contributor Author

trotyl commented Dec 1, 2017

Ready for review, likely it would require local checkout.

Coverage decrease is caused by extra getter/setter (which are functions and counted), could be ignored.

get subItemSelected(): boolean {
return !!this.nzMenuComponent.menuItems.find(e => e.selected && e.nzSubMenuComponent === this);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was accessing internal field originally, added type info for menuItems to allow type checking.

this.isLoadingOne = false;
}, 5000);
};
loadTwo = (value) => {
Copy link
Member

Choose a reason for hiding this comment

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

will cause error when click Click me! button

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will check it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, it's just by mistake.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 41.451% when pulling 1fbc608 on trotyl:boolean-attribute into 9073bc8 on NG-ZORRO:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 41.451% when pulling 0cd2d8b on trotyl:boolean-attribute into 5e341de on NG-ZORRO:master.

@vthinkxie vthinkxie merged commit 08f10e4 into NG-ZORRO:master Dec 5, 2017
hsuanxyz pushed a commit to hsuanxyz/ng-zorro-antd that referenced this pull request Dec 6, 2017
hsuanxyz pushed a commit to hsuanxyz/ng-zorro-antd that referenced this pull request Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

perf: remove unused life-cycle hooks Simply boolean attribute usage
4 participants