From 20a8395f4fd2d96b7a9b172ec4e509ff429b1ec4 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Tue, 9 Oct 2012 10:32:12 -0400 Subject: [PATCH] add/remove policy data from subsection --- cms/static/js/base.js | 18 +++++++--- cms/static/sass/_base.scss | 4 ++- cms/static/sass/_graphics.scss | 8 +++++ cms/templates/edit_subsection.html | 53 ++++++++++++++++-------------- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 13fcda55b1..7e91debead 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -40,8 +40,16 @@ $(document).ready(function() { $('.add-policy-data').bind('click', addPolicyMetadata); $('.remove-policy-data').bind('click', removePolicyMetadata); + $('.sync-date').bind('click', syncReleaseDate); + }); +function syncReleaseDate(e) { + e.preventDefault(); + $("#start_date").val(""); + $("#start_time").val(""); +} + function addPolicyMetadata(e) { e.preventDefault(); var template =$('#add-new-policy-element-template > li'); @@ -55,9 +63,10 @@ function removePolicyMetadata(e) { e.preventDefault(); policy_name = $(this).data('policy-name'); var _parent_el = $(this).parent('li:.policy-list-element'); - //$(_parent_el).remove(); - - _parent_el.appendTo("#policy-to-delete"); + if ($(_parent_el).hasClass("new-policy-list-element")) + _parent_el.remove(); + else + _parent_el.appendTo("#policy-to-delete"); } @@ -129,7 +138,8 @@ function saveSubsection(e) { // 'null' presented to the server means 'remove' $("#policy-to-delete > li.policy-list-element").each(function(i, element) { name = $(element).children('.policy-list-name').val(); - metadata[name] = null; + if (name != "") + metadata[name] = null; }); // Piece back together the date/time UI elements into one date/time string diff --git a/cms/static/sass/_base.scss b/cms/static/sass/_base.scss index 312d066078..2c9276ffd8 100644 --- a/cms/static/sass/_base.scss +++ b/cms/static/sass/_base.scss @@ -124,13 +124,15 @@ label { } .new-unit-item, -.new-subsection-item { +.new-subsection-item, +.new-policy-item { @include grey-button; margin: 5px 8px; padding: 3px 10px 4px 10px; font-size: 10px; .new-folder-icon, + .new-policy-icon, .new-unit-icon { position: relative; top: 2px; diff --git a/cms/static/sass/_graphics.scss b/cms/static/sass/_graphics.scss index 14662c7d42..dbc43a661f 100644 --- a/cms/static/sass/_graphics.scss +++ b/cms/static/sass/_graphics.scss @@ -171,6 +171,14 @@ background: url(../img/new-unit-icon.png) right no-repeat; } +.new-policy-icon { + display: inline-block; + width: 23px; + height: 12px; + margin-right: 8px; + background: url(../img/new-unit-icon.png) right no-repeat; +} + .textbook-icon { display: inline-block; width: 32px; diff --git a/cms/templates/edit_subsection.html b/cms/templates/edit_subsection.html index 6f2347398b..e6eeed0963 100644 --- a/cms/templates/edit_subsection.html +++ b/cms/templates/edit_subsection.html @@ -19,29 +19,32 @@
-
- - -
-
- - -
-
- - ${units.enum_units(subsection)} -
-
- -
    - % for policy_name in policy_metadata.keys(): -
  1. - -
  2. - % endfor - Add -
-
+
+ + +
+
+ + +
+
+ + ${units.enum_units(subsection)} +
+
+ +
    + % for policy_name in policy_metadata.keys(): +
  1. + +
  2. + % endfor + + + New Policy Data + +
+
@@ -49,7 +52,7 @@
- % if start_date != parent_start_date and parent_start_date is not None: + % if subsection.start != parent_item.start and subsection.start:

The date above differs from the release date of ${parent_item.display_name} – ${parent_start_date.strftime('%m/%d/%Y')} at ${parent_start_date.strftime('%H:%M')}. Sync to ${parent_item.display_name}.

% endif