Skip to content

Commit

Permalink
feat(cog2023): hide from search results
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisig committed Sep 10, 2024
1 parent 63e33bf commit 4da7114
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
30 changes: 26 additions & 4 deletions project/templates/project/partials/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@
.advanced-search:hover {
opacity: 0.7;
}

.disabled {
color: #B0B0B0 !important;
pointer-events: none;
}

.disabled .text-muted {
color: #B0B0B0 !important;
}

.disabled-land-message {
margin-left: auto;
}
</style>

<div class="fr-search-bar fr-search-bar--red position-relative d-flex flex-column" role="search">
Expand Down Expand Up @@ -155,13 +168,18 @@
count++

return `
<div class='level'>${levels[key]}</div>
${response[key].map(obj => (
`<div class="territory" id="territory-${obj.public_key}">
<div class='level'>${levels[key]}</div>*
${response[key].map(obj => {
const disabledLand = obj.area === 0
return `<div
class="territory ${disabledLand ? "disabled" : ""}"
id="territory-${obj.public_key}"
>
<div class='fr-mr-2v'>${obj.name}</div>
${obj.source_id !== "" ? `<div class='text-muted'>(${obj.source_id})</div>` : ``}
${disabledLand ? ` <i class="disabled-land-message">Territoire supprimé en 2024</i>` : ``}
</div>`
)).join('')}
}).join('')}
`
}
}).join('')
Expand Down Expand Up @@ -226,6 +244,10 @@
_paq.push(['trackEvent', 'local_report_download_funnel', 'search_territory', 'local_report_home_search_territory_selected'])
}

if (e.target.classList.contain('disabled')) {
return
}

const public_key = e.target.id.split('territory-')[1]
createDiagnostic(public_key)
}
Expand Down
1 change: 1 addition & 0 deletions public_data/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class LandSerializer(s.Serializer):
name = s.CharField()
source_id = s.SerializerMethodField()
public_key = s.CharField()
area = s.FloatField()

def get_source_id(self, obj) -> str:
return obj.get_official_id()

0 comments on commit 4da7114

Please sign in to comment.