mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 02:54:29 +08:00
35 lines
878 B
JavaScript
35 lines
878 B
JavaScript
import { get } from "@ember/object";
|
|
import EmberObject from "@ember/object";
|
|
import {
|
|
default as computed,
|
|
observes
|
|
} from "ember-addons/ember-computed-decorators";
|
|
|
|
export default EmberObject.extend({
|
|
searchContextEnabled: false, // checkbox to scope search
|
|
searchContext: null,
|
|
term: null,
|
|
highlightTerm: null,
|
|
|
|
@observes("term")
|
|
_sethighlightTerm() {
|
|
this.set("highlightTerm", this.term);
|
|
},
|
|
|
|
@computed("searchContext")
|
|
contextType: {
|
|
get(searchContext) {
|
|
if (searchContext) {
|
|
return get(searchContext, "type");
|
|
}
|
|
},
|
|
set(value, searchContext) {
|
|
// a bit hacky, consider cleaning this up, need to work through all observers though
|
|
const context = $.extend({}, searchContext);
|
|
context.type = value;
|
|
this.set("searchContext", context);
|
|
return this.get("searchContext.type");
|
|
}
|
|
}
|
|
});
|