Fixed the level editor so you can save again.

This commit is contained in:
Scott Erickson 2014-04-12 08:48:49 -07:00
parent 53579b2632
commit 10b1660419
8 changed files with 31 additions and 15 deletions

View file

@ -1,4 +1,4 @@
module.exports = nativeDescription: "English", englishDescription: "English", translation:
module.exports = nativeDescription: "English", englishDescription: "English", translation:
common:
loading: "Loading..."
saving: "Saving..."
@ -359,7 +359,7 @@ module.exports = nativeDescription: "English", englishDescription: "English", tr
thang_search_title: "Search Thang Types Here"
level_search_title: "Search Levels Here"
signup_to_create: "Sign Up to Create a New Content"
read_only_warning: "Note: you can't save any edits here, because you're not logged in as an admin."
read_only_warning2: "Note: you can't save any edits here, because you're not logged in."
article:
edit_btn_preview: "Preview"
@ -661,3 +661,4 @@ module.exports = nativeDescription: "English", englishDescription: "English", tr
leaderboard: "Leaderboard"
user_schema: "User Schema"
user_profile: "User Profile"
patches: "Patches"

View file

@ -26,11 +26,16 @@ block outer_content
a(href="#editor-level-components-tab-view", data-toggle="tab", data-i18n="editor.level_tab_components") Components
li
a(href="#editor-level-systems-tab-view", data-toggle="tab", data-i18n="editor.level_tab_systems") Systems
li
a(href="#editor-level-patches", data-toggle="tab", data-i18n="resources.patches")#patches-tab Patches
ul.nav.navbar-nav.navbar-right
li(data-toggle="coco-modal", data-target="modal/revert", data-i18n="editor.revert", disabled=authorized === true ? undefined : "true").btn.btn-primary.navbar-btn#revert-button Revert
li(data-i18n="common.save", disabled=authorized === true ? undefined : "true").btn.btn-primary.navbar-btn#commit-level-start-button Save
if authorized
li(data-i18n="common.save").btn.btn-primary.navbar-btn#commit-level-start-button Save
else
li(data-i18n="common.patch").btn.btn-primary.navbar-btn#commit-level-patch-button Patch
li(data-i18n="common.fork", disabled=anonymous ? "true": undefined).btn.btn-primary.navbar-btn#fork-level-start-button Fork
li(title="⌃↩ or ⌘↩: Play preview of current level", data-i18n="common.play")#play-button.btn.btn-inverse.banner.navbar-btn Play!
@ -74,6 +79,9 @@ block outer_content
div.tab-pane#editor-level-components-tab-view
div.tab-pane#editor-level-systems-tab-view
div.tab-pane#editor-level-patches
.patches-view
div#error-view

View file

@ -80,7 +80,7 @@ module.exports = class ArticleEditView extends View
afterRender: ->
super()
return if @startsLoading
@showReadOnly() unless me.isAdmin() or @article.hasWriteAccess(me)
@showReadOnly() if me.get('anonymous')
openPreview: ->
@preview = window.open('/editor/article/x/preview', 'preview', 'height=800,width=600')

View file

@ -12,6 +12,8 @@ ComponentsTabView = require './components_tab_view'
SystemsTabView = require './systems_tab_view'
LevelSaveView = require './save_view'
LevelForkView = require './fork_view'
SaveVersionModal = require 'views/modal/save_version_modal'
PatchesView = require 'views/editor/patches_view'
VersionHistoryView = require './versions_view'
ErrorView = require '../../error_view'
@ -26,6 +28,8 @@ module.exports = class EditorLevelView extends View
'click #commit-level-start-button': 'startCommittingLevel'
'click #fork-level-start-button': 'startForkingLevel'
'click #history-button': 'showVersionHistory'
'click #patches-tab': -> @patchesView.load()
'click #commit-level-patch-button': 'startPatchingLevel'
constructor: (options, @levelID) ->
super options
@ -88,7 +92,8 @@ module.exports = class EditorLevelView extends View
@componentsTab = @insertSubView new ComponentsTabView supermodel: @supermodel
@systemsTab = @insertSubView new SystemsTabView supermodel: @supermodel
Backbone.Mediator.publish 'level-loaded', level: @level
@showReadOnly() unless me.isAdmin() or @level.hasWriteAccess(me)
@showReadOnly() if me.get('anonymous')
@patchesView = @insertSubView(new PatchesView(@level), @$el.find('.patches-view'))
onPlayLevel: (e) ->
sendLevel = =>
@ -103,9 +108,12 @@ module.exports = class EditorLevelView extends View
@childWindow.onPlayLevelViewLoaded = (e) => sendLevel() # still a hack
@childWindow.focus()
startPatchingLevel: (e) ->
@openModalView new SaveVersionModal({model:@level})
Backbone.Mediator.publish 'level:view-switched', e
startCommittingLevel: (e) ->
levelSaveView = new LevelSaveView level: @level, supermodel: @supermodel
@openModalView levelSaveView
@openModalView new LevelSaveView level: @level, supermodel: @supermodel
Backbone.Mediator.publish 'level:view-switched', e
startForkingLevel: (e) ->

View file

@ -95,7 +95,7 @@ module.exports = class ThangTypeEditView extends View
@initComponents()
@insertSubView(new ColorsTabView(@thangType))
@patchesView = @insertSubView(new PatchesView(@thangType), @$el.find('.patches-view'))
@showReadOnly() unless me.isAdmin() or @thangType.hasWriteAccess(me)
@showReadOnly() if me.get('anonymous')
initComponents: =>
options =

View file

@ -262,7 +262,7 @@ class CocoView extends Backbone.View
showReadOnly: ->
return if me.isAdmin()
warning = $.i18n.t 'editor.read_only_warning', defaultValue: "Note: you can't save any edits here, because you're not logged in as an admin."
warning = $.i18n.t 'editor.read_only_warning2', defaultValue: "Note: you can't save any edits here, because you're not logged in."
noty text: warning, layout: 'center', type: 'information', killer: true, timeout: 5000
# Loading ModalViews

View file

@ -17,8 +17,8 @@ module.exports = class SaveVersionModal extends ModalView
constructor: (options) ->
super options
@model = options.model
new Patch()
@model = options.model or options.level
new Patch() # hack to get the schema to load, delete this later
@isPatch = not @model.hasWriteAccess()
getRenderData: ->
@ -33,7 +33,7 @@ module.exports = class SaveVersionModal extends ModalView
changeEl = @$el.find('.changes-stub')
deltaView = new DeltaView({model:@model})
@insertSubView(deltaView, changeEl)
$('.commit-message input').attr('placeholder', $.i18n.t('general.commit_msg'))
@$el.find('.commit-message input').attr('placeholder', $.i18n.t('general.commit_msg'))
onClickSaveButton: ->
Backbone.Mediator.publish 'save-new-version', {

View file

@ -39,7 +39,6 @@ LevelHandler = class LevelHandler extends Handler
return @getLeaderboardGPlusFriends(req, res, args[0]) if args[1] is 'leaderboard_gplus_friends'
return @getHistogramData(req, res, args[0]) if args[1] is 'histogram_data'
return @checkExistence(req, res, args[0]) if args[1] is 'exists'
return @sendNotFoundError(res)
super(arguments...)
fetchLevelByIDAndHandleErrors: (id, req, res, callback) ->