From 31243d2cdd863941f1cadf6352ef541ebb7a31f2 Mon Sep 17 00:00:00 2001 From: muhammedaltug Date: Wed, 25 Jan 2023 16:37:26 +0300 Subject: [PATCH 01/22] uncheck when already selected label click --- .../tree/src/lib/components/tree.component.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts b/npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts index f8216f184a..5df8ed5ee0 100644 --- a/npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts +++ b/npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts @@ -4,13 +4,13 @@ import { EventEmitter, Inject, Input, + OnInit, Optional, Output, TemplateRef, ViewEncapsulation, - OnInit, } from '@angular/core'; -import { NzFormatBeforeDropEvent, NzFormatEmitEvent } from 'ng-zorro-antd/tree'; +import { NzFormatBeforeDropEvent, NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree'; import { of } from 'rxjs'; import { TreeNodeTemplateDirective } from '../templates/tree-node-template.directive'; import { ExpandedIconTemplateDirective } from '../templates/expanded-icon-template.directive'; @@ -77,11 +77,16 @@ export class TreeComponent implements OnInit { this.subscriptionService.addOne(loaded$); } - onSelectedNodeChange(node) { + onSelectedNodeChange(node: NzTreeNode) { this.selectedNode = node.origin.entity; if (this.changeCheckboxWithNode) { + let newVal; + if (node.isChecked) { + newVal = this.checkedKeys.filter(x => x !== node.key); + } else { + newVal = [...this.checkedKeys, node.key]; + } this.selectedNodeChange.emit(node); - const newVal = [...this.checkedKeys, node.key]; this.checkedKeys = newVal; this.checkedKeysChange.emit(newVal); } else { From aa7c19843d2ea0f303c57df6ed393ff17f8d2aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= Date: Wed, 25 Jan 2023 16:52:33 +0300 Subject: [PATCH 02/22] Update Part-10.md --- docs/en/Tutorials/Part-10.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/en/Tutorials/Part-10.md b/docs/en/Tutorials/Part-10.md index d72505b309..9f1f274d17 100644 --- a/docs/en/Tutorials/Part-10.md +++ b/docs/en/Tutorials/Part-10.md @@ -1126,6 +1126,21 @@ protected override async Task OnInitializedAsync() * It is essential to call the `base.OnInitializedAsync()` since `AbpCrudPageBase` has some initialization code to be executed. +Override the `OpenCreateModalAsync` method and adding the following code: + +````csharp +protected override async Task OpenCreateModalAsync() + { + if (!authorList.Any()) + { + throw new UserFriendlyException(message: L["AnAuthorIsRequiredForCreatingBook"]); + } + + await base.OpenCreateModalAsync(); + NewEntity.AuthorId = authorList.First().Id; + } +```` + The final `@code` block should be the following: ````csharp @@ -1147,6 +1162,17 @@ The final `@code` block should be the following: await base.OnInitializedAsync(); authorList = (await AppService.GetAuthorLookupAsync()).Items; } + + protected override async Task OpenCreateModalAsync() + { + if (!authorList.Any()) + { + throw new UserFriendlyException(message: L["AnAuthorIsRequiredForCreatingBook"]); + } + + await base.OpenCreateModalAsync(); + NewEntity.AuthorId = authorList.First().Id; + } } ```` @@ -1156,7 +1182,6 @@ Finally, add the following `Field` definition into the `ModalBody` of the *Creat @L["Author"]