diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.component.html b/dmp-frontend/src/app/ui/description/listing/description-listing.component.html index 6daf95490..7eebe739b 100644 --- a/dmp-frontend/src/app/ui/description/listing/description-listing.component.html +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.component.html @@ -44,10 +44,10 @@
-
+
{{'DMP-LISTING.SORT-BY' | translate}}:
-
+
{{enumUtils.toRecentActivityOrderString(order.UpdatedAt)}} @@ -58,8 +58,14 @@
+
+ +
-
+
diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts b/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts index edbc8ff2c..e54641ad4 100644 --- a/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts @@ -35,6 +35,7 @@ import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { StartNewDescriptionDialogComponent } from '../start-new-description-dialog/start-new-description-dialog.component'; import { DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { SortDirection } from '@common/modules/hybrid-listing/hybrid-listing.component'; @Component({ selector: 'app-description-listing-component', @@ -73,6 +74,23 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit dmpText: string; descriptionText: string; + private _sortDirection: SortDirection = SortDirection.Descending; //SortDirection.Descending: "-" + set sortDirection(sortDirection: SortDirection) { + this._sortDirection = sortDirection; + } + get isAscending(): boolean { + return this._sortDirection == SortDirection.Ascending; + } + get isDescending(): boolean { + return this._sortDirection == SortDirection.Descending; + } + get sortingDirectionPrefix(): string { + return this.isAscending ? "+" : "-"; + } + get sortingTooltipText(): string { + return this.isAscending ? this.language.instant('DESCRIPTION-LISTING.ACTIONS.TOGGLE-ΑSCENDING') : this.language.instant('DESCRIPTION-LISTING.ACTIONS.TOGGLE-DESCENDING'); + } + constructor( private descriptionService: DescriptionService, private router: Router, @@ -184,11 +202,11 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit orderByChanged(){ if (this.formGroup.get('order').value == RecentActivityOrder.Status){ - this.lookup.order = { items: ['-' + nameof(x => x.status)] }; + this.lookup.order = { items: [this.sortingDirectionPrefix + nameof(x => x.status)] }; } else if(this.formGroup.get('order').value == RecentActivityOrder.Label){ - this.lookup.order = { items: ['-' + nameof(x => x.label)] }; + this.lookup.order = { items: [this.sortingDirectionPrefix + nameof(x => x.label)] }; }else{ - this.lookup.order = { items: ['-' + nameof(x => x.updatedAt)] }; + this.lookup.order = { items: [this.sortingDirectionPrefix + nameof(x => x.updatedAt)] }; } this.refresh(this.lookup); } @@ -394,4 +412,8 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit return this.lookup.like !== undefined && this.lookup.like !== null; } + toggleSortDirection(): void { + this.sortDirection = this.isAscending ? this.sortDirection = SortDirection.Descending : this.sortDirection = SortDirection.Ascending; + this.orderByChanged(); + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html index 09c0fcadd..bb1bc1593 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html @@ -29,10 +29,10 @@
-
+
{{'DMP-LISTING.SORT-BY' | translate}}:
-
+
{{enumUtils.toRecentActivityOrderString(order.UpdatedAt)}} @@ -42,7 +42,13 @@
-
+
+ +
+
{{ 'GENERAL.ACTIONS.TAKE-A-TOUR'| translate }} diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index c5ff0c96b..7bfe1095b 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -34,6 +34,7 @@ import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { AppPermission } from '@app/core/common/enum/permission.enum'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { DescriptionStatus } from '@app/core/common/enum/description-status'; +import { SortDirection } from '@common/modules/hybrid-listing/hybrid-listing.component'; @Component({ selector: 'app-dmp-listing-component', @@ -59,6 +60,23 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr scrollbar: boolean; order = RecentActivityOrder; + private _sortDirection: SortDirection = SortDirection.Descending; //SortDirection.Descending: "-" + set sortDirection(sortDirection: SortDirection) { + this._sortDirection = sortDirection; + } + get isAscending(): boolean { + return this._sortDirection == SortDirection.Ascending; + } + get isDescending(): boolean { + return this._sortDirection == SortDirection.Descending; + } + get sortingDirectionPrefix(): string { + return this.isAscending ? "+" : "-"; + } + get sortingTooltipText(): string { + return this.isAscending ? this.language.instant('DMP-LISTING.ACTIONS.TOGGLE-ΑSCENDING') : this.language.instant('DMP-LISTING.ACTIONS.TOGGLE-DESCENDING'); + } + constructor( private dmpService: DmpService, private router: Router, @@ -167,11 +185,11 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr orderByChanged(){ if (this.formGroup.get('order').value == RecentActivityOrder.Status){ - this.lookup.order = { items: ['-' + nameof(x => x.status)] }; + this.lookup.order = { items: [this.sortingDirectionPrefix + nameof(x => x.status)] }; } else if(this.formGroup.get('order').value == RecentActivityOrder.Label){ - this.lookup.order = { items: ['-' + nameof(x => x.label)] }; + this.lookup.order = { items: [this.sortingDirectionPrefix + nameof(x => x.label)] }; }else{ - this.lookup.order = { items: ['-' + nameof(x => x.updatedAt)] }; + this.lookup.order = { items: [this.sortingDirectionPrefix + nameof(x => x.updatedAt)] }; } this.refresh(this.lookup); } @@ -386,4 +404,9 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr public hasLikeCriteria(): boolean { return this.lookup.like !== undefined && this.lookup.like !== null; } + + toggleSortDirection(): void { + this.sortDirection = this.isAscending ? this.sortDirection = SortDirection.Descending : this.sortDirection = SortDirection.Ascending; + this.orderByChanged(); + } } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index b49cfb338..04c454b74 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -633,7 +633,9 @@ "CLONE": "Clone", "DELETE": "Delete", "DEPOSIT": "Deposit", - "EXPORT": "Export" + "EXPORT": "Export", + "TOGGLE-DESCENDING": "Order by ascending", + "TOGGLE-ΑSCENDING": "Order by descending" }, "EMPTY-LIST": "Nothing here yet." }, @@ -786,7 +788,9 @@ "EXPORT": "Export", "INVITE-SHORT": "Invite", "DELETE": "Delete", - "COPY-DESCRIPTION": "Copy Description" + "COPY-DESCRIPTION": "Copy Description", + "TOGGLE-DESCENDING": "Order by ascending", + "TOGGLE-ΑSCENDING": "Order by descending" }, "STATES": { "EDITED": "Edited",