mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Immediately show sql options when badge query is supplied
`buffered` and `model` are EmberObjects, so we need to call `get()` when accessing values to ensure they are autotracked
This commit is contained in:
parent
0f8e4d7acc
commit
240669da3a
@ -81,8 +81,8 @@ export default class AdminBadgesShowController extends Controller.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
get hasQuery() {
|
get hasQuery() {
|
||||||
let modelQuery = this.model.query;
|
let modelQuery = this.model.get("query");
|
||||||
let bufferedQuery = this.bufferedQuery;
|
let bufferedQuery = this.buffered.get("query");
|
||||||
|
|
||||||
if (bufferedQuery) {
|
if (bufferedQuery) {
|
||||||
return bufferedQuery.trim().length > 0;
|
return bufferedQuery.trim().length > 0;
|
||||||
|
@ -97,21 +97,21 @@
|
|||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label>
|
<label>
|
||||||
<Input @type="checkbox" @checked={{this.buffered.auto_revoke}} disabled={{this.readOnly}} />
|
<Input name="auto_revoke" @type="checkbox" @checked={{this.buffered.auto_revoke}} disabled={{this.readOnly}} />
|
||||||
{{i18n "admin.badges.auto_revoke"}}
|
{{i18n "admin.badges.auto_revoke"}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label>
|
<label>
|
||||||
<Input @type="checkbox" @checked={{this.buffered.target_posts}} disabled={{this.readOnly}} />
|
<Input name="target_posts" @type="checkbox" @checked={{this.buffered.target_posts}} disabled={{this.readOnly}} />
|
||||||
{{i18n "admin.badges.target_posts"}}
|
{{i18n "admin.badges.target_posts"}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label for="trigger">{{i18n "admin.badges.trigger"}}</label>
|
<label for="trigger">{{i18n "admin.badges.trigger"}}</label>
|
||||||
<ComboBox @name="trigger" @value={{this.buffered.trigger}} @content={{this.badgeTriggers}} @onChange={{action (mut this.buffered.trigger)}} @options={{hash
|
<ComboBox name="trigger" @value={{this.buffered.trigger}} @content={{this.badgeTriggers}} @onChange={{action (mut this.buffered.trigger)}} @options={{hash
|
||||||
disabled=this.readOnly
|
disabled=this.readOnly
|
||||||
}} />
|
}} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,8 +3,9 @@ import {
|
|||||||
exists,
|
exists,
|
||||||
query,
|
query,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { click, visit } from "@ember/test-helpers";
|
import { click, fillIn, settled, visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
acceptance("Admin - Badges - Show", function (needs) {
|
acceptance("Admin - Badges - Show", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
@ -37,6 +38,24 @@ acceptance("Admin - Badges - Show", function (needs) {
|
|||||||
exists(".image-uploader"),
|
exists(".image-uploader"),
|
||||||
"image uploader becomes visible after clicking the upload image radio button"
|
"image uploader becomes visible after clicking the upload image radio button"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// SQL fields
|
||||||
|
assert.false(exists("label[for=query]"), "sql input is hidden by default");
|
||||||
|
set(this.siteSettings, "enable_badge_sql", true);
|
||||||
|
await settled();
|
||||||
|
assert.true(exists("label[for=query]"), "sql input shows when enabled");
|
||||||
|
|
||||||
|
assert.false(
|
||||||
|
exists("input[name=auto_revoke]"),
|
||||||
|
"does not show sql-specific options when query is blank"
|
||||||
|
);
|
||||||
|
|
||||||
|
await fillIn(".ace-wrapper textarea", "SELECT 1");
|
||||||
|
|
||||||
|
assert.true(
|
||||||
|
exists("input[name=auto_revoke]"),
|
||||||
|
"shows sql-specific options when query is present"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("existing badge that has an icon", async function (assert) {
|
test("existing badge that has an icon", async function (assert) {
|
||||||
|
Loading…
Reference in New Issue
Block a user