From 5efcf9eac5e5fe87fa53961c0034e92066ab3457 Mon Sep 17 00:00:00 2001 From: Jonathan Piacenti Date: Tue, 21 Jul 2015 13:38:29 -0500 Subject: [PATCH 1/2] Visual improvements to Table block. --- .../public/css/mentoring-table.css | 39 ++++++++++++++++--- problem_builder/public/js/review_blocks.js | 7 ++-- problem_builder/table.py | 2 +- .../html/mentoring-table-container.html | 18 +++++---- .../html/mentoring-table-shared-list.html | 2 +- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/problem_builder/public/css/mentoring-table.css b/problem_builder/public/css/mentoring-table.css index f0188602..57f6b6cc 100644 --- a/problem_builder/public/css/mentoring-table.css +++ b/problem_builder/public/css/mentoring-table.css @@ -63,14 +63,16 @@ .mentoring-share-panel { float: right; + margin-bottom: .5em; } .mentoring-share-panel .mentoring-share-with { position: absolute; - right: 0; + right: 3.15em; background-color: rgb(255, 255, 255); - border: 1px solid rgb(221, 221, 221); + border: 2px solid rgb(221, 221, 221); padding: 1em; + font-size: .8em; } .mentoring-share-with .share-header { @@ -86,20 +88,44 @@ margin-right: 1em; } +.mentoring-share-with .remove-share { + color: black; + margin-right: 1.45em; +} + +.mentoring-share-with .add-share-field { + line-height: normal; + padding-top: .40em; + padding-bottom: .40em; +} + .mentoring-share-with .share-errors { color: darkred; font-size: .75em; text-align: center; + display: table-caption; } .new-share-container { margin-top: .5em; + vertical-align: top; +} + +ul.shared-list { + padding-left: 0; + padding-right: 0; + margin: 0 0 .25em 0; +} + +.share-errors-container { + display: table; + margin: 0 auto; } .shared-list li { list-style-type: none; display: block; - padding: .25em; + padding: .25em 0 .25em 0; margin: 0; } @@ -118,16 +144,19 @@ padding: 1em; background-color: rgb(255, 255, 255); position: absolute; - right: 0; + right: 3.15em; font-size: .8em; } .share-notification .notification-close { float: right; + font-size: 1.2em; + color: black; + cursor: pointer; } .report-download-container { - float: left; + text-align: right; } .mentoring .identification { diff --git a/problem_builder/public/js/review_blocks.js b/problem_builder/public/js/review_blocks.js index 6e6a4862..3f0e65bf 100644 --- a/problem_builder/public/js/review_blocks.js +++ b/problem_builder/public/js/review_blocks.js @@ -174,7 +174,7 @@ function MentoringTableBlock(runtime, element, initData) { }) }); - function addShare() { + function addShare(event) { var container = $newShareContainer.clone(); container.find('.add-share-username').val(''); container.insertAfter($element.find('.new-share-container').last()); @@ -182,12 +182,13 @@ function MentoringTableBlock(runtime, element, initData) { } function deleteShare(event) { + event.preventDefault(); $.ajax({ type: "POST", url: deleteShareUrl, - data: JSON.stringify({'username': $(event.target).prev()[0].innerHTML}), + data: JSON.stringify({'username': $(event.target).parent().prev()[0].innerHTML}), success: function () { - $(event.target).parent().remove(); + $(event.target).parent().parent().remove(); $errorHolder.html(''); }, error: errorMessage diff --git a/problem_builder/table.py b/problem_builder/table.py index 39c7548c..1bd49912 100644 --- a/problem_builder/table.py +++ b/problem_builder/table.py @@ -200,7 +200,7 @@ def share_results(self, data, suffix=''): raise JsonHandlerError( 400, _('Some users could not be shared with. Please check these usernames: {}').format( - ','.join(failed_users) + ', '.join(failed_users) ) ) return {} diff --git a/problem_builder/templates/html/mentoring-table-container.html b/problem_builder/templates/html/mentoring-table-container.html index 2049b164..482da594 100644 --- a/problem_builder/templates/html/mentoring-table-container.html +++ b/problem_builder/templates/html/mentoring-table-container.html @@ -1,9 +1,6 @@ {% load i18n %} {% if allow_sharing %}
- {% if allow_download %} - - {% endif %}
{% if view_options %} {% trans "Display Map from:" %} @@ -15,22 +12,24 @@ {% endif %} {% if share_notifications %}
+{% if allow_download %} + +{% endif %} \ No newline at end of file diff --git a/problem_builder/templates/html/mentoring-table-shared-list.html b/problem_builder/templates/html/mentoring-table-shared-list.html index 1b8a9daa..64b9ea57 100644 --- a/problem_builder/templates/html/mentoring-table-shared-list.html +++ b/problem_builder/templates/html/mentoring-table-shared-list.html @@ -4,6 +4,6 @@ {% endif %} \ No newline at end of file From ea1c060038382b0bfe99251591422296826ad1a2 Mon Sep 17 00:00:00 2001 From: Jonathan Piacenti Date: Tue, 21 Jul 2015 16:37:44 -0500 Subject: [PATCH 2/2] Further UI improvements. --- problem_builder/public/css/mentoring-table.css | 4 ++++ problem_builder/public/js/review_blocks.js | 18 +++++++++++++++--- .../html/mentoring-table-container.html | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/problem_builder/public/css/mentoring-table.css b/problem_builder/public/css/mentoring-table.css index 57f6b6cc..af544c6c 100644 --- a/problem_builder/public/css/mentoring-table.css +++ b/problem_builder/public/css/mentoring-table.css @@ -59,6 +59,8 @@ .share-with-instructions { max-width: 14.5em; + margin-bottom: 0; + text-align: left; } .mentoring-share-panel { @@ -109,6 +111,8 @@ .new-share-container { margin-top: .5em; vertical-align: top; + width: 100%; + text-align: left; } ul.shared-list { diff --git a/problem_builder/public/js/review_blocks.js b/problem_builder/public/js/review_blocks.js index 3f0e65bf..ffe8ef84 100644 --- a/problem_builder/public/js/review_blocks.js +++ b/problem_builder/public/js/review_blocks.js @@ -97,7 +97,9 @@ function MentoringTableBlock(runtime, element, initData) { sharedRefresh(data); $element.find(".new-share-container").each(function(index, container) { if (index === 0) { - $(container).find('.add-share-username').val(''); + var $container = $(container); + $container.find('.add-share-username').val(''); + $container.find('.add-share-field').show(); return; } $(container).remove() @@ -166,6 +168,13 @@ function MentoringTableBlock(runtime, element, initData) { }); $displayDropdown.on('change', function () { + if ($displayDropdown[0].selectedIndex !== 0) { + $shareButton.prop('disabled', true); + $element.find('.report-download-container').hide(); + } else { + $shareButton.prop('disabled', false); + $element.find('.report-download-container').show(); + } $.ajax({ type: "POST", url: tableLoadURL, @@ -174,11 +183,14 @@ function MentoringTableBlock(runtime, element, initData) { }) }); - function addShare(event) { + function addShare() { var container = $newShareContainer.clone(); container.find('.add-share-username').val(''); container.insertAfter($element.find('.new-share-container').last()); - container.find('.add-share-field').on('click', addShare) + container.find('.add-share-field').on('click', addShare); + var buttons = $element.find('.new-share-container .add-share-field'); + buttons.hide(); + buttons.last().show(); } function deleteShare(event) { diff --git a/problem_builder/templates/html/mentoring-table-container.html b/problem_builder/templates/html/mentoring-table-container.html index 482da594..20de8280 100644 --- a/problem_builder/templates/html/mentoring-table-container.html +++ b/problem_builder/templates/html/mentoring-table-container.html @@ -17,7 +17,7 @@