mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
33d68fab6e
6 changed files with 22 additions and 12 deletions
|
@ -235,6 +235,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
this.at = function(index) {
|
||||
return requests[index];
|
||||
};
|
||||
|
||||
this.all = function() {
|
||||
return requests.slice(0);
|
||||
};
|
||||
|
||||
this.filter = function(url_to_match) {
|
||||
if (requests.length == 0) return [];
|
||||
|
|
|
@ -254,7 +254,7 @@ module.exports = class ProfileView extends View
|
|||
link.icon = @iconForLink link for link in links
|
||||
context.profileLinks = _.sortBy links, (link) -> not link.icon # icons first
|
||||
if @sessions
|
||||
context.sessions = (s.attributes for s in @sessions.models when (s.get('submitted') or s.get('level-id') is 'gridmancer'))
|
||||
context.sessions = (s.attributes for s in @sessions.models when (s.get('submitted') or (s.get('levelID') is 'gridmancer') and s.get('code')?.thoktar?.plan?.length isnt 942)) # no default code
|
||||
context.sessions.sort (a, b) -> (b.playtime ? 0) - (a.playtime ? 0)
|
||||
else
|
||||
context.sessions = []
|
||||
|
|
|
@ -150,12 +150,6 @@ module.exports = class CocoView extends Backbone.View
|
|||
@lastToggleModalCall = 0
|
||||
|
||||
toggleModal: (e) ->
|
||||
if new Date().getTime() - CocoView.lastToggleModalCall < 5
|
||||
# Defensive move. This function has had a history of messing things up.
|
||||
console.error 'toggleModal is getting called too often!'
|
||||
return
|
||||
CocoView.lastToggleModalCall = new Date().getTime()
|
||||
|
||||
if $(e.currentTarget).prop('target') is '_blank'
|
||||
return true
|
||||
# special handler for opening modals that are dynamically loaded, rather than static in the page. It works (or should work) like Bootstrap's modals, except use coco-modal for the data-toggle value.
|
||||
|
@ -163,6 +157,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
return unless elem.data('toggle') is 'coco-modal'
|
||||
target = elem.data('target')
|
||||
view = application.router.getView(target, '_modal') # could set up a system for loading cached modals, if told to
|
||||
e.stopPropagation()
|
||||
@openModalView(view)
|
||||
|
||||
openModalView: (modalView, softly=false) ->
|
||||
|
|
|
@ -54,18 +54,15 @@ module.exports = class ModelModal extends View
|
|||
container = $(e.target).closest('.model-container')
|
||||
model = _.find @models, id: container.data('model-id')
|
||||
treema = @modelTreemas[model.id]
|
||||
changes = {}
|
||||
for key, val of treema.data when not _.isEqual val, model.get key
|
||||
console.log "Updating", key, "from", model.get(key), "to", val
|
||||
model.set key, val
|
||||
changes[key] = val
|
||||
for key, val of model.attributes when treema.get(key) is undefined and not _.string.startsWith key, '_'
|
||||
console.log "Deleting", key, "which was", val, "but man, that ain't going to work, now is it?"
|
||||
#changes[key] = undefined
|
||||
model.unset key
|
||||
if errors = model.validate()
|
||||
return console.warn model, "failed validation with errors:", errors
|
||||
res = model.save changes, {patch: true}
|
||||
return unless res = model.patch()
|
||||
res.error =>
|
||||
return if @destroyed
|
||||
console.error model, "failed to save with error:", res.responseText
|
||||
|
|
|
@ -229,7 +229,7 @@ UserHandler = class UserHandler extends Handler
|
|||
getLevelSessionsForEmployer: (req, res, userID) ->
|
||||
return @sendUnauthorizedError(res) unless req.user._id+'' is userID or req.user.isAdmin() or ('employer' in req.user.get('permissions'))
|
||||
query = creator: userID, levelID: {$in: ['gridmancer', 'greed', 'dungeon-arena', 'brawlwood', 'gold-rush']}
|
||||
projection = 'levelName levelID team playtime codeLanguage submitted' # code totalScore
|
||||
projection = 'levelName levelID team playtime codeLanguage submitted code totalScore'
|
||||
LevelSession.find(query).select(projection).exec (err, documents) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
documents = (LevelSessionHandler.formatEntity(req, doc) for doc in documents)
|
||||
|
|
14
test/app/views/editor/level/EditorLevelView.spec.coffee
Normal file
14
test/app/views/editor/level/EditorLevelView.spec.coffee
Normal file
|
@ -0,0 +1,14 @@
|
|||
EditorLevelView = require 'views/editor/level/edit'
|
||||
|
||||
emptyLevel = {"_id":"53a0a1e2d9048dbc3a793c81","name":"Emptiness","description":"Tis nothing..","documentation":{"generalArticles":[],"specificArticles":[]},"scripts":[],"thangs":[],"systems":[],"victory":{},"version":{"minor":0,"major":0,"isLatestMajor":true,"isLatestMinor":true},"index":"5388f9ac9a904d0000d94f87","slug":"emptiness","creator":"5388f9ac9a904d0000d94f87","original":"53a0a1e2d9048dbc3a793c81","watchers":["5388f9ac9a904d0000d94f87"],"__v":0,"created":"2014-06-17T20:15:30.207Z","permissions":[{"access":"owner","target":"5388f9ac9a904d0000d94f87"}]}
|
||||
|
||||
describe 'EditorLevelView', ->
|
||||
describe 'revert button', ->
|
||||
it 'opens just one modal when you click it', ->
|
||||
view = new EditorLevelView({}, 'something')
|
||||
request = jasmine.Ajax.requests.first()
|
||||
request.response {status:200, responseText: JSON.stringify(emptyLevel)}
|
||||
view.render()
|
||||
spyOn(view, 'openModalView')
|
||||
view.$el.find('#revert-button').click()
|
||||
expect(view.openModalView.calls.count()).toBe(1)
|
Loading…
Reference in a new issue