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

Make save button of datepicker configurable

Oliver Günther348bd42d85ea
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.html b/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.html
index 57d348396bb..92b7873e6f1 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.html
+++ b/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.html
@@ -103,7 +103,7 @@
type="submit"
class="button -highlight spot-action-bar--action"
data-qa-selector="op-datepicker-modal--action"
- [textContent]="text.save"
+ [textContent]="applyLabel"
></button>
</div>
</div>
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts
index e16de0e4b46..2312408a70c 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts
@@ -42,10 +42,13 @@ import {
ViewEncapsulation,
} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import {
- areDatesEqual,
- mappedDate,
+ ControlValueAccessor,
+ NG_VALUE_ACCESSOR,
+} from '@angular/forms';
+import {
+ areDatesEqual,
+ mappedDate,
onDayCreate,
parseDate,
setDates,
@@ -55,10 +58,23 @@ import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { DatePicker } from '../datepicker';
import flatpickr from 'flatpickr';
import { DayElement } from 'flatpickr/dist/types/instance';
-import { ActiveDateChange, DateFields, DateKeys } from '../wp-multi-date-form/wp-multi-date-form.component';
-import { fromEvent, merge, Observable, Subject } from 'rxjs';
+import {
+ ActiveDateChange,
+ DateFields,
+ DateKeys,
+} from '../wp-multi-date-form/wp-multi-date-form.component';
+import {
+ fromEvent,
+ merge,
+ Observable,
+ Subject,
+} from 'rxjs';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
-import { debounceTime, filter, map } from 'rxjs/operators';
+import {
+ debounceTime,
+ filter,
+ map,
+} from 'rxjs/operators';
import { DeviceService } from 'core-app/core/browser/device.service';
import { DateOption } from 'flatpickr/dist/types/options';
import { WeekdayService } from 'core-app/core/days/weekday.service';
@@ -92,6 +108,8 @@ export class OpMultiDatePickerComponent extends UntilDestroyedMixin implements O
@Input() value:string[] = [];
+ @Input() applyLabel:string;
+
private _opened = false;
@Input() set opened(opened:boolean) {
@@ -118,7 +136,7 @@ export class OpMultiDatePickerComponent extends UntilDestroyedMixin implements O
@Output('closed') closed = new EventEmitter();
text = {
- save: this.I18n.t('js.button_save'),
+ apply: this.I18n.t('js.modals.button_apply'),
cancel: this.I18n.t('js.button_cancel'),
startDate: this.I18n.t('js.work_packages.properties.startDate'),
endDate: this.I18n.t('js.work_packages.properties.dueDate'),
@@ -196,7 +214,8 @@ export class OpMultiDatePickerComponent extends UntilDestroyedMixin implements O
});
}
- ngOnInit(): void {
+ ngOnInit():void {
+ this.applyLabel = this.applyLabel || this.text.apply;
this.htmlId = `wp-datepicker-${this.fieldName as string}`;
this.setCurrentActivatedField(this.initialActivatedField);
diff --git a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.html b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.html
index 5fdd82793e9..8a09c09a78a 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.html
+++ b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.html
@@ -83,7 +83,7 @@
type="submit"
class="button -highlight spot-action-bar--action"
data-qa-selector="op-datepicker-modal--action"
- [textContent]="text.save"
+ [textContent]="applyLabel"
></button>
</div>
</div>
diff --git a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
index d9ae4d677cb..31441990b05 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
@@ -36,6 +36,7 @@ import {
forwardRef,
Injector,
Input,
+ OnInit,
Output,
ViewChild,
ViewEncapsulation,
@@ -74,7 +75,7 @@ export const opSingleDatePickerSelector = 'op-single-date-picker';
},
],
})
-export class OpSingleDatePickerComponent implements ControlValueAccessor, AfterContentInit {
+export class OpSingleDatePickerComponent implements ControlValueAccessor, OnInit, AfterContentInit {
@Output('closed') closed = new EventEmitter();
@Output('valueChange') valueChange = new EventEmitter();
@@ -100,6 +101,8 @@ export class OpSingleDatePickerComponent implements ControlValueAccessor, AfterC
@Input() minimalDate:Date|null = null;
+ @Input() applyLabel:string;
+
private _opened = false;
@Input() set opened(opened:boolean) {
@@ -135,7 +138,7 @@ export class OpSingleDatePickerComponent implements ControlValueAccessor, AfterC
public useDefaultTrigger = false;
text = {
- save: this.I18n.t('js.button_save'),
+ apply: this.I18n.t('js.modals.button_apply'),
cancel: this.I18n.t('js.button_cancel'),
date: this.I18n.t('js.work_packages.properties.date'),
placeholder: this.I18n.t('js.placeholders.default'),
@@ -156,6 +159,10 @@ export class OpSingleDatePickerComponent implements ControlValueAccessor, AfterC
populateInputsFromDataset(this);
}
+ ngOnInit() {
+ this.applyLabel = this.applyLabel || this.text.apply;
+ }
+
ngAfterContentInit() {
const trigger = (this.elementRef.nativeElement as HTMLElement).querySelector("[slot='trigger']");
this.useDefaultTrigger = trigger === null;
diff --git a/frontend/src/app/shared/components/op-non-working-days-list/op-non-working-days-list.component.html b/frontend/src/app/shared/components/op-non-working-days-list/op-non-working-days-list.component.html
index 672d6baf685..b97b5d1b354 100644
--- a/frontend/src/app/shared/components/op-non-working-days-list/op-non-working-days-list.component.html
+++ b/frontend/src/app/shared/components/op-non-working-days-list/op-non-working-days-list.component.html
@@ -27,6 +27,7 @@
[required]="true"
[showIgnoreNonWorkingDays]="false"
[name]="text.add_non_working_day"
+ [applyLabel]="text.add"
(closed)="datepickerOpened = false"
(valueChange)="addNonWorkingDay($event)"
>
diff --git a/frontend/src/app/shared/components/op-non-working-days-list/op-non-working-days-list.component.ts b/frontend/src/app/shared/components/op-non-working-days-list/op-non-working-days-list.component.ts
index 4b5019074b8..d5b8f244316 100644
--- a/frontend/src/app/shared/components/op-non-working-days-list/op-non-working-days-list.component.ts
+++ b/frontend/src/app/shared/components/op-non-working-days-list/op-non-working-days-list.component.ts
@@ -65,6 +65,7 @@ export class OpNonWorkingDaysListComponent implements OnInit {
change_title: this.I18n.t('js.admin.working_days.change_title'),
removed_title: this.I18n.t('js.admin.working_days.removed_title'),
non_working_day_name: this.I18n.t('js.modals.label_name'),
+ add: this.I18n.t('js.button_add'),
};
form_submitted = false;
diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rb
index 8d7090c958e..e5fb5a47f49 100644
--- a/spec/features/admin/working_days_spec.rb
+++ b/spec/features/admin/working_days_spec.rb
@@ -203,7 +203,7 @@ describe 'Working Days', js: true do
datepicker.set_date date1
page.within('[data-qa-selector="op-datepicker-modal"]') do
- click_on 'Save'
+ click_on 'Add'
end
expect(page).to have_selector('.fc-list-event-title', text: 'My holiday')
@@ -219,7 +219,7 @@ describe 'Working Days', js: true do
datepicker.set_date date2
page.within('[data-qa-selector="op-datepicker-modal"]') do
- click_on 'Save'
+ click_on 'Add'
end
click_on 'Apply changes'
@@ -237,7 +237,7 @@ describe 'Working Days', js: true do
click_on 'Non-working day'
page.within('[data-qa-selector="op-datepicker-modal"]') do
- click_on 'Save'
+ click_on 'Add'
end
expect(page).to have_selector('.flatpickr-calendar')
datepicker.expect_visible
@@ -249,7 +249,7 @@ describe 'Working Days', js: true do
datepicker.set_date date2
page.within('[data-qa-selector="op-datepicker-modal"]') do
- click_on 'Save'
+ click_on 'Add'
end
expect(page).not_to have_selector('.flatpickr-calendar')
diff --git a/spec/support/components/datepicker/datepicker.rb b/spec/support/components/datepicker/datepicker.rb
index 180a187866c..624f97e323d 100644
--- a/spec/support/components/datepicker/datepicker.rb
+++ b/spec/support/components/datepicker/datepicker.rb
@@ -109,8 +109,8 @@ module Components
select_day date.day
end
- def save!
- container.find('[data-qa-selector="op-datepicker-modal"] .button', text: I18n.t(:button_save)).click
+ def save!(text: I18n.t(:button_apply))
+ container.find('[data-qa-selector="op-datepicker-modal"] .button', text:).click
end
##
diff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rb
index 1867c5cd085..c5af9fd3984 100644
--- a/spec/support/components/datepicker/work_package_datepicker.rb
+++ b/spec/support/components/datepicker/work_package_datepicker.rb
@@ -156,6 +156,10 @@ module Components
end
end
+ def save!(text: I18n.t(:button_save))
+ super
+ end
+
def set_duration(value)
focus_duration
fill_in 'duration', with: value, fill_options: { clear: :backspace }
diff --git a/spec/support/components/work_packages/filters.rb b/spec/support/components/work_packages/filters.rb
index 84a7b6abb29..0981525d34c 100644
--- a/spec/support/components/work_packages/filters.rb
+++ b/spec/support/components/work_packages/filters.rb
@@ -197,7 +197,7 @@ module Components
datepicker = Components::WorkPackageDatepicker.new
datepicker.set_start_date(value[0])
datepicker.set_due_date(value[1])
- datepicker.save!
+ datepicker.save!(text: I18n.t(:button_apply))
elsif page.has_selector?("#filter_#{id} [data-qa-selector='op-single-date-picker']")
datepicker = Components::Datepicker.new
datepicker.set_date(value[0])
diff --git a/spec/support/pages/reminders/settings.rb b/spec/support/pages/reminders/settings.rb
index a3db4f41737..b9563014e18 100644
--- a/spec/support/pages/reminders/settings.rb
+++ b/spec/support/pages/reminders/settings.rb
@@ -129,7 +129,7 @@ module Pages
fill_in 'startDate', with: first.iso8601
fill_in 'endDate', with: last.iso8601
sleep 1
- page.find('[data-qa-selector="op-datepicker-modal--action"]', text: 'Save').click
+ page.find('[data-qa-selector="op-datepicker-modal--action"]', text: 'Apply').click
else
uncheck 'Temporarily pause daily email reminders'
end