Skip to content

Commit 11bab71

Browse files
committed
Add counter as requested
1 parent 2ed3ba0 commit 11bab71

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/onegov/pas/assets/js/custom.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
document.addEventListener("DOMContentLoaded", function () {
22
handleBulkAddCommission();
33
handleAttendanceFormSync();
4+
handleParliamentarianCounter();
45
});
56

67

@@ -115,6 +116,31 @@ function handleBulkAddCommission() {
115116
}
116117

117118

119+
function handleParliamentarianCounter() {
120+
if (!window.location.href.includes('/new-bulk')) {
121+
return;
122+
}
123+
124+
var $list = $('#parliamentarian_id');
125+
if (!$list.length || !$list.is('ul')) {
126+
return;
127+
}
128+
129+
var $counter = $('<li><strong></strong></li>');
130+
$list.prepend($counter);
131+
132+
function update() {
133+
var $boxes = $list.find("input[type='checkbox']");
134+
var total = $boxes.length;
135+
var checked = $boxes.filter(':checked').length;
136+
$counter.find('strong').text(checked + ' / ' + total);
137+
}
138+
139+
update();
140+
$list.on('change', 'input[type="checkbox"]', update);
141+
}
142+
143+
118144
function handleAttendanceFormSync() {
119145
// Pre-restrict interdependent dropdown values to prevent invalid
120146
// combinations. When a user selects a commission or parliamentarian,

src/onegov/pas/views/attendence.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ def add_plenary_attendence(self: AttendenceCollection,
514514
request: PasRequest,
515515
form: AttendenceAddPlenaryForm
516516
) -> RenderData | Response:
517+
request.include('custom')
517518

518519
if not request.is_admin:
519520
request.alert(_('You do not have permission to add plenary sessions.'))

0 commit comments

Comments
 (0)