diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index 6bcc24328..d61965365 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -85,7 +85,7 @@ block header span.spl(data-i18n="common.unwatch") Unwatch li(class=anonymous ? "disabled": "") - a(data-i18n="common.fork")#fork-level-start-button Fork + a(data-i18n="common.fork")#fork-start-button Fork li(class=anonymous ? "disabled": "") a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert")#revert-button Revert li(class=anonymous ? "disabled": "") diff --git a/app/templates/editor/level/fork.jade b/app/templates/editor/level/fork.jade deleted file mode 100644 index 6c4f43553..000000000 --- a/app/templates/editor/level/fork.jade +++ /dev/null @@ -1,17 +0,0 @@ -extends /templates/modal/modal_base - -block modal-header-content - h3(data-i18n="editor.fork_title") Fork New Version - -block modal-body-content - form#save-level-form.form - .form-group - label(for="level-name", data-i18n="general.name") Name - input#level-name(name="name", type="text").form-control - -block modal-footer-content - button.btn(data-dismiss="modal", data-i18n="common.cancel") Cancel - button.btn.btn-primary#fork-level-confirm-button(data-i18n="common.save") Save - -block modal-body-wait-content - h3(data-i18n="editor.fork_creating") Creating Fork... diff --git a/app/templates/editor/thang/thang-type-edit-view.jade b/app/templates/editor/thang/thang-type-edit-view.jade index dc83dc257..394c1f97a 100644 --- a/app/templates/editor/thang/thang-type-edit-view.jade +++ b/app/templates/editor/thang/thang-type-edit-view.jade @@ -52,6 +52,8 @@ block header span.glyphicon-chevron-down.glyphicon ul.dropdown-menu li.dropdown-header Actions + li(class=anonymous ? "disabled": "") + a(data-i18n="common.fork")#fork-start-button Fork li(class=anonymous ? "disabled": "") a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert")#revert-button Revert li.divider diff --git a/app/views/editor/level/LevelEditView.coffee b/app/views/editor/level/LevelEditView.coffee index 87c5d19d4..739144c5e 100644 --- a/app/views/editor/level/LevelEditView.coffee +++ b/app/views/editor/level/LevelEditView.coffee @@ -12,7 +12,7 @@ ScriptsTabView = require './scripts/ScriptsTabView' ComponentsTabView = require './components/ComponentsTabView' SystemsTabView = require './systems/SystemsTabView' SaveLevelModal = require './modals/SaveLevelModal' -LevelForkView = require './modals/ForkLevelModal' +ForkModal = require 'views/editor/ForkModal' SaveVersionModal = require 'views/modal/SaveVersionModal' PatchesView = require 'views/editor/PatchesView' RelatedAchievementsView = require 'views/editor/level/RelatedAchievementsView' @@ -30,7 +30,7 @@ module.exports = class LevelEditView extends RootView 'click .play-with-team-button': 'onPlayLevel' 'click .play-with-team-parent': 'onPlayLevelTeamSelect' 'click #commit-level-start-button': 'startCommittingLevel' - 'click #fork-level-start-button': 'startForkingLevel' + 'click #fork-start-button': 'startForking' 'click #level-history-button': 'showVersionHistory' 'click #undo-button': 'onUndo' 'click #redo-button': 'onRedo' @@ -130,9 +130,8 @@ module.exports = class LevelEditView extends RootView @openModalView new SaveLevelModal level: @level, supermodel: @supermodel Backbone.Mediator.publish 'level:view-switched', e - startForkingLevel: (e) -> - levelForkView = new LevelForkView level: @level - @openModalView levelForkView + startForking: (e) -> + @openModalView new ForkModal model: @level, editorPath: 'level' Backbone.Mediator.publish 'level:view-switched', e showVersionHistory: (e) -> diff --git a/app/views/editor/level/modals/ForkLevelModal.coffee b/app/views/editor/level/modals/ForkLevelModal.coffee deleted file mode 100644 index 335ffc4a1..000000000 --- a/app/views/editor/level/modals/ForkLevelModal.coffee +++ /dev/null @@ -1,45 +0,0 @@ -ModalView = require 'views/kinds/ModalView' -template = require 'templates/editor/level/fork' -forms = require 'lib/forms' -Level = require 'models/Level' - -module.exports = class ForkLevelModal extends ModalView - id: 'editor-level-fork-modal' - template: template - instant: false - modalWidthPercent: 60 - - events: - 'click #fork-level-confirm-button': 'forkLevel' - 'submit form': 'forkLevel' - - constructor: (options) -> - super options - @level = options.level - - getRenderData: (context={}) -> - context = super(context) - context.level = @level - context - - forkLevel: -> - @showLoading() - forms.clearFormAlerts(@$el) - newLevel = new Level($.extend(true, {}, @level.attributes)) - newLevel.unset '_id' - newLevel.unset 'version' - newLevel.unset 'creator' - newLevel.unset 'created' - newLevel.unset 'original' - newLevel.unset 'parent' - newLevel.set 'commitMessage', "Forked from #{@level.get('name')}" - newLevel.set 'name', @$el.find('#level-name').val() - newLevel.set 'permissions', [access: 'owner', target: me.id] - res = newLevel.save() - return unless res - res.error => - @hideLoading() - forms.applyErrorsToForm(@$el.find('form'), JSON.parse(res.responseText)) - res.success => - @hide() - application.router.navigate('editor/level/' + newLevel.get('slug'), {trigger: true}) diff --git a/app/views/editor/thang/ThangTypeEditView.coffee b/app/views/editor/thang/ThangTypeEditView.coffee index a208ef1ac..4ddeadecb 100644 --- a/app/views/editor/thang/ThangTypeEditView.coffee +++ b/app/views/editor/thang/ThangTypeEditView.coffee @@ -10,6 +10,7 @@ ThangComponentsEditView = require 'views/editor/component/ThangComponentsEditVie ThangTypeVersionsModal = require './ThangTypeVersionsModal' ThangTypeColorsTabView = require './ThangTypeColorsTabView' PatchesView = require 'views/editor/PatchesView' +ForkModal = require 'views/editor/ForkModal' SaveVersionModal = require 'views/modal/SaveVersionModal' template = require 'templates/editor/thang/thang-type-edit-view' storage = require 'lib/storage' @@ -36,6 +37,7 @@ module.exports = class ThangTypeEditView extends RootView 'click #marker-button': 'toggleDots' 'click #end-button': 'endAnimation' 'click #history-button': 'showVersionHistory' + 'click #fork-start-button': 'startForking' 'click #save-button': 'openSaveModal' 'click #patches-tab': -> @patchesView.load() 'click .play-with-level-button': 'onPlayLevel' @@ -406,12 +408,13 @@ module.exports = class ThangTypeEditView extends RootView @showingSelectedNode = false showVersionHistory: (e) -> - versionHistoryModal = new ThangTypeVersionsModal thangType: @thangType, @thangTypeID - @openModalView versionHistoryModal - Backbone.Mediator.publish 'level:view-switched', e + @openModalView new ThangTypeVersionsModal thangType: @thangType, @thangTypeID openSaveModal: -> - @openModalView(new SaveVersionModal({model: @thangType})) + @openModalView new SaveVersionModal model: @thangType + + startForking: (e) -> + @openModalView new ForkModal model: @thangType, editorPath: 'thang' onPlayLevelSelect: (e) -> if @childWindow and not @childWindow.closed