diff --git a/app/schemas/subscriptions/editor.coffee b/app/schemas/subscriptions/editor.coffee index 2665438be..a0a416f25 100644 --- a/app/schemas/subscriptions/editor.coffee +++ b/app/schemas/subscriptions/editor.coffee @@ -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'} diff --git a/app/templates/editor/campaign/campaign-analytics-modal.jade b/app/templates/editor/campaign/campaign-analytics-modal.jade index db429e173..01b5e01b5 100644 --- a/app/templates/editor/campaign/campaign-analytics-modal.jade +++ b/app/templates/editor/campaign/campaign-analytics-modal.jade @@ -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 diff --git a/app/views/editor/campaign/CampaignAnalyticsModal.coffee b/app/views/editor/campaign/CampaignAnalyticsModal.coffee index e2c33c038..7af2e3a70 100644 --- a/app/views/editor/campaign/CampaignAnalyticsModal.coffee +++ b/app/views/editor/campaign/CampaignAnalyticsModal.coffee @@ -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 diff --git a/app/views/editor/campaign/CampaignEditorView.coffee b/app/views/editor/campaign/CampaignEditorView.coffee index db3cb140e..a32e9d818 100644 --- a/app/views/editor/campaign/CampaignEditorView.coffee +++ b/app/views/editor/campaign/CampaignEditorView.coffee @@ -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)