From d68b06823a4c6e00d3b8b25ca9b2530011cbd88d Mon Sep 17 00:00:00 2001 From: Chris Lawton <chris.lawton@torchbox.com> Date: Tue, 22 Jan 2019 17:27:26 +0000 Subject: [PATCH] adds batch reviewer form modal and append selected project titles to it --- .../funds/base_submissions_table.html | 3 +++ .../includes/batch_update_reviewer_form.html | 5 +++++ .../includes/table_filter_and_search.html | 6 +++--- .../src/javascript/apply/batch-actions.js | 20 ++++++++++++------- .../sass/apply/components/_actions-bar.scss | 7 +++++-- 5 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 opentech/apply/funds/templates/funds/includes/batch_update_reviewer_form.html diff --git a/opentech/apply/funds/templates/funds/base_submissions_table.html b/opentech/apply/funds/templates/funds/base_submissions_table.html index e9296c842..322a4dca5 100644 --- a/opentech/apply/funds/templates/funds/base_submissions_table.html +++ b/opentech/apply/funds/templates/funds/base_submissions_table.html @@ -3,6 +3,7 @@ {% load render_table from django_tables2 %} {% block extra_css %} +<link rel="stylesheet" href="{% static 'css/apply/fancybox.css' %}"> {{ filter.form.media.css }} {% endblock %} @@ -16,6 +17,8 @@ {% block extra_js %} {{ filter.form.media.js }} + <script src="//cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.1/jquery.fancybox.min.js"></script> + <script src="{% static 'js/apply/fancybox-global.js' %}"></script> <script src="{% static 'js/apply/all-submissions-table.js' %}"></script> <script src="https://cdn.jsdelivr.net/npm/symbol-es6@0.1.2/symbol-es6.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/url-search-params/1.1.0/url-search-params.js"></script> diff --git a/opentech/apply/funds/templates/funds/includes/batch_update_reviewer_form.html b/opentech/apply/funds/templates/funds/includes/batch_update_reviewer_form.html new file mode 100644 index 000000000..cd6583cda --- /dev/null +++ b/opentech/apply/funds/templates/funds/includes/batch_update_reviewer_form.html @@ -0,0 +1,5 @@ +<div class="modal" id="batch-update-reviewers"> + <h4>Update Reviewers</h4> + <div class="js-batch-titles"></div> + {# insert form here #} +</div> diff --git a/opentech/apply/funds/templates/funds/includes/table_filter_and_search.html b/opentech/apply/funds/templates/funds/includes/table_filter_and_search.html index 390d8dc09..7edcad183 100644 --- a/opentech/apply/funds/templates/funds/includes/table_filter_and_search.html +++ b/opentech/apply/funds/templates/funds/includes/table_filter_and_search.html @@ -7,9 +7,7 @@ <button class="button button--action button--change-status" type="submit">Change status</button> </form> - <form action="" class="js-batch-update-reviewers"> - <button class="button button--action button--reviewers" type="submit">Reviewers</button> - </form> + <button data-fancybox data-src="#batch-update-reviewers" class="button button--action button--reviewers js-batch-update-reviewers" type="submit">Reviewers</button> </div> {# Right #} @@ -45,3 +43,5 @@ </ul> </form> </div> + +{% include "funds/includes/batch_update_reviewer_form.html" %} diff --git a/opentech/static_src/src/javascript/apply/batch-actions.js b/opentech/static_src/src/javascript/apply/batch-actions.js index 9b0f95c89..f86d49f94 100644 --- a/opentech/static_src/src/javascript/apply/batch-actions.js +++ b/opentech/static_src/src/javascript/apply/batch-actions.js @@ -6,7 +6,8 @@ const $checkbox = $('.js-batch-select'); const $allCheckboxInput = $('.js-batch-select-all'); const $changeStatusForm = $('.js-batch-update-status'); - const $changeReviewersForm = $('.js-batch-update-reviewers'); + const $batchReviewersButton = $('.js-batch-update-reviewers'); + const $batchTitles = $('.js-batch-titles'); const activeClass = 'batch-actions-enabled'; $allCheckboxInput.change(function () { @@ -38,6 +39,17 @@ } }); + // append selected project titles to batch update reviewer modal + $batchReviewersButton.click(function () { + $batchTitles.html(''); + + $checkbox.each(function () { + if ($(this).is(':checked')) { + $batchTitles.append(`<p>${$(this).parents('tr').find('.js-title').data('tooltip')}</p>`); + } + }); + }); + function toggleBatchActions() { if ($('.js-batch-select:checked').length) { $body.addClass(activeClass); @@ -66,10 +78,4 @@ } }); }); - - // reviewers form handler - $changeReviewersForm.submit(function (e) { - e.preventDefault(); - console.log('reviewers form submitted'); - }); })(jQuery); diff --git a/opentech/static_src/src/sass/apply/components/_actions-bar.scss b/opentech/static_src/src/sass/apply/components/_actions-bar.scss index 027d6b1ed..07bc37235 100644 --- a/opentech/static_src/src/sass/apply/components/_actions-bar.scss +++ b/opentech/static_src/src/sass/apply/components/_actions-bar.scss @@ -16,8 +16,11 @@ align-items: center; & > * { - padding-left: 20px; - margin: 0; + margin: 0 0 0 20px; + + &:first-child { + margin-left: 0; + } } } -- GitLab