Skip to content

Commit

Permalink
subleg padding and sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed May 31, 2024
1 parent 69e672b commit e70baa3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
18 changes: 12 additions & 6 deletions peachjam/js/components/LegislationTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,10 @@ export default {
const sortAsc = this.sort[0] !== '-';
const sortKey = sortAsc ? this.sort : this.sort.substring(1);
data.sort((a, b) => {
const fa = a[sortKey] ? a[sortKey].toLowerCase() : '';
const fb = b[sortKey] ? b[sortKey].toLowerCase() : '';
// year is the exception that we want to sort desc by default
return fa.localeCompare(fb) * (sortAsc ? 1 : -1) * (sortKey === 'year' ? -1 : 1);
});
this.sortRows(data, sortKey, sortAsc);
for (const item of data) {
this.sortRows(item.children, sortKey, sortAsc);
}
this.filteredData = data;
this.rows = [];
Expand Down Expand Up @@ -344,6 +342,14 @@ export default {
}
this.rows.push(record);
});
},
sortRows (rows, sortKey, sortAsc) {
rows.sort((a, b) => {
const fa = a[sortKey] ? a[sortKey].toLowerCase() : '';
const fb = b[sortKey] ? b[sortKey].toLowerCase() : '';
// year is the exception that we want to sort desc by default
return fa.localeCompare(fb) * (sortAsc ? 1 : -1) * (sortKey === 'year' ? -1 : 1);
});
}
}
};
Expand Down
20 changes: 16 additions & 4 deletions peachjam/static/stylesheets/components/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
}

.doc-table-children {
.doc-table-row {
// extra initial padding for child rows
grid-template-columns: 30px repeat(12, 1fr);
.cell-title {
padding-left: 20px;
}
}

Expand All @@ -55,8 +54,21 @@
.cell-date {
grid-column: span 2;
}
}

@include media-breakpoint-down(md) {
.doc-table-children {
.cell-title {
padding-left: 0px;
}

.doc-table-row {
// extra initial padding for child rows
grid-template-columns: 30px repeat(12, 1fr);
}
}

@include media-breakpoint-down(md) {
&.doc-table-title-subtitle-date {
.doc-table-head {
.cell-subtitle,
.cell-date {
Expand Down
9 changes: 7 additions & 2 deletions peachjam_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ class Meta:


class ChildLegislationSerializer(serializers.ModelSerializer):
year = serializers.SerializerMethodField("get_year")

class Meta:
model = Legislation
fields = ("title", "citation", "work_frbr_uri", "repealed", "date")
fields = ("title", "citation", "work_frbr_uri", "repealed", "year")

def get_year(self, instance):
"""Use the FRBR work uri, rather than the document year."""
return instance.frbr_uri_date.split("-")[0]


class LegislationSerializer(serializers.ModelSerializer):
Expand All @@ -91,7 +97,6 @@ class Meta:
"title",
"children",
"citation",
"date",
"work_frbr_uri",
"repealed",
"year",
Expand Down

0 comments on commit e70baa3

Please sign in to comment.