mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
FIX: Bugs with year selector and erase button (#17749)
This commit is contained in:
parent
381365facc
commit
a799268b66
@ -401,22 +401,22 @@ export default Component.extend({
|
||||
},
|
||||
|
||||
_setPickerMinDate(date) {
|
||||
if (date && !moment(date, this.dateFormat).isValid()) {
|
||||
date = null;
|
||||
}
|
||||
|
||||
schedule("afterRender", () => {
|
||||
this._picker.setMinDate(moment(date, this.dateFormat).toDate());
|
||||
if (moment(date, this.dateFormat).isValid()) {
|
||||
this._picker.setMinDate(moment(date, this.dateFormat).toDate());
|
||||
} else {
|
||||
this._picker.setMinDate(null);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_setPickerDate(date) {
|
||||
if (date && !moment(date, this.dateFormat).isValid()) {
|
||||
date = null;
|
||||
}
|
||||
|
||||
schedule("afterRender", () => {
|
||||
this._picker.setDate(moment.utc(date), true);
|
||||
if (moment(date, this.dateFormat).isValid()) {
|
||||
this._picker.setDate(moment.utc(date), true);
|
||||
} else {
|
||||
this._picker.setDate(null);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
@translatedLabel={{this.formattedTo}}
|
||||
@class="date-time" />
|
||||
{{#if this.toFilled}}
|
||||
<DButton @icon="times" action={{action "eraseToDateTime"}} @class="delete-to-date" />
|
||||
<DButton @icon="times" @action={{action "eraseToDateTime"}} @class="delete-to-date" />
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
|
@ -1,4 +1,8 @@
|
||||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
query,
|
||||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
@ -77,4 +81,45 @@ acceptance("Local Dates - composer", function (needs) {
|
||||
"it outputs a preview date in selected timezone"
|
||||
);
|
||||
});
|
||||
|
||||
test("date modal - controls", async function (assert) {
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
await click(".d-editor-button-bar .local-dates");
|
||||
|
||||
await click('.pika-table td[data-day="5"] > .pika-button');
|
||||
|
||||
assert.ok(
|
||||
query("#from-date-time").textContent.includes("5,"),
|
||||
"selected FROM date works"
|
||||
);
|
||||
|
||||
await click(".date-time-control.to .date-time");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".pika-table .is-disabled").length,
|
||||
4,
|
||||
"date just before selected FROM date is disabled"
|
||||
);
|
||||
|
||||
await click('.pika-table td[data-day="10"] > .pika-button');
|
||||
|
||||
assert.ok(
|
||||
query(".date-time-control.to button").textContent.includes("10,"),
|
||||
"selected TO date works"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
query(".pika-table .is-selected").textContent,
|
||||
"10",
|
||||
"selected date is the 10th"
|
||||
);
|
||||
|
||||
await click(".delete-to-date");
|
||||
|
||||
assert.notOk(
|
||||
query(".pika-table .is-selected"),
|
||||
"deleting selected TO date works"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user