From 499e7c2999c6970043ba1ed0041b85445ea7646f Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Mon, 19 Jan 2015 15:21:42 -0800 Subject: [PATCH] Update campaign editor analytics Color in level name based on number of users remaining. --- app/styles/editor/campaign/campaign-analytics-modal.sass | 9 +++++++++ .../editor/campaign/campaign-analytics-modal.jade | 3 ++- app/views/editor/campaign/CampaignAnalyticsModal.coffee | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/styles/editor/campaign/campaign-analytics-modal.sass b/app/styles/editor/campaign/campaign-analytics-modal.sass index 75e0ee6d9..c0c2accdc 100644 --- a/app/styles/editor/campaign/campaign-analytics-modal.sass +++ b/app/styles/editor/campaign/campaign-analytics-modal.sass @@ -1,3 +1,12 @@ #campaign-analytics-modal .modal-dialog width: 75% + .level-name-container + position: relative + .level-name-background + position: absolute + height: 100% + left: 0px + top: 0px + background-color: green + opacity: 0.25 diff --git a/app/templates/editor/campaign/campaign-analytics-modal.jade b/app/templates/editor/campaign/campaign-analytics-modal.jade index 30b21089c..133518234 100644 --- a/app/templates/editor/campaign/campaign-analytics-modal.jade +++ b/app/templates/editor/campaign/campaign-analytics-modal.jade @@ -24,7 +24,8 @@ block modal-body-content tbody - for (var i = 0; i < campaignCompletions.levels.length; i++) tr - td= campaignCompletions.levels[i].level + td.level-name-container= campaignCompletions.levels[i].level + span.level-name-background(style="width:#{campaignCompletions.levels[i].usersRemaining || 0}%;") td= campaignCompletions.levels[i].started td= campaignCompletions.levels[i].finished td= campaignCompletions.levels[i].dropped diff --git a/app/views/editor/campaign/CampaignAnalyticsModal.coffee b/app/views/editor/campaign/CampaignAnalyticsModal.coffee index f8837b616..94d5393df 100644 --- a/app/views/editor/campaign/CampaignAnalyticsModal.coffee +++ b/app/views/editor/campaign/CampaignAnalyticsModal.coffee @@ -101,8 +101,10 @@ module.exports = class CampaignAnalyticsModal extends ModalView success = (data) => return if @destroyed # console.log 'getCampaignLevelCompletions success', data + maxStarted = if data.length > 0 then (_.max data, ((a) -> a.started)).started else 0 mapFn = (item) -> item.completionRate = if item.started > 0 then (item.finished / item.started * 100).toFixed(2) else 0.0 + item.usersRemaining = Math.round(item.started / maxStarted * 100.0) unless maxStarted is 0 item @campaignCompletions.levels = _.map data, mapFn, @