Commit fdf647c0 by Calen Pennington

Split problem metadata out from problem editing contents when rendering

parent 3eadcd29
from mitxmako.shortcuts import render_to_response from mitxmako.shortcuts import render_to_response
from keystore.django import keystore from keystore.django import keystore
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
def index(request): def index(request):
...@@ -20,4 +18,5 @@ def edit_item(request): ...@@ -20,4 +18,5 @@ def edit_item(request):
return render_to_response('unit.html', { return render_to_response('unit.html', {
'contents': item.get_html(), 'contents': item.get_html(),
'type': item.type, 'type': item.type,
'name': item.name,
}) })
section.problem-new, section#unit-wrapper {
section.problem-edit,
section.html-edit {
> header { > header {
border-bottom: 2px solid #333; border-bottom: 2px solid #333;
@include clearfix(); @include clearfix();
...@@ -17,10 +15,19 @@ section.html-edit { ...@@ -17,10 +15,19 @@ section.html-edit {
float: right; float: right;
} }
} }
> section { > section {
padding: 20px; padding: 20px;
a.save-update {
@extend .button;
@include inline-block();
margin-top: 20px;
}
}
}
section.problem-new,
section.problem-edit,
section.html-edit {
textarea { textarea {
@include box-sizing(border-box); @include box-sizing(border-box);
display: block; display: block;
...@@ -60,12 +67,5 @@ section.html-edit { ...@@ -60,12 +67,5 @@ section.html-edit {
margin-bottom: 1em; margin-bottom: 1em;
} }
} }
a.save-update {
@extend .button;
@include inline-block();
margin-top: 20px;
}
}
} }
<div id="unit-wrapper" class="${type}"> <section id="unit-wrapper" class="${type}">
<header>
<h1 class="editable">${name}</h1>
<p>Unit type: ${type}</p>
<!-- <div class="actions"> -->
<!-- <a href="#" class="cancel">Cancel</a> -->
<!-- <a href="#" class="save-update">Save &amp; Update</a> -->
<!-- </div> -->
</header>
<section>
${contents} ${contents}
</div> </section>
<section>
<div class="actions">
<a href="" class="save-update">Save &amp; Update</a>
<a href="#" class="cancel">Cancel</a>
</div>
</section>
</section>
<%namespace name='static' file='../static_content.html'/>
<section class="html-edit"> <section class="html-edit">
<header> <textarea name="" class="edit-box" rows="8" cols="40">${module.definition['data']['text']}</textarea>
<h1 class="editable">${module.name}</h1> <div class="preview">${module.definition['data']['text']}</div>
<p>Unit type: HTML</p>
<!-- <div class="actions"> -->
<!-- <a href="#" class="cancel">Cancel</a> -->
<!-- <a href="#" class="save-update">Save &amp; Update</a> -->
<!-- </div> -->
</header>
<section>
<header>
</header>
<section>
<textarea name="" id="edit-box" rows="8" cols="40">${module.definition['data']['text']}</textarea>
<div id="edit-preview" class="preview">${module.definition['data']['text']}</div>
</section>
<div class="actions">
<a href="" class="save-update">Save &amp; Update</a>
<a href="#" class="cancel">Cancel</a>
</div>
</section>
</section> </section>
class @HTML class @HTML
constructor: (id) -> constructor: (@id) ->
$('#' + id + " #edit-box").on('input', -> id = @id
$('#' + id + ' #edit-preview').empty().append($(this).val()) $("##{id} .edit-box").on('input', ->
$("##{id} .preview").empty().append($(this).val())
) )
save: -> $("##{@id} .edit-box").val()
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