diff --git a/src/gui/html/elements/loot-plugin-card.html b/src/gui/html/elements/loot-plugin-card.html
index 74e7e39f..5c8c58ee 100644
--- a/src/gui/html/elements/loot-plugin-card.html
+++ b/src/gui/html/elements/loot-plugin-card.html
@@ -330,6 +330,9 @@ loot-clear-metadata
this._setTagsContent(cardContent.tags);
this._setMessagesContent(cardContent.messages);
+ this.hasUserEdits = this.data.hasUserEdits;
+ this.isSearchResult = this.data.isSearchResult;
+
/* Update the conflict filter toggle state. */
this.$.showOnlyConflicts.checked = this.data.isConflictFilterChecked;
diff --git a/src/gui/html/js/plugin.js b/src/gui/html/js/plugin.js
index ed72bcd8..77c52c93 100644
--- a/src/gui/html/js/plugin.js
+++ b/src/gui/html/js/plugin.js
@@ -189,7 +189,7 @@
this.isMenuOpen = false;
this._isEditorOpen = false;
this.isConflictFilterChecked = false;
- this.isSearchResult = false;
+ this._isSearchResult = false;
}
static fromJson(key, value) {
@@ -354,6 +354,7 @@
this._userlist = userlist;
this._dispatchItemContentChangeEvent();
+ this._dispatchCardContentChangeEvent();
}
}
@@ -393,6 +394,18 @@
}
}
+ get isSearchResult() {
+ return this._isSearchResult;
+ }
+
+ set isSearchResult(isSearchResult) {
+ if (this._isSearchResult !== isSearchResult) {
+ this._isSearchResult = isSearchResult;
+
+ this._dispatchCardContentChangeEvent();
+ }
+ }
+
getCardContent(filters) {
return new PluginCardContent(this, filters);
}
diff --git a/src/tests/gui/html/js/test_plugin.js b/src/tests/gui/html/js/test_plugin.js
index ddbbcdce..a80fa77a 100644
--- a/src/tests/gui/html/js/test_plugin.js
+++ b/src/tests/gui/html/js/test_plugin.js
@@ -885,6 +885,55 @@ describe('Plugin', () => {
});
});
+ describe('#isSearchResult', () => {
+ let handleEvent;
+
+ afterEach(() => {
+ document.removeEventListener('loot-plugin-card-content-change', handleEvent);
+ });
+
+ it('getting value should return false if it has not been set in the constructor', () => {
+ const plugin = new loot.Plugin({ name: 'test' });
+
+ plugin.isSearchResult.should.be.false();
+ });
+
+ it('setting value should store set value', () => {
+ const plugin = new loot.Plugin({ name: 'test' });
+
+ plugin.isSearchResult = true;
+
+ plugin.isSearchResult.should.be.true();
+ });
+
+ it('setting value to the current value should not fire an event', (done) => {
+ const plugin = new loot.Plugin({ name: 'test' });
+
+ handleEvent = () => {
+ done(new Error('Should not have fired an event'));
+ };
+
+ document.addEventListener('loot-plugin-card-content-change', handleEvent);
+
+ plugin.isSearchResult = plugin.isSearchResult;
+
+ setTimeout(done, 100);
+ });
+
+ it('setting value not equal to the current value should fire an event', (done) => {
+ const plugin = new loot.Plugin({ name: 'test' });
+
+ handleEvent = (evt) => {
+ evt.detail.pluginId.should.equal(plugin.id);
+ done();
+ };
+
+ document.addEventListener('loot-plugin-card-content-change', handleEvent);
+
+ plugin.isSearchResult = true;
+ });
+ });
+
describe('#getCardContent()', () => {
let plugin;
beforeEach(() => {