mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Refactored getRenderData from SearchView to children
This commit is contained in:
parent
93f7d8c0a4
commit
5909f15678
4 changed files with 29 additions and 23 deletions
|
@ -6,3 +6,12 @@ module.exports = class ThangTypeHomeView extends SearchView
|
|||
model: require 'models/Article'
|
||||
modelURL: '/db/article'
|
||||
tableTemplate: require 'templates/editor/article/table'
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
context.currentEditor = 'editor.article_title'
|
||||
context.currentNew = 'editor.new_article_title'
|
||||
context.currentNewSignup = 'editor.new_article_title_login'
|
||||
context.currentSearch = 'editor.article_search_title'
|
||||
@$el.i18n()
|
||||
context
|
||||
|
|
|
@ -6,3 +6,12 @@ module.exports = class EditorSearchView extends SearchView
|
|||
model: require 'models/Level'
|
||||
modelURL: '/db/level'
|
||||
tableTemplate: require 'templates/editor/level/table'
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
context.currentEditor = 'editor.level_title'
|
||||
context.currentNew = 'editor.new_level_title'
|
||||
context.currentNewSignup = 'editor.new_level_title_login'
|
||||
context.currentSearch = 'editor.level_search_title'
|
||||
@$el.i18n()
|
||||
context
|
||||
|
|
|
@ -5,10 +5,19 @@ module.exports = class ThangTypeHomeView extends SearchView
|
|||
modelLabel: 'Thang Type'
|
||||
model: require 'models/ThangType'
|
||||
modelURL: '/db/thang.type'
|
||||
tableTemplate: require 'templates/editor/thang/table'
|
||||
tableTemplate: require 'templates/editor/thang/table'
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
context.currentEditor = 'editor.thang_title'
|
||||
context.currentNew = 'editor.new_thang_title'
|
||||
context.currentNewSignup = 'editor.new_thang_title_login'
|
||||
context.currentSearch = 'editor.thang_search_title'
|
||||
@$el.i18n()
|
||||
context
|
||||
|
||||
onSearchChange: =>
|
||||
super()
|
||||
@$el.find("img").error(-> $(this).hide())
|
||||
|
||||
# TODO: do the new thing on click, not just enter
|
||||
# TODO: do the new thing on click, not just enter
|
||||
|
|
|
@ -26,27 +26,6 @@ module.exports = class SearchView extends View
|
|||
'shown.bs.modal #new-model-modal': 'focusOnName'
|
||||
'hidden.bs.modal #new-model-modal': 'onModalHidden'
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
switch @modelLabel
|
||||
when 'Level'
|
||||
context.currentEditor = 'editor.level_title'
|
||||
context.currentNew = 'editor.new_level_title'
|
||||
context.currentNewSignup = 'editor.new_level_title_login'
|
||||
context.currentSearch = 'editor.level_search_title'
|
||||
when 'Thang Type'
|
||||
context.currentEditor = 'editor.thang_title'
|
||||
context.currentNew = 'editor.new_thang_title'
|
||||
context.currentNewSignup = 'editor.new_thang_title_login'
|
||||
context.currentSearch = 'editor.thang_search_title'
|
||||
when 'Article'
|
||||
context.currentEditor = 'editor.article_title'
|
||||
context.currentNew = 'editor.new_article_title'
|
||||
context.currentNewSignup = 'editor.new_article_title_login'
|
||||
context.currentSearch = 'editor.article_search_title'
|
||||
@$el.i18n()
|
||||
context
|
||||
|
||||
constructor: (options) ->
|
||||
@runSearch = _.debounce(@runSearch, 500)
|
||||
super options
|
||||
|
|
Loading…
Reference in a new issue