Skip to content

Commit

Permalink
Merge pull request #7 from StadGent/fix/status-display
Browse files Browse the repository at this point in the history
fix filtering on status and make sure status is always set
  • Loading branch information
razoreater authored Sep 26, 2024
2 parents 24ddec8 + 09cb1ee commit b4f0abb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
31 changes: 26 additions & 5 deletions webcomponents/besluiten-detail/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,30 @@ class BesluitenDetail extends HTMLElement {
this.datum = this.formatDate(this.getAttribute('datum'));
this.url = this.getAttribute('url');
this.status = this.getAttribute('status');
this.status_green = ['Aanvaard tot de zitting als hoogdringend agendapunt', 'Goedgekeurd', 'Behandeld'].includes(this.getAttribute('status'));;
this.status_red = ['Afgekeurd', 'Afgevoerd', 'Geweigerd', 'Ingetrokken'].includes(this.getAttribute('status'));;
this.status_na = ['Gedeeltelijke ingetrokken', 'Verdaagd'].includes(this.getAttribute('status'));;
switch(this.status) {
case 'Aanvaard tot de zitting als hoogdringend agendapunt':
case 'Goedgekeurd':
case 'Behandeld':
this.status_color = 'true';
break;
case 'Afgekeurd':
case 'Afgevoerd':
case 'Geweigerd':
case 'Ingetrokken':
this.status_color = 'false';
break;
case 'Gedeeltelijk ingetrokken':
case 'Verdaagd':
this.status_color = 'void';
break;
case '':
this.status_color = 'void';
this.status = 'Onbekend';
break;
default:
this.status_color = 'void';
break;
}
this.innerHTML += this.createDetail();
}
}
Expand All @@ -37,7 +58,7 @@ class BesluitenDetail extends HTMLElement {
<dt>Datum van de zitting:</dt>
<dd>${this.datum}</dd>
</dl>
<span class="resolutions-detail__status resolutions-detail__status--${this.status_green ? 'true' : this.status_red ? 'false' : 'void'}" >${this.status}</span>
<span class="resolutions-detail__status resolutions-detail__status--${this.status_color}" >${this.status}</span>
</div>
<a href="${this.url}" class="teaser-overlay-link" tabindex="-1" aria-hidden="true">${this.titel}</a>
</div>
Expand All @@ -47,7 +68,7 @@ class BesluitenDetail extends HTMLElement {
renderResults(besluit) {
this.titel = besluit.title.value;
this.orgaan = '@todo';
this.datum = this.formatDate(besluit.date.value)
this.datum = this.formatDate(besluit.date.value);
this.url = besluit.url.value;
this.status = besluit.status.value || '';
this.approved = besluit.status.value == 'Goedgekeurd';
Expand Down
23 changes: 12 additions & 11 deletions webcomponents/besluiten-lijst/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BesluitenLijst extends HTMLElement {

let list = "";
besluiten.forEach(besluit => {
list += this.createDetail(besluit)
list += this.createDetail(besluit);
});

this.shadowRoot.querySelectorAll(".js-resolutions-items")[0].innerHTML = list;
Expand Down Expand Up @@ -101,25 +101,28 @@ class BesluitenLijst extends HTMLElement {
let filterparams = "";
if (statussen) {
const statussenArray = statussen.split(",");
filterparams += "VALUES ?status { " + statussenArray.map(status => `"${status.trim()}"@nl`).join(" ") + " }"
// NOTE: adding query part here, status is not optional when filtering on status
filterparams += `?besluit prov:wasGeneratedBy/besluit:heeftStemming/besluit:gevolg ?status. \n`;
filterparams += "VALUES ?status { " + statussenArray.map(status => `"${status.trim()}"@nl`).join(" ") + " }";
} else {
filterparams += `BIND(COALESCE(?status, "Ontwerp") AS ?status)`;
// TODO: adding query part here, status is ONLY optional when not filtering on status
filterparams += `OPTIONAL { ?besluit prov:wasGeneratedBy/besluit:heeftStemming/besluit:gevolg ?status }`;
filterparams += `BIND(COALESCE(?status, "Onbekend"@nl) AS ?status)`;
}
if (bestuurseenheden) {
const bestuurseenhedenArray = bestuurseenheden.split(" ");
filterparams += "VALUES ?bestuureenheidURI { " + bestuurseenhedenArray.map(bestuurseenheid => `<${bestuurseenheid.trim()}>`).join(" ") + " }"
filterparams += "VALUES ?bestuureenheidURI { " + bestuurseenhedenArray.map(bestuurseenheid => `<${bestuurseenheid.trim()}>`).join(" ") + " }";
}
if (bestuursorganen) {
const bestuursorganenArray = bestuursorganen.split(" ");
filterparams += "VALUES ?bestuursorgaanURI { " + bestuursorganenArray.map(bestuursorgaan => `<${bestuursorgaan.trim()}>`).join(" ") + " }"
filterparams += "VALUES ?bestuursorgaanURI { " + bestuursorganenArray.map(bestuursorgaan => `<${bestuursorgaan.trim()}>`).join(" ") + " }";
}

// Date filter.
const startdate = this.getAttribute('start');
const enddate = this.getAttribute('eind');
if (startdate && enddate) {
filterparams += `FILTER(?zitting_datum >= "${startdate}"^^xsd:date && ?zitting_datum <= "${enddate}"^^xsd:date)`;
console.log(filterparams)
} else if (startdate) {
filterparams += `FILTER(?zitting_datum >= "${startdate}"^^xsd:date)`;
} else if (enddate) {
Expand Down Expand Up @@ -153,11 +156,9 @@ class BesluitenLijst extends HTMLElement {
// @TODO: remove OPTIONAL {} when eenheden are available.
let queryOptional = `OPTIONAL {${queryBestuurseenheid}}`;

// @TODO: remove OPTIONAL {} when statusses are available.
queryOptional += `OPTIONAL { ?besluit prov:wasGeneratedBy/besluit:heeftStemming/besluit:gevolg ?status }`;

// @TODO: remove with query below after Bestuursorgaan has been moved to Zitting iso BehandelingVanAgendapunt
const endpoint = this.getAttribute('sparql-endpoint')
const endpoint = this.getAttribute('sparql-endpoint');
if (endpoint.includes("probe")) {
queryBestuursorgaan = `
prov:wasGeneratedBy ?behandelingVanAgendapunt .
Expand Down Expand Up @@ -257,14 +258,14 @@ class BesluitenLijst extends HTMLElement {
pageUp() {
this.offset += this.amount;
console.log(this.offset);
this.getBesluiten()
this.getBesluiten();
}

pageDown() {
if (this.offset >= this.amount) {
this.offset -= this.amount;
console.log(this.offset);
this.getBesluiten()
this.getBesluiten();
}
}

Expand Down

0 comments on commit b4f0abb

Please sign in to comment.