Skip to content

Commit

Permalink
adds improvements to legislation
Browse files Browse the repository at this point in the history
  • Loading branch information
actlikewill committed May 22, 2024
1 parent 43d475c commit 26225e5
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 10 deletions.
26 changes: 19 additions & 7 deletions liiweb/templates/liiweb/legislation_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,31 @@ <h1 class="my-4">{% trans 'Legislation' %}</h1>
<li class="nav-item">
<a class="nav-link {% if view.variant == 'current' %}active{% endif %}"
href="{% url 'legislation_list' %}">
{% trans 'Current legislation' %}
{% block current_tab_title %}
{% trans 'Current legislation' %}
{% endblock %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if view.variant == 'repealed' %}active{% endif %}"
href="{% url 'legislation_list_repealed' %}">
{% trans 'Repealed legislation' %}
<a class="nav-link {% if view.variant == 'subleg' %}active{% endif %}"
href="{% url 'legislation_list_subsidiary' %}">
{% block sublegislation_tab_title %}{{ PEACHJAM_SETTINGS.subleg_label }}{% endblock %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if view.variant == 'subleg' %}active{% endif %}"
href="{% url 'legislation_list_subsidiary' %}">
{{ PEACHJAM_SETTINGS.subleg_label }}
<a class="nav-link {% if view.variant == 'uncommenced' %}active{% endif %}"
href="{% url 'legislation_list_uncommenced' %}">
{% block uncommenced_tab_title %}
{% trans 'Uncommenced legislation' %}
{% endblock %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if view.variant == 'repealed' %}active{% endif %}"
href="{% url 'legislation_list_repealed' %}">
{% block repealed_tab_title %}
{% trans 'Repealed legislation' %}
{% endblock %}
</a>
</li>
<li class="nav-item">
Expand Down
5 changes: 5 additions & 0 deletions liiweb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
views.LegislationListView.as_view(variant="subleg"),
name="legislation_list_subsidiary",
),
path(
"legislation/uncommenced",
views.LegislationListView.as_view(variant="uncommenced"),
name="legislation_list_uncommenced",
),
# This redirects old Ulii case laws to work with peachjam urls
re_path(
r"^(?P<country>[a-z]{2})/judgment/(?P<court>[-\w]+)/(?P<year>\d+)/(?P<number>\d+)$",
Expand Down
2 changes: 2 additions & 0 deletions liiweb/views/legislation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def filter_queryset(self, qs):
qs = qs.exclude(parent_work=None).filter(
repealed=False, metadata_json__principal=True
)
elif self.variant == "uncommenced":
qs = qs.filter(metadata_json__commencement_date=None)
return qs

def get_context_data(self, **kwargs):
Expand Down
71 changes: 71 additions & 0 deletions peachjam/js/components/LegislationTable/Row.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<div
v-for="(row, index) in filteredData"
:key="index"
:class="`table-row legislation-table__row ${
row.children.length ? 'has-children' : ''
}`"
role="button"
@click="handleRowClick"
>
<div
v-if="row.children.length"
class="column-caret indent"
>
<i class="bi bi-caret-right-fill" />
<i class="bi bi-caret-down-fill" />
</div>
<div
v-else
class="indent"
/>
<div class="table-row__content-col">
<div class="content d-flex justify-content-between">
<div class="content__title">
<a :href="`${row.work_frbr_uri}`">{{ row.title }}</a>
<i
v-if="row.languages.length > 1"
class="bi bi-translate ps-2"
:title="$t('Multiple languages available')"
/>
</div>
<div v-if="showDates" class="content__secondary">
{{ row.date }}
</div>
<div v-else class="content__secondary">
{{ row.citation }}
</div>
<div
v-if="row.children.length"
:id="`row-accordion-${index}`"
class="accordion-collapse collapse accordion content__children"
data-bs-parent=".legislation-table__row"
>
<div class="accordion-body p-0">
<div
v-for="(subleg, subleg_index) in row.children"
:key="subleg_index"
class="content mb-3"
>
<div class="content__title">
<a :href="`${subleg.work_frbr_uri}`">{{ subleg.title }}</a>
</div>
<div v-if="showDates" class="content__secondary">
{{ subleg.date }}
</div>
<div v-else class="content__secondary">
{{ subleg.citation }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'LegislationRows',
props: ['filteredData', 'showDates', 'handleRowClick']
};
</script>
50 changes: 47 additions & 3 deletions peachjam/js/components/LegislationTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<div class="table-row legislation-table__row headings">
<div class="indent" />
<div class="table-row__content-col">
<div class="content">
<div class="content d-flex">
<div
class="content__title align-items-center"
role="button"
Expand Down Expand Up @@ -190,31 +190,47 @@
</a>.
</div>
</div>
<div v-if="yearGroups.length" class="legislation-table">
<div v-for="(row, index) in yearGroups" :key="index" class="my-3">
<p class="h5">
{{ row.year }}
</p>
<LegislationRows
class="d-flex"
:filtered-data="row.documents"
:show-dates="showDates"
@handleRowClick="handleRowClick"
/>
</div>
</div>
</div>
</div>
<!-- DOM Hack for i18next to parse facet to locale json. i18next skips t functions in script element -->
<div v-if="false">
{{ $t('Years') }}
{{ $t('Taxonomies') }}
{{ $t('Alphabetical') }}
</div>
</div>
</template>

<script>
import FilterFacets from '../FilterFacets/index.vue';
import LegislationRows from './Row.vue';
import debounce from 'lodash/debounce';
export default {
name: 'LegislationTable',
components: {
FilterFacets
FilterFacets, LegislationRows
},
props: ['showDates'],
data: () => ({
offCanvasFacets: null,
facets: [],
tableData: [],
filteredData: [],
yearGroups: [],
lockAccordion: false,
q: '',
windowWith: window.innerWidth,
Expand All @@ -227,13 +243,15 @@ export default {
watch: {
q () {
this.filterData();
this.groupByYear();
},
sortableFields () {
this.filterData();
},
facets () {
this.offCanvasFacets.hide();
this.filterData();
this.groupByYear();
}
},
beforeUnmount () {
Expand All @@ -250,6 +268,7 @@ export default {
const tableJsonElement = document.getElementById('legislation-table');
this.tableData = JSON.parse(tableJsonElement.textContent);
this.filterData();
this.groupByYear();
this.setFacets();
},
Expand Down Expand Up @@ -310,8 +329,18 @@ export default {
taxonomyOptions.sort((a, b) => a.value.localeCompare(b.value));
// Sort descending
yearsOptions.sort((a, b) => b.value - a.value);
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('').map(letter => ({
label: letter.toUpperCase(),
value: letter
}));
this.facets = [
{
title: this.$t('Alphabetical'),
name: 'alphabetical',
type: 'letter-radio',
value: [],
options: alphabet
},
{
title: this.$t('Years'),
name: 'year',
Expand Down Expand Up @@ -367,6 +396,9 @@ export default {
});
Object.keys(facetDict).forEach((key) => {
data = data.filter((item) => {
if (key === 'alphabetical') {
return item.title.toLowerCase().startsWith(facetDict[key]);
}
if (Array.isArray(facetDict[key])) {
const arr1 = facetDict[key].map((x) => String(x));
const arr2 = item[key].map((x) => String(x));
Expand All @@ -391,6 +423,18 @@ export default {
}
});
this.filteredData = data;
},
groupByYear () {
const yearGroup = this.filteredData.reduce((acc, item) => {
let year = acc.find((group) => group.year === item.year);
if (!year) {
year = { year: item.year, documents: [] };
acc.push(year);
}
year.documents.push(item);
return acc;
}, []);
this.yearGroups = yearGroup.sort((a, b) => b.year - a.year);
}
}
};
Expand Down
24 changes: 24 additions & 0 deletions peachjam/templates/peachjam/judgment_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
{% extends 'peachjam/layouts/document_detail.html' %}
{% load i18n %}
{% block breadcrumbs %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'judgment_list' %}">{% trans 'Judgments' %}</a>
</li>
{% if document.court.court_class.show_listing_page %}
<li class="breadcrumb-item">
<a href="{% url 'court_class' document.court.court_class.slug %}">{{ document.court.court_class.name }}</a>
</li>
{% endif %}
{% if document.court %}
<li class="breadcrumb-item">
<a href="{% url 'court' document.court.code %}">{{ document.court.name }}</a>
</li>
{% endif %}
{% if document.registry %}
<li class="breadcrumb-item">
<a href="{% url 'court_registry' document.court.code document.registry.code %}">{{ document.registry.name }}</a>
</li>
{% endif %}
</ol>
</nav>
{% endblock %}
{% block document-metadata-content-citation %}
{{ block.super }}
{% if document.mnc %}
Expand Down
1 change: 1 addition & 0 deletions peachjam/templates/peachjam/layouts/document_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<div class="d-md-flex justify-content-md-between py-4">
<div>
<h1>{{ document.title }}</h1>
{% block sub-title %}{% endblock %}
{% include 'peachjam/_labels.html' %}
</div>
<div class="d-flex align-items-center">
Expand Down

0 comments on commit 26225e5

Please sign in to comment.