OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Show warning when incompatible filters are used
Oliver Günther8db3ebb016f1
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex 8126a2effa3..ea5bacc7923 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -996,6 +996,8 @@ en:modification_label: 'Modified within the comparison time period'filters:title: 'Filter work packages'+ baseline_incompatible: 'This filter is not compatible with baseline and will not be included in the comparison.'+ baseline_warning: 'Baseline mode is on but some of your active filters are not included in the comparison.'inline_create:title: 'Click here to add a new work package to this list'create:diff --git a/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.html b/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.htmlindex 31588e5a392..3f8ec9d94d0 100644--- a/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.html+++ b/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.html@@ -3,9 +3,14 @@<labelfor="operators-{{filter.id}}"class="advanced-filters--filter-name"- [textContent]="filter.name"- [attr.title]="filter.name"+ [class.op-query-filter--icon-label]="baselineIncompatibleFilter">+ <span [textContent]="filter.name" [attr.title]="filter.name"></span>+ <span+ *ngIf="baselineIncompatibleFilter"+ [title]="text.incompatible_filter"+ data-qa-selector="query-filter-baseline-incompatible"+ class="spot-icon spot-icon_warning"></span></label><!-- Operator -->diff --git a/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.sass b/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.sassnew file mode 100644index 00000000000..651216fc640--- /dev/null+++ b/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.sass@@ -0,0 +1,7 @@+@import "helpers"++.op-query-filter+ &--icon-label+ display: flex+ align-items: center+ column-gap: $spot-spacing-0-25diff --git a/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.ts b/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.tsindex 38ae103846b..0fb5d5f76b2 100644--- a/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.ts+++ b/frontend/src/app/features/work-packages/components/filters/query-filter/query-filter.component.ts@@ -27,22 +27,36 @@//++import {- Component, EventEmitter, Input, OnInit, Output,+ Component,+ EventEmitter,+ HostBinding,+ Input,+ OnInit,+ Output,+ ViewEncapsulation,} from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { halHref, compareByHref } from 'core-app/shared/helpers/angular/tracking-functions';+import {+ compareByHref,+ halHref,+} from 'core-app/shared/helpers/angular/tracking-functions';import { BannersService } from 'core-app/core/enterprise/banners.service';import { WorkPackageViewFiltersService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service';import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';import { QueryFilterResource } from 'core-app/features/hal/resources/query-filter-resource';+import { WorkPackageViewBaselineService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service';@Component({selector: '[query-filter]',+ styleUrls: ['./query-filter.component.sass'],templateUrl: './query-filter.component.html',+ encapsulation: ViewEncapsulation.None,})export class QueryFilterComponent implements OnInit {+ @HostBinding('class.op-query-filter') className = true;+@Input() public shouldFocus = false;@Input() public filter:QueryFilterInstanceResource;@@ -57,6 +71,8 @@ export class QueryFilterComponent implements OnInit {public eeShowBanners = false;+ public baselineIncompatibleFilter = false;+public trackByHref = halHref;public compareByHref = compareByHref;@@ -68,13 +84,17 @@ export class QueryFilterComponent implements OnInit {upsale_for_more: this.I18n.t('js.filter.upsale_for_more'),upsale_link: this.I18n.t('js.filter.upsale_link'),button_delete: this.I18n.t('js.button_delete'),+ incompatible_filter: this.I18n.t('js.work_packages.filters.baseline_incompatible'),};- constructor(readonly wpTableFilters:WorkPackageViewFiltersService,+ constructor(+ readonly wpTableFilters:WorkPackageViewFiltersService,+ readonly wpTableBaseline:WorkPackageViewBaselineService,readonly schemaCache:SchemaCacheService,readonly I18n:I18nService,readonly currentProject:CurrentProjectService,- readonly bannerService:BannersService) {+ readonly bannerService:BannersService,+ ) {}public onFilterUpdated(filter:QueryFilterInstanceResource) {@@ -99,6 +119,7 @@ export class QueryFilterComponent implements OnInit {this.eeShowBanners = this.bannerService.eeShowBanners;this.availableOperators = this.schemaCache.of(this.filter).availableOperators;this.showValuesInput = this.showValues();+ this.baselineIncompatibleFilter = this.wpTableBaseline.isActive() && this.wpTableBaseline.isIncompatibleFilter(this.filter.id);}private showValues() {diff --git a/frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.html b/frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.htmlindex 4ce320beaf6..d26b16d0a1c 100644--- a/frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.html+++ b/frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.html@@ -70,4 +70,13 @@</div></li></ul>++ <div+ *ngIf="baselineIncompatibleFilters.length > 0"+ class="op-toast -warning">+ <div class="op-toast--content">+ <p [textContent]="text.baseline_warning">+ </p>+ </div>+ </div></fieldset>diff --git a/frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.ts b/frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.tsindex 3f6b6fb4fee..f484f9e80d5 100644--- a/frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.ts+++ b/frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.ts@@ -28,9 +28,11 @@import {ChangeDetectionStrategy,+ ChangeDetectorRef,Component,Input,OnChanges,+ OnInit,Output,ViewChild,} from '@angular/core';@@ -44,6 +46,8 @@ import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destrimport { componentDestroyed } from '@w11k/ngx-componentdestroyed';import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';import { QueryFilterResource } from 'core-app/features/hal/resources/query-filter-resource';+import { WorkPackageViewBaselineService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service';+import { combineLatestWith } from 'rxjs';const ADD_FILTER_SELECT_INDEX = -1;@@ -52,7 +56,7 @@ const ADD_FILTER_SELECT_INDEX = -1;changeDetection: ChangeDetectionStrategy.OnPush,templateUrl: './query-filters.component.html',})-export class QueryFiltersComponent extends UntilDestroyedMixin implements OnChanges {+export class QueryFiltersComponent extends UntilDestroyedMixin implements OnInit, OnChanges {@ViewChild(NgSelectComponent) public ngSelectComponent:NgSelectComponent;@Input() public filters:QueryFilterInstanceResource[];@@ -68,6 +72,8 @@ export class QueryFiltersComponent extends UntilDestroyedMixin implements OnChanpublic focusElementIndex = 0;+ public baselineIncompatibleFilters:string[] = [];+public trackByName = trackByName;public text = {@@ -79,16 +85,35 @@ export class QueryFiltersComponent extends UntilDestroyedMixin implements OnChanbutton_delete: this.I18n.t('js.button_delete'),please_select: this.I18n.t('js.placeholders.selection'),filter_by_text: this.I18n.t('js.work_packages.label_filter_by_text'),+ baseline_warning: this.I18n.t('js.work_packages.filters.baseline_warning'),};constructor(readonly wpTableFilters:WorkPackageViewFiltersService,+ readonly wpTableBaseline:WorkPackageViewBaselineService,readonly wpFiltersService:WorkPackageFiltersService,readonly I18n:I18nService,+ readonly cdRef:ChangeDetectorRef,) {super();}+ ngOnInit():void {+ this.wpTableFilters.live$()+ .pipe(+ combineLatestWith(this.wpTableBaseline.live$()),+ this.untilDestroyed(),+ )+ .subscribe(([filters]) => {+ if (this.wpTableBaseline.isActive()) {+ this.baselineIncompatibleFilters = this.wpTableBaseline.detectIncompatibleFilters(filters);+ } else {+ this.baselineIncompatibleFilters = [];+ }+ this.cdRef.detectChanges();+ });+ }+ngOnChanges() {this.updateRemainingFilters();}@@ -154,7 +179,8 @@ export class QueryFiltersComponent extends UntilDestroyedMixin implements OnChanpublic isFilterAvailable(filter:QueryFilterResource):boolean {return (this.wpTableFilters.availableFilters.some((availableFilter) => availableFilter.id === filter.id)- && !(this.wpTableFilters.hidden.includes(filter.id) || filter.isTemplated()));+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call+ && !(this.wpTableFilters.hidden.includes(filter.id) || filter.isTemplated()));}public onOpen() {diff --git a/frontend/src/app/features/work-packages/components/wp-table/sort-header/sort-header.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/sort-header/sort-header.directive.tsindex eb410042c32..6b471a9e6b1 100644--- a/frontend/src/app/features/work-packages/components/wp-table/sort-header/sort-header.directive.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/sort-header/sort-header.directive.ts@@ -27,18 +27,29 @@//++import {- AfterViewInit, ChangeDetectorRef, Component, ElementRef, Input,+ AfterViewInit,+ ChangeDetectorRef,+ Component,+ ElementRef,+ Input,} from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { RelationQueryColumn, TypeRelationQueryColumn } from 'core-app/features/work-packages/components/wp-query/query-column';+import {+ RelationQueryColumn,+ TypeRelationQueryColumn,+} from 'core-app/features/work-packages/components/wp-query/query-column';import { WorkPackageTable } from 'core-app/features/work-packages/components/wp-fast-table/wp-fast-table';-import { QUERY_SORT_BY_ASC, QUERY_SORT_BY_DESC } from 'core-app/features/hal/resources/query-sort-by-resource';+import {+ QUERY_SORT_BY_ASC,+ QUERY_SORT_BY_DESC,+} from 'core-app/features/hal/resources/query-sort-by-resource';import { WorkPackageViewHierarchiesService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-hierarchy.service';import { WorkPackageViewSortByService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service';import { WorkPackageViewGroupByService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-group-by.service';import { WorkPackageViewRelationColumnsService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-relation-columns.service';import { combineLatest } from 'rxjs';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';+import { WorkPackageViewBaselineService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service';@Component({selector: 'sortHeader',@@ -75,13 +86,16 @@ export class SortHeaderDirective extends UntilDestroyedMixin implements AfterVieprivate currentSortDirection:any;- constructor(private wpTableHierarchies:WorkPackageViewHierarchiesService,+ constructor(+ private wpTableHierarchies:WorkPackageViewHierarchiesService,private wpTableSortBy:WorkPackageViewSortByService,private wpTableGroupBy:WorkPackageViewGroupByService,+ private wpTableBaseline:WorkPackageViewBaselineService,private wpTableRelationColumns:WorkPackageViewRelationColumnsService,private elementRef:ElementRef,private cdRef:ChangeDetectorRef,- private I18n:I18nService) {+ private I18n:I18nService,+ ) {super();}diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service.tsindex 02f8f127933..f5deb8405c3 100644--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service.ts+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service.ts@@ -42,8 +42,15 @@ import { WorkPackageResource } from 'core-app/features/hal/resources/work-packagimport { IWorkPackageTimestamp } from 'core-app/features/hal/resources/work-package-timestamp-resource';import * as moment from 'moment-timezone';import { Moment } from 'moment';+import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';export const DEFAULT_TIMESTAMP = 'PT0S';+export const BASELINE_INCOMPATIBLE_FILTERS = [+ 'attachmentContent',+ 'attachmentFileName',+ 'watcher',+ 'comment',+];@Injectable()export class WorkPackageViewBaselineService extends WorkPackageQueryStateService<string[]> {@@ -63,6 +70,15 @@ export class WorkPackageViewBaselineService extends WorkPackageQueryStateServicepublic nonWorkingDays$:Observable<IDay[]> = this.requireNonWorkingDaysOfTwoYears();+ public detectIncompatibleFilters(filters:QueryFilterInstanceResource[]):string[] {+ return BASELINE_INCOMPATIBLE_FILTERS+ .filter((el) => !!filters.find((filter) => filter.id === el));+ }++ public isIncompatibleFilter(filter:string):boolean {+ return BASELINE_INCOMPATIBLE_FILTERS.includes(filter);+ }+public yesterdayDate():string {return moment().subtract(1, 'days').format('YYYY-MM-DD');}diff --git a/spec/features/work_packages/table/baseline/baseline_query_spec.rb b/spec/features/work_packages/table/baseline/baseline_query_spec.rbindex dc3a540ec6f..0e5bd289d5d 100644--- a/spec/features/work_packages/table/baseline/baseline_query_spec.rb+++ b/spec/features/work_packages/table/baseline/baseline_query_spec.rb@@ -38,6 +38,7 @@ describe 'baseline query saving',let(:wp_table) { Pages::WorkPackagesTable.new(project) }let(:baseline) { Components::WorkPackages::Baseline.new }let(:baseline_modal) { Components::WorkPackages::BaselineModal.new }+ let(:filters) { Components::WorkPackages::Filters.new }shared_let(:berlin_user) docreate(:user,@@ -53,6 +54,37 @@ describe 'baseline query saving',member_with_permissions: %i[view_work_packages save_queries manage_public_queries])end+ it 'shows a warning when an incompatible filter is used', with_flag: { show_changes: true } do+ login_as berlin_user+ wp_table.visit!++ baseline_modal.expect_closed+ baseline.expect_no_legends+ baseline_modal.toggle_drop_modal+ baseline_modal.expect_open+ baseline_modal.expect_selected '-'++ baseline_modal.select_filter 'yesterday'+ baseline_modal.set_time '09:00'+ baseline_modal.expect_offset 'UTC+2'+ baseline_modal.apply++ loading_indicator_saveguard++ filters.open+ filters.add_filter_by('Watcher', 'is (OR)', 'me')++ loading_indicator_saveguard++ expect(page).to have_selector(+ '.op-toast.-warning',+ text: 'Baseline mode is on but some of your active filters are not included in the comparison.'+ )+ page.within('#filter_watcher') do+ expect(page).to have_selector('[data-qa-selector="query-filter-baseline-incompatible"]')+ end+ end+it 'can configure and save baseline queries', with_flag: { show_changes: true } dologin_as berlin_userwp_table.visit!