Allow single-click creation of course components that only have one template.

This commit is contained in:
Peter Fogg
2013-05-31 16:22:51 -04:00
parent 56ed47b37f
commit 68581610a4
2 changed files with 18 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
class CMS.Views.UnitEdit extends Backbone.View
events:
'click .new-component .new-component-type a': 'showComponentTemplates'
'click .new-component .new-component-type a.multiple_templates': 'showComponentTemplates'
'click .new-component .new-component-type a.single_template': 'saveNewComponent'
'click .new-component .cancel-button': 'closeNewComponent'
'click .new-component-templates .new-component-template a': 'saveNewComponent'
'click .new-component-templates .cancel-button': 'closeNewComponent'

View File

@@ -53,13 +53,22 @@
<div class="new-component">
<h5>Add New Component</h5>
<ul class="new-component-type">
% for type in sorted(component_templates.keys()):
<li>
<a href="#" data-type="${type}">
<span class="large-template-icon large-${type}-icon"></span>
<span class="name">${type}</span>
</a>
</li>
% for type, templates in sorted(component_templates.items()):
% if len(templates) == 1:
<li>
<a href="#" class="single_template" data-type="${type}" data-location="${templates[0][1]}">
<span class="large-template-icon large-${type}-icon"></span>
<span class="name">${type}</span>
</a>
</li>
% else:
<li>
<a href="#" class="multiple_templates" data-type="${type}">
<span class="large-template-icon large-${type}-icon"></span>
<span class="name">${type}</span>
</a>
</li>
% endif
% endfor
</ul>
</div>