Skip to content

Commit

Permalink
Update the dialog content when chaning the scheduling mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Dec 16, 2024
1 parent 16ded3c commit f7d3b70
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,39 @@
body.with_row(mb: 3) do
flex_layout(align_items: :flex_end, justify_content: :space_between) do |first_row|
first_row.with_column do
render(Primer::Alpha::FormControl.new(label: I18n.t("work_packages.datepicker_modal.mode.title"))) do |component|
concat(render(Primer::Alpha::FormControl.new(label: I18n.t("work_packages.datepicker_modal.mode.title"))) do |component|
component.with_input do
render(Primer::Alpha::SegmentedControl.new("aria-label": I18n.t("work_packages.datepicker_modal.mode.title"))) do |control|
control.with_item(tag: :a,
href: work_package_datepicker_dialog_content_path(manually_scheduled: true),
href: work_package_datepicker_dialog_content_path(params.merge(manually_scheduled: true).permit!),
data: { turbo_stream: true },
label: I18n.t("work_packages.datepicker_modal.mode.manual"),
title: I18n.t("work_packages.datepicker_modal.mode.manual"),
selected: manually_scheduled)
control.with_item(tag: :a,
href: work_package_datepicker_dialog_content_path(manually_scheduled: false),
href: work_package_datepicker_dialog_content_path(params.merge(manually_scheduled: false).permit!),
data: { turbo_stream: true },
label: I18n.t("work_packages.datepicker_modal.mode.automatic"),
title: I18n.t("work_packages.datepicker_modal.mode.automatic"),
selected: !manually_scheduled)
end
end
end
end)
concat(
f.hidden_field(:work_package,
name: "work_package[manually_scheduled]",
value: manually_scheduled)
)
concat(
f.hidden_field(:work_package,
name: "work_package[manually_scheduled_touched]",
value: params[:manually_scheduled].present?)
)
concat(
f.hidden_field(:work_package,
name: "work_package[manually_scheduled_was]",
value: work_package.schedule_manually)
)
end

first_row.with_column(mb: 1) do
Expand Down
7 changes: 5 additions & 2 deletions app/controllers/work_packages/date_picker_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def find_work_package

def touched_field_map
params.require(:work_package)
.slice("schedule_manually_touched",
.slice("manually_scheduled_was",
"ignore_non_working_days_touched",
"start_date_touched",
"due_date_touched",
Expand All @@ -129,7 +129,9 @@ def touched_field_map

def manually_scheduled
if params[:manually_scheduled].present?
params.delete(:manually_scheduled)
params[:manually_scheduled]
elsif params[:work_package].present? && params[:work_package][:manually_scheduled].present?
params[:work_package][:manually_scheduled]
else
work_package.schedule_manually
end
Expand All @@ -138,6 +140,7 @@ def manually_scheduled
def work_package_datepicker_params
params.require(:work_package)
.slice(*allowed_touched_params)
.merge(manually_scheduled:)
.permit!
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export abstract class DialogPreviewController extends Controller {
}
});

this.debouncedPreview = debounce((event:Event) => { void this.preview(event); }, 100);
this.debouncedPreview = debounce((event:Event) => { void this.preview(event); }, 300);

// Turbo supports morphing, by adding the <turbo-frame refresh="morph">
// attribute. However, it does not work that well with primer input: when
Expand Down

0 comments on commit f7d3b70

Please sign in to comment.