Commit 59ee0c5a by Calen Pennington

Merge pull request #1018 from MITx/fix/cdodge/delete-last-component-does-not-stick

Fix/cdodge/delete last component does not stick
parents b7e0625b afd85845
...@@ -16,4 +16,6 @@ Changes ...@@ -16,4 +16,6 @@ Changes
Upcoming Upcoming
-------- --------
* Created changelog * Fix: Deleting last component in a unit does not work
\ No newline at end of file * Fix: Unit name is editable when a unit is public
* Fix: Visual feedback inconsistent when saving a unit name change
...@@ -581,8 +581,11 @@ def save_item(request): ...@@ -581,8 +581,11 @@ def save_item(request):
if request.POST.get('data') is not None: if request.POST.get('data') is not None:
data = request.POST['data'] data = request.POST['data']
store.update_item(item_location, 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'] children = request.POST['children']
store.update_children(item_location, children) store.update_children(item_location, children)
......
...@@ -169,12 +169,21 @@ class CMS.Views.UnitEdit.NameEdit extends Backbone.View ...@@ -169,12 +169,21 @@ class CMS.Views.UnitEdit.NameEdit extends Backbone.View
initialize: => initialize: =>
@model.on('change:metadata', @render) @model.on('change:metadata', @render)
@model.on('change:state', @setEnabled)
@setEnabled()
@saveName @saveName
@$spinner = $('<span class="spinner-in-field-icon"></span>'); @$spinner = $('<span class="spinner-in-field-icon"></span>');
render: => render: =>
@$('.unit-display-name-input').val(@model.get('metadata').display_name) @$('.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: => saveName: =>
# Treat the metadata dictionary as immutable # Treat the metadata dictionary as immutable
metadata = $.extend({}, @model.get('metadata')) metadata = $.extend({}, @model.get('metadata'))
...@@ -191,6 +200,7 @@ class CMS.Views.UnitEdit.NameEdit extends Backbone.View ...@@ -191,6 +200,7 @@ class CMS.Views.UnitEdit.NameEdit extends Backbone.View
'margin-top': '-10px' 'margin-top': '-10px'
}); });
inputField.after(@$spinner); inputField.after(@$spinner);
@$spinner.fadeIn(10)
# save the name after a slight delay # save the name after a slight delay
if @timer if @timer
......
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