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 "Rename datepicker component id to inputId so it won't interfere with the componen's id."

Alexander Brandon Colesf6ee0dac592e
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index 73ce152b78f..10f1dda926f 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -81,7 +81,7 @@ module CustomFieldsHelper
angular_component_tag "opce-basic-single-date-picker",
inputs: {
required: custom_field.required?,
- inputId: field_id,
+ id: field_id,
name: field_name
}
when "text"
diff --git a/app/views/filters/date/_between_dates.html.erb b/app/views/filters/date/_between_dates.html.erb
index c4475cf9d13..014f8e6129b 100644
--- a/app/views/filters/date/_between_dates.html.erb
+++ b/app/views/filters/date/_between_dates.html.erb
@@ -3,14 +3,14 @@
<%= angular_component_tag "opce-basic-single-date-picker",
inputs: {
value: from_value,
- inputId: "between-dates-from-value-#{filter.name}",
+ id: "between-dates-from-value-#{filter.name}",
name: "from_value"
} %>
<span><%= t(:label_date_to) %>:</span>
<%= angular_component_tag "opce-basic-single-date-picker",
inputs: {
value: to_value,
- inputId: "between-dates-to-value-#{filter.name}",
+ id: "between-dates-to-value-#{filter.name}",
name: "to_value"
} %>
</div>
diff --git a/app/views/filters/date/_on_date.html.erb b/app/views/filters/date/_on_date.html.erb
index 37b069ee8b1..a6b8706de10 100644
--- a/app/views/filters/date/_on_date.html.erb
+++ b/app/views/filters/date/_on_date.html.erb
@@ -3,7 +3,7 @@
<%= angular_component_tag "opce-basic-single-date-picker",
inputs: {
value: value,
- inputId: "on-date-value-#{filter.name}",
+ id: "on-date-value-#{filter.name}",
name: "value"
} %>
</div>
diff --git a/app/views/work_packages/bulk/edit.html.erb b/app/views/work_packages/bulk/edit.html.erb
index 2480e4dc523..eaf3f3c30bb 100644
--- a/app/views/work_packages/bulk/edit.html.erb
+++ b/app/views/work_packages/bulk/edit.html.erb
@@ -190,7 +190,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= angular_component_tag "opce-basic-single-date-picker",
class: "form--text-field-container",
inputs: {
- inputId: "work_package_start_date",
+ id: "work_package_start_date",
name: "work_package[start_date]"
} %>
</div>
@@ -201,7 +201,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= angular_component_tag "opce-basic-single-date-picker",
class: "form--text-field-container",
inputs: {
- inputId: "work_package_due_date",
+ id: "work_package_due_date",
name: "work_package[due_date]"
} %>
</div>
diff --git a/app/views/work_packages/moves/new.html.erb b/app/views/work_packages/moves/new.html.erb
index 886eb9ef34c..a72132df529 100644
--- a/app/views/work_packages/moves/new.html.erb
+++ b/app/views/work_packages/moves/new.html.erb
@@ -186,7 +186,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="form--field-container -visible-overflow">
<%= angular_component_tag "opce-basic-single-date-picker",
inputs: {
- inputId: "start_date",
+ id: "start_date",
name: "start_date"
} %>
</div>
@@ -196,7 +196,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="form--field-container -visible-overflow">
<%= angular_component_tag "opce-basic-single-date-picker",
inputs: {
- inputId: "due_date",
+ id: "due_date",
name: "due_date"
} %>
</div>
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-date-time-value/filter-date-time-value.component.html b/frontend/src/app/features/work-packages/components/filters/filter-date-time-value/filter-date-time-value.component.html
index d77b3326c78..97e00c37d36 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-date-time-value/filter-date-time-value.component.html
+++ b/frontend/src/app/features/work-packages/components/filters/filter-date-time-value/filter-date-time-value.component.html
@@ -1,5 +1,5 @@
<op-basic-single-date-picker
- [inputId]="'values-' + filter.id"
+ [id]="'values-' + filter.id"
[name]="'v[' + filter.id + ']'"
class="advanced-filters--date-field"
required="true"
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 d33f4a4024f..b29454ccebc 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
@@ -3,7 +3,7 @@
[value]="isoDateFormatter(begin)"
[opAutofocus]="shouldFocus"
required="true"
- [inputId]="'values-' + filter.id + '-begin'"
+ [id]="'values-' + filter.id + '-begin'"
[name]="'v[' + filter.id + ']-begin'"
classes="advanced-filters--date-field"
></op-basic-single-date-picker>
@@ -14,7 +14,7 @@
<op-basic-single-date-picker
(valueChange)="parseEnd($event)"
[value]="isoDateFormatter(end)"
- [inputId]="'values-' + filter.id + '-end'"
+ [id]="'values-' + filter.id + '-end'"
[name]="'v[' + filter.id + ']-end'"
classes="advanced-filters--date-field"
></op-basic-single-date-picker>
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-date-value/filter-date-value.component.html b/frontend/src/app/features/work-packages/components/filters/filter-date-value/filter-date-value.component.html
index cd494d58671..5226c44b67e 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-date-value/filter-date-value.component.html
+++ b/frontend/src/app/features/work-packages/components/filters/filter-date-value/filter-date-value.component.html
@@ -1,5 +1,5 @@
<op-basic-single-date-picker
- [inputId]="'values-' + filter.id"
+ [id]="'values-' + filter.id"
[name]="'v[' + filter.id + ']'"
class="advanced-filters--date-field"
[opAutofocus]="shouldFocus"
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-dates-value/filter-dates-value.component.html b/frontend/src/app/features/work-packages/components/filters/filter-dates-value/filter-dates-value.component.html
index 22a95cc8293..0bae891d1aa 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-dates-value/filter-dates-value.component.html
+++ b/frontend/src/app/features/work-packages/components/filters/filter-dates-value/filter-dates-value.component.html
@@ -1,5 +1,5 @@
<op-basic-range-date-picker
- [inputId]="'values-' + filter.id"
+ [id]="'values-' + filter.id"
[name]="'v[' + filter.id + ']'"
class="advanced-filters--date-field"
diff --git a/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.html b/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.html
index 37e41636bc5..99f15a7d473 100644
--- a/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.html
+++ b/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.html
@@ -12,7 +12,7 @@
</span>
<span class="form--text-field-container -slim" *ngIf="valueVisible">
<op-basic-single-date-picker
- [inputId]="fieldId + '_visible'"
+ [id]="fieldId + '_visible'"
[name]="fieldId + '_input'"
[value]="fieldValue"
(valueChange)="updateField($event)"
diff --git a/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.html b/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.html
index e2caee42464..05fe101b3ce 100644
--- a/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.html
+++ b/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.html
@@ -8,7 +8,7 @@
[ngClass]="inputClassNames"
[attr.data-value]="value"
[attr.data-action]="dataAction"
- [id]="inputId"
+ [id]="id"
[name]="name"
[attr.name]="name"
[required]="required"
@@ -24,7 +24,7 @@
class="spot-input"
data-test-selector="op-basic-range-date-picker-start"
[ngClass]="inputClassNames"
- id="{{ inputId }}-start"
+ id="{{ id }}-start"
name="{{ name }}-start"
[required]="required"
[disabled]="disabled"
@@ -37,7 +37,7 @@
class="spot-input"
data-test-selector="op-basic-range-date-picker-end"
[ngClass]="inputClassNames"
- id="{{ inputId }}-end"
+ id="{{ id }}-end"
name="{{ name }}-end"
[required]="required"
[disabled]="disabled"
@@ -48,7 +48,7 @@
type="hidden"
data-test-selector="op-basic-range-date-picker--value"
[attr.data-value]="stringValue"
- [id]="inputId"
+ [id]="id"
[name]="name"
[attr.name]="name"
[attr.data-action]="dataAction"
diff --git a/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts
index 79195f54deb..9c5d403c4c2 100644
--- a/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts
@@ -121,7 +121,7 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
// This comment can be removed once the https://github.com/bigskysoftware/idiomorph/pull/131
// is accepted.
- @Input() inputId = `flatpickr-input-${+(new Date())}`;
+ id = `flatpickr-input-${+(new Date())}`;
@Input() name = '';
@@ -197,7 +197,7 @@ export class OpBasicRangeDatePickerComponent implements OnInit, ControlValueAcce
private initializeDatePicker() {
this.datePickerInstance = new DatePicker(
this.injector,
- this.inputId,
+ this.id,
this.value || '',
{
allowInput: true,
diff --git a/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.html b/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.html
index 9abfe2379d1..3e7fe691030 100644
--- a/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.html
+++ b/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.html
@@ -9,7 +9,7 @@
[ngModel]="value"
[attr.data-value]="value"
[attr.data-action]="dataAction"
- [id]="inputId"
+ [id]="id"
[name]="name"
[attr.name]="name"
[required]="required"
@@ -28,7 +28,7 @@
[ngClass]="inputClassNames"
[attr.data-value]="value"
[attr.data-action]="dataAction"
- [id]="inputId"
+ [id]="id"
[name]="name"
[attr.name]="name"
[required]="required"
diff --git a/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts
index b0fd8fc0e2c..99984ef3426 100644
--- a/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts
@@ -92,14 +92,11 @@ export class OpBasicSingleDatePickerComponent implements ControlValueAccessor, O
// the same element will have a different id set, and it will not be matched. The old element
// will have the angular `@Input id` property, while new one will have the html id attribute.
//
- // The solution is to rename the `id` to `inputId`. The component would still get an id
- // attribute assigned if provided when declaring the component, but angular will not
- // programatically overwrite the `id` getter.
- //
- // This comment can be removed once the https://github.com/bigskysoftware/idiomorph/pull/131
- // is accepted.
-
- @Input() inputId = `flatpickr-input-${+(new Date())}`;
+ // The solution is to not have the id as an input property, this way the angular id won't
+ // interfere when calling the html id attribute of the component. The component would still
+ // get an id attribute assigned if provided when declaring the component, but it will not
+ // programatically overwrite the id accessor from angular.
+ id = `flatpickr-input-${+(new Date())}`;
@Input() name = '';
@@ -173,7 +170,7 @@ export class OpBasicSingleDatePickerComponent implements ControlValueAccessor, O
private initializeDatePicker() {
this.datePickerInstance = new DatePicker(
this.injector,
- this.inputId,
+ this.id,
this.value || '',
{
allowInput: true,
diff --git a/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.html b/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.html
index f7d56f1d2e9..c586528f5d6 100644
--- a/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.html
+++ b/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.html
@@ -12,7 +12,7 @@
type="text"
class="spot-input"
[attr.data-value]="value"
- [id]="inputId"
+ [id]="id"
[ngModel]="value"
(ngModelChange)="changeValueFromInputDebounced($event)"
(click)="onInputClick($event)"
diff --git a/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts
index 7616ba295cd..cee2aa1b292 100644
--- a/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts
@@ -84,7 +84,7 @@ export class OpModalSingleDatePickerComponent implements ControlValueAccessor, O
return this._value;
}
- @Input() inputId = `flatpickr-input-${+(new Date())}`;
+ @Input() id = `flatpickr-input-${+(new Date())}`;
@Input() name = '';
@@ -230,7 +230,7 @@ export class OpModalSingleDatePickerComponent implements ControlValueAccessor, O
this.datePickerInstance = new DatePicker(
this.injector,
- this.inputId,
+ this.id,
this.workingDate || '',
{
mode: 'single',
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts
index 3ad0faf470b..41a4ae113d4 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts
@@ -40,7 +40,7 @@ import { TimezoneService } from 'core-app/core/datetime/timezone.service';
(keydown.enter)="handler.handleUserSubmit()"
(picked)="handler.handleUserSubmit()"
class="inline-edit--field"
- [inputId]="handler.htmlId"
+ [id]="handler.htmlId"
[required]="required"
[disabled]="inFlight"
[opAutofocus]="autofocus"
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 ee9e70d4c55..05afd1a12d3 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
@@ -20,7 +20,7 @@
class="op-non-working-days-list--add-button"
>
<op-modal-single-date-picker
- inputId="test"
+ id="test"
name="test"
[opened]="datepickerOpened"
[required]="true"
diff --git a/lib/primer/open_project/forms/date_picker.html.erb b/lib/primer/open_project/forms/date_picker.html.erb
index 461527ede4a..147f06d4284 100644
--- a/lib/primer/open_project/forms/date_picker.html.erb
+++ b/lib/primer/open_project/forms/date_picker.html.erb
@@ -41,7 +41,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= render Primer::ConditionalWrapper.new(condition: @input.auto_check_src, tag: "auto-check", csrf: auto_check_authenticity_token, src: @input.auto_check_src) do %>
<%= angular_component_tag @datepicker_options.fetch(:component),
inputs: @datepicker_options.merge(
- inputId: @datepicker_options.fetch(:id) { builder.field_id(@input.name) },
+ id: @datepicker_options.fetch(:id) { builder.field_id(@input.name) },
name: @datepicker_options.fetch(:name) { builder.field_name(@input.name) },
value: @datepicker_options.fetch(:value) { @input.input_arguments[:value] || builder.object&.send(@input.name) },
inputClassNames: @datepicker_options.fetch(:class) { @input.input_arguments[:class] },
diff --git a/lib/tabular_form_builder.rb b/lib/tabular_form_builder.rb
index 648329fdf2e..4c55d02171c 100644
--- a/lib/tabular_form_builder.rb
+++ b/lib/tabular_form_builder.rb
@@ -101,7 +101,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
inputs = {
value: @object.public_send(field),
- inputId: field_id(field, index: options[:index]),
+ id: field_id(field, index: options[:index]),
name: options[:name] || field_name(field, index: options[:index])
}
diff --git a/modules/backlogs/app/views/rb_sprints/_sprint.html.erb b/modules/backlogs/app/views/rb_sprints/_sprint.html.erb
index 6bc67f9092e..af87f44bda9 100644
--- a/modules/backlogs/app/views/rb_sprints/_sprint.html.erb
+++ b/modules/backlogs/app/views/rb_sprints/_sprint.html.erb
@@ -56,14 +56,14 @@ See COPYRIGHT and LICENSE files for more details.
inputs: {
value: sprint.effective_date,
inputClassNames: "effective_date editor",
- inputId: "effective_date_#{sprint.id}",
+ id: "effective_date_#{sprint.id}",
name: :effective_date
} %>
<%= angular_component_tag "opce-basic-single-date-picker",
inputs: {
value: sprint.start_date,
inputClassNames: "start_date editor",
- inputId: "start_date_#{sprint.id}",
+ id: "start_date_#{sprint.id}",
name: :start_date
} %>
<%= text_field_tag :name,
diff --git a/modules/costs/app/views/admin/cost_types/index.html.erb b/modules/costs/app/views/admin/cost_types/index.html.erb
index 4d61b8398d6..952e8403d82 100644
--- a/modules/costs/app/views/admin/cost_types/index.html.erb
+++ b/modules/costs/app/views/admin/cost_types/index.html.erb
@@ -64,7 +64,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= angular_component_tag "opce-basic-single-date-picker",
inputs: {
value: @fixed_date,
- inputId: :start_date,
+ id: :start_date,
name: :fixed_date
} %>
</div>
diff --git a/modules/reporting/lib/widget/filters/date.rb b/modules/reporting/lib/widget/filters/date.rb
index 9c58ce59401..f7ec62ebe89 100644
--- a/modules/reporting/lib/widget/filters/date.rb
+++ b/modules/reporting/lib/widget/filters/date.rb
@@ -42,7 +42,7 @@ class Widget::Filters::Date < Widget::Filters::Base
text1 = angular_component_tag "opce-basic-single-date-picker",
inputs: {
value: filter.operator.forced == :integers ? "" : filter.values.first.to_s,
- inputId: "#{id_prefix}arg_1_val",
+ id: "#{id_prefix}arg_1_val",
name:
}
label1 + text1
@@ -56,7 +56,7 @@ class Widget::Filters::Date < Widget::Filters::Base
text2 = angular_component_tag "opce-basic-single-date-picker",
inputs: {
value: filter.operator.forced == :integers ? "" : filter.values.second.to_s,
- inputId: "#{id_prefix}arg_2_val",
+ id: "#{id_prefix}arg_2_val",
name: name.to_s
}
label2 + text2
diff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rb
index 207552323d5..4eac6fc9a78 100644
--- a/spec/lib/custom_field_form_builder_spec.rb
+++ b/spec/lib/custom_field_form_builder_spec.rb
@@ -109,7 +109,7 @@ RSpec.describe CustomFieldFormBuilder do
<opce-basic-single-date-picker
class="custom-class"
data-value="null"
- data-input-id='"user_custom_field_#{custom_field.id}"'
+ data-id='"user_custom_field_#{custom_field.id}"'
data-name='"user[#{custom_field.id}]"'
></opce-basic-single-date-picker>
HTML