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

Show "Today" link below date field to simply set current date

Henriette Darge3e82be4f3bd4
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 9a3dc650e27..0ae5ef373c1 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -435,7 +435,7 @@ en:
label_sum_for: "Sum for"
label_subject: "Subject"
label_this_week: "this week"
- label_today: "today"
+ label_today: "Today"
label_time_entry_plural: "Spent time"
label_up: "Up"
label_user_plural: "Users"
diff --git a/frontend/src/app/components/datepicker/datepicker.modal.helper.ts b/frontend/src/app/components/datepicker/datepicker.modal.helper.ts
index 81950addf47..77ace246263 100644
--- a/frontend/src/app/components/datepicker/datepicker.modal.helper.ts
+++ b/frontend/src/app/components/datepicker/datepicker.modal.helper.ts
@@ -46,11 +46,11 @@ export class DatePickerModalHelper {
public parseDate(date:Date|string):Date|'' {
if (date instanceof Date) {
- return date;
+ return date.setHours(0,0,0,0);
} else if (date === '') {
return '';
} else {
- return new Date(date);
+ return new Date(date).setHours(0,0,0,0);
}
}
@@ -79,6 +79,7 @@ export class DatePickerModalHelper {
// Keep currently active month and avoid jump because of two-month layout
datePicker.datepickerInstance.currentMonth = currentMonth;
+ datePicker.datepickerInstance.redraw();
}
public setDatepickerRestrictions(dates:{ [key in DateKeys]:string }, datePicker:DatePicker) {
diff --git a/frontend/src/app/components/datepicker/datepicker.modal.html b/frontend/src/app/components/datepicker/datepicker.modal.html
index 80c002d6e67..83b6c9a665f 100644
--- a/frontend/src/app/components/datepicker/datepicker.modal.html
+++ b/frontend/src/app/components/datepicker/datepicker.modal.html
@@ -27,6 +27,11 @@
<span class="icon2 icon-small icon-cancel"></span>
</a>
</div>
+ <div class="form--field-extra-actions">
+ <a (click)="setToday('date')"
+ [textContent]="text.today">
+ </a>
+ </div>
</div>
</ng-container>
@@ -51,6 +56,12 @@
<span class="icon2 icon-small icon-cancel"></span>
</a>
</div>
+ <div class="form--field-extra-actions">
+ <a *ngIf="datepickerHelper.isStateOfCurrentActivatedField('start')"
+ (click)="setToday('start')"
+ [textContent]="text.today">
+ </a>
+ </div>
</div>
<div class="form--field">
<label class="form--label"
@@ -72,6 +83,12 @@
<span class="icon2 icon-small icon-cancel"></span>
</a>
</div>
+ <div class="form--field-extra-actions">
+ <a *ngIf="datepickerHelper.isStateOfCurrentActivatedField('end')"
+ (click)="setToday('end')"
+ [textContent]="text.today">
+ </a>
+ </div>
</div>
</ng-container>
<div class="form--field datepicker-modal--scheduling-action-container">
diff --git a/frontend/src/app/components/datepicker/datepicker.modal.ts b/frontend/src/app/components/datepicker/datepicker.modal.ts
index 01e2ebcfcdf..9e264b1bf51 100644
--- a/frontend/src/app/components/datepicker/datepicker.modal.ts
+++ b/frontend/src/app/components/datepicker/datepicker.modal.ts
@@ -70,7 +70,8 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit {
date: this.I18n.t('js.work_packages.properties.date'),
startDate: this.I18n.t('js.work_packages.properties.startDate'),
endDate: this.I18n.t('js.work_packages.properties.dueDate'),
- placeholder: this.I18n.t('js.placeholders.default')
+ placeholder: this.I18n.t('js.placeholders.default'),
+ today: this.I18n.t('js.label_today')
};
public onDataUpdated = new EventEmitter<string>();
@@ -148,11 +149,15 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit {
updateDate(key:DateKeys, val:string) {
this.dates[key] = val;
if (this.datepickerHelper.validDate(val) && this.datePickerInstance) {
- this.datepickerHelper.toggleCurrentActivatedField(this.dates, this.datePickerInstance);
this.setDatesToDatepicker();
}
}
+ setToday(key:DateKeys) {
+ this.datepickerHelper.toggleCurrentActivatedField(this.dates, this.datePickerInstance);
+ this.updateDate(key, this.timezoneService.formattedISODate(Date.now()));
+ }
+
reposition(element:JQuery<HTMLElement>, target:JQuery<HTMLElement>) {
element.position({
my: 'left top',