Skip to content

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

Revert "Use range datepicker for updated at"

Oliver Günthera9d8b1a7f0d7
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-date-times-value/filter-date-times-value.component.html b/frontend/src/app/features/work-packages/components/filters/filter-date-times-value/filter-date-times-value.component.html
index 90479531517..b16909d1045 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-date-times-value/filter-date-times-value.component.html
+++ b/frontend/src/app/features/work-packages/components/filters/filter-date-times-value/filter-date-times-value.component.html
@@ -1,13 +1,23 @@
-<op-basic-range-date-picker
- [id]="'values-' + filter.id"
- [name]="'v[' + filter.id + ']'"
- class="advanced-filters--date-field"
-
- [value]="value"
- (valueChange)="value = $event"
+<op-basic-single-date-picker
+ (valueChange)="begin = isoDateParser($event)"
+ [value]="isoDateFormatter(begin)"
[opAutofocus]="shouldFocus"
-></op-basic-range-date-picker>
+ required="true"
+ [id]="'values-' + filter.id + '-begin'"
+ [name]="'v[' + filter.id + ']-begin'"
+ classes="advanced-filters--date-field"
+></op-basic-single-date-picker>
+
+<span class="advanced-filters--affix" [textContent]="text.spacer">
+</span>
+<op-basic-single-date-picker
+ (valueChange)="end = isoDateParser($event)"
+ [value]="isoDateFormatter(end)"
+ [id]="'values-' + filter.id + '-end'"
+ [name]="'v[' + filter.id + ']-end'"
+ classes="advanced-filters--date-field"
+></op-basic-single-date-picker>
<span
class="advanced-filters--tooltip-trigger -multiline"
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-date-times-value/filter-date-times-value.component.ts b/frontend/src/app/features/work-packages/components/filters/filter-date-times-value/filter-date-times-value.component.ts
index 90ea2ac73b7..9fe4a6af965 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-date-times-value/filter-date-times-value.component.ts
+++ b/frontend/src/app/features/work-packages/components/filters/filter-date-times-value/filter-date-times-value.component.ts
@@ -70,23 +70,24 @@ export class FilterDateTimesValueComponent extends AbstractDateTimeValueControll
super(I18n, timezoneService);
}
- public get value():string[] {
- return (this.filter.values as string[]) || [];
+ public get begin():HalResource|string {
+ return this.filter.values[0];
}
- public set value(val:string[]) {
- this.filter.values = val;
+ public set begin(val) {
+ this.filter.values[0] = val || '';
this.filterChanged.emit(this.filter);
}
- public get begin():HalResource|string {
- return this.filter.values[0];
- }
-
public get end() {
return this.filter.values[1];
}
+ public set end(val) {
+ this.filter.values[1] = val || '';
+ this.filterChanged.emit(this.filter);
+ }
+
public get lowerBoundary():Moment|null {
if (this.begin && this.timezoneService.isValidISODateTime(this.begin.toString())) {
return this.timezoneService.parseDatetime(this.begin.toString());
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-dates-value/filter-dates-value.component.ts b/frontend/src/app/features/work-packages/components/filters/filter-dates-value/filter-dates-value.component.ts
index de086cd629b..cf61853bd31 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-dates-value/filter-dates-value.component.ts
+++ b/frontend/src/app/features/work-packages/components/filters/filter-dates-value/filter-dates-value.component.ts
@@ -27,12 +27,7 @@
//++
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import {
- Component,
- HostBinding,
- Input,
- Output,
-} from '@angular/core';
+import { Component, HostBinding, Input, Output } from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { DebouncedEventEmitter } from 'core-app/shared/helpers/rxjs/debounced-event-emitter';
import * as moment from 'moment';
@@ -64,8 +59,7 @@ export class FilterDatesValueComponent extends UntilDestroyedMixin {
constructor(
readonly timezoneService:TimezoneService,
- readonly I18n:I18nService,
- ) {
+ readonly I18n:I18nService) {
super();
}
@@ -77,4 +71,27 @@ export class FilterDatesValueComponent extends UntilDestroyedMixin {
this.filter.values = val;
this.filterChanged.emit(this.filter);
}
+
+ public get begin():any {
+ return this.filter.values[0];
+ }
+
+ public get end():HalResource|string {
+ return this.filter.values[1];
+ }
+
+ public parser(data:any) {
+ if (moment(data, 'YYYY-MM-DD', true).isValid()) {
+ return data;
+ }
+ return null;
+ }
+
+ public formatter(data:any) {
+ if (moment(data, 'YYYY-MM-DD', true).isValid()) {
+ const d = this.timezoneService.parseDate(data);
+ return this.timezoneService.formattedISODate(d);
+ }
+ return null;
+ }
}
diff --git a/spec/features/work_packages/table/queries/filter_spec.rb b/spec/features/work_packages/table/queries/filter_spec.rb
index 2c0d2bdb420..583f69fc116 100644
--- a/spec/features/work_packages/table/queries/filter_spec.rb
+++ b/spec/features/work_packages/table/queries/filter_spec.rb
@@ -29,10 +29,10 @@
require 'spec_helper'
describe 'filter work packages', js: true do
- shared_let(:user) { create(:admin) }
- shared_let(:watcher) { create(:user) }
- shared_let(:role) { create(:existing_role, permissions: [:view_work_packages]) }
- shared_let(:project) { create(:project, members: { watcher => role }) }
+ let(:user) { create(:admin) }
+ let(:watcher) { create(:user) }
+ let(:project) { create(:project, members: { watcher => role }) }
+ let(:role) { create(:existing_role, permissions: [:view_work_packages]) }
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
let(:filters) { Components::WorkPackages::Filters.new }
@@ -491,76 +491,32 @@ describe 'filter work packages', js: true do
end
end
- describe 'datetime filters' do
- shared_let(:wp_updated_today) do
- create(:work_package,
- subject: 'Created today',
- project:,
- created_at: Time.current.change(hour: 12),
- updated_at: Time.current.change(hour: 12),
- )
- end
- shared_let(:wp_updated_5d_ago) do
- create(:work_package,
- subject: 'Created 5d ago',
- project:,
- created_at: 5.days.ago,
- updated_at: 5.days.ago,
- )
- end
-
- it 'filters on date by created_at (Regression #28459)' do
- wp_table.visit!
- loading_indicator_saveguard
- wp_table.expect_work_package_listed wp_updated_today, wp_updated_5d_ago
-
- filters.open
-
- filters.add_filter_by 'Created on',
- 'on',
- [Date.current.iso8601],
- 'createdAt'
-
- loading_indicator_saveguard
-
- wp_table.expect_work_package_listed wp_updated_today
- wp_table.ensure_work_package_not_listed! wp_updated_5d_ago
- end
-
- it 'filters on date by updated_at' do
- wp_table.visit!
- loading_indicator_saveguard
- wp_table.expect_work_package_listed wp_updated_today, wp_updated_5d_ago
-
- filters.open
-
- filters.add_filter_by 'Updated',
- 'on',
- [Date.current.iso8601],
- 'updatedAt'
-
- loading_indicator_saveguard
-
- wp_table.expect_work_package_listed wp_updated_today
- wp_table.ensure_work_package_not_listed! wp_updated_5d_ago
- end
+ describe 'specific filters' do
+ describe 'filters on date by created_at (Regression #28459)' do
+ let!(:wp_updated_today) do
+ create(:work_package, subject: 'Created today', project:, created_at: Time.current.change(hour: 12))
+ end
+ let!(:wp_updated_5d_ago) do
+ create(:work_package, subject: 'Created 5d ago', project:, created_at: 5.days.ago)
+ end
- it 'filters between date by updated_at' do
- wp_table.visit!
- loading_indicator_saveguard
- wp_table.expect_work_package_listed wp_updated_today, wp_updated_5d_ago
+ it do
+ wp_table.visit!
+ loading_indicator_saveguard
+ wp_table.expect_work_package_listed wp_updated_today, wp_updated_5d_ago
- filters.open
+ filters.open
- filters.add_filter_by 'Updated',
- 'between',
- [1.day.ago.iso8601, Date.current.iso8601],
- 'updatedAt'
+ filters.add_filter_by 'Created on',
+ 'on',
+ [Date.current.iso8601],
+ 'createdAt'
- loading_indicator_saveguard
+ loading_indicator_saveguard
- wp_table.expect_work_package_listed wp_updated_today
- wp_table.ensure_work_package_not_listed! wp_updated_5d_ago
+ wp_table.expect_work_package_listed wp_updated_today
+ wp_table.ensure_work_package_not_listed! wp_updated_5d_ago
+ end
end
end