bind the disabling/enabling of the unit name input field based on whether the page state is public or not. We shouldn't be able to edit when public.
This commit is contained in:
@@ -580,8 +580,11 @@ def save_item(request):
|
||||
if request.POST.get('data') is not None:
|
||||
data = request.POST['data']
|
||||
store.update_item(item_location, data)
|
||||
|
||||
if request.POST.get('children') is not None:
|
||||
|
||||
# cdodge: note calling request.POST.get('children') will return None if children is an empty array
|
||||
# so it lead to a bug whereby the last component to be deleted in the UI was not actually
|
||||
# deleting the children object from the children collection
|
||||
if 'children' in request.POST and request.POST['children'] is not None:
|
||||
children = request.POST['children']
|
||||
store.update_children(item_location, children)
|
||||
|
||||
|
||||
@@ -169,12 +169,21 @@ class CMS.Views.UnitEdit.NameEdit extends Backbone.View
|
||||
|
||||
initialize: =>
|
||||
@model.on('change:metadata', @render)
|
||||
@model.on('change:state', @setEnabled)
|
||||
@setEnabled()
|
||||
@saveName
|
||||
@$spinner = $('<span class="spinner-in-field-icon"></span>');
|
||||
|
||||
render: =>
|
||||
@$('.unit-display-name-input').val(@model.get('metadata').display_name)
|
||||
|
||||
setEnabled: =>
|
||||
disabled = @model.get('state') == 'public'
|
||||
if disabled
|
||||
@$('.unit-display-name-input').attr('disabled', true)
|
||||
else
|
||||
@$('.unit-display-name-input').removeAttr('disabled')
|
||||
|
||||
saveName: =>
|
||||
# Treat the metadata dictionary as immutable
|
||||
metadata = $.extend({}, @model.get('metadata'))
|
||||
@@ -196,7 +205,7 @@ class CMS.Views.UnitEdit.NameEdit extends Backbone.View
|
||||
if @timer
|
||||
clearTimeout @timer
|
||||
@timer = setTimeout( =>
|
||||
@model.save(metadata: metadata)
|
||||
@model.save(metadata: metadata, children: null)
|
||||
@timer = null
|
||||
@$spinner.delay(500).fadeOut(150)
|
||||
, 500)
|
||||
|
||||
Reference in New Issue
Block a user