From b73ceb5642ba76a20f2aa1d17fefbacb3f41f516 Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Wed, 24 Oct 2012 09:36:26 -0400 Subject: [PATCH 1/5] show spinner more than once --- cms/static/js/base.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 84c520a6ac..522d0e1b5b 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -315,6 +315,7 @@ function saveSubsection(e) { 'margin-top': '-10px' }); $changedInput.after($spinner); + $spinner.show(); } var id = $(this).data('id'); From ef5ce4e8f4f353410d0a5f338adb6495f2fd9fd9 Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Wed, 24 Oct 2012 11:48:44 -0400 Subject: [PATCH 2/5] fixed policy editing workflow --- cms/static/js/base.js | 32 ++++++++++++++++++++++++++---- cms/static/sass/_subsection.scss | 28 +++++++++++++++++++++++++- cms/templates/edit_subsection.html | 7 ++++++- 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 522d0e1b5b..8ad8bb7a8f 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -63,6 +63,9 @@ $(document).ready(function() { // add/remove policy metadata button click handlers $('.add-policy-data').bind('click', addPolicyMetadata); $('.remove-policy-data').bind('click', removePolicyMetadata); + $body.on('click', '.edit-policy-data', editPolicyMetadata); + $body.on('click', '.policy-list-element .save-button', savePolicyMetadata); + $body.on('click', '.policy-list-element .cancel-button', cancelPolicyMetadata); $('.sync-date').bind('click', syncReleaseDate); @@ -161,19 +164,40 @@ function addPolicyMetadata(e) { newNode.insertBefore('.add-policy-data'); $('.remove-policy-data').bind('click', removePolicyMetadata); newNode.find('.policy-list-name').focus(); - newNode.find('.save-button').bind('click', savePolicyMetadata); - newNode.find('.cancel-button').bind('click', cancelPolicyMetadata); +} + +function editPolicyMetadata(e) { + e.preventDefault(); + + var $policyElement = $(this).parents('.policy-list-element'); + $policyElement.data('currentValues', [$policyElement.find('.policy-list-name').val(), $policyElement.find('.policy-list-value').val()]); + $policyElement.addClass('new-policy-list-element').addClass('editing'); + $policyElement.find('.policy-list-name, .policy-list-value').removeAttr('disabled'); } function savePolicyMetadata(e) { e.preventDefault(); + + var $policyElement = $(this).parents('.policy-list-element'); $('.save-subsection').click(); - $(this).parents('.policy-list-element').removeClass('new-policy-list-element'); + $policyElement.removeClass('new-policy-list-element'); + $policyElement.find('.policy-list-name').attr('disabled', 'disabled'); + $policyElement.find('.policy-list-value').attr('disabled', 'disabled'); + $policyElement.removeClass('editing'); } function cancelPolicyMetadata(e) { e.preventDefault(); - $(this).parents('.policy-list-element').remove(); + + var $policyElement = $(this).parents('.policy-list-element'); + if(!$policyElement.hasClass('editing')) { + $policyElement.remove(); + } else { + $policyElement.removeClass('new-policy-list-element'); + $policyElement.find('.policy-list-name').val($policyElement.data('currentValues')[0]); + $policyElement.find('.policy-list-value').val($policyElement.data('currentValues')[1]); + } + $policyElement.removeClass('editing'); } function removePolicyMetadata(e) { diff --git a/cms/static/sass/_subsection.scss b/cms/static/sass/_subsection.scss index 5d05c81e96..23dae7e353 100644 --- a/cms/static/sass/_subsection.scss +++ b/cms/static/sass/_subsection.scss @@ -22,12 +22,19 @@ } .policy-list { + .policy-list-name, + .policy-list-value { + border: none; + @include box-shadow(none); + } + .policy-list-name { margin-right: 5px; margin-bottom: 10px; } .policy-list-value { + width: 320px; margin-right: 10px; } } @@ -37,11 +44,26 @@ .cancel-button { display: none; } + + .edit-icon { + margin-right: 8px; + } + + &.editing, + &.new-policy-list-element { + .policy-list-name, + .policy-list-value { + border: 1px solid #b0b6c2; + @include linear-gradient(top, rgba(255, 255, 255, 0), rgba(255, 255, 255, .3)); + background-color: #edf1f5; + @include box-shadow(0 1px 2px rgba(0, 0, 0, .1) inset); + } + } } .new-policy-list-element { padding: 10px 10px 0; - margin: 0 -10px; + margin: 0 -10px 10px; border-radius: 3px; background: $mediumGrey; @@ -54,6 +76,10 @@ @include white-button; } + .edit-icon { + display: none; + } + .delete-icon { display: none; } diff --git a/cms/templates/edit_subsection.html b/cms/templates/edit_subsection.html index ab715fbe1b..d86f65f9c4 100644 --- a/cms/templates/edit_subsection.html +++ b/cms/templates/edit_subsection.html @@ -36,7 +36,11 @@
    % for policy_name in policy_metadata.keys():
  1. - + + Save + Cancel + +
  2. % endfor @@ -55,6 +59,7 @@ Save Cancel + From dee6219510a68a48a78b87ca2a15cb39f62a4db4 Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Wed, 24 Oct 2012 14:39:03 -0400 Subject: [PATCH 3/5] brought delete button back to drafts; save on delete component --- cms/static/coffee/src/views/unit.coffee | 3 ++- cms/static/sass/_unit.scss | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cms/static/coffee/src/views/unit.coffee b/cms/static/coffee/src/views/unit.coffee index 3fa43f531c..a0576e9178 100644 --- a/cms/static/coffee/src/views/unit.coffee +++ b/cms/static/coffee/src/views/unit.coffee @@ -236,4 +236,5 @@ class CMS.Views.UnitEdit.SaveDraftButton extends Backbone.View @$el.addClass('disabled') enable: => - @$el.removeClass('disabled') \ No newline at end of file + @$el.removeClass('disabled') + @model.save() \ No newline at end of file diff --git a/cms/static/sass/_unit.scss b/cms/static/sass/_unit.scss index e15288024f..8bebc335ef 100644 --- a/cms/static/sass/_unit.scss +++ b/cms/static/sass/_unit.scss @@ -326,6 +326,10 @@ display: none; } + #delete-draft { + display: inline-block; + } + .save-button, .preview-button, .publish-button, From 1e988c3f5e830586b611bdbe8e23249b51c72cf9 Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Wed, 24 Oct 2012 14:46:37 -0400 Subject: [PATCH 4/5] disabled policy names always and removed edit button --- cms/static/js/base.js | 3 --- cms/static/sass/_subsection.scss | 3 +-- cms/templates/edit_subsection.html | 4 +--- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 8ad8bb7a8f..dcc172210c 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -63,7 +63,6 @@ $(document).ready(function() { // add/remove policy metadata button click handlers $('.add-policy-data').bind('click', addPolicyMetadata); $('.remove-policy-data').bind('click', removePolicyMetadata); - $body.on('click', '.edit-policy-data', editPolicyMetadata); $body.on('click', '.policy-list-element .save-button', savePolicyMetadata); $body.on('click', '.policy-list-element .cancel-button', cancelPolicyMetadata); @@ -172,7 +171,6 @@ function editPolicyMetadata(e) { var $policyElement = $(this).parents('.policy-list-element'); $policyElement.data('currentValues', [$policyElement.find('.policy-list-name').val(), $policyElement.find('.policy-list-value').val()]); $policyElement.addClass('new-policy-list-element').addClass('editing'); - $policyElement.find('.policy-list-name, .policy-list-value').removeAttr('disabled'); } function savePolicyMetadata(e) { @@ -182,7 +180,6 @@ function savePolicyMetadata(e) { $('.save-subsection').click(); $policyElement.removeClass('new-policy-list-element'); $policyElement.find('.policy-list-name').attr('disabled', 'disabled'); - $policyElement.find('.policy-list-value').attr('disabled', 'disabled'); $policyElement.removeClass('editing'); } diff --git a/cms/static/sass/_subsection.scss b/cms/static/sass/_subsection.scss index 23dae7e353..0d7d518ffd 100644 --- a/cms/static/sass/_subsection.scss +++ b/cms/static/sass/_subsection.scss @@ -22,8 +22,7 @@ } .policy-list { - .policy-list-name, - .policy-list-value { + input[disabled] { border: none; @include box-shadow(none); } diff --git a/cms/templates/edit_subsection.html b/cms/templates/edit_subsection.html index d86f65f9c4..b3e4031822 100644 --- a/cms/templates/edit_subsection.html +++ b/cms/templates/edit_subsection.html @@ -36,10 +36,9 @@
      % for policy_name in policy_metadata.keys():
    1. - + Save Cancel -
    2. % endfor @@ -59,7 +58,6 @@ Save Cancel - From ddf3e2e39c9c02e7ac7ff24509dbc08b58f44ada Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Wed, 24 Oct 2012 14:56:30 -0400 Subject: [PATCH 5/5] removed unused edit policy function --- cms/static/js/base.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index dcc172210c..17a0b33ca3 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -165,14 +165,6 @@ function addPolicyMetadata(e) { newNode.find('.policy-list-name').focus(); } -function editPolicyMetadata(e) { - e.preventDefault(); - - var $policyElement = $(this).parents('.policy-list-element'); - $policyElement.data('currentValues', [$policyElement.find('.policy-list-name').val(), $policyElement.find('.policy-list-value').val()]); - $policyElement.addClass('new-policy-list-element').addClass('editing'); -} - function savePolicyMetadata(e) { e.preventDefault();