mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-12 16:51:35 -05:00
d4c5d418ff
* Do not cache campaign * Instead have an on leave message if there are unsaved changes * Propagate campaignIndex values to campaign and levels so that they signal a change in order The save modal seems to have a lot of issues with identifying what models have changed. I tried using different methods, but none were consistent. Moving on to other bugs.
25 lines
889 B
CoffeeScript
25 lines
889 B
CoffeeScript
CocoModel = require './CocoModel'
|
|
schema = require 'schemas/models/campaign.schema'
|
|
Level = require 'models/Level'
|
|
Levels = require 'collections/Levels'
|
|
CocoCollection = require 'collections/CocoCollection'
|
|
|
|
module.exports = class Campaign extends CocoModel
|
|
@className: 'Campaign'
|
|
@schema: schema
|
|
urlRoot: '/db/campaign'
|
|
@denormalizedLevelProperties: _.keys(_.omit(schema.properties.levels.additionalProperties.properties, ['unlocks', 'position', 'rewards']))
|
|
@denormalizedCampaignProperties: ['name', 'i18n', 'slug']
|
|
|
|
getLevels: ->
|
|
levels = new Levels(_.values(@get('levels')))
|
|
levels.comparator = 'campaignIndex'
|
|
levels.sort()
|
|
return levels
|
|
|
|
getNonLadderLevels: ->
|
|
levels = new Levels(_.values(@get('levels')))
|
|
levels.reset(levels.reject (level) -> level.isLadder())
|
|
levels.comparator = 'campaignIndex'
|
|
levels.sort()
|
|
return levels
|