Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwood committed Sep 16, 2024
1 parent a397807 commit 23cb422
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 46 deletions.
3 changes: 2 additions & 1 deletion grantnav/csv_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
("Funding Org: Org Type (additional data)", "result.additional_data.TSGFundingOrgType"),
("Funding Org: Canonical Org ID (additional data)", "result.additional_data.GNCanonicalFundingOrgId"),
("Funding Org: Canonical Name (additional data)", "result.additional_data.GNCanonicalFundingOrgName"),
("Type of Recipient", "result.additional_data.TSGRecipientType"),
("Recipient Org: Date Registered (additional data)", "result.additional_data.recipientOrgInfos.0.dateRegistered"),
("Recipient Org: Date Removed (additional data)", "result.additional_data.recipientOrgInfos.0.dateRemoved"),
("Recipient Org: Org ID(s) (additional data)", "result.additional_data.recipientOrgInfos.0.orgIDs"),
Expand All @@ -126,7 +127,7 @@

# These two always need to be on the end
("#comment License (see note)", "dataset.license"),
("#comment See http://grantnav.threesixtygiving.org/datasets/ for license information.", ""),
("#comment See http://grantnav.threesixtygiving.org/datasets/ for further license information.", ""),
])

grant_csv_titles = list(grants_csv.keys())
Expand Down
95 changes: 51 additions & 44 deletions grantnav/frontend/templates/components/field-chooser-listbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,67 +129,74 @@ <h4 class="margin-top:1 margin-bottom:1">2. Download the results</h4>

<script id="recommended-fields-list" type="application/json">
[
"result.id",
"result.title",
"result.description",
"result.currency",
"result.amountAppliedFor",
"result.amountAwarded",
"result.amountDisbursed",
"result.awardDateDateOnly",
"result.recipientOrganization.0.url",
"result.plannedDates.0.startDateDateOnly",
"result.plannedDates.0.endDateDateOnly",
"result.plannedDates.0.duration",
"result.actualDates.0.startDate",
"result.actualDates.0.endDateDateOnly",
"result.actualDates.0.duration",
"result.recipientOrganization.0.id",
"result.recipientOrganization.0.name",
"result.recipientOrganization.0.charityNumber",
"result.recipientOrganization.0.companyNumber",
"result.recipientOrganization.0.postalCode",
"result.recipientOrganization.0.location.0.geoCodeType",
"result.recipientOrganization.0.location.0.geoCode",
"result.recipientOrganization.0.location.0.name",
"result.fundingOrganization.0.id",
"result.fundingOrganization.0.name",
"result.fundingOrganization.0.postalCode",
"result.grantProgramme.0.code",
"result.grantProgramme.0.title",
"result.grantProgramme.0.url",
"result.fundingType.0.title",
"result.beneficiaryLocation.0.name",
"result.beneficiaryLocation.0.countryCode",
"result.beneficiaryLocation.0.geoCode",
"result.beneficiaryLocation.0.geoCodeType",
"result.fromOpenCall"
"result.id",
"result.title",
"result.description",
"result.currency",
"result.amountAwarded",
"result.awardDateDateOnly",

"result.plannedDates.0.startDateDateOnly",
"result.plannedDates.0.endDateDateOnly",
"result.plannedDates.0.duration",

"result.grantProgramme.0.code",
"result.grantProgramme.0.title",
"result.grantProgramme.0.url",

"result.recipientOrganization.0.id",
"result.recipientOrganization.0.name",
"result.recipientOrganization.0.charityNumber",
"result.recipientOrganization.0.companyNumber",
"result.recipientOrganization.0.postalCode",
"result.recipientOrganization.0.location.0.name",
"result.recipientOrganization.0.location.0.geoCodeType",
"result.recipientOrganization.0.location.0.geoCode",

"result.fundingOrganization.0.id",
"result.fundingOrganization.0.name",

"result.dateModified",

"result.additional_data.recipientRegionName",
"result.additional_data.recipientDistrictName",
"result.additional_data.TSGFundingOrgType",
"result.additional_data.TSGRecipientType",
"result.simple_grant_type",
"result.additional_data.recipientOrgInfos.organisationTypePrimary",
"result.additional_data.GNRecipientOrgRegionName",
"result.additional_data.GNRecipientOrgDistrictName",
"result.additional_data.GNBeneficiaryRegionName",
"result.additional_data.GNBeneficiaryDistrictName",
"result.additional_data.GNBeneficiaryCountyName",
"result.additional_data.GNRecipientOrgCountyName",
"result.additional_data.GNBestCountyName"
]
</script>

<script>
class GNSelected extends Array {
constructor(btn) {
constructor (btn) {
super();
this.btn = btn;
}

clear() {
clear () {
this.length = 0;
this._updateDom();
}

add(item) {
add (item) {
this.push(item);
this._updateDom();
}

remove(item) {
remove (item) {
this.pop(item);
this._updateDom();
}

_updateDom() {
_updateDom () {
this.btn.setAttribute('aria-disabled', this.length === 0);
if (this.length > 0) {
this.btn.getElementsByClassName('dl-selected-counter')[0].innerText = `(${this.length})`;
Expand All @@ -200,7 +207,7 @@ <h4 class="margin-top:1 margin-bottom:1">2. Download the results</h4>
}

class GNListBox {
constructor() {
constructor () {
this.addBtn = document.getElementById('dl-add-fields-btn');
this.addAllBtn = document.getElementById('dl-add-all-fields-btn');
this.clearBtn = document.getElementById('dl-clear-fields-btn');
Expand All @@ -219,7 +226,7 @@ <h4 class="margin-top:1 margin-bottom:1">2. Download the results</h4>
}

/* Filters the list of available fields */
filterCheckboxes(event) {
filterCheckboxes (event) {
const inputText = event.srcElement.value;
const checkboxes = document.querySelectorAll('.field-select');

Expand Down Expand Up @@ -256,12 +263,12 @@ <h4 class="margin-top:1 margin-bottom:1">2. Download the results</h4>
}
}

removeItemToRemove(item) {
removeItemToRemove (item) {
this.toRemove.add(item);
this.removeBtn.setAttribute('aria-disabled', this.toRemove.length === 0);
}

select(event) {
select (event) {
const item = event.srcElement;

/* if already selected then toggle this off / remove from selection */
Expand Down
2 changes: 1 addition & 1 deletion grantnav/frontend/user_csv_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def process(request):

return views.grants_csv_paged(
json.loads(request.POST.get("json_query", {})),
grant_csv_titles=[item["column_title"] for item in fields],
grant_csv_titles=[item["column_title"] for item in fields] + grant_csv_titles[-2:],
grant_csv_paths=[item["path"] for item in fields],
)

0 comments on commit 23cb422

Please sign in to comment.