Commit 7ccdc5d4 by Calen Pennington

Grey out inactive items when changing state in unit editing view

parent 9d6a7ffe
...@@ -18,6 +18,8 @@ class CMS.Views.UnitEdit extends Backbone.View ...@@ -18,6 +18,8 @@ class CMS.Views.UnitEdit extends Backbone.View
) )
@visibility_view.render() @visibility_view.render()
@model.on('change:state', @render)
@$newComponentItem = @$('.new-component-item') @$newComponentItem = @$('.new-component-item')
@$newComponentTypePicker = @$('.new-component') @$newComponentTypePicker = @$('.new-component')
@$newComponentTemplatePickers = @$('.new-component-templates') @$newComponentTemplatePickers = @$('.new-component-templates')
...@@ -81,6 +83,14 @@ class CMS.Views.UnitEdit extends Backbone.View ...@@ -81,6 +83,14 @@ class CMS.Views.UnitEdit extends Backbone.View
components: => @$('.component').map((idx, el) -> $(el).data('id')).get() components: => @$('.component').map((idx, el) -> $(el).data('id')).get()
wait: (value) =>
@$('.unit-body').toggleClass("waiting", value)
render: =>
if @model.hasChanged('state')
@$el.toggleClass("edit-state-#{@model.previous('state')} edit-state-#{@model.get('state')}")
@wait(false)
saveDraft: => saveDraft: =>
@model.save() @model.save()
...@@ -94,6 +104,8 @@ class CMS.Views.UnitEdit extends Backbone.View ...@@ -94,6 +104,8 @@ class CMS.Views.UnitEdit extends Backbone.View
) )
deleteDraft: (event) -> deleteDraft: (event) ->
@wait(true)
$.post('/delete_item', { $.post('/delete_item', {
id: @$el.data('id') id: @$el.data('id')
delete_children: true delete_children: true
...@@ -102,18 +114,20 @@ class CMS.Views.UnitEdit extends Backbone.View ...@@ -102,18 +114,20 @@ class CMS.Views.UnitEdit extends Backbone.View
) )
createDraft: (event) -> createDraft: (event) ->
@wait(true)
$.post('/create_draft', { $.post('/create_draft', {
id: @$el.data('id') id: @$el.data('id')
}, => }, =>
@$el.toggleClass('edit-state-public edit-state-draft')
@model.set('state', 'draft') @model.set('state', 'draft')
) )
publishDraft: (event) -> publishDraft: (event) ->
@wait(true)
$.post('/publish_draft', { $.post('/publish_draft', {
id: @$el.data('id') id: @$el.data('id')
}, => }, =>
@$el.toggleClass('edit-state-public edit-state-draft')
@model.set('state', 'public') @model.set('state', 'public')
) )
...@@ -123,10 +137,11 @@ class CMS.Views.UnitEdit extends Backbone.View ...@@ -123,10 +137,11 @@ class CMS.Views.UnitEdit extends Backbone.View
else else
target_url = '/publish_draft' target_url = '/publish_draft'
@wait(true)
$.post(target_url, { $.post(target_url, {
id: @$el.data('id') id: @$el.data('id')
}, => }, =>
@$el.toggleClass('edit-state-public edit-state-private')
@model.set('state', @$('#visibility').val()) @model.set('state', @$('#visibility').val())
) )
......
...@@ -29,6 +29,10 @@ h1 { ...@@ -29,6 +29,10 @@ h1 {
margin: 36px 6px; margin: 36px 6px;
} }
.waiting {
opacity: 0.1;
}
.page-actions { .page-actions {
float: right; float: right;
margin-top: 42px; margin-top: 42px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment