Skip to content

Commit

Permalink
Change display of strong/weak votes.
Browse files Browse the repository at this point in the history
Fixes #1744.
  • Loading branch information
dracos committed Dec 14, 2023
1 parent e5f4893 commit cfeb1e8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 58 deletions.
6 changes: 1 addition & 5 deletions classes/Divisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@ private function divisionsByPolicy($q) {
if ( !array_key_exists($policy_id, $policies) ) {
$policies[$policy_id] = array(
'policy_id' => $policy_id,
'weak_count' => 0,
'divisions' => array()
);
if ( $this->policies ) {
Expand All @@ -633,12 +632,9 @@ private function divisionsByPolicy($q) {
}
}


$division = $this->getDivisionDetails($row);

if ( !$division['strong'] ) {
$policies[$policy_id]['weak_count']++;
}

$policies[$policy_id]['divisions'][] = $division;
};

Expand Down
6 changes: 0 additions & 6 deletions www/docs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,6 @@ $(function(){
t.parent().next(".nav-menu").toggleClass('closed');
});

$('.js-show-all-votes').on('click', function(){
$(this).fadeOut();
$('.policy-vote--minor').slideDown();
$('#policy-votes-type').text('All');
});

$('a[href="#past-list-dates"]').on('click', function(e){
e.preventDefault();
$(this).trigger('blur');
Expand Down
28 changes: 0 additions & 28 deletions www/docs/style/sass/pages/_mp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -610,26 +610,6 @@
}
}

html.js {
.policy-vote--minor {
display: none;
}
}

.policy-vote--minor {
padding-left: 1.5em;
line-height: 1.3em !important; // override .vote-descriptions .policy-votes > li

.policy-vote__text,
.policy-vote__date {
font-size: 0.9em;
}

.policy-vote__text {
color: #666;
}
}

.policy-vote__date {
display: block;
color: #b5af9d; // desaturated taupe colour
Expand Down Expand Up @@ -709,14 +689,6 @@ html.js {
margin-bottom: 0;
}
}

.js-show-all-votes {
display: none;
}
}

html.js .policy-votes-list-footer .js-show-all-votes {
display: block;
}

.voting-information-provenance {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<li id="<?= $division['division_id'] ?>" class="<?= $show_all || $division['strong'] ? 'policy-vote--major' : 'policy-vote--minor' ?>">
<li id="<?= $division['division_id'] ?>">
<span class="policy-vote__date">On <?= strftime('%e %b %Y', strtotime($division['date'])) ?>:</span>
<span class="policy-vote__text"><?= $full_name ?><?= $division['text'] ?></span>
<?php if ($division['date'] > '2020-06-01' && $division['date'] < '2020-06-10' && $division['vote'] == 'absent') { ?>
Expand Down
52 changes: 35 additions & 17 deletions www/includes/easyparliament/templates/html/mp/divisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,31 @@
<?php endif; ?>

<?php $displayed_votes = false; ?>
<?php if ( isset($policydivisions) && $policydivisions ) { ?>

<?php if ($has_voting_record) { ?>
<?php
# $policydivisions contains all the relevant divisions for this MP
# $has_voting_record is true if the MP has voted on any policy
if (isset($policydivisions) && $policydivisions && $has_voting_record) {
# for some historical reason, the divisions page actually
# does all divisions, but generally this is an array of one
# (the current policy)
foreach ($policydivisions as $policy) { ?>

<?php foreach ($policydivisions as $policy) { ?>
<?php
$show_all = false;
if ( $policy['weak_count'] == 0 || $policy['weak_count'] == count($policy['divisions']) ) {
$show_all = true;
$divisions_scoring = [];
$divisions_informative = [];
foreach ($policy['divisions'] as $division) {
if ($division['strong']) {
$divisions_scoring[] = $division;
} else {
$divisions_informative[] = $division;
}
}
?>

<?php if ( isset($policy['header']) ) { ?>
<?php
# a header dict is used to give human information about the specific policy
if ( isset($policy['header']) ) { ?>
<div class="panel policy-votes-hero" style="background-image: url('<?php echo $policy['header']['image']; ?>');">
<h2><?php echo $policy['header']['title']; ?></h2>
<p><?php echo $policy['header']['description']; ?>.</p>
Expand All @@ -69,8 +81,9 @@
</div>
<?php } ?>


<?php if ( isset($policy['position']) ) { ?>
<?php
# display the calculated position for the policy on this page
if ( isset($policy['position']) ) { ?>
<div class="panel">
<?php if ( $policy['position']['has_strong'] ) { ?>
<h3 class="policy-vote-overall-stance">
Expand All @@ -84,9 +97,6 @@
data on PublicWhip.org.uk</a>.
</p>

<h3 class="policy-votes-list-header"><span id="policy-votes-type"><?=
$show_all ? 'All' : 'Key';
?></span> votes about <?= $policy['desc'] ?>:</h3>
<?php } else { ?>
<h3 class="policy-vote-overall-stance">
We don&rsquo;t have enough information to calculate <?= $full_name ?>&rsquo;s position on this issue
Expand All @@ -97,17 +107,26 @@
</p>
<?php } ?>

<?php if ($divisions_scoring) { ?>
<h3 class="policy-votes-list-header">Scoring votes</h3>
<ul class="vote-descriptions policy-votes">
<?php foreach ($policy['divisions'] as $division) {
<?php foreach ($divisions_scoring as $division) {
include('_division_description.php');
$displayed_votes = true;
} ?>
</ul>
<?php } ?>
<?php if ($divisions_informative) { ?>
<h3 class="policy-votes-list-header">Informative votes</h3>
<ul class="vote-descriptions policy-votes">
<?php foreach ($divisions_informative as $division) {
include('_division_description.php');
$displayed_votes = true;
} ?>
</ul>
<?php } ?>

<div class="policy-votes-list-footer">
<?php if ( !$show_all && $policy['weak_count'] > 0 ) { ?>
<p><button class="button secondary-button small js-show-all-votes">Show all votes, including <?= $policy['weak_count'] ?> less important <?= $policy['weak_count'] == 1 ? 'vote' : 'votes' ?></button></p>
<?php } ?>
<p class="voting-information-provenance">
Vote information from <a href="https://www.publicwhip.org.uk/mp.php?mpid=<?= $member_id ?>&amp;dmp=<?= $policy['policy_id'] ?>">PublicWhip</a>.
Last updated: <?= $policy_last_update[$policy['policy_id']] ?>.
Expand All @@ -117,7 +136,6 @@

</div>
<?php } ?>
<?php } ?>
<?php } ?>

<?php } ?>
Expand Down
1 change: 0 additions & 1 deletion www/includes/easyparliament/templates/html/mp/recent.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<?php

$displayed_votes = false;
$show_all = true;
$current_date = '';
$sidebar_links = array();

Expand Down

0 comments on commit cfeb1e8

Please sign in to comment.