Made new related achievements open in a new tab in the level editor.

This commit is contained in:
Nick Winter 2014-09-02 15:00:14 -07:00
parent 523cbfd38e
commit d8ef2f8596
3 changed files with 16 additions and 1 deletions

View file

@ -21,3 +21,8 @@ block modal-body-content
label
input(type="checkbox", name="queryOptions" id="#{goal.id}" value="#{goal.id}")
span.spl= goal.name
block modal-footer
.modal-footer
button.btn(data-dismiss="modal", data-i18n="common.cancel") Cancel
button#save-new-achievement-link.btn.btn-primary.new-model-submit(data-i18n="common.create") Create

View file

@ -35,7 +35,9 @@ module.exports = class RelatedAchievementsView extends CocoView
c
onNewAchievementSaved: (achievement) ->
app.router.navigate('/editor/achievement/' + (achievement.get('slug') or achievement.id), {trigger: true})
# We actually open the new tab in NewAchievementModal, so we don't replace this window.
#url = '/editor/achievement/' + (achievement.get('slug') or achievement.id)
#app.router.navigate(, {trigger: true}) # Let's open a new tab instead.
makeNewAchievement: ->
modal = new NewAchievementModal model: Achievement, modelLabel: 'Achievement', level: @level

View file

@ -8,6 +8,9 @@ module.exports = class NewAchievementModal extends NewModelModal
template: template
plain: false
events:
'click #save-new-achievement-link': 'onAchievementSubmitted'
constructor: (options) ->
super options
@level = options.level
@ -18,6 +21,11 @@ module.exports = class NewAchievementModal extends NewModelModal
console.debug 'level', c.level
c
onAchievementSubmitted: (e) ->
slug = _.string.slugify @$el.find('#name').val()
url = "/editor/achievement/#{slug}"
window.open url, '_blank'
createQuery: ->
checked = @$el.find('[name=queryOptions]:checked')
checkedValues = ($(check).val() for check in checked)