Added delta views to the other save modals. Fixed modified deltas in delta views. A few style tweaks.

This commit is contained in:
Scott Erickson 2014-04-10 11:13:33 -07:00
parent 5629284c76
commit 3c832d3707
13 changed files with 54 additions and 18 deletions

View file

@ -54,7 +54,7 @@ module.exports.interpretDelta = (delta, path, left, schema) ->
betterDelta.path = betterPath.join(' :: ') betterDelta.path = betterPath.join(' :: ')
betterDelta.schema = childSchema betterDelta.schema = childSchema
betterDelta.left = childLeft betterDelta.left = childLeft
betterDelta.right = jsondiffpatch.patch childLeft, delta betterDelta.right = jsondiffpatch.patch childLeft, delta unless betterDelta.action is 'moved-index'
betterDelta betterDelta

View file

@ -111,6 +111,9 @@ a[data-toggle="modal"]
@include box-shadow(0 0 0 #000) @include box-shadow(0 0 0 #000)
//position: absolute //position: absolute
width: 99% width: 99%
.background-wrapper.plain
background: white
.modal-content .modal-content
@include box-shadow(none) @include box-shadow(none)

View file

@ -34,3 +34,10 @@
color: red color: red
.panel-heading .panel-heading
background-color: lighten(red, 42%) background-color: lighten(red, 42%)
.delta-moved-index
border-color: darkslategray
strong
color: darkslategray
.panel-heading
background-color: lighten(darkslategray, 60%)

View file

@ -1,6 +1,6 @@
#save-version-modal #save-version-modal
.modal-body .modal-body
padding: 0px 50px 30px 20px padding: 10px 50px 30px 20px
#cla-link #cla-link
cursor: pointer cursor: pointer

View file

@ -13,7 +13,7 @@ block content
button(data-i18n="general.history").btn.btn-primary#history-button History button(data-i18n="general.history").btn.btn-primary#history-button History
button(data-toggle="coco-modal", data-target="modal/revert", data-i18n="editor.revert", disabled=authorized === true ? undefined : "true").btn.btn-primary#revert-button Revert button(data-toggle="coco-modal", data-target="modal/revert", data-i18n="editor.revert", disabled=authorized === true ? undefined : "true").btn.btn-primary#revert-button Revert
button(data-i18n="article.edit_btn_preview", disabled=authorized === true ? undefined : "true").btn.btn-primary#preview-button Preview button(data-i18n="article.edit_btn_preview", disabled=authorized === true ? undefined : "true").btn.btn-primary#preview-button Preview
button(data-toggle="coco-modal", data-target="modal/save_version", data-i18n="common.save", disabled=authorized === true ? undefined : "true").btn.btn-primary#save-button Save button(data-i18n="common.save", disabled=authorized === true ? undefined : "true").btn.btn-primary#save-button Save
h3(data-i18n="article.edit_article_title") Edit Article h3(data-i18n="article.edit_article_title") Edit Article
span span

View file

@ -30,4 +30,7 @@
if delta.action === 'text-diff' if delta.action === 'text-diff'
.col-md-12 .col-md-12
div.text-diff div.text-diff
if delta.action === 'moved-index'
.col-md-12
span Moved array value #{JSON.stringify(delta.left)} to index #{delta.destinationIndex}
- i += 1 - i += 1

View file

@ -13,7 +13,7 @@ block content
img#portrait.img-thumbnail img#portrait.img-thumbnail
button.btn.btn-secondary#history-button(data-i18n="general.history") History button.btn.btn-secondary#history-button(data-i18n="general.history") History
button.btn.btn-primary#save-button(data-toggle="coco-modal", data-target="modal/save_version", data-i18n="common.save", disabled=authorized === true ? undefined : "true") Save button.btn.btn-primary#save-button(data-i18n="common.save", disabled=authorized === true ? undefined : "true") Save
button.btn.btn-primary#revert-button(data-toggle="coco-modal", data-target="modal/revert", data-i18n="editor.revert", disabled=authorized === true ? undefined : "true") Revert button.btn.btn-primary#revert-button(data-toggle="coco-modal", data-target="modal/revert", data-i18n="editor.revert", disabled=authorized === true ? undefined : "true") Revert
h3 Edit Thang Type: "#{thangType.attributes.name}" h3 Edit Thang Type: "#{thangType.attributes.name}"

View file

@ -4,14 +4,14 @@ block modal-header-content
h3(data-i18n="versions.save_version_title") Save New Version h3(data-i18n="versions.save_version_title") Save New Version
block modal-body-content block modal-body-content
form.form .changes-stub
.form-group form.form-inline
label.control-label(for="commitMessage", data-i18n="general.commit_msg") Commit Message .form-group.commit-message
textarea#commit-message.input-large.form-control(name="commitMessage", type="text") input.form-control#commit-message(name="commitMessage", type="text", placeholder="Commit Message")
.form-group .checkbox
label.control-label(for="level-version-is-major", data-i18n="versions.new_major_version") New Major Version label
input#major-version.input-large.form-control(name="version-is-major", type="checkbox") input#major-version(name="version-is-major", type="checkbox")
span.help-block | Major Changes
block modal-body-wait-content block modal-body-wait-content
h3(data-i18n="common.saving") Saving... h3(data-i18n="common.saving") Saving...

View file

@ -3,6 +3,7 @@ VersionHistoryView = require './versions_view'
ErrorView = require '../../error_view' ErrorView = require '../../error_view'
template = require 'templates/editor/article/edit' template = require 'templates/editor/article/edit'
Article = require 'models/Article' Article = require 'models/Article'
SaveVersionModal = require 'views/modal/save_version_modal'
module.exports = class ArticleEditView extends View module.exports = class ArticleEditView extends View
id: "editor-article-edit-view" id: "editor-article-edit-view"
@ -12,6 +13,7 @@ module.exports = class ArticleEditView extends View
events: events:
'click #preview-button': 'openPreview' 'click #preview-button': 'openPreview'
'click #history-button': 'showVersionHistory' 'click #history-button': 'showVersionHistory'
'click #save-button': 'openSaveModal'
subscriptions: subscriptions:
'save-new-version': 'saveNewArticle' 'save-new-version': 'saveNewArticle'
@ -80,11 +82,14 @@ module.exports = class ArticleEditView extends View
return if @startsLoading return if @startsLoading
@showReadOnly() unless me.isAdmin() or @article.hasWriteAccess(me) @showReadOnly() unless me.isAdmin() or @article.hasWriteAccess(me)
openPreview: => openPreview: ->
@preview = window.open('/editor/article/x/preview', 'preview', 'height=800,width=600') @preview = window.open('/editor/article/x/preview', 'preview', 'height=800,width=600')
@preview.focus() if window.focus @preview.focus() if window.focus
@preview.onload = => @pushChangesToPreview() @preview.onload = => @pushChangesToPreview()
return false return false
openSaveModal: ->
@openModalView(new SaveVersionModal({model: @article}))
saveNewArticle: (e) -> saveNewArticle: (e) ->
@treema.endExistingEdits() @treema.endExistingEdits()

View file

@ -9,6 +9,7 @@ module.exports = class LevelSaveView extends SaveVersionModal
template: template template: template
instant: false instant: false
modalWidthPercent: 60 modalWidthPercent: 60
plain: true
events: events:
'click #save-version-button': 'commitLevel' 'click #save-version-button': 'commitLevel'

View file

@ -9,6 +9,7 @@ View = require 'views/kinds/RootView'
ThangComponentEditView = require 'views/editor/components/main' ThangComponentEditView = require 'views/editor/components/main'
VersionHistoryView = require './versions_view' VersionHistoryView = require './versions_view'
ColorsTabView = require './colors_tab_view' ColorsTabView = require './colors_tab_view'
SaveVersionModal = require 'views/modal/save_version_modal'
ErrorView = require '../../error_view' ErrorView = require '../../error_view'
template = require 'templates/editor/thang/edit' template = require 'templates/editor/thang/edit'
@ -33,6 +34,7 @@ module.exports = class ThangTypeEditView extends View
'click #marker-button': 'toggleDots' 'click #marker-button': 'toggleDots'
'click #end-button': 'endAnimation' 'click #end-button': 'endAnimation'
'click #history-button': 'showVersionHistory' 'click #history-button': 'showVersionHistory'
'click #save-button': 'openSaveModal'
subscriptions: subscriptions:
'save-new-version': 'saveNewThangType' 'save-new-version': 'saveNewThangType'
@ -396,11 +398,14 @@ module.exports = class ThangTypeEditView extends View
@showAnimation() @showAnimation()
@showingSelectedNode = false @showingSelectedNode = false
destroy: ->
@camera?.destroy()
super()
showVersionHistory: (e) -> showVersionHistory: (e) ->
versionHistoryView = new VersionHistoryView thangType:@thangType, @thangTypeID versionHistoryView = new VersionHistoryView thangType:@thangType, @thangTypeID
@openModalView versionHistoryView @openModalView versionHistoryView
Backbone.Mediator.publish 'level:view-switched', e Backbone.Mediator.publish 'level:view-switched', e
openSaveModal: ->
@openModalView(new SaveVersionModal({model: @thangType}))
destroy: ->
@camera?.destroy()
super()

View file

@ -5,6 +5,7 @@ module.exports = class ModalView extends CocoView
closeButton: true closeButton: true
closesOnClickOutside: true closesOnClickOutside: true
modalWidthPercent: null modalWidthPercent: null
plain: false
shortcuts: shortcuts:
'esc': 'hide' 'esc': 'hide'
@ -31,6 +32,7 @@ module.exports = class ModalView extends CocoView
@$el.on 'hide.bs.modal', => @$el.on 'hide.bs.modal', =>
@onHidden() unless @hidden @onHidden() unless @hidden
@hidden = true @hidden = true
@$el.find('.background-wrapper').addClass('plain') if @plain
afterInsert: -> afterInsert: ->
super() super()

View file

@ -1,18 +1,28 @@
ModalView = require 'views/kinds/ModalView' ModalView = require 'views/kinds/ModalView'
template = require 'templates/modal/save_version' template = require 'templates/modal/save_version'
DeltaView = require 'views/editor/delta'
module.exports = class SaveVersionModal extends ModalView module.exports = class SaveVersionModal extends ModalView
id: 'save-version-modal' id: 'save-version-modal'
template: template template: template
plain: true
events: events:
'click #save-version-button': 'onClickSaveButton' 'click #save-version-button': 'onClickSaveButton'
'click #cla-link': 'onClickCLALink' 'click #cla-link': 'onClickCLALink'
'click #agreement-button': 'onAgreedToCLA' 'click #agreement-button': 'onAgreedToCLA'
constructor: (options) ->
super options
@model = options.model
afterRender: -> afterRender: ->
super() super()
@$el.find(if me.get('signedCLA') then '#accept-cla-wrapper' else '#save-version-button').hide() @$el.find(if me.get('signedCLA') then '#accept-cla-wrapper' else '#save-version-button').hide()
return unless @model
changeEl = @$el.find('.changes-stub')
deltaView = new DeltaView({model:@model})
@insertSubView(deltaView, changeEl)
onClickSaveButton: -> onClickSaveButton: ->
Backbone.Mediator.publish 'save-new-version', { Backbone.Mediator.publish 'save-new-version', {