Set up the rest of the component/system buttons and nav bars.

This commit is contained in:
Scott Erickson 2014-04-17 13:24:17 -07:00
parent 9eff958dcb
commit b5406b0149
4 changed files with 42 additions and 6 deletions
app
templates/editor/level/system
views/editor

View file

@ -7,6 +7,8 @@ nav.navbar.navbar-default(role='navigation')
a(href="#system-config-schema" data-toggle="tab") Config Schema
li
a(href="#system-settings" data-toggle="tab") Settings
li
a(href="#system-patches" data-toggle="tab" data-i18n="resources.patches")#system-patches-tab Patches
ul.nav.navbar-nav.navbar-right
li.dropdown
@ -14,15 +16,15 @@ nav.navbar.navbar-default(role='navigation')
span.glyphicon-chevron-down.glyphicon
ul.dropdown-menu
li.dropdown-header Actions
li#component-watch-button
a
li
a#system-watch-button
span.watch
span.glyphicon.glyphicon-eye-open
span.spl Watch
span.unwatch.secret
span.glyphicon.glyphicon-eye-close
span.spl Unwatch
li#patch-component-button
li#patch-system-button
a(data-i18n="common.submit_patch") Submit Patch
li#create-new-system
a(data-i18n="editor.level_system_btn_new") Create New System
@ -41,3 +43,5 @@ nav.navbar.navbar-default(role='navigation')
#config-schema-treema
.tab-pane#system-settings
#edit-system-treema
.tab-pane#system-patches
.patches-view

View file

@ -1,7 +1,7 @@
View = require 'views/kinds/CocoView'
VersionHistoryView = require 'views/editor/component/versions_view'
template = require 'templates/editor/level/component/edit'
LevelComponent = require 'models/LevelComponent'
VersionHistoryView = require 'views/editor/component/versions_view'
PatchesView = require 'views/editor/patches_view'
SaveVersionModal = require 'views/modal/save_version_modal'
@ -12,9 +12,9 @@ module.exports = class LevelComponentEditView extends View
events:
'click #done-editing-component-button': 'endEditing'
'click #component-history-button': 'showVersionHistory'
'click .nav a': (e) -> $(e.target).tab('show')
'click #component-patches-tab': -> @patchesView.load()
'click #component-history-button': 'showVersionHistory'
'click #patch-component-button': 'startPatchingComponent'
'click #component-watch-button': 'toggleWatchComponent'
@ -96,7 +96,7 @@ module.exports = class LevelComponentEditView extends View
null
showVersionHistory: (e) ->
versionHistoryView = new VersionHistoryView component:@levelComponent, @levelComponent.id
versionHistoryView = new VersionHistoryView {}, @levelComponent.id
@openModalView versionHistoryView
Backbone.Mediator.publish 'level:view-switched', e

View file

@ -1,6 +1,9 @@
View = require 'views/kinds/CocoView'
template = require 'templates/editor/level/system/edit'
LevelSystem = require 'models/LevelSystem'
VersionHistoryView = require 'views/editor/system/versions_view'
PatchesView = require 'views/editor/patches_view'
SaveVersionModal = require 'views/modal/save_version_modal'
module.exports = class LevelSystemEditView extends View
id: "editor-level-system-edit-view"
@ -10,6 +13,10 @@ module.exports = class LevelSystemEditView extends View
events:
'click #done-editing-system-button': 'endEditing'
'click .nav a': (e) -> $(e.target).tab('show')
'click #system-patches-tab': -> @patchesView.load()
'click #system-history-button': 'showVersionHistory'
'click #patch-system-button': 'startPatchingSystem'
'click #system-watch-button': 'toggleWatchSystem'
constructor: (options) ->
super options
@ -26,6 +33,7 @@ module.exports = class LevelSystemEditView extends View
@buildSettingsTreema()
@buildConfigSchemaTreema()
@buildCodeEditor()
@patchesView = @insertSubView(new PatchesView(@levelSystem), @$el.find('.patches-view'))
buildSettingsTreema: ->
data = _.pick @levelSystem.attributes, (value, key) => key in @editableSettings
@ -88,6 +96,21 @@ module.exports = class LevelSystemEditView extends View
Backbone.Mediator.publish 'level-system-editing-ended', levelSystem: @levelSystem
null
showVersionHistory: (e) ->
versionHistoryView = new VersionHistoryView {}, @levelSystem.id
@openModalView versionHistoryView
Backbone.Mediator.publish 'level:view-switched', e
startPatchingSystem: (e) ->
@openModalView new SaveVersionModal({model:@levelSystem})
Backbone.Mediator.publish 'level:view-switched', e
toggleWatchSystem: ->
console.log 'toggle watch system?'
button = @$el.find('#system-watch-button')
@levelSystem.watch(button.find('.watch').is(':visible'))
button.find('> span').toggleClass('secret')
destroy: ->
@editor?.destroy()
super()

View file

@ -0,0 +1,9 @@
VersionsModalView = require 'views/modal/versions_modal'
module.exports = class SystemVersionsView extends VersionsModalView
id: "editor-system-versions-view"
url: "/db/level.system/"
page: "system"
constructor: (options, @ID) ->
super options, ID, require 'models/LevelSystem'