From 8a67454f98326be778ccd6d39421d18602cb7a9b Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Mon, 3 Jun 2013 15:36:55 -0400 Subject: [PATCH] Prevent creation of unnecessary template divs, and rename .single_templates to .single-templates for convention. --- .../component_settings_editor_helpers.py | 2 +- cms/static/coffee/src/views/unit.coffee | 4 +- cms/templates/unit.html | 96 ++++++++++--------- 3 files changed, 52 insertions(+), 50 deletions(-) diff --git a/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py b/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py index da1eb3b8ea..21240593e9 100644 --- a/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py +++ b/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py @@ -32,7 +32,7 @@ def click_component_from_menu(instance_id, expected_css): if len(elements) == 1: # Multiple templates world.css_click(elem_css) else: # Single template - assert(len(filter(lambda ele: ele.has_class('single_template'), elements)) == 1) + assert(len(filter(lambda ele: ele.has_class('single-template'), elements)) == 1) assert_equal(1, len(world.css_find(expected_css))) diff --git a/cms/static/coffee/src/views/unit.coffee b/cms/static/coffee/src/views/unit.coffee index 11d219a546..058bcf0ce1 100644 --- a/cms/static/coffee/src/views/unit.coffee +++ b/cms/static/coffee/src/views/unit.coffee @@ -1,7 +1,7 @@ class CMS.Views.UnitEdit extends Backbone.View events: - 'click .new-component .new-component-type a.multiple_templates': 'showComponentTemplates' - 'click .new-component .new-component-type a.single_template': 'saveNewComponent' + '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' diff --git a/cms/templates/unit.html b/cms/templates/unit.html index bb2a8f5193..aba9889b14 100644 --- a/cms/templates/unit.html +++ b/cms/templates/unit.html @@ -54,12 +54,12 @@
Add New Component
% for type, templates in sorted(component_templates.items()): + % if len(templates) > 1 or type == 'advanced':
% if type == "problem": -
- - % endif -
-
    - % for name, location, has_markdown in templates: - % if has_markdown or type != "problem": -
  • - - ${name} - -
  • - % endif - - %endfor -
-
- % if type == "problem": -
-
- % endif - Cancel -
+ % endif +
+
    + % for name, location, has_markdown in templates: + % if has_markdown or type != "problem": +
  • + + ${name} + +
  • + % endif + + %endfor +
+
+ % if type == "problem": +
+
    + % for name, location, has_markdown in templates: + % if not has_markdown: +
  • + + ${name} + +
  • + % endif + % endfor +
+
+
+ % endif + Cancel + + % endif % endfor