mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-04 01:43:40 -04:00
Private clans UI
Add private checkbox for clan creation. Add info popover for private clans. Subscribe prompt for create/join if necessary. Don’t list private clans in public list.
This commit is contained in:
parent
5c40221ab2
commit
6d892359c7
6 changed files with 51 additions and 8 deletions
app
schemas/models
styles/clans
templates/clans
views/clans
|
@ -7,7 +7,7 @@ _.extend ClanSchema.properties,
|
||||||
description: {type: 'string'}
|
description: {type: 'string'}
|
||||||
members: c.array {title: 'Members'}, c.objectId()
|
members: c.array {title: 'Members'}, c.objectId()
|
||||||
ownerID: c.objectId()
|
ownerID: c.objectId()
|
||||||
type: {type: 'string', 'enum': ['public']}
|
type: {type: 'string', 'enum': ['public', 'private']}
|
||||||
|
|
||||||
c.extendBasicProperties ClanSchema, 'Clan'
|
c.extendBasicProperties ClanSchema, 'Clan'
|
||||||
|
|
||||||
|
|
|
@ -6,3 +6,6 @@
|
||||||
|
|
||||||
.create-clan-description
|
.create-clan-description
|
||||||
width: 50%
|
width: 50%
|
||||||
|
|
||||||
|
.popover
|
||||||
|
max-width: 100%
|
||||||
|
|
|
@ -3,7 +3,9 @@ extends /templates/base
|
||||||
block content
|
block content
|
||||||
|
|
||||||
if clan
|
if clan
|
||||||
h1= clan.get('name')
|
h1 #{clan.get('name')}
|
||||||
|
if clan.get('type') === 'private'
|
||||||
|
small (private)
|
||||||
if clan.get('description')
|
if clan.get('description')
|
||||||
.clan-description
|
.clan-description
|
||||||
each line in clan.get('description').split('\n')
|
each line in clan.get('description').split('\n')
|
||||||
|
|
|
@ -6,6 +6,12 @@ block content
|
||||||
input.create-clan-name(type='text' placeholder='New clan name')
|
input.create-clan-name(type='text' placeholder='New clan name')
|
||||||
p
|
p
|
||||||
textarea.create-clan-description(rows=2, placeholder='New clan description')
|
textarea.create-clan-description(rows=2, placeholder='New clan description')
|
||||||
|
p
|
||||||
|
input(type='checkbox').private-clan-checkbox
|
||||||
|
span.spl Private
|
||||||
|
span.spl (
|
||||||
|
a.private-more-info more info
|
||||||
|
span )
|
||||||
p
|
p
|
||||||
button.btn.btn-success.create-clan-btn Create New Clan
|
button.btn.btn-success.create-clan-btn Create New Clan
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
app = require 'core/application'
|
|
||||||
AuthModal = require 'views/core/AuthModal'
|
|
||||||
RootView = require 'views/core/RootView'
|
RootView = require 'views/core/RootView'
|
||||||
template = require 'templates/clans/clan-details'
|
template = require 'templates/clans/clan-details'
|
||||||
|
app = require 'core/application'
|
||||||
|
AuthModal = require 'views/core/AuthModal'
|
||||||
CocoCollection = require 'collections/CocoCollection'
|
CocoCollection = require 'collections/CocoCollection'
|
||||||
Clan = require 'models/Clan'
|
Clan = require 'models/Clan'
|
||||||
EarnedAchievement = require 'models/EarnedAchievement'
|
EarnedAchievement = require 'models/EarnedAchievement'
|
||||||
LevelSession = require 'models/LevelSession'
|
LevelSession = require 'models/LevelSession'
|
||||||
|
SubscribeModal = require 'views/core/SubscribeModal'
|
||||||
ThangType = require 'models/ThangType'
|
ThangType = require 'models/ThangType'
|
||||||
User = require 'models/User'
|
User = require 'models/User'
|
||||||
|
|
||||||
# TODO: Message for clan not found
|
# TODO: Add message for clan not found
|
||||||
# TODO: join/leave mostly duped from clans view
|
# TODO: join/leave mostly duped from clans view
|
||||||
|
|
||||||
module.exports = class ClanDetailsView extends RootView
|
module.exports = class ClanDetailsView extends RootView
|
||||||
|
@ -135,6 +136,8 @@ module.exports = class ClanDetailsView extends RootView
|
||||||
|
|
||||||
onJoinClan: (e) ->
|
onJoinClan: (e) ->
|
||||||
return @openModalView(new AuthModal()) if me.isAnonymous()
|
return @openModalView(new AuthModal()) if me.isAnonymous()
|
||||||
|
return unless @clan.loaded
|
||||||
|
return @openModalView new SubscribeModal() if @clan.get('type') is 'private' and not me.isPremium()
|
||||||
options =
|
options =
|
||||||
url: "/db/clan/#{@clanID}/join"
|
url: "/db/clan/#{@clanID}/join"
|
||||||
method: 'PUT'
|
method: 'PUT'
|
||||||
|
|
|
@ -4,6 +4,7 @@ RootView = require 'views/core/RootView'
|
||||||
template = require 'templates/clans/clans'
|
template = require 'templates/clans/clans'
|
||||||
CocoCollection = require 'collections/CocoCollection'
|
CocoCollection = require 'collections/CocoCollection'
|
||||||
Clan = require 'models/Clan'
|
Clan = require 'models/Clan'
|
||||||
|
SubscribeModal = require 'views/core/SubscribeModal'
|
||||||
|
|
||||||
# TODO: Waiting for async messages
|
# TODO: Waiting for async messages
|
||||||
# TODO: Invalid clan name message
|
# TODO: Invalid clan name message
|
||||||
|
@ -28,11 +29,15 @@ module.exports = class MainAdminView extends RootView
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
context = super()
|
context = super()
|
||||||
context.idNameMap = @idNameMap
|
context.idNameMap = @idNameMap
|
||||||
context.publicClans = @publicClans.models
|
context.publicClans = _.filter(@publicClans.models, (clan) -> clan.get('type') is 'public')
|
||||||
context.myClans = @myClans.models
|
context.myClans = @myClans.models
|
||||||
context.myClanIDs = me.get('clans') ? []
|
context.myClanIDs = me.get('clans') ? []
|
||||||
context
|
context
|
||||||
|
|
||||||
|
afterRender: ->
|
||||||
|
super()
|
||||||
|
@setupPrivateInfoPopover()
|
||||||
|
|
||||||
initData: ->
|
initData: ->
|
||||||
@idNameMap = {}
|
@idNameMap = {}
|
||||||
|
|
||||||
|
@ -54,20 +59,44 @@ module.exports = class MainAdminView extends RootView
|
||||||
@listenTo me, 'sync', => @render?()
|
@listenTo me, 'sync', => @render?()
|
||||||
|
|
||||||
refreshNames: (clans) ->
|
refreshNames: (clans) ->
|
||||||
|
clanIDs = _.filter(clans, (clan) -> clan.get('type') is 'public')
|
||||||
|
clanIDs = _.map(clans, (clan) -> clan.get('ownerID'))
|
||||||
options =
|
options =
|
||||||
url: '/db/user/-/names'
|
url: '/db/user/-/names'
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
data: {ids: _.map(clans, (clan) -> clan.get('ownerID'))}
|
data: {ids: clanIDs}
|
||||||
success: (models, response, options) =>
|
success: (models, response, options) =>
|
||||||
@idNameMap[userID] = models[userID].name for userID of models
|
@idNameMap[userID] = models[userID].name for userID of models
|
||||||
@render?()
|
@render?()
|
||||||
@supermodel.addRequestResource('user_names', options, 0).load()
|
@supermodel.addRequestResource('user_names', options, 0).load()
|
||||||
|
|
||||||
|
setupPrivateInfoPopover: ->
|
||||||
|
popoverTitle = 'Private Clans'
|
||||||
|
popoverContent = "<p>Additional features:"
|
||||||
|
popoverContent += "<ul>"
|
||||||
|
popoverContent += "<li>Detailed progress reporting"
|
||||||
|
popoverContent += "<li>Not visible in Public Clans list below"
|
||||||
|
popoverContent += "<li>Only students with the invite link will be able to join"
|
||||||
|
popoverContent += "</ul>"
|
||||||
|
popoverContent += "<p><img src='/images/loading_image.png'></p>"
|
||||||
|
popoverContent += "<p>*A CodeCombat subscription is required to create or join private Clans.</p>"
|
||||||
|
@$el.find('.private-more-info').popover(
|
||||||
|
animation: true
|
||||||
|
html: true
|
||||||
|
placement: 'right'
|
||||||
|
trigger: 'hover'
|
||||||
|
title: popoverTitle
|
||||||
|
content: popoverContent
|
||||||
|
container: @$el
|
||||||
|
)
|
||||||
|
|
||||||
onClickCreateClan: (e) ->
|
onClickCreateClan: (e) ->
|
||||||
return @openModalView(new AuthModal()) if me.isAnonymous()
|
return @openModalView(new AuthModal()) if me.isAnonymous()
|
||||||
|
clanType = if $('.private-clan-checkbox').prop('checked') then 'private' else 'public'
|
||||||
|
return @openModalView new SubscribeModal() if clanType is 'private' and not me.isPremium()
|
||||||
if name = $('.create-clan-name').val()
|
if name = $('.create-clan-name').val()
|
||||||
clan = new Clan()
|
clan = new Clan()
|
||||||
clan.set 'type', 'public'
|
clan.set 'type', clanType
|
||||||
clan.set 'name', name
|
clan.set 'name', name
|
||||||
clan.set 'description', description if description = $('.create-clan-description').val()
|
clan.set 'description', description if description = $('.create-clan-description').val()
|
||||||
clan.save {},
|
clan.save {},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue