From 7cd84038bf17fb7185d8521187c70b77723f802a Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Wed, 28 Nov 2018 22:21:58 -0600 Subject: [PATCH] Update labels on style toggle --- manage/manage-actions.js | 1 + manage/manage-ui.js | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/manage/manage-actions.js b/manage/manage-actions.js index 0d9cfb17..2776a5cd 100644 --- a/manage/manage-actions.js +++ b/manage/manage-actions.js @@ -188,6 +188,7 @@ Object.assign(handleEvent, { toggle(event, entry) { API.toggleStyle(entry.styleId, this.matches('.enable') || this.checked); + UI.addLabels(entry); }, toggleBulkActions() { diff --git a/manage/manage-ui.js b/manage/manage-ui.js index b72eece5..d233b4b7 100644 --- a/manage/manage-ui.js +++ b/manage/manage-ui.js @@ -18,11 +18,11 @@ const UI = { labels: { 'usercss': { - is: style => typeof style.usercssData !== 'undefined', + is: ({style}) => typeof style.usercssData !== 'undefined', text: 'usercss' }, 'disabled': { - is: style => !style.enabled, + is: ({entry}) => !$('.entry-state-toggle', entry).checked, text: t('genericDisabledLabel') } }, @@ -164,7 +164,7 @@ const UI = { $('.entry-last-update', entry).title = lastUpdate; UI.createStyleTargetsElement({entry, style}); - UI.addLabels({entry, style}); + UI.addLabels(entry); return entry; }, @@ -264,16 +264,17 @@ const UI = { } }, - addLabels: ({entry, style}) => { + addLabels: entry => { + const style = entry.styleMeta; const container = $('.entry-labels', entry); const label = document.createElement('span'); const labels = document.createElement('span'); labels.className = 'entry-labels'; label.className = 'entry-label '; Object.keys(UI.labels).forEach(item => { - if (UI.labels[item].is(style)) { + if (UI.labels[item].is({entry, style})) { const newLabel = label.cloneNode(true); - newLabel.className += item; + newLabel.dataset.label = item; newLabel.textContent = UI.labels[item].text; labels.appendChild(newLabel); }