Update campaign editor analytics

Double-click level row in overview to open level details view.
This commit is contained in:
Matt Lott 2015-01-20 15:02:24 -08:00
parent ffb59d5cec
commit d51eddef29
4 changed files with 30 additions and 10 deletions

View file

@ -1,6 +1,9 @@
c = require 'schemas/schemas'
module.exports =
'editor:campaign-analytics-modal-closed': c.object {title: 'Campaign editor analytics modal closed'},
targetLevelSlug: {type: 'string'}
'editor:save-new-version': c.object {title: 'Save New Version', description: 'Published when a version gets saved', required: ['major', 'commitMessage']},
major: {type: 'boolean'}
commitMessage: {type: 'string'}

View file

@ -7,6 +7,7 @@ block modal-header-content
input.form-control#input-startday(type='text', style='width:100px;', value=campaignCompletions.startDay)
input.form-control#input-endday(type='text', style='width:100px;', value=campaignCompletions.endDay)
button.btn.btn-default.btn-sm#reload-button(style='margin-left:10px;') Reload
div(style='font-size:10px') Double-click row to open level details.
block modal-body-content
if campaignCompletions && campaignCompletions.levels
@ -23,7 +24,7 @@ block modal-body-content
td Completion %
tbody
- for (var i = 0; i < campaignCompletions.levels.length; i++)
tr
tr.level(data-level-slug=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

View file

@ -13,6 +13,7 @@ module.exports = class CampaignAnalyticsModal extends ModalView
events:
'click #reload-button': 'onClickReloadButton'
'dblclick .level': 'onDblClickLevel'
constructor: (options, @campaignHandle, @campaignCompletions) ->
super options
@ -29,6 +30,20 @@ module.exports = class CampaignAnalyticsModal extends ModalView
$("#input-endday").datepicker dateFormat: "yy-mm-dd"
@addCompletionLineGraphs()
onClickReloadButton: () =>
startDay = $('#input-startday').val()
endDay = $('#input-endday').val()
delete @campaignCompletions.levels
@campaignCompletions.startDay = startDay
@campaignCompletions.endDay = endDay
@render()
@getCampaignAnalytics startDay, endDay
onDblClickLevel: (e) ->
row = $(e.target).parents('.level')
Backbone.Mediator.publish 'editor:campaign-analytics-modal-closed', targetLevelSlug: row.data 'level-slug'
@hide()
addCompletionLineGraphs: ->
return unless @campaignCompletions.levels
for level in @campaignCompletions.levels
@ -81,15 +96,6 @@ module.exports = class CampaignAnalyticsModal extends ModalView
.attr('stroke-width', 1)
.attr('fill', 'none')
onClickReloadButton: () =>
startDay = $('#input-startday').val()
endDay = $('#input-endday').val()
delete @campaignCompletions.levels
@campaignCompletions.startDay = startDay
@campaignCompletions.endDay = endDay
@render()
@getCampaignAnalytics startDay, endDay
getCampaignAnalytics: (startDay, endDay) =>
if startDay?
startDayDashed = startDay

View file

@ -24,6 +24,9 @@ module.exports = class CampaignEditorView extends RootView
'click #analytics-button': 'onClickAnalyticsButton'
'click #save-button': 'onClickSaveButton'
subscriptions:
'editor:campaign-analytics-modal-closed' : 'onAnalyticsModalClosed'
constructor: (options, @campaignHandle) ->
super(options)
@campaign = new Campaign({_id:@campaignHandle})
@ -140,6 +143,13 @@ module.exports = class CampaignEditorView extends RootView
onClickAnalyticsButton: ->
@openModalView new CampaignAnalyticsModal {}, @campaignHandle, @campaignAnalytics
onAnalyticsModalClosed: (options) ->
if options.targetLevelSlug? and @treema.childrenTreemas?.levels?.childrenTreemas?
for original, level of @treema.childrenTreemas.levels.childrenTreemas
if level.data?.slug is options.targetLevelSlug
@openCampaignLevelView @supermodel.getModelByOriginal Level, original
break
onClickSaveButton: ->
@toSave.set @toSave.filter (m) -> m.hasLocalChanges()
@openModalView new SaveCampaignModal({}, @toSave)