From 60cf22e4b2a42440e12f2f7ebd91d4630ae84556 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 17 Oct 2012 13:46:40 -0400 Subject: [PATCH 1/2] work in progress: set start date --- cms/static/js/base.js | 41 +++++++++++++++++++++++++++++++++++++ cms/templates/overview.html | 15 +++++++++++--- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 256759e7d8..7ef7aff963 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -77,6 +77,10 @@ $(document).ready(function() { $('.new-course-button').bind('click', addNewCourse); + // section name editing + $('.section-name').bind('click', editSectionName); + $('.edit-section-name-cancel').bind('click', cancelEditSectionName); + $('.edit-section-name-save').bind('click', saveEditSectionName); }); function showImportSubmit(e) { @@ -576,3 +580,40 @@ function cancelNewSubsection(e) { e.preventDefault(); $(this).parents('li.branch').remove(); } + +function editSectionName(e) { + e.preventDefault(); + $(this).children('div.section-name-edit').show(); + $(this).children('span.section-name-span').hide(); +} + +function cancelEditSectionName(e) { + e.preventDefault(); + $(this).parent().hide(); + $(this).parent().siblings('span.section-name-span').show(); + e.stopPropagation(); +} + +function saveEditSectionName(e) { + e.preventDefault(); + + id = $(this).closest("section.courseware-section").data("id"); + display_name = $(this).prev('.edit-section-name').val(); + + 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' : {'display_name' : display_name}, 'data': null, 'children' : null}) + }).success(function() + { + alert('Your changes have been saved.'); + $_this.parent().siblings('span.section-name-span').html(display_name); + $_this.parent().siblings('span.section-name-span').show(); + $_this.parent().hide(); + e.stopPropagation(); + }); +} diff --git a/cms/templates/overview.html b/cms/templates/overview.html index 9739f4c1a2..7f08a313fe 100644 --- a/cms/templates/overview.html +++ b/cms/templates/overview.html @@ -52,9 +52,18 @@
-
-

${section.display_name}

-

Unscheduled: click here to set

+
+

+ ${section.display_name} + +

+

+ Unscheduled: + click here to set +

From 6047aae9fbf0b5751975590fd4170016ad7b4c25 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 17 Oct 2012 15:28:34 -0400 Subject: [PATCH 2/2] get basics of set section date time. Need to pass to Tom for some styling considerations --- cms/static/js/base.js | 54 +++++++++++++++++++++++++++++--- cms/static/sass/_courseware.scss | 3 +- cms/templates/overview.html | 36 ++++++++++++++++++--- 3 files changed, 83 insertions(+), 10 deletions(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 1486a10c5b..718c106c76 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -81,6 +81,11 @@ $(document).ready(function() { $('.section-name').bind('click', editSectionName); $('.edit-section-name-cancel').bind('click', cancelEditSectionName); $('.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) { @@ -184,10 +189,7 @@ function onSectionReordered() { }); } -function getEdxTimeFromDateTimeInputs(date_id, time_id, format) { - var input_date = $('#'+date_id).val(); - var input_time = $('#'+time_id).val(); - +function getEdxTimeFromDateTimeVals(date_val, time_val, format) { var edxTimeStr = null; if (input_date != '') { @@ -205,6 +207,13 @@ function getEdxTimeFromDateTimeInputs(date_id, time_id, format) { 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) { e.preventDefault(); @@ -627,3 +636,40 @@ function saveEditSectionName(e) { 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 diff --git a/cms/static/sass/_courseware.scss b/cms/static/sass/_courseware.scss index 40e34375f6..15b7882069 100644 --- a/cms/static/sass/_courseware.scss +++ b/cms/static/sass/_courseware.scss @@ -45,7 +45,7 @@ input.courseware-unit-search-input { } header { - height: 47px; + height: 67px; .item-details { float: left; @@ -80,7 +80,6 @@ input.courseware-unit-search-input { } h4 { - display: none; font-size: 12px; color: #878e9d; diff --git a/cms/templates/overview.html b/cms/templates/overview.html index 7f08a313fe..f4055145fa 100644 --- a/cms/templates/overview.html +++ b/cms/templates/overview.html @@ -1,9 +1,23 @@ <%inherit file="base.html" /> +<%! + from time import mktime + import dateutil.parser + import logging + from datetime import datetime +%> <%! from django.core.urlresolvers import reverse %> <%block name="title">CMS Courseware Overview +<%namespace name='static' file='static_content.html'/> <%namespace name="units" file="widgets/units.html" /> +<%block name="jsextra"> + + + + + + <%block name="header_extras">