Make edit and delete buttons show up on cms unit editing page

This commit is contained in:
Calen Pennington
2012-09-26 11:52:33 -04:00
parent f53217e523
commit dc062f5668
6 changed files with 739 additions and 717 deletions

View File

@@ -12,7 +12,7 @@ from xmodule.vertical_module import VerticalModule
log = logging.getLogger("mitx.xmodule_modifiers")
def wrap_xmodule(get_html, module, template):
def wrap_xmodule(get_html, module, template, context=None):
"""
Wraps the results of get_html in a standard <section> with identifying
data so that the appropriate javascript module can be loaded onto it.
@@ -24,14 +24,18 @@ def wrap_xmodule(get_html, module, template):
class_: the module class name
module_name: the js_module_name of the module
"""
if context is None:
context = {}
@wraps(get_html)
def _get_html():
return render_to_string(template, {
context.update({
'content': get_html(),
'class_': module.__class__.__name__,
'module_name': module.js_module_name
})
return render_to_string(template, context)
return _get_html

View File

@@ -12,7 +12,7 @@ from .x_module import XModuleDescriptor
def write_module_styles(output_root, extra_descriptors):
return _write_styles(output_root, _list_modules(extra_descriptors))
return _write_styles('.xmodule_display', output_root, _list_modules(extra_descriptors))
def write_module_js(output_root, extra_descriptors):
@@ -20,7 +20,7 @@ def write_module_js(output_root, extra_descriptors):
def write_descriptor_styles(output_root, extra_descriptors):
return _write_styles(output_root, _list_descriptors(extra_descriptors))
return _write_styles('.xmodule_edit', output_root, _list_descriptors(extra_descriptors))
def write_descriptor_js(output_root, extra_descriptors):
@@ -53,7 +53,7 @@ def _ensure_dir(dir_):
raise
def _write_styles(output_root, classes):
def _write_styles(selector, output_root, classes):
_ensure_dir(output_root)
css_fragments = defaultdict(set)
@@ -78,8 +78,8 @@ def _write_styles(output_root, classes):
with open(output_root / '_module-styles.scss', 'w') as module_styles:
for class_, fragment_names in css_imports.items():
imports = "\n".join('@import "{0}";'.format(name) for name in fragment_names)
module_styles.write(""".xmodule_{class_} {{ {imports} }}""".format(
class_=class_, imports=imports
module_styles.write("""{selector}.xmodule_{class_} {{ {imports} }}""".format(
class_=class_, imports=imports, selector=selector
))

View File

@@ -1,3 +1,14 @@
<section class="xmodule_edit xmodule_${class_}" data-type="${module_name}">
${content}
</section>
<div class="xmodule_edit xmodule_${class_} ${editable_class}" data-type="${module_name}">
<%include file="xmodule_display.html"/>
% if editable_data:
<div class="component-actions">
<a href="#" class="edit-button"><span class="edit-icon white"></span>Edit</a>
<a href="#" class="delete-button"><span class="delete-icon white"></span>Delete</a>
</div>
<div class="component-editor">
${editor_content}
<a href="#" class="save-button">Save</a>
<a href="#" class="cancel-button">Cancel</a>
</div>
% endif
</div>