discourse/app/assets/javascripts/admin/components/site-text-summary.js.es6
Gerhard Schlager 7c4d4331bc FEATURE: Better handling of quotation marks in site text search
It also matches 3 dots with the ellipsis symbol.
2018-11-12 13:26:41 +01:00

41 lines
867 B
JavaScript

import { on } from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
classNames: ["site-text"],
classNameBindings: ["siteText.overridden"],
@on("didInsertElement")
highlightTerm() {
const term = this._searchTerm();
if (term) {
this.$(".site-text-id, .site-text-value").highlight(term, {
className: "text-highlight"
});
}
this.$(".site-text-value").ellipsis();
},
click() {
this.send("edit");
},
_searchTerm() {
const regex = this.get("searchRegex");
const siteText = this.get("siteText");
if (regex && siteText) {
const matches = siteText.value.match(new RegExp(regex, "i"));
if (matches) return matches[0];
}
return this.get("term");
},
actions: {
edit() {
this.sendAction("editAction", this.get("siteText"));
}
}
});