mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
parent
0e2b919ec1
commit
2ded5ff4f0
2 changed files with 23 additions and 22 deletions
|
@ -32,8 +32,8 @@ block content
|
||||||
th(data-i18n="clans.chieftain") Chieftain
|
th(data-i18n="clans.chieftain") Chieftain
|
||||||
th
|
th
|
||||||
tbody
|
tbody
|
||||||
if publicClans.length
|
if view.publicClansArray.length
|
||||||
each clan in publicClans
|
each clan in view.publicClansArray
|
||||||
tr
|
tr
|
||||||
td
|
td
|
||||||
if clan.get('ownerID') === me.id
|
if clan.get('ownerID') === me.id
|
||||||
|
@ -42,12 +42,12 @@ block content
|
||||||
a(href="/clans/#{clan.id}")= clan.get('name')
|
a(href="/clans/#{clan.id}")= clan.get('name')
|
||||||
td= clan.get('memberCount')
|
td= clan.get('memberCount')
|
||||||
td
|
td
|
||||||
if idNameMap && idNameMap[clan.get('ownerID')]
|
if view.idNameMap && view.idNameMap[clan.get('ownerID')]
|
||||||
a(href="/user/#{clan.get('ownerID')}")= idNameMap[clan.get('ownerID')]
|
a(href="/user/#{clan.get('ownerID')}")= view.idNameMap[clan.get('ownerID')]
|
||||||
else
|
else
|
||||||
a(href="/user/#{clan.get('ownerID')}") Anoner
|
a(href="/user/#{clan.get('ownerID')}") Anoner
|
||||||
td
|
td
|
||||||
if myClanIDs.indexOf(clan.id) < 0
|
if view.myClanIDs.indexOf(clan.id) < 0
|
||||||
button.btn.btn-success.join-clan-btn(data-id="#{clan.id}", data-i18n="clans.join_clan") Join Clan
|
button.btn.btn-success.join-clan-btn(data-id="#{clan.id}", data-i18n="clans.join_clan") Join Clan
|
||||||
else if clan.get('ownerID') !== me.id
|
else if clan.get('ownerID') !== me.id
|
||||||
button.btn.btn-xs.btn-warning.leave-clan-btn(data-id="#{clan.id}", data-i18n="clans.leave_clan") Leave Clan
|
button.btn.btn-xs.btn-warning.leave-clan-btn(data-id="#{clan.id}", data-i18n="clans.leave_clan") Leave Clan
|
||||||
|
@ -62,8 +62,8 @@ block content
|
||||||
th(data-i18n="clans.type") Type
|
th(data-i18n="clans.type") Type
|
||||||
th
|
th
|
||||||
tbody
|
tbody
|
||||||
if myClans.length
|
if view.myClansArray.length
|
||||||
each clan in myClans
|
each clan in view.myClansArray
|
||||||
tr
|
tr
|
||||||
td
|
td
|
||||||
if clan.get('ownerID') === me.id
|
if clan.get('ownerID') === me.id
|
||||||
|
@ -72,8 +72,8 @@ block content
|
||||||
a(href="/clans/#{clan.id}")= clan.get('name')
|
a(href="/clans/#{clan.id}")= clan.get('name')
|
||||||
td= clan.get('memberCount')
|
td= clan.get('memberCount')
|
||||||
td
|
td
|
||||||
if idNameMap && idNameMap[clan.get('ownerID')]
|
if view.idNameMap && view.idNameMap[clan.get('ownerID')]
|
||||||
a(href="/user/#{clan.get('ownerID')}")= idNameMap[clan.get('ownerID')]
|
a(href="/user/#{clan.get('ownerID')}")= view.idNameMap[clan.get('ownerID')]
|
||||||
else
|
else
|
||||||
a(href="/user/#{clan.get('ownerID')}") Anoner
|
a(href="/user/#{clan.get('ownerID')}") Anoner
|
||||||
td= clan.get('type')
|
td= clan.get('type')
|
||||||
|
|
|
@ -13,6 +13,7 @@ SubscribeModal = require 'views/core/SubscribeModal'
|
||||||
module.exports = class ClansView extends RootView
|
module.exports = class ClansView extends RootView
|
||||||
id: 'clans-view'
|
id: 'clans-view'
|
||||||
template: template
|
template: template
|
||||||
|
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'click .create-clan-btn': 'onClickCreateClan'
|
'click .create-clan-btn': 'onClickCreateClan'
|
||||||
|
@ -20,28 +21,25 @@ module.exports = class ClansView extends RootView
|
||||||
'click .leave-clan-btn': 'onLeaveClan'
|
'click .leave-clan-btn': 'onLeaveClan'
|
||||||
'click .private-clan-checkbox': 'onClickPrivateCheckbox'
|
'click .private-clan-checkbox': 'onClickPrivateCheckbox'
|
||||||
|
|
||||||
constructor: (options) ->
|
initialize: ->
|
||||||
super options
|
@publicClansArray = []
|
||||||
@initData()
|
@myClansArray = []
|
||||||
|
@idNameMap = {}
|
||||||
|
@loadData()
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
@stopListening?()
|
@stopListening?()
|
||||||
|
|
||||||
getRenderData: ->
|
|
||||||
context = super()
|
|
||||||
context.idNameMap = @idNameMap
|
|
||||||
context.publicClans = _.filter(@publicClans.models, (clan) -> clan.get('type') is 'public')
|
|
||||||
context.myClans = @myClans.models
|
|
||||||
context.myClanIDs = me.get('clans') ? []
|
|
||||||
context
|
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
super()
|
super()
|
||||||
@setupPrivateInfoPopover()
|
@setupPrivateInfoPopover()
|
||||||
|
|
||||||
initData: ->
|
onLoaded: ->
|
||||||
@idNameMap = {}
|
super()
|
||||||
|
@publicClansArray = _.filter(@publicClans.models, (clan) -> clan.get('type') is 'public')
|
||||||
|
@myClansArray = @myClans.models
|
||||||
|
|
||||||
|
loadData: ->
|
||||||
sortClanList = (a, b) ->
|
sortClanList = (a, b) ->
|
||||||
if a.get('memberCount') isnt b.get('memberCount')
|
if a.get('memberCount') isnt b.get('memberCount')
|
||||||
if a.get('memberCount') < b.get('memberCount') then 1 else -1
|
if a.get('memberCount') < b.get('memberCount') then 1 else -1
|
||||||
|
@ -52,12 +50,15 @@ module.exports = class ClansView extends RootView
|
||||||
@refreshNames @publicClans.models
|
@refreshNames @publicClans.models
|
||||||
@render?()
|
@render?()
|
||||||
@supermodel.loadCollection(@publicClans, 'public_clans', {cache: false})
|
@supermodel.loadCollection(@publicClans, 'public_clans', {cache: false})
|
||||||
|
|
||||||
@myClans = new CocoCollection([], { url: "/db/user/#{me.id}/clans", model: Clan, comparator: sortClanList })
|
@myClans = new CocoCollection([], { url: "/db/user/#{me.id}/clans", model: Clan, comparator: sortClanList })
|
||||||
@listenTo @myClans, 'sync', =>
|
@listenTo @myClans, 'sync', =>
|
||||||
@refreshNames @myClans.models
|
@refreshNames @myClans.models
|
||||||
@render?()
|
@render?()
|
||||||
@supermodel.loadCollection(@myClans, 'my_clans', {cache: false})
|
@supermodel.loadCollection(@myClans, 'my_clans', {cache: false})
|
||||||
|
|
||||||
@listenTo me, 'sync', => @render?()
|
@listenTo me, 'sync', => @render?()
|
||||||
|
@myClanIDs = me.get('clans') ? []
|
||||||
|
|
||||||
refreshNames: (clans) ->
|
refreshNames: (clans) ->
|
||||||
clanIDs = _.filter(clans, (clan) -> clan.get('type') is 'public')
|
clanIDs = _.filter(clans, (clan) -> clan.get('type') is 'public')
|
||||||
|
|
Loading…
Reference in a new issue