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' c = require 'schemas/schemas'
module.exports = 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']}, 'editor:save-new-version': c.object {title: 'Save New Version', description: 'Published when a version gets saved', required: ['major', 'commitMessage']},
major: {type: 'boolean'} major: {type: 'boolean'}
commitMessage: {type: 'string'} 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-startday(type='text', style='width:100px;', value=campaignCompletions.startDay)
input.form-control#input-endday(type='text', style='width:100px;', value=campaignCompletions.endDay) 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 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 block modal-body-content
if campaignCompletions && campaignCompletions.levels if campaignCompletions && campaignCompletions.levels
@ -23,7 +24,7 @@ block modal-body-content
td Completion % td Completion %
tbody tbody
- for (var i = 0; i < campaignCompletions.levels.length; i++) - 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 td.level-name-container= campaignCompletions.levels[i].level
span.level-name-background(style="width:#{campaignCompletions.levels[i].usersRemaining || 0}%;") span.level-name-background(style="width:#{campaignCompletions.levels[i].usersRemaining || 0}%;")
td= campaignCompletions.levels[i].started td= campaignCompletions.levels[i].started

View file

@ -13,6 +13,7 @@ module.exports = class CampaignAnalyticsModal extends ModalView
events: events:
'click #reload-button': 'onClickReloadButton' 'click #reload-button': 'onClickReloadButton'
'dblclick .level': 'onDblClickLevel'
constructor: (options, @campaignHandle, @campaignCompletions) -> constructor: (options, @campaignHandle, @campaignCompletions) ->
super options super options
@ -29,6 +30,20 @@ module.exports = class CampaignAnalyticsModal extends ModalView
$("#input-endday").datepicker dateFormat: "yy-mm-dd" $("#input-endday").datepicker dateFormat: "yy-mm-dd"
@addCompletionLineGraphs() @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: -> addCompletionLineGraphs: ->
return unless @campaignCompletions.levels return unless @campaignCompletions.levels
for level in @campaignCompletions.levels for level in @campaignCompletions.levels
@ -81,15 +96,6 @@ module.exports = class CampaignAnalyticsModal extends ModalView
.attr('stroke-width', 1) .attr('stroke-width', 1)
.attr('fill', 'none') .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) => getCampaignAnalytics: (startDay, endDay) =>
if startDay? if startDay?
startDayDashed = startDay startDayDashed = startDay

View file

@ -24,6 +24,9 @@ module.exports = class CampaignEditorView extends RootView
'click #analytics-button': 'onClickAnalyticsButton' 'click #analytics-button': 'onClickAnalyticsButton'
'click #save-button': 'onClickSaveButton' 'click #save-button': 'onClickSaveButton'
subscriptions:
'editor:campaign-analytics-modal-closed' : 'onAnalyticsModalClosed'
constructor: (options, @campaignHandle) -> constructor: (options, @campaignHandle) ->
super(options) super(options)
@campaign = new Campaign({_id:@campaignHandle}) @campaign = new Campaign({_id:@campaignHandle})
@ -140,6 +143,13 @@ module.exports = class CampaignEditorView extends RootView
onClickAnalyticsButton: -> onClickAnalyticsButton: ->
@openModalView new CampaignAnalyticsModal {}, @campaignHandle, @campaignAnalytics @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: -> onClickSaveButton: ->
@toSave.set @toSave.filter (m) -> m.hasLocalChanges() @toSave.set @toSave.filter (m) -> m.hasLocalChanges()
@openModalView new SaveCampaignModal({}, @toSave) @openModalView new SaveCampaignModal({}, @toSave)