Commit 6047aae9 by Chris Dodge

get basics of set section date time. Need to pass to Tom for some styling considerations

parent 2fd86bd7
...@@ -81,6 +81,11 @@ $(document).ready(function() { ...@@ -81,6 +81,11 @@ $(document).ready(function() {
$('.section-name').bind('click', editSectionName); $('.section-name').bind('click', editSectionName);
$('.edit-section-name-cancel').bind('click', cancelEditSectionName); $('.edit-section-name-cancel').bind('click', cancelEditSectionName);
$('.edit-section-name-save').bind('click', saveEditSectionName); $('.edit-section-name-save').bind('click', saveEditSectionName);
// section date setting
$('.set-publish-date').bind('click', setSectionScheduleDate);
$('.edit-section-start-cancel').bind('click', cancelSetSectionScheduleDate);
$('.edit-section-start-save').bind('click', saveSetSectionScheduleDate);
}); });
function showImportSubmit(e) { function showImportSubmit(e) {
...@@ -184,10 +189,7 @@ function onSectionReordered() { ...@@ -184,10 +189,7 @@ function onSectionReordered() {
}); });
} }
function getEdxTimeFromDateTimeInputs(date_id, time_id, format) { function getEdxTimeFromDateTimeVals(date_val, time_val, format) {
var input_date = $('#'+date_id).val();
var input_time = $('#'+time_id).val();
var edxTimeStr = null; var edxTimeStr = null;
if (input_date != '') { if (input_date != '') {
...@@ -205,6 +207,13 @@ function getEdxTimeFromDateTimeInputs(date_id, time_id, format) { ...@@ -205,6 +207,13 @@ function getEdxTimeFromDateTimeInputs(date_id, time_id, format) {
return edxTimeStr; return edxTimeStr;
} }
function getEdxTimeFromDateTimeInputs(date_id, time_id, format) {
var input_date = $('#'+date_id).val();
var input_time = $('#'+time_id).val();
return getEdxTimeFromDateTimeVals(input_date, input_time, format);
}
function saveSubsection(e) { function saveSubsection(e) {
e.preventDefault(); e.preventDefault();
...@@ -627,3 +636,40 @@ function saveEditSectionName(e) { ...@@ -627,3 +636,40 @@ function saveEditSectionName(e) {
e.stopPropagation(); e.stopPropagation();
}); });
} }
function setSectionScheduleDate(e) {
e.preventDefault();
$(this).closest("h4").hide();
$(this).parent().siblings(".datepair").show();
}
function cancelSetSectionScheduleDate(e) {
e.preventDefault();
$(this).closest(".datepair").hide();
$(this).parent().siblings("h4").show();
}
function saveSetSectionScheduleDate(e) {
e.preventDefault();
input_date = $(this).siblings('input.date').val();
input_time = $(this).siblings('input.time').val();
start = getEdxTimeFromDateTimeVals(input_date, input_time);
id = $(this).closest("section.courseware-section").data("id");
var $_this = $(this);
// call into server to commit the new order
$.ajax({
url: "/save_item",
type: "POST",
dataType: "json",
contentType: "application/json",
data:JSON.stringify({ 'id' : id, 'metadata' : {'start' : start}, 'data': null, 'children' : null})
}).success(function()
{
alert('Your changes have been saved.');
location.reload();
});
}
\ No newline at end of file
...@@ -45,7 +45,7 @@ input.courseware-unit-search-input { ...@@ -45,7 +45,7 @@ input.courseware-unit-search-input {
} }
header { header {
height: 47px; height: 67px;
.item-details { .item-details {
float: left; float: left;
...@@ -80,7 +80,6 @@ input.courseware-unit-search-input { ...@@ -80,7 +80,6 @@ input.courseware-unit-search-input {
} }
h4 { h4 {
display: none;
font-size: 12px; font-size: 12px;
color: #878e9d; color: #878e9d;
......
<%inherit file="base.html" /> <%inherit file="base.html" />
<%!
from time import mktime
import dateutil.parser
import logging
from datetime import datetime
%>
<%! from django.core.urlresolvers import reverse %> <%! from django.core.urlresolvers import reverse %>
<%block name="title">CMS Courseware Overview</%block> <%block name="title">CMS Courseware Overview</%block>
<%namespace name='static' file='static_content.html'/>
<%namespace name="units" file="widgets/units.html" /> <%namespace name="units" file="widgets/units.html" />
<%block name="jsextra">
<link rel="stylesheet" type="text/css" href="${static.url('js/vendor/timepicker/jquery.timepicker.css')}" />
<script src="${static.url('js/vendor/timepicker/jquery.timepicker.js')}"></script>
<script src="${static.url('js/vendor/timepicker/datepair.js')}"></script>
<script src="${static.url('js/vendor/date.js')}"></script>
</%block>
<%block name="header_extras"> <%block name="header_extras">
<script type="text/template" id="new-section-template"> <script type="text/template" id="new-section-template">
<section class="courseware-section branch new-section"> <section class="courseware-section branch new-section">
...@@ -57,13 +71,27 @@ ...@@ -57,13 +71,27 @@
<span class="section-name-span">${section.display_name}</span> <span class="section-name-span">${section.display_name}</span>
<div class="section-name-edit" style="display:none"> <div class="section-name-edit" style="display:none">
<input type="text" value="${section.display_name}" class="edit-section-name" autocomplete="off"/> <input type="text" value="${section.display_name}" class="edit-section-name" autocomplete="off"/>
<a href="#" class="edit-section-name-save">Save</a><a href="#" class="edit-section-name-cancel">Cancel</a> <a href="#" class="save-button edit-section-name-save">Save</a><a href="#" class="cancel-button edit-section-name-cancel">Cancel</a>
</div> </div>
</h3> </h3>
<h4> <h4 class='section-published-date'>
<strong>Unscheduled:</strong> <%
<a href="#" class="set-publish-date">click here to set</a> start_date = datetime.fromtimestamp(mktime(section.start)) if section.start is not None else None
start_date_str = start_date.strftime('%m/%d/%Y') if start_date is not None else ''
start_time_str = start_date.strftime('%H:%M') if start_date is not None else ''
%>
%if start_date is None:
<strong>Unscheduled:</strong>
<a href="#" class="set-publish-date">click here to set</a>
%else:
<strong>${start_date_str} at ${start_time_str}</strong> <a href="#" class="set-publish-date">click here to edit</a>
%endif
</h4> </h4>
<div class="datepair" data-language="javascript" style="display: none">
<input type="text" name="start_date" value="${start_date_str}" placeholder="MM/DD/YYYY" class="date" size='15' autocomplete="off"/>
<input type="text" name="start_time" value="${start_time_str}" placeholder="HH:MM" class="time" size='10' autocomplete="off"/>
<a href="#" class="save-button edit-section-start-save">Save</a><a href="#" class="cancel-button edit-section-start-cancel">Cancel</a>
</div>
</div> </div>
<div class="item-actions"> <div class="item-actions">
<a href="#" class="delete-button delete-section-button"><span class="delete-icon"></span></a> <a href="#" class="delete-button delete-section-button"><span class="delete-icon"></span></a>
......
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