mirror of
https://github.com/discourse/discourse.git
synced 2024-12-30 17:13:43 +08:00
a7f596da7a
A change in relative picker was causing a serie of events which ultimately would cause the whole list of time options to be reset and re-rendered which would cause a new instance of the picker to be created, causing a reset. The fix is using id in the each loop to help ember identify that it doesn’t have to re-render a specific component.
104 lines
2.7 KiB
Ruby
104 lines
2.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Modals
|
|
class Bookmark < PageObjects::Modals::Base
|
|
def fill_name(name)
|
|
fill_in("bookmark-name", with: name)
|
|
end
|
|
|
|
def name
|
|
find("#bookmark-name")
|
|
end
|
|
|
|
def select_preset_reminder(identifier)
|
|
find("#tap_tile_#{identifier}").click
|
|
end
|
|
|
|
def has_active_preset?(identifier)
|
|
has_css?("#tap_tile_#{identifier}.tap-tile.active")
|
|
end
|
|
|
|
def has_preset?(identifier)
|
|
has_css?("#tap_tile_#{identifier}")
|
|
end
|
|
|
|
def has_no_preset?(identifier)
|
|
has_no_css?("#tap_tile_#{identifier}")
|
|
end
|
|
|
|
def editing_id?(bookmark_id)
|
|
has_css?(".bookmark-reminder-modal[data-bookmark-id='#{bookmark_id}']")
|
|
end
|
|
|
|
def open_options_panel
|
|
find(".bookmark-options-button").click
|
|
end
|
|
|
|
def has_open_options_panel?
|
|
has_css?(".bookmark-options-panel")
|
|
end
|
|
|
|
def select_relative_time_duration(duration)
|
|
find("#bookmark-relative-time-picker").fill_in(with: duration)
|
|
end
|
|
|
|
def select_relative_time_interval(interval)
|
|
select_kit = PageObjects::Components::SelectKit.new(".relative-time-intervals")
|
|
select_kit.expand
|
|
select_kit.select_row_by_value(interval)
|
|
end
|
|
|
|
def select_auto_delete_preference(preference)
|
|
select_kit = PageObjects::Components::SelectKit.new("#bookmark-auto-delete-preference")
|
|
select_kit.expand
|
|
select_kit.select_row_by_value(preference)
|
|
end
|
|
|
|
def has_auto_delete_preference?(preference)
|
|
select_kit = PageObjects::Components::SelectKit.new("#bookmark-auto-delete-preference")
|
|
select_kit.has_selected_value?(preference)
|
|
end
|
|
|
|
def custom_date_picker
|
|
find(".tap-tile-date-input #custom-date .date-picker")
|
|
end
|
|
|
|
def custom_time_picker
|
|
find(".tap-tile-time-input #custom-time")
|
|
end
|
|
|
|
def save
|
|
find("#save-bookmark").click
|
|
end
|
|
|
|
def delete
|
|
find("#delete-bookmark").click
|
|
end
|
|
|
|
def confirm_delete
|
|
find(".dialog-footer .btn-danger").click
|
|
end
|
|
|
|
def existing_reminder_alert
|
|
find(".existing-reminder-at-alert")
|
|
end
|
|
|
|
def existing_reminder_alert_message(bookmark)
|
|
I18n.t(
|
|
"js.bookmarks.reminders.existing_reminder",
|
|
at_date_time:
|
|
I18n.t(
|
|
"js.bookmarks.reminders.at_time",
|
|
date_time:
|
|
bookmark
|
|
.reminder_at_in_zone(bookmark.user.user_option&.timezone || "UTC")
|
|
.strftime("%b %-d, %Y %l:%M %P")
|
|
.gsub(" ", " "), # have to do this because %l adds padding before the hour but not in JS
|
|
),
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|