mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Merge pull request #3185 from Imperadeiro98/the-branch
Refactor to use view in template
This commit is contained in:
commit
e375b8cdc8
16 changed files with 43 additions and 90 deletions
|
@ -1,7 +1,7 @@
|
|||
extends /templates/base
|
||||
|
||||
block content
|
||||
|
||||
|
||||
.form-horizontal
|
||||
.form-group
|
||||
label.control-label.col-sm-2(for="espionage-name-or-email" data-i18n="admin.av_espionage") Espionage
|
||||
|
@ -19,11 +19,11 @@ block content
|
|||
button.btn(data-i18n="admin.av_usersearch_search").btn-primary.btn-large#user-search-button Search
|
||||
#user-search-result
|
||||
|
||||
|
||||
|
||||
h3(data-i18n="admin.av_title") Admin Views
|
||||
|
||||
h4(data-i18n="admin.av_entities_sub_title") Entities
|
||||
|
||||
|
||||
ul
|
||||
li
|
||||
a(href="/admin/level-sessions", data-i18n="admin.av_entities_active_instances_url") Active Instances
|
||||
|
@ -59,8 +59,8 @@ block content
|
|||
h3 Prepaids
|
||||
a.btn.btn-secondary#create-free-sub-btn Create Free Subscription Link
|
||||
span.spl.spr
|
||||
if freeSubLink
|
||||
input#free-sub-input(type="text", readonly, value="#{freeSubLink}")
|
||||
if view.freeSubLink
|
||||
input#free-sub-input(type="text", readonly, value="#{view.freeSubLink}")
|
||||
|
||||
.form-inline
|
||||
.form-group
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
.modal-dialog
|
||||
.modal-content
|
||||
if state === 'purchasing'
|
||||
if view.state === 'purchasing'
|
||||
.alert.alert-info(data-i18n="buy_gems.purchasing")
|
||||
|
||||
else if state === 'retrying'
|
||||
|
||||
else if view.state === 'retrying'
|
||||
#retrying-alert.alert.alert-danger(data-i18n="buy_gems.retrying")
|
||||
|
||||
else
|
||||
|
@ -24,7 +24,7 @@
|
|||
th.free-cell(data-i18n="subscribe.free")
|
||||
th
|
||||
//- TODO: find a better way to localize '$9.99/month'
|
||||
span $#{price}/
|
||||
span $#{(view.product.amount / 100)}/
|
||||
span(data-i18n="subscribe.month")
|
||||
tbody
|
||||
tr
|
||||
|
@ -81,21 +81,21 @@
|
|||
#payment-methods-info(data-i18n="subscribe.payment_methods")
|
||||
|
||||
button.btn.btn-lg.btn-illustrated.parent-button(data-i18n="subscribe.parent_button")
|
||||
button.btn.btn-lg.btn-illustrated.sale-button(title="#{saleButtonTitle}", data-i18n="subscribe.sale_button")
|
||||
button.btn.btn-lg.btn-illustrated.sale-button(data-i18n="[title]subscribe.sale_button_title", data-i18n="subscribe.sale_button")
|
||||
button.btn.btn-lg.btn-illustrated.purchase-button(data-i18n="subscribe.subscribe_title")
|
||||
|
||||
if state === 'declined'
|
||||
if view.state === 'declined'
|
||||
#declined-alert.alert.alert-danger.alert-dismissible
|
||||
span(data-i18n="buy_gems.declined")
|
||||
button.close(type="button" data-dismiss="alert")
|
||||
span(aria-hidden="true") ×
|
||||
|
||||
if state === 'unknown_error'
|
||||
span(aria-hidden="true") ×
|
||||
|
||||
if view.state === 'unknown_error'
|
||||
#error-alert.alert.alert-danger.alert-dismissible
|
||||
button.close(type="button" data-dismiss="alert")
|
||||
span(aria-hidden="true") ×
|
||||
p(data-i18n="loading_error.unknown")
|
||||
p= stateMessage
|
||||
p= view.stateMessage
|
||||
|
||||
.parent-button-popover-content.hidden
|
||||
.email-parent-form
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
extends /templates/base
|
||||
|
||||
block content
|
||||
if !unauthorized
|
||||
- var authorized = me.isAdmin() || me.isArtisan();
|
||||
if authorized
|
||||
ol.breadcrumb
|
||||
li
|
||||
a(href="/editor", data-i18n="editor.main_title") CodeCombat Editors
|
||||
li
|
||||
a(href="/editor/achievement", data-i18n="editor.achievement_title") Achievement Editor
|
||||
li.active
|
||||
| #{achievement.attributes.name}
|
||||
| #{view.achievement.attributes.name}
|
||||
|
||||
button.achievement-tool-button(data-i18n="", disabled=me.isAdmin() === true ? undefined : "true").btn.btn-primary#recalculate-all-button Recalculate All
|
||||
button.achievement-tool-button(data-i18n="", disabled=me.isAdmin() === true ? undefined : "true").btn.btn-primary#recalculate-button Recalculate
|
||||
|
@ -17,7 +18,7 @@ block content
|
|||
|
||||
h3(data-i18n="achievement.edit_achievement_title") Edit Achievement
|
||||
span
|
||||
|: "#{achievement.attributes.name}"
|
||||
|: "#{view.achievement.attributes.name}"
|
||||
|
||||
#achievement-treema
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ div.well
|
|||
a(data-i18n="editor.level_components_title")#all-thangs-link Back To All Thangs
|
||||
span#thang-props
|
||||
a#thang-name-link
|
||||
span= thang.id
|
||||
input.secret(value=thang.id)
|
||||
span= view.thangData.id
|
||||
input.secret(value=view.thangData.id)
|
||||
| (
|
||||
span(data-i18n="editor.level_components_type") Type
|
||||
| :
|
||||
a#thang-type-link
|
||||
span= thang.thangType
|
||||
input.secret(value=thang.thangType)
|
||||
span= view.thangData.thangType
|
||||
input.secret(value=view.thangData.thangType)
|
||||
| )
|
||||
|
||||
#thang-components-edit-view
|
|
@ -1,21 +1,22 @@
|
|||
extends /templates/base
|
||||
|
||||
block content
|
||||
if !unauthorized
|
||||
- var authorized = me.isAdmin();
|
||||
if authorized
|
||||
ol.breadcrumb
|
||||
li
|
||||
a(href="/editor", data-i18n="editor.main_title") CodeCombat Editors
|
||||
li
|
||||
a(href="/editor/poll", data-i18n="editor.poll_title") Poll Editor
|
||||
li.active
|
||||
| #{poll.attributes.name}
|
||||
| #{view.poll.attributes.name}
|
||||
|
||||
button.poll-tool-button(data-i18n="common.delete", disabled=!me.isAdmin()).btn.btn-primary#delete-button Delete
|
||||
button.poll-tool-button(data-i18n="common.save", disabled=!me.isAdmin()).btn.btn-primary#save-button Save
|
||||
|
||||
h3(data-i18n="poll.edit_poll_title") Edit Poll
|
||||
span
|
||||
|: "#{poll.attributes.name}"
|
||||
|: "#{view.poll.attributes.name}"
|
||||
|
||||
#poll-treema
|
||||
|
||||
|
|
|
@ -4,15 +4,15 @@ block modal-header-content
|
|||
h3 Choose Container for Vector Icon
|
||||
|
||||
block modal-body-content
|
||||
if chosenContainer
|
||||
if view.container
|
||||
form.form
|
||||
.form-group
|
||||
select#container-select.form-control
|
||||
for container in containers
|
||||
option(value=container, selected=container === chosenContainer)= container
|
||||
|
||||
canvas(width=demoSize height=demoSize)#resulting-icon
|
||||
|
||||
for container in view.containers
|
||||
option(value=container, selected=container === view.container)= container
|
||||
|
||||
canvas(width=view.demoSize height=view.demoSize)#resulting-icon
|
||||
|
||||
.alert.alert-info Arrow keys to move, Shift-Plus/Minus to scale.
|
||||
else
|
||||
div forgetting something?
|
||||
|
|
|
@ -3,7 +3,7 @@ extends /templates/core/modal-base
|
|||
block modal-header
|
||||
|
||||
block modal-body-content
|
||||
for model in models
|
||||
for model in view.models
|
||||
.model-container(data-model-id=model.id)
|
||||
h3= model.type() + ': ' + model.id
|
||||
.model-treema(data-model-id=model.id)
|
||||
|
|
|
@ -4,13 +4,13 @@ block modal-header-content
|
|||
h3(data-i18n="play.achievements") Achievements
|
||||
|
||||
block modal-body-content
|
||||
for achievement in achievements
|
||||
for achievement in view.achievements.models
|
||||
.panel(class=achievement.earned ? 'earned' : '')
|
||||
.panel-body
|
||||
img.icon(src=achievement.getImageURL(), draggable="false")
|
||||
h3= achievement.name + (achievement.earned && achievement.earned.get('achievedAmount') ? (' - ' + achievement.earned.get('achievedAmount') + 'x') : '')
|
||||
p= achievement.description
|
||||
|
||||
|
||||
if achievement.earnedDate
|
||||
.created=moment(achievement.earnedDate).fromNow()
|
||||
else
|
||||
|
@ -22,7 +22,7 @@ block modal-body-content
|
|||
span.gems.label.label-default
|
||||
span= achievement.earnedGems || rewards.gems
|
||||
img.gem(src="/images/common/gem.png", draggable="false")
|
||||
|
||||
|
||||
- worth = achievement.get('worth');
|
||||
if worth
|
||||
span.worth.label.label-default
|
||||
|
|
|
@ -17,11 +17,6 @@ module.exports = class MainAdminView extends RootView
|
|||
'click #create-free-sub-btn': 'onClickFreeSubLink'
|
||||
'click #terminal-create': 'onClickTerminalSubLink'
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
context.freeSubLink = @freeSubLink
|
||||
context
|
||||
|
||||
checkForFormSubmissionEnterPress: (e) ->
|
||||
if e.which is 13 and @$el.find('#espionage-name-or-email').val() isnt ''
|
||||
@enterEspionageMode()
|
||||
|
|
|
@ -27,16 +27,6 @@ module.exports = class SubscribeModal extends ModalView
|
|||
constructor: (options) ->
|
||||
super(options)
|
||||
@state = 'standby'
|
||||
@saleButtonTitle = $.i18n.t('subscribe.sale_button_title')
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.saleButtonTitle = @saleButtonTitle
|
||||
c.state = @state
|
||||
c.stateMessage = @stateMessage
|
||||
c.price = @product.amount / 100
|
||||
#c.price = 3.99 # Sale
|
||||
return c
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
|
|
|
@ -51,12 +51,6 @@ module.exports = class AchievementEditView extends RootView
|
|||
@treema.childrenTreemas.rewards?.open(3)
|
||||
@pushChangesToPreview()
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.achievement = @achievement
|
||||
context.authorized = me.isAdmin() or me.isArtisan()
|
||||
context
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
|
|
|
@ -31,11 +31,6 @@ module.exports = class LevelThangEditView extends CocoView
|
|||
@oldPath = options.oldPath
|
||||
@reportChanges = _.debounce @reportChanges, 1000
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.thang = @thangData
|
||||
context
|
||||
|
||||
onLoaded: -> @render()
|
||||
afterRender: ->
|
||||
super()
|
||||
|
|
|
@ -59,12 +59,6 @@ module.exports = class PollEditView extends RootView
|
|||
@treema.childrenTreemas.answers?.open 1
|
||||
@pushChangesToPreview()
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.poll = @poll
|
||||
context.authorized = me.isAdmin()
|
||||
context
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = class VectorIconSetupModal extends ModalView
|
|||
'click #center': 'onClickCenter'
|
||||
'click #zero-bounds': 'onClickZeroBounds'
|
||||
'click #done-button': 'onClickDone'
|
||||
|
||||
|
||||
shortcuts:
|
||||
'shift+-': -> @incrScale(-0.02)
|
||||
'shift+=': -> @incrScale(0.02)
|
||||
|
@ -40,18 +40,11 @@ module.exports = class VectorIconSetupModal extends ModalView
|
|||
actions.portrait.container = @container
|
||||
@thangType.set('actions', actions)
|
||||
@thangType.buildActions()
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.containers = @containers
|
||||
c.chosenContainer = @container
|
||||
c.demoSize = @demoSize
|
||||
c
|
||||
|
||||
|
||||
afterRender: ->
|
||||
@initStage()
|
||||
super()
|
||||
|
||||
|
||||
initStage: ->
|
||||
return unless @containers and @container
|
||||
@stage = @thangType.getVectorPortraitStage(@demoSize)
|
||||
|
@ -65,7 +58,7 @@ module.exports = class VectorIconSetupModal extends ModalView
|
|||
@container = $(e.target).val()
|
||||
@saveChanges()
|
||||
@initStage()
|
||||
|
||||
|
||||
refreshSprite: ->
|
||||
return unless @stage
|
||||
stage = @thangType.getVectorPortraitStage(@demoSize)
|
||||
|
@ -100,7 +93,7 @@ module.exports = class VectorIconSetupModal extends ModalView
|
|||
@scale += amount
|
||||
@updateSpriteProperties()
|
||||
@stage.update()
|
||||
|
||||
|
||||
incrRegX: (amount) ->
|
||||
@regX += amount
|
||||
@updateSpriteProperties()
|
||||
|
@ -110,7 +103,7 @@ module.exports = class VectorIconSetupModal extends ModalView
|
|||
@regY += amount
|
||||
@updateSpriteProperties()
|
||||
@stage.update()
|
||||
|
||||
|
||||
onClickDone: ->
|
||||
@saveChanges()
|
||||
@trigger 'done'
|
||||
|
|
|
@ -16,11 +16,6 @@ module.exports = class ModelModal extends ModalView
|
|||
@supermodel.loadModel model, 'source_document'
|
||||
model.fetch cache: false
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.models = @models
|
||||
c
|
||||
|
||||
afterRender: ->
|
||||
return unless @supermodel.finished()
|
||||
@modelTreemas = {}
|
||||
|
|
|
@ -105,11 +105,6 @@ module.exports = class PlayAchievementsModal extends ModalView
|
|||
achievement.description = utils.i18n achievement.attributes, 'description'
|
||||
@render()
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.achievements = @achievements.models
|
||||
context
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
|
|
Loading…
Reference in a new issue