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:select): support custom template in select component #3071

Merged
merged 13 commits into from
Jun 22, 2019

Conversation

andrew-yangy
Copy link
Contributor

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: #2946

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@andrew-yangy
Copy link
Contributor Author

I also tried to add a nzSameContentInSelect property for nz-option so that the customContent template can be used for select component directly, like this

<ng-container *ngIf="nzSelectService.listOfCachedSelectedOption[0]?.nzSameContentInSelect; else customTemplate">
        <ng-template [ngTemplateOutlet]="nzSelectService.listOfCachedSelectedOption[0]?.template"></ng-template>
      </ng-container>
      <ng-template #customTemplate>
        <ng-container *ngIf="nzCustomTemplate; else noTemplate">
          <ng-template [ngTemplateOutlet]="nzCustomTemplate" [ngTemplateOutletContext]="{ $implicit: nzSelectService.listOfCachedSelectedOption[0] }"></ng-template>
        </ng-container>
        <ng-template #noTemplate>
          {{ nzSelectService.listOfCachedSelectedOption[0]?.nzLabel }}
        </ng-template>
      </ng-template>

However, <ng-template [ngTemplateOutlet]="nzSelectService.listOfCachedSelectedOption[0]?.template"></ng-template> </ng-container> this part will be cleared and rerendered every time click the select section, I guess this is something to do with this issue angular/angular#20810

@codecov
Copy link

codecov bot commented Mar 11, 2019

Codecov Report

Merging #3071 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3071      +/-   ##
==========================================
+ Coverage   95.45%   95.47%   +0.01%     
==========================================
  Files         685      685              
  Lines       14042    14077      +35     
  Branches     1865     1874       +9     
==========================================
+ Hits        13404    13440      +36     
+ Misses        231      226       -5     
- Partials      407      411       +4
Impacted Files Coverage Δ
...mponents/select/nz-select-top-control.component.ts 100% <100%> (ø) ⬆️
components/select/nz-select.component.ts 96.95% <100%> (+0.03%) ⬆️
components/select/nz-option-container.component.ts 95.34% <0%> (-2.33%) ⬇️
components/carousel/nz-carousel-definitions.ts 100% <0%> (ø) ⬆️
components/i18n/languages/date-picker/sk_SK.ts 100% <0%> (ø) ⬆️
components/i18n/languages/date-picker/et_EE.ts 100% <0%> (ø) ⬆️
components/core/tree/nz-tree-base.service.ts 94.66% <0%> (ø) ⬆️
components/carousel/nz-carousel.component.ts 93.71% <0%> (ø) ⬆️
...mponents/input-number/nz-input-number.component.ts 97.6% <0%> (+0.01%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c82f26...761c176. Read the comment docs.

@netlify
Copy link

netlify bot commented Mar 11, 2019

Deploy preview for ng-zorro-master ready!

Built with commit 761c176

https://deploy-preview-3071--ng-zorro-master.netlify.com

@wzhudev wzhudev requested a review from vthinkxie March 12, 2019 01:38
Copy link
Member

@vthinkxie vthinkxie left a comment

Choose a reason for hiding this comment

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

Hi @ddvkid
thanks a lot for your pr
plz make sure your pr meet the commit guideline https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/CONTRIBUTING.md#commit

@andrew-yangy
Copy link
Contributor Author

Hi @ddvkid
thanks a lot for your pr
plz make sure your pr meet the commit guideline https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/CONTRIBUTING.md#commit

Thanks for your comments, can you be more specific what I need to change? how about merging all the commits into one with more meaningful message?

@vthinkxie
Copy link
Member

@andrew-yangy andrew-yangy changed the title Feature/custom template select feat(module:select): support custom template in select componet Mar 12, 2019
@andrew-yangy andrew-yangy changed the title feat(module:select): support custom template in select componet feat(module:select): support custom template in select component Mar 12, 2019
@andrew-yangy andrew-yangy force-pushed the feature/custom-template-select branch 2 times, most recently from c1a1f06 to c5f53d5 Compare March 12, 2019 04:13
@andrew-yangy
Copy link
Contributor Author

@vthinkxie any idea why the checks failed, and is the new commit format okay?

@vthinkxie vthinkxie self-requested a review March 12, 2019 06:41
@andrew-yangy
Copy link
Contributor Author

@vthinkxie is this still going to be reviewed?

@vthinkxie
Copy link
Member

@ddvkid commit message is ok, plz check your test and rebase onto the latest master

@andrew-yangy andrew-yangy force-pushed the feature/custom-template-select branch 2 times, most recently from 541b371 to 6f583b1 Compare March 28, 2019 03:28
@wzhudev
Copy link
Member

wzhudev commented Mar 28, 2019

@ddvkid Hello! Please rebase to the master branch.

@andrew-yangy andrew-yangy force-pushed the feature/custom-template-select branch 2 times, most recently from f90d912 to a0241fa Compare March 28, 2019 06:11
@andrew-yangy
Copy link
Contributor Author

@vthinkxie @wendzhue the tests have been fixed, can you please have a review?

@andrew-yangy
Copy link
Contributor Author

@vthinkxie updates?

@andrew-yangy
Copy link
Contributor Author

@vthinkxie ?

@andrew-yangy andrew-yangy force-pushed the feature/custom-template-select branch from 6e0171a to 854bce2 Compare June 22, 2019 09:05
templateUrl: './nz-select-top-control.component.html'
templateUrl: './nz-select-top-control.component.html',
host: {
'[class.ant-select-selection--single]': 'nzSelectService.isSingleMode',
Copy link
Member

@vthinkxie vthinkxie Jun 22, 2019

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this is because I moved these into the component's host https://github.com/NG-ZORRO/ng-zorro-antd/pull/3071/files#diff-290abbcec228b4006c68b790f2878cf5L18
I can change it back in order to be consistent.

Copy link
Member

@vthinkxie vthinkxie left a comment

Choose a reason for hiding this comment

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

templateUrl: './nz-select-top-control.component.html'
templateUrl: './nz-select-top-control.component.html',
host: {
'[style.cursor]': 'nzShowSearch ? "inherit" : "pointer"'
Copy link
Member

Choose a reason for hiding this comment

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

any reason add this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm.. I can't recall it's been too long... let me try.

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 couldn't replicate the issue I ran into... it might be fixed by other updates, so I just removed it.

Copy link
Member

@vthinkxie vthinkxie left a comment

Choose a reason for hiding this comment

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

Everything looks great now, approved
Thanks a lot for your contribution!

@vthinkxie vthinkxie merged commit aad02a5 into NG-ZORRO:master Jun 22, 2019
Ricbet pushed a commit to Ricbet/ng-zorro-antd that referenced this pull request Apr 9, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants