}
diff --git a/projects/rero/ng-core/src/lib/record/search/aggregation/date-range/date-range.component.html b/projects/rero/ng-core/src/lib/record/search/aggregation/date-range/date-range.component.html
index ab353490..d058f0d4 100644
--- a/projects/rero/ng-core/src/lib/record/search/aggregation/date-range/date-range.component.html
+++ b/projects/rero/ng-core/src/lib/record/search/aggregation/date-range/date-range.component.html
@@ -16,16 +16,26 @@
along with this program. If not, see
-
-
- @if (hasQueryParam) {
-
- }
-
+ [showIcon]="true"
+ [readonlyInput]="true" >
+
+
+
+ @for (cfg of buttonConfig; track cfg) {
+
+ }
+
+
+
+
+
+ @if (hasQueryParam) {
+
+ }
diff --git a/projects/rero/ng-core/src/lib/record/search/aggregation/date-range/date-range.component.ts b/projects/rero/ng-core/src/lib/record/search/aggregation/date-range/date-range.component.ts
index f4782dac..353db6b8 100644
--- a/projects/rero/ng-core/src/lib/record/search/aggregation/date-range/date-range.component.ts
+++ b/projects/rero/ng-core/src/lib/record/search/aggregation/date-range/date-range.component.ts
@@ -18,6 +18,7 @@
import { Component, OnDestroy, OnInit, inject, input } from '@angular/core';
import { Subscription } from 'rxjs';
import { RecordSearchService } from '../../record-search.service';
+import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'ng-core-aggregation-date-range',
@@ -26,6 +27,7 @@ import { RecordSearchService } from '../../record-search.service';
export class AggregationDateRangeComponent implements OnInit, OnDestroy {
protected recordSearchService: RecordSearchService = inject(RecordSearchService);
+ protected translateService: TranslateService = inject(TranslateService);
// COMPONENTS ATTRIBUTES ====================================================
// Buckets list
@@ -44,6 +46,7 @@ export class AggregationDateRangeComponent implements OnInit, OnDestroy {
/** True if route have aggregation query param. */
hasQueryParam = false;
+ buttonConfig = [];
/** Subscription to search service. */
private searchServiceSubscription: Subscription;
@@ -53,10 +56,15 @@ export class AggregationDateRangeComponent implements OnInit, OnDestroy {
// Define min/max values if not exists
if (this.config().min && this.config().min !== null) {
this.minDate = new Date(this.config().min);
+ } else{
+ this.minDate = new Date(1900, 0, 0);
}
if (this.config().max && this.config().max !== null) {
this.maxDate = new Date(this.config().max);
+ } else {
+ this.maxDate = new Date();
}
+ this.dateRangeModel = [this.minDate, this.maxDate];
this.searchServiceSubscription = this.recordSearchService.aggregationsFilters.subscribe((filters: any) => {
if (!filters) {
@@ -66,10 +74,30 @@ export class AggregationDateRangeComponent implements OnInit, OnDestroy {
this.hasQueryParam = filter !== undefined;
this.dateRangeModel = (filter)
? filter.values[0].split('--').map((item: string) => new Date(+item)) // split filter data and transform each part into Date
- : [];
+ : [this.minDate, this.maxDate];
});
+ const today = new Date();
+ this.buttonConfig = [
+ {
+ value: [new Date(new Date().setDate(today.getDate() - 31)), today],
+ label: this.translateService.instant('Last month')
+ }, {
+ value: [new Date(new Date().setDate(today.getDate() - 366)), today],
+ label: this.translateService.instant('Last year')
+ }, {
+ value: [new Date(today.getFullYear(), today.getMonth(), 1), new Date(today.getFullYear(), today.getMonth() + 1, 0)],
+ label: this.translateService.instant('This month')
+ },
+ {
+ value: [new Date(today.getFullYear(), 0, 1), new Date(today.getFullYear() + 1, 0, 1)],
+ label: this.translateService.instant('This year')
+ }
+ ];
+ }
+ setRange(value) {
+ this.dateRangeModel = value;
+ this.updateFilter();
}
-
/** OnDestroy hook */
ngOnDestroy(): void {
this.searchServiceSubscription.unsubscribe();
diff --git a/projects/rero/ng-core/src/lib/record/search/aggregation/slider/slider.component.html b/projects/rero/ng-core/src/lib/record/search/aggregation/slider/slider.component.html
index 0e229081..6e9e900a 100644
--- a/projects/rero/ng-core/src/lib/record/search/aggregation/slider/slider.component.html
+++ b/projects/rero/ng-core/src/lib/record/search/aggregation/slider/slider.component.html
@@ -14,27 +14,23 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see
.
-->
-
-
-
-
+
+
+
@if (hasQueryParam) {
-
+
}
-
diff --git a/projects/rero/ng-core/src/lib/record/search/aggregation/slider/slider.component.ts b/projects/rero/ng-core/src/lib/record/search/aggregation/slider/slider.component.ts
index 93330815..9fe8c738 100644
--- a/projects/rero/ng-core/src/lib/record/search/aggregation/slider/slider.component.ts
+++ b/projects/rero/ng-core/src/lib/record/search/aggregation/slider/slider.component.ts
@@ -58,7 +58,7 @@ export class AggregationSliderComponent implements OnDestroy, OnInit {
if (!filters) {
return;
}
- let filter = filters.find((element: any) => element.key === this.key);
+ let filter = filters.find((element: any) => element.key === this.key());
if (filter) {
filter = filter.values[0].split('--').map((item: string) => +item);
this.hasQueryParam = true;
diff --git a/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.html b/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.html
index 10660a43..263eb2ec 100644
--- a/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.html
+++ b/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.html
@@ -15,23 +15,14 @@
along with this program. If not, see
.
-->
@if (options().length > 0) {
-
-
- @if(item.icon) {
-
+
+
+
+ @if (selectedOption()?.icon) {
+
}
- {{ item.label }}
-
-
- @if(item.icon) {
-
- }
- {{item.label }}
-
-
+ {{ selectedOption()?.label | translate }} …
+
+
+
}
diff --git a/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.ts b/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.ts
index 2534c8a9..e09de98a 100644
--- a/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.ts
+++ b/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.ts
@@ -17,15 +17,7 @@
import { Component, computed, inject, input, output } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
-import { DropdownChangeEvent } from 'primeng/dropdown';
-
-export interface ISortOption {
- value: string;
- label: string;
- defaultQuery?: boolean;
- defaultNoQuery?: boolean;
- icon?: string;
-}
+import { MenuItem, MenuItemCommandEvent } from 'primeng/api';
@Component({
selector: 'ng-core-menu-sort',
@@ -37,42 +29,25 @@ export class MenuSortComponent {
protected activatedRoute: ActivatedRoute = inject(ActivatedRoute);
/** Input */
- config = input.required();
+ config = input.required