From 4bfe91cdabd713daf460f337c58d89abcae4500d Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Mon, 7 Oct 2019 17:58:10 +0300 Subject: [PATCH 1/9] feature(theme-shared): add sort order icon component --- .../theme-shared/src/lib/components/index.ts | 1 + .../sort-order-icon.component.html | 3 ++ .../sort-order-icon.component.ts | 29 +++++++++++++++++++ .../src/lib/theme-shared.module.ts | 19 +++++++----- 4 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.html create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/index.ts b/npm/ng-packs/packages/theme-shared/src/lib/components/index.ts index 0792538400..900d9fa925 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/index.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/index.ts @@ -8,3 +8,4 @@ export * from './modal/modal.component'; export * from './profile/profile.component'; export * from './table-empty-message/table-empty-message.component'; export * from './toast/toast.component'; +export * from './sort-order-icon/sort-order-icon.component'; diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.html b/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.html new file mode 100644 index 0000000000..e554610d3c --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.html @@ -0,0 +1,3 @@ + + + diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.ts b/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.ts new file mode 100644 index 0000000000..0a71a4b9d7 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.ts @@ -0,0 +1,29 @@ +import { Component, Input, OnInit } from '@angular/core'; + +@Component({ + selector: 'abp-sort-order-icon', + templateUrl: './sort-order-icon.component.html', +}) +export class SortOrderIconComponent implements OnInit { + @Input() + selectedKey: string; + + @Input() + key: string; + + @Input() + order: string; + + @Input() + iconClass: string; + + get icon(): string { + if (!this.selectedKey) return 'fa-sort'; + if (this.selectedKey === this.key) return `fa-sort-${this.order}`; + else return ''; + } + + constructor() {} + + ngOnInit(): void {} +} diff --git a/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts b/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts index a1839f6217..2c7292ebc4 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts @@ -14,6 +14,7 @@ import { LoaderBarComponent } from './components/loader-bar/loader-bar.component import { ModalComponent } from './components/modal/modal.component'; import { ProfileComponent } from './components/profile/profile.component'; import { ToastComponent } from './components/toast/toast.component'; +import { SortOrderIconComponent } from './components/sort-order-icon/sort-order-icon.component'; import styles from './contants/styles'; import { ErrorHandler } from './handlers/error.handler'; import { chartJsLoaded$ } from './utils/widget-utils'; @@ -32,8 +33,8 @@ export function appendScript(injector: Injector) { 'style', styles, 'head', - 'afterbegin' - ) /* lazyLoadService.load(null, 'script', scripts) */ + 'afterbegin', + ) /* lazyLoadService.load(null, 'script', scripts) */, ).pipe(take(1)); }; @@ -53,7 +54,8 @@ export function appendScript(injector: Injector) { ModalComponent, ProfileComponent, TableEmptyMessageComponent, - ToastComponent + ToastComponent, + SortOrderIconComponent, ], exports: [ BreadcrumbComponent, @@ -65,9 +67,10 @@ export function appendScript(injector: Injector) { ModalComponent, ProfileComponent, TableEmptyMessageComponent, - ToastComponent + ToastComponent, + SortOrderIconComponent, ], - entryComponents: [ErrorComponent] + entryComponents: [ErrorComponent], }) export class ThemeSharedModule { static forRoot(): ModuleWithProviders { @@ -78,10 +81,10 @@ export class ThemeSharedModule { provide: APP_INITIALIZER, multi: true, deps: [Injector, ErrorHandler], - useFactory: appendScript + useFactory: appendScript, }, - { provide: MessageService, useClass: MessageService } - ] + { provide: MessageService, useClass: MessageService }, + ], }; } } From 4b682fb2622d96f39ad54cb17824e6890d75132e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 8 Oct 2019 11:12:01 +0300 Subject: [PATCH 2/9] Adjust namespace for Volo.Abp.AspNetCore.ExceptionHandling --- .../Pages/Error/Index.cshtml.cs | 2 +- .../Mvc/ExceptionHandling/AbpExceptionFilter.cs | 1 + .../Builder/AbpApplicationBuilderExtensions.cs | 2 +- .../AbpExceptionHandlingMiddleware.cs | 3 ++- .../DefaultExceptionToErrorInfoConverter.cs | 2 +- .../DefaultHttpExceptionStatusCodeFinder.cs | 3 +-- .../ExceptionHttpStatusCodeOptions.cs | 2 +- .../IExceptionToErrorInfoConverter.cs | 2 +- .../IHttpExceptionStatusCodeFinder.cs | 2 +- .../PersonAppServiceClientProxy_Tests.cs | 10 ++++++++++ .../Volo/Abp/TestApp/Application/IPeopleAppService.cs | 2 ++ .../Volo/Abp/TestApp/Application/PeopleAppService.cs | 7 +++++++ 12 files changed, 29 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Error/Index.cshtml.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Error/Index.cshtml.cs index af779b4c0a..66ea202442 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Error/Index.cshtml.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Error/Index.cshtml.cs @@ -2,7 +2,7 @@ using System; using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -using Volo.Abp.AspNetCore.Mvc.ExceptionHandling; +using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.Http; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Error diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs index 8ff0846b74..28c1c18fda 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.DependencyInjection; using Volo.Abp.Http; using Volo.Abp.Json; diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs index e2c930f39c..22c0079571 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.RequestLocalization; using Microsoft.Extensions.DependencyInjection; using Volo.Abp; using Volo.Abp.AspNetCore.Auditing; -using Volo.Abp.AspNetCore.Mvc.ExceptionHandling; +using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.AspNetCore.Tracing; using Volo.Abp.AspNetCore.Uow; using Volo.Abp.DependencyInjection; diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingMiddleware.cs index e108a71b24..cdd921dae4 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingMiddleware.cs @@ -4,12 +4,13 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Net.Http.Headers; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Uow; using Volo.Abp.DependencyInjection; using Volo.Abp.Http; using Volo.Abp.Json; -namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling +namespace Volo.Abp.AspNetCore.ExceptionHandling { public class AbpExceptionHandlingMiddleware : IMiddleware, ITransientDependency { diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs index af22ff2f7e..d1ae5dd59a 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs @@ -15,7 +15,7 @@ using Volo.Abp.Localization; using Volo.Abp.Localization.ExceptionHandling; using Volo.Abp.Validation; -namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling +namespace Volo.Abp.AspNetCore.ExceptionHandling { public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConverter, ITransientDependency { diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs index 7625fa1d63..d9079fc347 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Net; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; @@ -9,7 +8,7 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.ExceptionHandling; using Volo.Abp.Validation; -namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling +namespace Volo.Abp.AspNetCore.ExceptionHandling { public class DefaultHttpExceptionStatusCodeFinder : IHttpExceptionStatusCodeFinder, ITransientDependency { diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/ExceptionHttpStatusCodeOptions.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/ExceptionHttpStatusCodeOptions.cs index b987eb4073..d8766219f8 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/ExceptionHttpStatusCodeOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/ExceptionHttpStatusCodeOptions.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Net; -namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling +namespace Volo.Abp.AspNetCore.ExceptionHandling { public class ExceptionHttpStatusCodeOptions { diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/IExceptionToErrorInfoConverter.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/IExceptionToErrorInfoConverter.cs index ad5e5fa1aa..a25206a918 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/IExceptionToErrorInfoConverter.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/IExceptionToErrorInfoConverter.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Http; -namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling +namespace Volo.Abp.AspNetCore.ExceptionHandling { /// /// This interface can be implemented to convert an object to an object. diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/IHttpExceptionStatusCodeFinder.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/IHttpExceptionStatusCodeFinder.cs index 0566a247e1..726d738b7c 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/IHttpExceptionStatusCodeFinder.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/IHttpExceptionStatusCodeFinder.cs @@ -2,7 +2,7 @@ using System.Net; using Microsoft.AspNetCore.Http; -namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling +namespace Volo.Abp.AspNetCore.ExceptionHandling { public interface IHttpExceptionStatusCodeFinder { diff --git a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs index aeae7ef1b4..e8b6608e8d 100644 --- a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs +++ b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection; using Shouldly; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Http.Client; using Volo.Abp.Http.Modeling; using Volo.Abp.TestApp.Application; using Volo.Abp.TestApp.Application.Dto; @@ -103,6 +104,15 @@ namespace Volo.Abp.Http.DynamicProxying personInDb.Age.ShouldBe(person.Age); } + [Fact] + public async Task GetWithAuthorized() + { + (await Assert.ThrowsAsync(async () => + { + await _peopleAppService.GetWithAuthorized(); + })).Error.Message.ShouldContain("Authorization"); + } + [Fact] public async Task GetWithComplexType() { diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs index cf2393869d..38b0e87787 100644 --- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs @@ -14,6 +14,8 @@ namespace Volo.Abp.TestApp.Application Task RemovePhone(Guid id, string number); + Task GetWithAuthorized(); + Task GetWithComplexType(GetWithComplexTypeInput input); } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs index e21cc14d08..d7909542d4 100644 --- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Dtos; using Volo.Abp.TestApp.Domain; using Volo.Abp.Domain.Repositories; @@ -46,6 +47,12 @@ namespace Volo.Abp.TestApp.Application Repository.Update(person); } + [Authorize] + public virtual Task GetWithAuthorized() + { + return Task.CompletedTask; + } + public Task GetWithComplexType(GetWithComplexTypeInput input) { return Task.FromResult(input); From bca421cbf56b71a16b1898c77472b8733cac5b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 8 Oct 2019 11:20:43 +0300 Subject: [PATCH 3/9] Add AbpAspNetCoreMvcModule assembly to the partmanager --- .../Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs | 1 + .../Volo/Abp/Http/AbpHttpClientTestModule.cs | 8 +------- .../DynamicProxying/PersonAppServiceClientProxy_Tests.cs | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs index 1600419ccb..8bce7bfd62 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs @@ -111,6 +111,7 @@ namespace Volo.Abp.AspNetCore.Mvc var application = context.Services.GetSingletonInstance(); partManager.FeatureProviders.Add(new AbpConventionalControllerFeatureProvider(application)); + partManager.ApplicationParts.Add(new AssemblyPart(typeof(AbpAspNetCoreMvcModule).Assembly)); Configure(mvcOptions => { diff --git a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/AbpHttpClientTestModule.cs b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/AbpHttpClientTestModule.cs index ecde843177..2835c086b8 100644 --- a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/AbpHttpClientTestModule.cs +++ b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/AbpHttpClientTestModule.cs @@ -1,5 +1,4 @@ -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Http.Client; using Volo.Abp.Http.DynamicProxying; @@ -23,11 +22,6 @@ namespace Volo.Abp.Http { options.RemoteServices.Default = new RemoteServiceConfiguration("/"); }); - - //This is needed after ASP.NET Core 3.0 upgrade. - context.Services.AddMvc() - .PartManager.ApplicationParts - .Add(new AssemblyPart(typeof(AbpAspNetCoreMvcModule).Assembly)); } } } diff --git a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs index e8b6608e8d..893aad6043 100644 --- a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs +++ b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs @@ -6,7 +6,6 @@ using Shouldly; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Repositories; using Volo.Abp.Http.Client; -using Volo.Abp.Http.Modeling; using Volo.Abp.TestApp.Application; using Volo.Abp.TestApp.Application.Dto; using Volo.Abp.TestApp.Domain; From 8b2b5deddd41f399d072e60446023b6908e7f758 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 8 Oct 2019 11:22:25 +0300 Subject: [PATCH 4/9] fixed project chnage bug in docs module --- .../docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml | 2 +- .../src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml index 38daad78b0..f74a47fb50 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml @@ -87,7 +87,7 @@ - + diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs index 1b5c446e04..d35e60fd5e 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs @@ -187,7 +187,7 @@ namespace Volo.Docs.Pages.Documents.Project ProjectSelectItems = projects.Items.Select(p => new SelectListItem { Text = p.Name, - Value = p.Id != Project.Id ? "/" + DocumentsUrlPrefix + LanguageCode + "/" + p.ShortName + "/" + DocsAppConsts.Latest : null, + Value = p.Id != Project.Id ? DocumentsUrlPrefix + LanguageCode + "/" + p.ShortName + "/" + DocsAppConsts.Latest : null, Selected = p.Id == Project.Id }).ToList(); } From 4fa105bb77b123ec2861b8f9033bb6f986b960e4 Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Tue, 8 Oct 2019 13:02:40 +0300 Subject: [PATCH 5/9] fix(core): change pipe inputs --- npm/ng-packs/packages/core/src/lib/pipes/sort.pipe.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/pipes/sort.pipe.ts b/npm/ng-packs/packages/core/src/lib/pipes/sort.pipe.ts index ce8ac78bb1..262025345d 100644 --- a/npm/ng-packs/packages/core/src/lib/pipes/sort.pipe.ts +++ b/npm/ng-packs/packages/core/src/lib/pipes/sort.pipe.ts @@ -9,7 +9,7 @@ export type SortOrder = 'asc' | 'desc'; export class SortPipe implements PipeTransform { intialValue: any[]; - transform(value: any[], sortOrder: SortOrder = 'asc', sortKey: string): any { + transform(value: any[], sortOrder: SortOrder | string = 'asc', sortKey?: string): any { sortOrder = sortOrder && (sortOrder.toLowerCase() as any); if (!this.intialValue) this.intialValue = clone(value); From d78000144e069c57d4144da8f0754ce79cd4114b Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Tue, 8 Oct 2019 13:03:36 +0300 Subject: [PATCH 6/9] feature(identity): add abpSort pipe --- .../lib/components/roles/roles.component.html | 8 ++- .../lib/components/roles/roles.component.ts | 36 +++++++++---- .../lib/components/users/users.component.html | 18 ++++--- .../lib/components/users/users.component.ts | 50 ++++++++++++------- 4 files changed, 71 insertions(+), 41 deletions(-) diff --git a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html index db52b77f82..c6d86b5968 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html +++ b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html @@ -24,7 +24,7 @@ {{ 'AbpIdentity::Actions' | abpLocalization }} - + {{ 'AbpIdentity::RoleName' | abpLocalization }} - + diff --git a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts index 7ebda6be18..f179e6b713 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts +++ b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts @@ -11,7 +11,7 @@ import { IdentityState } from '../../states/identity.state'; @Component({ selector: 'abp-roles', - templateUrl: './roles.component.html' + templateUrl: './roles.component.html', }) export class RolesComponent { @Select(IdentityState.getRoles) @@ -30,15 +30,15 @@ export class RolesComponent { providerKey: string; - pageQuery: ABP.PageQueryParams = { - sorting: 'name' - }; + pageQuery: ABP.PageQueryParams = {}; loading = false; modalBusy = false; - sortOrder = 'asc'; + sortOrder: string = ''; + + sortKey: string = ''; @ViewChild('modalContent', { static: false }) modalContent: TemplateRef; @@ -54,10 +54,10 @@ export class RolesComponent { this.form = this.fb.group({ name: new FormControl({ value: this.selected.name || '', disabled: this.selected.isStatic }, [ Validators.required, - Validators.maxLength(256) + Validators.maxLength(256), ]), isDefault: [this.selected.isDefault || false], - isPublic: [this.selected.isPublic || false] + isPublic: [this.selected.isPublic || false], }); } @@ -89,7 +89,7 @@ export class RolesComponent { .dispatch( this.selected.id ? new UpdateRole({ ...this.form.value, id: this.selected.id }) - : new CreateRole(this.form.value) + : new CreateRole(this.form.value), ) .subscribe(() => { this.modalBusy = false; @@ -100,7 +100,7 @@ export class RolesComponent { delete(id: string, name: string) { this.confirmationService .warn('AbpIdentity::RoleDeletionConfirmationMessage', 'AbpIdentity::AreYouSure', { - messageLocalizationParams: [name] + messageLocalizationParams: [name], }) .subscribe((status: Toaster.Status) => { if (status === Toaster.Status.confirm) { @@ -124,7 +124,21 @@ export class RolesComponent { .subscribe(); } - changeSortOrder() { - this.sortOrder = this.sortOrder.toLowerCase() === 'asc' ? 'desc' : 'asc'; + sortByKey(sortKey: string) { + this.sortKey = sortKey; + switch (this.sortOrder) { + case '': + this.sortOrder = 'asc'; + break; + case 'asc': + this.sortOrder = 'desc'; + break; + case 'desc': + this.sortOrder = ''; + this.sortKey = ''; + break; + default: + break; + } } } diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html index c17fd7f7c0..84746413fe 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html @@ -30,7 +30,7 @@ {{ 'AbpIdentity::Actions' | abpLocalization }} - + {{ 'AbpIdentity::UserName' | abpLocalization }} - + + + + {{ 'AbpIdentity::EmailAddress' | abpLocalization }} + + + + {{ 'AbpIdentity::PhoneNumber' | abpLocalization }} + - {{ 'AbpIdentity::EmailAddress' | abpLocalization }} - {{ 'AbpIdentity::PhoneNumber' | abpLocalization }} diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts index 18f7507f29..16fadcfa63 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts @@ -12,13 +12,13 @@ import { GetUserById, GetUserRoles, GetUsers, - UpdateUser + UpdateUser, } from '../../actions/identity.actions'; import { Identity } from '../../models/identity'; import { IdentityState } from '../../states/identity.state'; @Component({ selector: 'abp-users', - templateUrl: './users.component.html' + templateUrl: './users.component.html', }) export class UsersComponent { @Select(IdentityState.getUsers) @@ -42,9 +42,7 @@ export class UsersComponent { providerKey: string; - pageQuery: ABP.PageQueryParams = { - sorting: 'userName' - }; + pageQuery: ABP.PageQueryParams = {}; isModalVisible: boolean; @@ -52,7 +50,9 @@ export class UsersComponent { modalBusy = false; - sortOrder = 'asc'; + sortOrder: string = ''; + + sortKey: string = ''; trackByFn: TrackByFunction = (index, item) => Object.keys(item)[0] || index; @@ -80,10 +80,10 @@ export class UsersComponent { roleNames: this.fb.array( this.roles.map(role => this.fb.group({ - [role.name]: [!!snq(() => this.selectedUserRoles.find(userRole => userRole.id === role.id))] - }) - ) - ) + [role.name]: [!!snq(() => this.selectedUserRoles.find(userRole => userRole.id === role.id))], + }), + ), + ), }); if (!this.selected.userName) { this.form.addControl('password', new FormControl('', [Validators.required, Validators.maxLength(32)])); @@ -107,7 +107,7 @@ export class UsersComponent { .pipe( switchMap(() => this.store.dispatch(new GetUserRoles(id))), pluck('IdentityState'), - take(1) + take(1), ) .subscribe((state: Identity.State) => { this.selected = state.selectedUser; @@ -123,7 +123,7 @@ export class UsersComponent { const { roleNames } = this.form.value; const mappedRoleNames = snq( () => roleNames.filter(role => !!role[Object.keys(role)[0]]).map(role => Object.keys(role)[0]), - [] + [], ); this.store @@ -132,12 +132,12 @@ export class UsersComponent { ? new UpdateUser({ ...this.form.value, id: this.selected.id, - roleNames: mappedRoleNames + roleNames: mappedRoleNames, }) : new CreateUser({ ...this.form.value, - roleNames: mappedRoleNames - }) + roleNames: mappedRoleNames, + }), ) .subscribe(() => { this.modalBusy = false; @@ -148,7 +148,7 @@ export class UsersComponent { delete(id: string, userName: string) { this.confirmationService .warn('AbpIdentity::UserDeletionConfirmationMessage', 'AbpIdentity::AreYouSure', { - messageLocalizationParams: [userName] + messageLocalizationParams: [userName], }) .subscribe((status: Toaster.Status) => { if (status === Toaster.Status.confirm) { @@ -172,7 +172,21 @@ export class UsersComponent { .subscribe(); } - changeSortOrder() { - this.sortOrder = this.sortOrder.toLowerCase() === 'asc' ? 'desc' : 'asc'; + sortByKey(sortKey: string) { + this.sortKey = sortKey; + switch (this.sortOrder) { + case '': + this.sortOrder = 'asc'; + break; + case 'asc': + this.sortOrder = 'desc'; + break; + case 'desc': + this.sortOrder = ''; + this.sortKey = ''; + break; + default: + break; + } } } From 4eef7393f87ef7331351564530cc0869a4598b1f Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Tue, 8 Oct 2019 13:03:58 +0300 Subject: [PATCH 7/9] feature(tenant-management): add abpSort pipe --- .../components/tenants/tenants.component.html | 8 ++-- .../components/tenants/tenants.component.ts | 48 ++++++++++++------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html index 2b84c34dea..8c27fe180c 100644 --- a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html +++ b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html @@ -31,7 +31,7 @@ {{ 'AbpTenantManagement::Actions' | abpLocalization }} - + {{ 'AbpTenantManagement::TenantName' | abpLocalization }} - + diff --git a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts index f9c90764c2..e945cc5e69 100644 --- a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts +++ b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts @@ -10,7 +10,7 @@ import { DeleteTenant, GetTenants, GetTenantById, - UpdateTenant + UpdateTenant, } from '../../actions/tenant-management.actions'; import { TenantManagementService } from '../../services/tenant-management.service'; import { TenantManagementState } from '../../states/tenant-management.state'; @@ -23,7 +23,7 @@ interface SelectedModalContent { @Component({ selector: 'abp-tenants', - templateUrl: './tenants.component.html' + templateUrl: './tenants.component.html', }) export class TenantsComponent { @Select(TenantManagementState.get) @@ -50,15 +50,15 @@ export class TenantsComponent { _useSharedDatabase: boolean; - pageQuery: ABP.PageQueryParams = { - sorting: 'name' - }; + pageQuery: ABP.PageQueryParams = {}; loading = false; modalBusy = false; - sortOrder = 'asc'; + sortOrder: string = ''; + + sortKey: string = ''; get useSharedDatabase(): boolean { return this.defaultConnectionStringForm.get('useSharedDatabase').value; @@ -78,7 +78,7 @@ export class TenantsComponent { private confirmationService: ConfirmationService, private tenantService: TenantManagementService, private fb: FormBuilder, - private store: Store + private store: Store, ) {} onSearch(value) { @@ -88,14 +88,14 @@ export class TenantsComponent { private createTenantForm() { this.tenantForm = this.fb.group({ - name: [this.selected.name || '', [Validators.required, Validators.maxLength(256)]] + name: [this.selected.name || '', [Validators.required, Validators.maxLength(256)]], }); } private createDefaultConnectionStringForm() { this.defaultConnectionStringForm = this.fb.group({ useSharedDatabase: this._useSharedDatabase, - defaultConnectionString: [this.defaultConnectionString || ''] + defaultConnectionString: [this.defaultConnectionString || ''], }); } @@ -103,7 +103,7 @@ export class TenantsComponent { this.selectedModalContent = { title, template, - type + type, }; this.isModalVisible = true; @@ -117,7 +117,7 @@ export class TenantsComponent { switchMap(selected => { this.selected = selected; return this.tenantService.getDefaultConnectionString(id); - }) + }), ) .subscribe(fetchedConnectionString => { this._useSharedDatabase = fetchedConnectionString ? false : true; @@ -158,7 +158,7 @@ export class TenantsComponent { .deleteDefaultConnectionString(this.selected.id) .pipe( take(1), - finalize(() => (this.modalBusy = false)) + finalize(() => (this.modalBusy = false)), ) .subscribe(() => { this.isModalVisible = false; @@ -168,7 +168,7 @@ export class TenantsComponent { .updateDefaultConnectionString({ id: this.selected.id, defaultConnectionString: this.connectionString }) .pipe( take(1), - finalize(() => (this.modalBusy = false)) + finalize(() => (this.modalBusy = false)), ) .subscribe(() => { this.isModalVisible = false; @@ -184,7 +184,7 @@ export class TenantsComponent { .dispatch( this.selected.id ? new UpdateTenant({ ...this.tenantForm.value, id: this.selected.id }) - : new CreateTenant(this.tenantForm.value) + : new CreateTenant(this.tenantForm.value), ) .pipe(finalize(() => (this.modalBusy = false))) .subscribe(() => { @@ -195,7 +195,7 @@ export class TenantsComponent { delete(id: string, name: string) { this.confirmationService .warn('AbpTenantManagement::TenantDeletionConfirmationMessage', 'AbpTenantManagement::AreYouSure', { - messageLocalizationParams: [name] + messageLocalizationParams: [name], }) .subscribe((status: Toaster.Status) => { if (status === Toaster.Status.confirm) { @@ -219,7 +219,21 @@ export class TenantsComponent { .subscribe(); } - changeSortOrder() { - this.sortOrder = this.sortOrder.toLowerCase() === 'asc' ? 'desc' : 'asc'; + sortByKey(sortKey: string) { + this.sortKey = sortKey; + switch (this.sortOrder) { + case '': + this.sortOrder = 'asc'; + break; + case 'asc': + this.sortOrder = 'desc'; + break; + case 'desc': + this.sortOrder = ''; + this.sortKey = ''; + break; + default: + break; + } } } From d3303420e0485ccfbff02840101b9f686c7cb328 Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Tue, 8 Oct 2019 13:04:54 +0300 Subject: [PATCH 8/9] fix(theme-shared): remove unnecessary brackets --- .../components/sort-order-icon/sort-order-icon.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.html b/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.html index e554610d3c..63b4f648f5 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.html +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.html @@ -1,3 +1,3 @@ - - + + From 6b7f2ae2ca47001c7f8bd977ea9827c9b273a6ea Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 8 Oct 2019 14:08:48 +0300 Subject: [PATCH 9/9] feat(core): add sort method to sort.pipe --- .../packages/core/src/lib/core.module.ts | 3 ++ .../core/src/lib/directives/sort.directive.ts | 12 +++++ npm/ng-packs/packages/core/src/public-api.ts | 1 + .../lib/components/users/users.component.html | 22 ++++++--- .../lib/components/users/users.component.ts | 22 +-------- .../components/tenants/tenants.component.html | 9 +++- .../components/tenants/tenants.component.ts | 22 +-------- .../sort-order-icon.component.ts | 46 ++++++++++++++++--- 8 files changed, 82 insertions(+), 55 deletions(-) create mode 100644 npm/ng-packs/packages/core/src/lib/directives/sort.directive.ts diff --git a/npm/ng-packs/packages/core/src/lib/core.module.ts b/npm/ng-packs/packages/core/src/lib/core.module.ts index d3c98f9925..7e002884db 100644 --- a/npm/ng-packs/packages/core/src/lib/core.module.ts +++ b/npm/ng-packs/packages/core/src/lib/core.module.ts @@ -27,6 +27,7 @@ import { getInitialData, localeInitializer } from './utils/initial-utils'; import { ConfigPlugin, NGXS_CONFIG_PLUGIN_OPTIONS } from './plugins/config/config.plugin'; import { ForDirective } from './directives/for.directive'; import { AbstractNgModelComponent } from './abstracts/ng-model.component'; +import { SortDirective } from './directives/sort.directive'; @NgModule({ imports: [ @@ -46,6 +47,7 @@ import { AbstractNgModelComponent } from './abstracts/ng-model.component'; EllipsisDirective, ForDirective, FormSubmitDirective, + SortDirective, LocalizationPipe, SortPipe, PermissionDirective, @@ -68,6 +70,7 @@ import { AbstractNgModelComponent } from './abstracts/ng-model.component'; FormSubmitDirective, LocalizationPipe, SortPipe, + SortDirective, PermissionDirective, VisibilityDirective, InputEventDebounceDirective, diff --git a/npm/ng-packs/packages/core/src/lib/directives/sort.directive.ts b/npm/ng-packs/packages/core/src/lib/directives/sort.directive.ts new file mode 100644 index 0000000000..c00892998d --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/directives/sort.directive.ts @@ -0,0 +1,12 @@ +import { Directive, ElementRef, Input, Optional, Self } from '@angular/core'; +import { Table } from 'primeng/table'; + +@Directive({ + selector: '[abpSort]', +}) +export class SortDirective { + constructor(private elementRef: ElementRef, @Optional() @Self() table: Table) { + console.warn(elementRef); + setInterval(() => console.warn(table.value), 1000); + } +} diff --git a/npm/ng-packs/packages/core/src/public-api.ts b/npm/ng-packs/packages/core/src/public-api.ts index 4178d9e13f..3513427c2d 100644 --- a/npm/ng-packs/packages/core/src/public-api.ts +++ b/npm/ng-packs/packages/core/src/public-api.ts @@ -12,6 +12,7 @@ export * from './lib/enums'; export * from './lib/guards'; export * from './lib/interceptors'; export * from './lib/models'; +export * from './lib/pipes'; export * from './lib/plugins'; export * from './lib/services'; export * from './lib/states'; diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html index 84746413fe..4bc837f1fd 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html @@ -29,6 +29,7 @@ /> {{ 'AbpIdentity::Actions' | abpLocalization }} - + {{ 'AbpIdentity::UserName' | abpLocalization }} - + - + {{ 'AbpIdentity::EmailAddress' | abpLocalization }} - + - + {{ 'AbpIdentity::PhoneNumber' | abpLocalization }} - + diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts index 16fadcfa63..ffc69c58ed 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts @@ -50,9 +50,9 @@ export class UsersComponent { modalBusy = false; - sortOrder: string = ''; + sortOrder = ''; - sortKey: string = ''; + sortKey = ''; trackByFn: TrackByFunction = (index, item) => Object.keys(item)[0] || index; @@ -171,22 +171,4 @@ export class UsersComponent { .pipe(finalize(() => (this.loading = false))) .subscribe(); } - - sortByKey(sortKey: string) { - this.sortKey = sortKey; - switch (this.sortOrder) { - case '': - this.sortOrder = 'asc'; - break; - case 'asc': - this.sortOrder = 'desc'; - break; - case 'desc': - this.sortOrder = ''; - this.sortKey = ''; - break; - default: - break; - } - } } diff --git a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html index 8c27fe180c..ef4a69daf4 100644 --- a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html +++ b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html @@ -58,9 +58,14 @@ {{ 'AbpTenantManagement::Actions' | abpLocalization }} - + {{ 'AbpTenantManagement::TenantName' | abpLocalization }} - + diff --git a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts index e945cc5e69..439a6dadc1 100644 --- a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts +++ b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts @@ -56,9 +56,9 @@ export class TenantsComponent { modalBusy = false; - sortOrder: string = ''; + sortOrder = ''; - sortKey: string = ''; + sortKey = ''; get useSharedDatabase(): boolean { return this.defaultConnectionStringForm.get('useSharedDatabase').value; @@ -218,22 +218,4 @@ export class TenantsComponent { .pipe(finalize(() => (this.loading = false))) .subscribe(); } - - sortByKey(sortKey: string) { - this.sortKey = sortKey; - switch (this.sortOrder) { - case '': - this.sortOrder = 'asc'; - break; - case 'asc': - this.sortOrder = 'desc'; - break; - case 'desc': - this.sortOrder = ''; - this.sortKey = ''; - break; - default: - break; - } - } } diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.ts b/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.ts index 0a71a4b9d7..d42603d3a2 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/sort-order-icon/sort-order-icon.component.ts @@ -1,18 +1,37 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; @Component({ selector: 'abp-sort-order-icon', templateUrl: './sort-order-icon.component.html', }) -export class SortOrderIconComponent implements OnInit { +export class SortOrderIconComponent { + private _order: string; + private _selectedKey: string; + @Input() - selectedKey: string; + set selectedKey(value: string) { + this._selectedKey = value; + this.selectedKeyChange.emit(value); + } + get selectedKey(): string { + return this._selectedKey; + } + + @Output() readonly selectedKeyChange = new EventEmitter(); @Input() key: string; @Input() - order: string; + set order(value: string) { + this._order = value; + this.orderChange.emit(value); + } + get order(): string { + return this._order; + } + + @Output() readonly orderChange = new EventEmitter(); @Input() iconClass: string; @@ -23,7 +42,20 @@ export class SortOrderIconComponent implements OnInit { else return ''; } - constructor() {} - - ngOnInit(): void {} + sort(key: string) { + this.selectedKey = key; + switch (this.order) { + case '': + this.order = 'asc'; + break; + case 'asc': + this.order = 'desc'; + this.orderChange.emit('desc'); + break; + case 'desc': + this.order = ''; + this.selectedKey = ''; + break; + } + } }