mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: experimental outlet for navigation filter (#22897)
Temporary outlet for navigation filter for /filter page. In addition, copy button and reset button were added to core.
This commit is contained in:
parent
03690ccccf
commit
db4e2f41c2
@ -1,12 +1,48 @@
|
|||||||
import Controller, { inject as controller } from "@ember/controller";
|
import Controller, { inject as controller } from "@ember/controller";
|
||||||
|
import { tracked } from "@glimmer/tracking";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
import { bind } from "discourse-common/utils/decorators";
|
||||||
|
import discourseDebounce from "discourse-common/lib/debounce";
|
||||||
|
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
@controller("discovery/filter") discoveryFilter;
|
@controller("discovery/filter") discoveryFilter;
|
||||||
|
|
||||||
queryString = "";
|
@tracked copyIcon = "link";
|
||||||
|
@tracked copyClass = "btn-default";
|
||||||
|
@tracked newQueryString = "";
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
this.queryString = this.discoveryFilter.q;
|
this.newQueryString = this.discoveryFilter.q;
|
||||||
|
}
|
||||||
|
|
||||||
|
@bind
|
||||||
|
updateQueryString(string) {
|
||||||
|
this.newQueryString = string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
clearInput() {
|
||||||
|
this.newQueryString = "";
|
||||||
|
this.discoveryFilter.updateTopicsListQueryParams(this.newQueryString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
copyQueryString() {
|
||||||
|
this.copyIcon = "check";
|
||||||
|
this.copyClass = "btn-default ok";
|
||||||
|
|
||||||
|
navigator.clipboard.writeText(window.location);
|
||||||
|
|
||||||
|
discourseDebounce(this._restoreButton, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bind
|
||||||
|
_restoreButton() {
|
||||||
|
if (this.isDestroying || this.isDestroyed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.copyIcon = "link";
|
||||||
|
this.copyClass = "btn-default";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,41 @@
|
|||||||
{{d-icon "filter" class="topic-query-filter__icon"}}
|
{{d-icon "filter" class="topic-query-filter__icon"}}
|
||||||
<Input
|
<Input
|
||||||
class="topic-query-filter__filter-term"
|
class="topic-query-filter__filter-term"
|
||||||
@value={{this.queryString}}
|
@value={{this.newQueryString}}
|
||||||
@enter={{action
|
@enter={{action
|
||||||
this.discoveryFilter.updateTopicsListQueryParams
|
this.discoveryFilter.updateTopicsListQueryParams
|
||||||
this.queryString
|
this.newQueryString
|
||||||
}}
|
}}
|
||||||
@type="text"
|
@type="text"
|
||||||
|
id="queryStringInput"
|
||||||
|
autocomplete="off"
|
||||||
|
/>
|
||||||
|
{{! EXPERIMENTAL OUTLET - don't use because it will be removed soon }}
|
||||||
|
<PluginOutlet
|
||||||
|
@name="below-filter-input"
|
||||||
|
@outletArgs={{hash
|
||||||
|
updateQueryString=this.updateQueryString
|
||||||
|
newQueryString=this.newQueryString
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{{#if this.newQueryString}}
|
||||||
|
<div class="topic-query-filter__controls">
|
||||||
|
<DButton
|
||||||
|
@icon="times"
|
||||||
|
@action={{action this.clearInput}}
|
||||||
|
@disabled={{unless this.newQueryString "true"}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{{#if this.discoveryFilter.q}}
|
||||||
|
<DButton
|
||||||
|
@icon={{this.copyIcon}}
|
||||||
|
@class={{this.copyClass}}
|
||||||
|
@action={{this.copyQueryString}}
|
||||||
|
@disabled={{unless this.newQueryString "true"}}
|
||||||
|
/>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</DSection>
|
</DSection>
|
Loading…
Reference in New Issue
Block a user