Skip to content

Commit

Permalink
fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Jan 6, 2025
1 parent 6a02285 commit 9792f6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
14 changes: 7 additions & 7 deletions modules/costs/app/components/time_entries/activity_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ActivityForm < ApplicationForm
focusDirectly: false,
multiple: false,
decorated: true,
disabled: project.blank?,
disabled: !project_or_work_package_selected?,
append_to: "#time-entry-dialog"
}
) do |select|
Expand All @@ -53,14 +53,14 @@ class ActivityForm < ApplicationForm

private

delegate :project, to: :model
delegate :project, :work_package, to: :model

def project_or_work_package_selected?
work_package.present? || project.present?
end

def placeholder_text
if project.blank?
I18n.t("time_entry.activity_select_project_first")
else
I18n.t("time_entry.activity_select")
end
I18n.t("placeholder_activity_select_work_package_first") unless project_or_work_package_selected?
end

def activities
Expand Down
2 changes: 2 additions & 0 deletions modules/costs/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ en:
label_valid_from: "Valid from"
label_yes: "Yes"

placeholder_activity_select_work_package_first: Work package selection is required first

notice_something_wrong: "Something went wrong. Please try again."
notice_successful_restore: "Successful restore."
notice_successful_lock: "Locked successfully."
Expand Down
16 changes: 8 additions & 8 deletions spec/features/support/components/time_logging_modal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class TimeLoggingModal
:user_field

def initialize
@activity_field = EditField.new(page, "activity")
@comment_field = EditField.new(page, "comment")
@hours_field = EditField.new(page, "hours")
@spent_on_field = EditField.new(page, "spentOn")
@work_package_field = EditField.new(page, "workPackage")
@user_field = EditField.new(page, "user")
@activity_field = EditField.new(page, "time_entry[activity_id]")
@comment_field = EditField.new(page, "time_entry[comment]")
@hours_field = EditField.new(page, "time_entry[hours]")
@spent_on_field = EditField.new(page, "time_entry[spent_on]")
@work_package_field = EditField.new(page, "time_entry[work_package_id]")
@user_field = EditField.new(page, "time_entry[user_id]")
end

def is_visible(visible)
Expand All @@ -55,7 +55,7 @@ def is_visible(visible)
.to have_text(I18n.t("js.button_log_time"))
end
else
expect(page).to have_no_css ".spot-modal"
expect(page).to have_no_css "dialog#time-entry-dialog"
end
end

Expand Down Expand Up @@ -138,7 +138,7 @@ def field_object(field_name)
end

def modal_container
page.find(".spot-modal")
page.find("dialog#time-entry-dialog")
end
end
end

0 comments on commit 9792f6a

Please sign in to comment.