From 7fcbe0f95e3a2729eb6c22b036070fb7b9262b8b Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 12 Jan 2016 17:34:57 +0000 Subject: [PATCH] Fix conflict filter not doing anything I'd forgotten to finish replacing usage of the data-conflicts body attribute with the loot.filters.conflictTargetPluginName variable, so the filter was actually given no plugin name. Fixes #529. --- src/gui/html/js/events.js | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/gui/html/js/events.js b/src/gui/html/js/events.js index b31512c2..c7486e03 100644 --- a/src/gui/html/js/events.js +++ b/src/gui/html/js/events.js @@ -45,7 +45,7 @@ function onChangeGame(evt) { filter. Don't need to deactivate the others beforehand. Strictly not deactivating the conflicts filter either, just resetting it's value. */ - document.body.removeAttribute('data-conflicts'); + loot.filters.conflictTargetPluginName = undefined; /* Clear the UI of all existing game-specific data. Also clear the card and li variables for each plugin object. */ @@ -105,18 +105,7 @@ function onUpdateMasterlist() { }).catch(handlePromiseError); } function onSortPlugins() { - if (document.body.hasAttribute('data-conflicts')) { - /* Deactivate any existing plugin conflict filter. */ - loot.game.plugins.forEach((plugin) => { - plugin.isConflictFilterChecked = false; - }); - /* Un-highlight any existing filter plugin. */ - const cards = document.getElementById('main').getElementsByTagName('loot-plugin-card'); - for (let i = 0; i < cards.length; ++i) { - cards[i].classList.toggle('highlight', false); - } - document.body.removeAttribute('data-conflicts'); - } + undoConflictsFilter(); let promise = Promise.resolve(); if (loot.settings.updateMasterlist) { @@ -544,24 +533,28 @@ function onEditorClose(evt) { document.getElementById('cardsNav').updateSize(); }).catch(handlePromiseError); } -function onConflictsFilter(evt) { +function undoConflictsFilter() { + loot.filters.conflictTargetPluginName = undefined; /* Deactivate any existing plugin conflict filter. */ loot.game.plugins.forEach((plugin) => { - if (plugin.id !== evt.target.id) { - plugin.isConflictFilterChecked = false; - } + plugin.isConflictFilterChecked = false; }); /* Un-highlight any existing filter plugin. */ const cards = document.getElementById('main').getElementsByTagName('loot-plugin-card'); for (let i = 0; i < cards.length; ++i) { cards[i].classList.toggle('highlight', false); } +} +function onConflictsFilter(evt) { + /* Deactivate any existing plugin conflict filter. */ + undoConflictsFilter(); /* evt.detail is true if the filter has been activated. */ if (evt.detail) { - document.body.setAttribute('data-conflicts', evt.target.getName()); + evt.target.data.isConflictFilterChecked = true; + loot.filters.conflictTargetPluginName = evt.target.getName(); evt.target.classList.toggle('highlight', true); } else { - document.body.removeAttribute('data-conflicts'); + loot.filters.conflictTargetPluginName = undefined; } filterPluginData(loot.game.plugins, loot.filters); }