FIX: Pre-select Later Today on bookmark edit if the time is the same (#9636)

If the user chooses "Later Today" as the reminder for a bookmark, then edits that bookmark, we should pre-select "Later Today" if that time has not changed (e.g. later is still 6pm). We do this to avoid confusion instead of opening the custom date + time section.
This commit is contained in:
Martin Brennan 2020-05-05 16:28:31 +10:00 committed by GitHub
parent 6aa9014509
commit 5cf6984a1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -103,6 +103,11 @@ export default Controller.extend(ModalFunctionality, {
_initializeExistingBookmarkData() {
if (this._existingBookmarkHasReminder()) {
let parsedReminderAt = this._parseCustomDateTime(this.model.reminderAt);
if (parsedReminderAt.isSame(this.laterToday())) {
return this.set("selectedReminderType", REMINDER_TYPES.LATER_TODAY);
}
this.setProperties({
customReminderDate: parsedReminderAt.format("YYYY-MM-DD"),
customReminderTime: parsedReminderAt.format("HH:mm"),

View File

@ -195,3 +195,21 @@ test("Editing a bookmark", async assert => {
);
assert.verifySteps(["tomorrow"]);
});
test("Editing a bookmark that has a Later Today reminder, and it is before 6pm today", async assert => {
mockSuccessfulBookmarkPost(assert);
await visit("/t/internationalization-localization/280");
await openBookmarkModal();
await fillIn("input#bookmark-name", "Test name");
await click("#tap_tile_later_today");
await openEditBookmarkModal();
assert.not(
exists("#bookmark-custon-date > input"),
"it does not show the custom date input"
);
assert.ok(
exists("#tap_tile_later_today.active"),
"it preselects Later Today"
);
assert.verifySteps(["later_today"]);
});