Skip to content
Snippets Groups Projects
Commit f5b8fbae authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Include base components for batch status update

parent 5c52f7f8
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,10 @@ class ProgressSubmissionForm(forms.ModelForm): ...@@ -24,6 +24,10 @@ class ProgressSubmissionForm(forms.ModelForm):
self.should_show = bool(choices) self.should_show = bool(choices)
class BatchProgressSubmissionForm(forms.Form):
action = forms.ChoiceField(label='Take action')
class ScreeningSubmissionForm(forms.ModelForm): class ScreeningSubmissionForm(forms.ModelForm):
class Meta: class Meta:
......
<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>
...@@ -6,14 +6,13 @@ ...@@ -6,14 +6,13 @@
<h4 class="heading heading--normal heading--no-margin">{{ heading }}</h4> <h4 class="heading heading--normal heading--no-margin">{{ heading }}</h4>
{% endif %} {% endif %}
{% if use_batch_actions %} {% if use_batch_actions %}
<div class="actions-bar__inner actions-bar__inner--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> <p class="actions-bar__total"><span class="js-total-actions">0</span> Selected</p>
<form action="" class="js-batch-update-status"> <button data-fancybox data-src="#batch-progress" class="button button--action button--reviewers js-batch-button" type="button">Status</button>
<button class="button button--action button--change-status" type="submit">Change status</button>
</form>
<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> </div>
{% endif %} {% endif %}
</div> </div>
...@@ -53,3 +52,4 @@ ...@@ -53,3 +52,4 @@
</div> </div>
{% include "funds/includes/batch_update_reviewer_form.html" %} {% include "funds/includes/batch_update_reviewer_form.html" %}
{% include "funds/includes/batch_progress_form.html" %}
...@@ -33,6 +33,7 @@ from opentech.apply.utils.views import DelegateableListView, DelegateableView, V ...@@ -33,6 +33,7 @@ from opentech.apply.utils.views import DelegateableListView, DelegateableView, V
from .differ import compare from .differ import compare
from .forms import ( from .forms import (
BatchUpdateReviewersForm, BatchUpdateReviewersForm,
BatchProgressSubmissionForm,
ProgressSubmissionForm, ProgressSubmissionForm,
ScreeningSubmissionForm, ScreeningSubmissionForm,
UpdateReviewersForm, UpdateReviewersForm,
...@@ -127,9 +128,23 @@ class BatchUpdateReviewersView(DelegatedViewMixin, FormView): ...@@ -127,9 +128,23 @@ class BatchUpdateReviewersView(DelegatedViewMixin, FormView):
return super().form_valid(form) 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): class BaseReviewerSubmissionsTable(BaseAdminSubmissionsTable):
table_class = ReviewerSubmissionsTable table_class = ReviewerSubmissionsTable
filterset_class = SubmissionReviewerFilterAndSearch filterset_class = SubmissionReviewerFilterAndSearch
form_views = [
BatchUpdateReviewersView,
BatchProgressSubmissionView,
]
def get_queryset(self): def get_queryset(self):
# Reviewers can only see submissions they have reviewed # Reviewers can only see submissions they have reviewed
...@@ -182,7 +197,8 @@ class SubmissionOverviewView(AllActivityContextMixin, BaseAdminSubmissionsTable) ...@@ -182,7 +197,8 @@ class SubmissionOverviewView(AllActivityContextMixin, BaseAdminSubmissionsTable)
class SubmissionAdminListView(AllActivityContextMixin, BaseAdminSubmissionsTable, DelegateableListView): class SubmissionAdminListView(AllActivityContextMixin, BaseAdminSubmissionsTable, DelegateableListView):
template_name = 'funds/submissions.html' template_name = 'funds/submissions.html'
form_views = [ form_views = [
BatchUpdateReviewersView BatchUpdateReviewersView,
BatchProgressSubmissionView,
] ]
...@@ -199,7 +215,8 @@ class SubmissionListView(ViewDispatcher): ...@@ -199,7 +215,8 @@ class SubmissionListView(ViewDispatcher):
class SubmissionsByRound(AllActivityContextMixin, BaseAdminSubmissionsTable, DelegateableListView): class SubmissionsByRound(AllActivityContextMixin, BaseAdminSubmissionsTable, DelegateableListView):
template_name = 'funds/submissions_by_round.html' template_name = 'funds/submissions_by_round.html'
form_views = [ form_views = [
BatchUpdateReviewersView BatchUpdateReviewersView,
BatchProgressSubmissionView,
] ]
excluded_fields = ('round', 'lead', 'fund') excluded_fields = ('round', 'lead', 'fund')
...@@ -220,9 +237,13 @@ class SubmissionsByRound(AllActivityContextMixin, BaseAdminSubmissionsTable, Del ...@@ -220,9 +237,13 @@ class SubmissionsByRound(AllActivityContextMixin, BaseAdminSubmissionsTable, Del
@method_decorator(staff_required, name='dispatch') @method_decorator(staff_required, name='dispatch')
class SubmissionsByStatus(BaseAdminSubmissionsTable): class SubmissionsByStatus(BaseAdminSubmissionsTable, DelegateableListView):
template_name = 'funds/submissions_by_status.html' template_name = 'funds/submissions_by_status.html'
status_mapping = PHASES_MAPPING status_mapping = PHASES_MAPPING
form_views = [
BatchUpdateReviewersView,
BatchProgressSubmissionView,
]
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.status = kwargs.get('status') self.status = kwargs.get('status')
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
const $body = $('body'); const $body = $('body');
const $checkbox = $('.js-batch-select'); const $checkbox = $('.js-batch-select');
const $allCheckboxInput = $('.js-batch-select-all'); const $allCheckboxInput = $('.js-batch-select-all');
const $batchReviewersButton = $('.js-batch-update-reviewers'); const $batchButtons = $('.js-batch-button');
const $batchTitlesList = $('.js-batch-titles'); const $batchTitlesList = $('.js-batch-titles');
const $batchTitleCount = $('.js-batch-title-count'); const $batchTitleCount = $('.js-batch-title-count');
const $hiddenIDlist = $('#id_submission_ids'); const $hiddenIDlist = $('#id_submission_ids');
...@@ -48,31 +48,33 @@ ...@@ -48,31 +48,33 @@
}); });
// append selected project titles to batch update reviewer modal // append selected project titles to batch update reviewer modal
$batchReviewersButton.click(function () { $batchButtons.each(function () {
$batchTitlesList.html(''); $(this).click(function () {
$batchTitleCount.html(''); $batchTitlesList.html('');
$batchTitlesList.addClass(closedClass); $batchTitleCount.html('');
$toggleBatchList.html('Show'); $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'));
}
});
$batchTitleCount.append(`${selectedIDs.length} submissions selected`); let selectedIDs = [];
$hiddenIDlist.val(selectedIDs.join(','));
$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 // show/hide the list of actions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment