Fix new work package creation form post

pull/11151/head
Oliver Günther 2 years ago
parent 5a52c02a85
commit e87a76760b
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 4
      frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
  2. 22
      spec/features/work_packages/new/new_work_package_datepicker_spec.rb
  3. 14
      spec/support/edit_fields/date_edit_field.rb

@ -203,6 +203,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
this.handleDatePickerChange(field, castArray(update)); this.handleDatePickerChange(field, castArray(update));
} }
this.onDataChange();
this.cdRef.detectChanges(); this.cdRef.detectChanges();
}); });
@ -237,7 +238,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
switchMap((fieldsToUpdate:FieldUpdates) => this switchMap((fieldsToUpdate:FieldUpdates) => this
.apiV3Service .apiV3Service
.work_packages .work_packages
.id(this.changeset.id) .withOptionalId(this.changeset.id === 'new' ? null : this.changeset.id)
.form .form
.forPayload({ .forPayload({
...fieldsToUpdate, ...fieldsToUpdate,
@ -498,6 +499,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
const dates = [startDate, endDate]; const dates = [startDate, endDate];
setDates(dates, this.datePickerInstance, enforceDate); setDates(dates, this.datePickerInstance, enforceDate);
this.onDataChange();
} }
private handleDatePickerChange(activeField:DateFields, dates:Date[]) { private handleDatePickerChange(activeField:DateFields, dates:Date[]) {

@ -35,12 +35,13 @@ require 'features/work_packages/work_packages_page'
describe 'New work package datepicker', describe 'New work package datepicker',
with_settings: { date_format: '%Y-%m-%d' }, with_settings: { date_format: '%Y-%m-%d' },
with_flag: { work_packages_duration_field_active: true },
js: true, selenium: true do js: true, selenium: true do
let(:project) { create :project_with_types, public: true } let(:project) { create :project_with_types, public: true }
let(:user) { create :admin } let(:user) { create :admin }
let(:wp_page_create) { Pages::FullWorkPackageCreate.new(project:) } let(:wp_page_create) { Pages::FullWorkPackageCreate.new(project:) }
let(:start_date) { wp_page_create.edit_field(:combinedDate) } let(:date_field) { wp_page_create.edit_field(:combinedDate) }
before do before do
login_as(user) login_as(user)
@ -49,18 +50,21 @@ describe 'New work package datepicker',
end end
it 'can open and select the datepicker' do it 'can open and select the datepicker' do
start_date.input_element.click date_field.input_element.click
date_field.ignore_non_working_days true
start = (Time.zone.today - 1.day).iso8601 start = (Time.zone.today - 1.day).iso8601
start_date.activate_start_date_within_modal date_field.focus_start_date
start_date.datepicker.set_date start, true date_field.set_active_date start
due = (Time.zone.today + 1.day).iso8601 due = (Time.zone.today + 1.day).iso8601
start_date.activate_due_date_within_modal date_field.focus_due_date
start_date.datepicker.set_date due, true date_field.set_active_date due
start_date.save! date_field.expect_duration 3
start_date.expect_inactive!
start_date.expect_value "#{start} - #{due}" date_field.save!
date_field.expect_inactive!
date_field.expect_value "#{start} - #{due}"
end end
end end

@ -18,7 +18,15 @@ class DateEditField < EditField
@datepicker ||= ::Components::WorkPackageDatepicker.new modal_selector @datepicker ||= ::Components::WorkPackageDatepicker.new modal_selector
end end
delegate :expect_duration, :set_duration, to: :datepicker delegate :set_start_date,
:set_due_date,
:focus_start_date,
:focus_due_date,
:expect_start_highlighted,
:expect_due_highlighted,
:expect_duration,
:set_duration,
:ignore_non_working_days, to: :datepicker
def modal_selector def modal_selector
'[data-qa-selector="op-datepicker-modal"]' '[data-qa-selector="op-datepicker-modal"]'
@ -117,7 +125,7 @@ class DateEditField < EditField
datepicker.set_start_date value.first datepicker.set_start_date value.first
datepicker.set_due_date value.last datepicker.set_due_date value.last
else else
select_value value set_active_date value
end end
save! if save save! if save
@ -135,7 +143,7 @@ class DateEditField < EditField
expect(input_element.value).to eq(value) expect(input_element.value).to eq(value)
end end
def select_value(value) def set_active_date(value)
datepicker.set_date value datepicker.set_date value
end end

Loading…
Cancel
Save