mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -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'
|
model: require 'models/Article'
|
||||||
modelURL: '/db/article'
|
modelURL: '/db/article'
|
||||||
tableTemplate: require 'templates/editor/article/table'
|
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'
|
model: require 'models/Level'
|
||||||
modelURL: '/db/level'
|
modelURL: '/db/level'
|
||||||
tableTemplate: require 'templates/editor/level/table'
|
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
|
||||||
|
|
|
@ -7,6 +7,15 @@ module.exports = class ThangTypeHomeView extends SearchView
|
||||||
modelURL: '/db/thang.type'
|
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: =>
|
onSearchChange: =>
|
||||||
super()
|
super()
|
||||||
@$el.find("img").error(-> $(this).hide())
|
@$el.find("img").error(-> $(this).hide())
|
||||||
|
|
|
@ -26,27 +26,6 @@ module.exports = class SearchView extends View
|
||||||
'shown.bs.modal #new-model-modal': 'focusOnName'
|
'shown.bs.modal #new-model-modal': 'focusOnName'
|
||||||
'hidden.bs.modal #new-model-modal': 'onModalHidden'
|
'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) ->
|
constructor: (options) ->
|
||||||
@runSearch = _.debounce(@runSearch, 500)
|
@runSearch = _.debounce(@runSearch, 500)
|
||||||
super options
|
super options
|
||||||
|
|
Loading…
Reference in a new issue