diff --git a/opentech/apply/funds/forms.py b/opentech/apply/funds/forms.py index 0a71b92e8892a8f0e27251e79c5abb814e7595d5..f1c21b703159c35667ac8d966f8cb70af4fe349d 100644 --- a/opentech/apply/funds/forms.py +++ b/opentech/apply/funds/forms.py @@ -24,6 +24,10 @@ class ProgressSubmissionForm(forms.ModelForm): self.should_show = bool(choices) +class BatchProgressSubmissionForm(forms.Form): + action = forms.ChoiceField(label='Take action') + + class ScreeningSubmissionForm(forms.ModelForm): class Meta: diff --git a/opentech/apply/funds/templates/funds/includes/batch_progress_form.html b/opentech/apply/funds/templates/funds/includes/batch_progress_form.html new file mode 100644 index 0000000000000000000000000000000000000000..20943a97776d577586d9301ee0d8d8d591a0516f --- /dev/null +++ b/opentech/apply/funds/templates/funds/includes/batch_progress_form.html @@ -0,0 +1,9 @@ +<div class="modal modal--secondary" id="batch-progress"> + <h4 class="modal__header-bar">Update Status</h4> + <div class="modal__list-item modal__list-item--meta" aria-live="polite"> + <span class="js-batch-title-count"></span> + <a href="#" class="modal__hide-link js-toggle-batch-list">Show</a> + </div> + <div class="modal__list js-batch-titles is-closed" aria-live="polite"></div> + {% include 'funds/includes/delegated_form_base.html' with form=batch_progress_form value='Update'%} +</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 ba2f54d0b562e7ae0d35414fdbbda299eb7e45d8..ce03ee52519671e430f0d13ef509a156a965c518 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 @@ -6,14 +6,13 @@ <h4 class="heading heading--normal heading--no-margin">{{ heading }}</h4> {% endif %} + {% if use_batch_actions %} <div class="actions-bar__inner actions-bar__inner--batch-actions"> <p class="actions-bar__total"><span class="js-total-actions">0</span> Selected</p> - <form action="" class="js-batch-update-status"> - <button class="button button--action button--change-status" type="submit">Change status</button> - </form> + <button data-fancybox data-src="#batch-progress" class="button button--action button--reviewers js-batch-button" type="button">Status</button> - <button data-fancybox data-src="#batch-update-reviewers" class="button button--action button--reviewers js-batch-update-reviewers" type="button">Reviewers</button> + <button data-fancybox data-src="#batch-update-reviewers" class="button button--action button--reviewers js-batch-button" type="button">Reviewers</button> </div> {% endif %} </div> @@ -53,3 +52,4 @@ </div> {% include "funds/includes/batch_update_reviewer_form.html" %} +{% include "funds/includes/batch_progress_form.html" %} diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index bff504909e79e9fb2c3900294a85e579af155782..8f1dd9e1cded3c27530a4c345ee08f87d2493b91 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -33,6 +33,7 @@ from opentech.apply.utils.views import DelegateableListView, DelegateableView, V from .differ import compare from .forms import ( BatchUpdateReviewersForm, + BatchProgressSubmissionForm, ProgressSubmissionForm, ScreeningSubmissionForm, UpdateReviewersForm, @@ -127,9 +128,23 @@ class BatchUpdateReviewersView(DelegatedViewMixin, FormView): return super().form_valid(form) +@method_decorator(staff_required, name='dispatch') +class BatchProgressSubmissionView(DelegatedViewMixin, FormView): + form_class = BatchProgressSubmissionForm + context_name = 'batch_progress_form' + + def form_valid(self, form): + print('wooooop') + return super().form_valid(form) + + class BaseReviewerSubmissionsTable(BaseAdminSubmissionsTable): table_class = ReviewerSubmissionsTable filterset_class = SubmissionReviewerFilterAndSearch + form_views = [ + BatchUpdateReviewersView, + BatchProgressSubmissionView, + ] def get_queryset(self): # Reviewers can only see submissions they have reviewed @@ -182,7 +197,8 @@ class SubmissionOverviewView(AllActivityContextMixin, BaseAdminSubmissionsTable) class SubmissionAdminListView(AllActivityContextMixin, BaseAdminSubmissionsTable, DelegateableListView): template_name = 'funds/submissions.html' form_views = [ - BatchUpdateReviewersView + BatchUpdateReviewersView, + BatchProgressSubmissionView, ] @@ -199,7 +215,8 @@ class SubmissionListView(ViewDispatcher): class SubmissionsByRound(AllActivityContextMixin, BaseAdminSubmissionsTable, DelegateableListView): template_name = 'funds/submissions_by_round.html' form_views = [ - BatchUpdateReviewersView + BatchUpdateReviewersView, + BatchProgressSubmissionView, ] excluded_fields = ('round', 'lead', 'fund') @@ -220,9 +237,13 @@ class SubmissionsByRound(AllActivityContextMixin, BaseAdminSubmissionsTable, Del @method_decorator(staff_required, name='dispatch') -class SubmissionsByStatus(BaseAdminSubmissionsTable): +class SubmissionsByStatus(BaseAdminSubmissionsTable, DelegateableListView): template_name = 'funds/submissions_by_status.html' status_mapping = PHASES_MAPPING + form_views = [ + BatchUpdateReviewersView, + BatchProgressSubmissionView, + ] def get(self, request, *args, **kwargs): self.status = kwargs.get('status') diff --git a/opentech/static_src/src/javascript/apply/batch-actions.js b/opentech/static_src/src/javascript/apply/batch-actions.js index 6d2af16f8d6269e0b28086a1440e76f8f18a2fab..64c310378d7de5b116b06b8cc95c97295f5b08f9 100644 --- a/opentech/static_src/src/javascript/apply/batch-actions.js +++ b/opentech/static_src/src/javascript/apply/batch-actions.js @@ -5,7 +5,7 @@ const $body = $('body'); const $checkbox = $('.js-batch-select'); const $allCheckboxInput = $('.js-batch-select-all'); - const $batchReviewersButton = $('.js-batch-update-reviewers'); + const $batchButtons = $('.js-batch-button'); const $batchTitlesList = $('.js-batch-titles'); const $batchTitleCount = $('.js-batch-title-count'); const $hiddenIDlist = $('#id_submission_ids'); @@ -48,31 +48,33 @@ }); // append selected project titles to batch update reviewer modal - $batchReviewersButton.click(function () { - $batchTitlesList.html(''); - $batchTitleCount.html(''); - $batchTitlesList.addClass(closedClass); - $toggleBatchList.html('Show'); - - let selectedIDs = []; - - $checkbox.each(function () { - if ($(this).is(':checked')) { - const href = $(this).parents('tr').find('.js-title').find('a').attr('href'); - const title = $(this).parents('tr').find('.js-title').data('tooltip'); - - $batchTitlesList.append(` - <a href="${href}" class="modal__list-item" target="_blank" rel="noopener noreferrer" title="${title}"> - ${title} - <svg class="modal__open-link-icon"><use xlink:href="#open-in-new-tab"></use></svg> - </a> - `); - selectedIDs.push($(this).parents('tr').data('record-id')); - } - }); + $batchButtons.each(function () { + $(this).click(function () { + $batchTitlesList.html(''); + $batchTitleCount.html(''); + $batchTitlesList.addClass(closedClass); + $toggleBatchList.html('Show'); - $batchTitleCount.append(`${selectedIDs.length} submissions selected`); - $hiddenIDlist.val(selectedIDs.join(',')); + let selectedIDs = []; + + $checkbox.each(function () { + if ($(this).is(':checked')) { + const href = $(this).parents('tr').find('.js-title').find('a').attr('href'); + const title = $(this).parents('tr').find('.js-title').data('tooltip'); + + $batchTitlesList.append(` + <a href="${href}" class="modal__list-item" target="_blank" rel="noopener noreferrer" title="${title}"> + ${title} + <svg class="modal__open-link-icon"><use xlink:href="#open-in-new-tab"></use></svg> + </a> + `); + selectedIDs.push($(this).parents('tr').data('record-id')); + } + }); + + $batchTitleCount.append(`${selectedIDs.length} submissions selected`); + $hiddenIDlist.val(selectedIDs.join(',')); + }); }); // show/hide the list of actions