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

Use op-single-date-picker for budget forms

Benjamin Bädorff33e1b8dbd6c
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 37b99b7a2d8..1a1e76dfa24 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
@@ -35,6 +35,7 @@ import {
forwardRef,
Injector,
Input,
+ OnInit,
Output,
ViewChild,
ViewEncapsulation,
@@ -68,7 +69,7 @@ export const opSingleDatePickerSelector = 'op-single-date-picker';
},
],
})
-export class OpSingleDatePickerComponent implements ControlValueAccessor {
+export class OpSingleDatePickerComponent implements ControlValueAccessor, OnInit {
@Output('valueChange') valueChange = new EventEmitter();
private _value = '';
@@ -123,6 +124,13 @@ export class OpSingleDatePickerComponent implements ControlValueAccessor {
populateInputsFromDataset(this);
}
+ ngOnInit(): void {
+ if (!this.value) {
+ const today = parseDate(new Date()) as Date;
+ this.writeValue(this.timezoneService.formattedISODate(today));
+ }
+ }
+
open() {
this.opened = true;
this.initializeDatepicker();
diff --git a/modules/budgets/app/views/budgets/_form.html.erb b/modules/budgets/app/views/budgets/_form.html.erb
index 3faf450b057..7cc911adb14 100644
--- a/modules/budgets/app/views/budgets/_form.html.erb
+++ b/modules/budgets/app/views/budgets/_form.html.erb
@@ -40,7 +40,15 @@ See COPYRIGHT and LICENSE files for more details.
resource: resource %>
</div>
<div class="form--field">
- <%= f.text_field :fixed_date, container_class: '-xslim', class: '-augmented-datepicker' %>
+ <label class="form--label" for='budget_fixed_date'><%= WorkPackage.human_attribute_name(:fixed_date) %></label>
+ <div class="form--field-container -visible-overflow">
+ <%= angular_component_tag 'op-single-date-picker',
+ inputs: {
+ value: @budget.fixed_date,
+ id: "budget_fixed_date",
+ name: "budget[fixed_date]"
+ }
+ %>
</div>
<%= render partial: 'budgets/subform/material_budget_subform' %>