-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
286 add filtering to events #415
Conversation
-moz-column-rule: 1px solid rgba(28,110,164,0.39); | ||
column-rule: 1px solid rgba(28,110,164,0.39); | ||
@include for-mobile-down { | ||
-webkit-column-count: 1; | ||
-moz-column-count: 1; | ||
column-count: 1; | ||
-webkit-column-gap: 26px; | ||
-moz-column-gap: 26px; | ||
column-gap: 26px; | ||
-webkit-column-rule: 1px solid rgba(28,110,164,0.39); | ||
-moz-column-rule: 1px solid rgba(28,110,164,0.39); | ||
column-rule: 1px solid rgba(28,110,164,0.39); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trenger du alpha på disse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ja
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finnes det ikke en ekvivalent i hex? Alpha er litt ulempe å bruke med mindre det er nødvendig nemlig. Det er fordi universell utforming-verktøy ikke klarer å avgjøre om kontrast er akseptabelt eller ikke da fargen er gjennomsiktig. Med andre ord avhenger fargene av bakgrunnen.
backend/samfundet/views.py
Outdated
def url_args(self, query_word: str) -> str: | ||
query = self.request.GET.get(query_word, None) | ||
if query is None: | ||
return '' | ||
return query.split(',')[0] | ||
|
||
def general_search(self, events_query: QuerySet, search_term: str) -> QuerySet: | ||
fields = [f for f in Event._meta.fields if (isinstance(f, CharField) or isinstance(f, TextField))] | ||
queries = [Q(**{f.name + '__contains': search_term}) for f in fields] | ||
qs = Q() | ||
for query in queries: | ||
qs = qs | query | ||
|
||
return events_query.filter(qs) | ||
|
||
def statusGroup(self) -> str: | ||
if self.request.GET.get('archived', None) == 'true': | ||
return 'active' | ||
return 'archived' | ||
|
||
def get(self, request: Request) -> Response: | ||
events: dict = {} | ||
for event in Event.objects.all().values(): | ||
events_query = Event.objects.all() | ||
|
||
if '?' in self.request.build_absolute_uri(): | ||
events_query = self.general_search(events_query, self.url_args('search')).filter( | ||
Q(location__contains=self.url_args('location')), Q(status_group=self.statusGroup()) | ||
) | ||
|
||
for event in events_query.all().order_by('start_dt').values(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jeg tror dette kan gjøres lettere med query params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eller hvis du kan legge til docstring så kanskje jeg henger mer med
backend/samfundet/views.py
Outdated
def general_search(self, events_query: QuerySet, search_term: str) -> QuerySet: | ||
fields = [f for f in Event._meta.fields if (isinstance(f, CharField) or isinstance(f, TextField))] | ||
queries = [Q(**{f.name + '__contains': search_term}) for f in fields] | ||
qs = Q() | ||
for query in queries: | ||
qs = qs | query | ||
|
||
return events_query.filter(qs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trenger vi så generisk filter for bare ett view? Kan kanskje skjønne det hvis det var universalt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ja, er enklest sånn for å søke etter ord i alle tekst felter, kunne evt laget en egen funksjon ett sted som alle kan ha nytte av
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hva om man ikke ønsker å søke i alle tekstfelt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fjerne if setningen så er det alle felter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kanskje man kan ta inn en liste med felter man ønsker å filtrere på?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
<div className={styles.filterColumn}> | ||
<label className={styles.container} key={t(KEY.all_venues)}> | ||
<RadioButton name="venues" value="" onChange={() => setSelectedVenue(all_venues)} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trenger den ikke value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
</Button> | ||
</div> | ||
</div> | ||
) : null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dette er en stor ternary. Det kan gjøres enklere. Vurder subkomponent også
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
|
||
export function EventsPage() { | ||
const all_venues = 'all'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trekk ut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
getVenues().then((data) => { | ||
setVenues(data); | ||
}); | ||
setShowSpinner(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nå stopper den uansett om ting lastes eller ikke
backend/samfundet/views.py
Outdated
|
||
if '?' in self.request.build_absolute_uri(): | ||
events_query = general_search(events_query, self.url_args('search')) | ||
events_query = events_query.filter(location__contains=self.url_args('location')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
events_query = events_query.filter(location__contains=self.url_args('location')) | |
location = request.query_params.get('location', '') | |
events_query = events_query.filter(location__contains=self.url_args('location')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hva skjer dersom location ikke er der, da blir filteret rart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hva med spørsmålet?
events_query = general_search(events_query, self.url_args('search')) | ||
events_query = events_query.filter(location__contains=self.url_args('location')) | ||
|
||
for event in events_query.order_by('start_dt').values(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trenger du .values()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Håndterer det som et dict når jeg sorterer den, da trenger jeg .values() for å gjøre det om
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ser ikke ut som du trenger det. Du henter jo bare ut et felt.
Som data i responsen kanskje vi kan bruke serializer i stedet slik at det blir likt som resten av api-et.
justify-content: center; | ||
align-items: center; | ||
background: #a03033; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
-moz-column-rule: 1px solid rgba(28, 110, 164, 0.39); | ||
column-rule: 2px solid rgba(28, 110, 164, 0.39); | ||
@include for-mobile-down { | ||
-webkit-column-count: 1; | ||
-moz-column-count: 1; | ||
column-count: 1; | ||
-webkit-column-gap: 2%; | ||
-moz-column-gap: 2%; | ||
column-gap: 2%; | ||
-webkit-column-rule: 1px solid rgba(28, 110, 164, 0.39); | ||
-moz-column-rule: 1px solid rgba(28, 110, 164, 0.39); | ||
column-rule: 1px solid rgba(28, 110, 164, 0.39); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Litt skeptisk til alpha. Tror du bør finne absolutt-farge for å garantere god kontrast.
const [venues, setVenues] = useState<VenueDto[]>([]); | ||
const [filterToggle, setFilterToggle] = useState<boolean>(false); | ||
const [eventsOptions, setEventsOption] = useState<EventOptionsDto | null>(null); | ||
const handleClick = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function
.catch((error) => { | ||
toast.error(t(KEY.common_something_went_wrong)); | ||
console.error(error); | ||
}); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
// eslint-disable-next-line react-hooks/exhaustive-deps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
litt rar plassering
}, []); | ||
|
||
const handleFilterToggle = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
}; | ||
|
||
export function FilterRow({ label, name, property, urlArgs }: FilterRowProps) { | ||
const { t } = useTranslation<string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hvorfor typer du denne?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prøv å følge komponent strukturen definert i docs.
{t(KEY.all)} | ||
</label> | ||
{Object.keys(property).map((option, key) => ( | ||
<label key={key} className={styles.container}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hvorfor label? RadioButton har det
export type EventOptionsDto = { | ||
name?: string; | ||
description?: string; | ||
renders?: object; | ||
actions: { POST: EventOptionsPostDto }; | ||
}; | ||
|
||
export type EventOptionsPostDto = { | ||
id?: EventOptionsPostKeysDto; | ||
end_dt?: EventOptionsPostKeysDto; | ||
image_url?: EventOptionsPostKeysDto; | ||
title_nb: EventOptionsPostKeysDto; | ||
title_en?: EventOptionsPostKeysDto; | ||
description_long_nb?: EventOptionsPostKeysDto; | ||
description_long_en?: EventOptionsPostKeysDto; | ||
description_short_nb?: EventOptionsPostKeysDto; | ||
description_short_en?: EventOptionsPostKeysDto; | ||
location?: EventOptionsPostKeysDto; | ||
codeword?: EventOptionsPostKeysDto; | ||
created_at?: EventOptionsPostKeysDto; | ||
updated_at?: EventOptionsPostKeysDto; | ||
start_dt?: EventOptionsPostKeysDto; | ||
duration?: EventOptionsPostKeysDto; | ||
publish_dt?: EventOptionsPostKeysDto; | ||
host?: EventOptionsPostKeysDto; | ||
status_group: EventOptionsPostKeysChoisesDto; | ||
age_group: EventOptionsPostKeysChoisesDto; | ||
category: EventOptionsPostKeysChoisesDto; | ||
price_group: EventOptionsPostKeysChoisesDto; | ||
capacity?: EventOptionsPostKeysDto; | ||
event_group?: EventOptionsPostKeysDto; | ||
}; | ||
|
||
export type EventOptionsPostKeysDto = { | ||
actions?: object; | ||
type?: string; | ||
required?: boolean; | ||
read_only?: boolean; | ||
label: string; | ||
}; | ||
|
||
export type EventOptionsPostKeysChoisesDto = { | ||
type: string; | ||
required: boolean; | ||
read_only: boolean; | ||
label: string; | ||
choices: EventOptionsChoises_Dto; | ||
}; | ||
|
||
export type EventOptionsChoises_Dto = [ | ||
{ | ||
value: string; | ||
display_name: string; | ||
}, | ||
]; | ||
|
||
|
||
// ==================== // | ||
// Event // | ||
// ==================== // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evgiz kan du ta en titt?
frontend/src/i18n/constants.ts
Outdated
form_confirm: 'form_confirm', | ||
duration: 'duration', | ||
publication: 'publication', | ||
closed_period: 'closed_period', | ||
saksdokument: 'saksdokument', | ||
select_event: 'select_event', | ||
all: 'all', | ||
search_all: 'search_all', | ||
archived_events: 'archived_events', | ||
event_category: 'event_category', | ||
choose_age: 'choose_age', | ||
choose_status: 'choose_status', | ||
photos: 'photos', | ||
nybygg: 'nybygg', | ||
common_sulten: 'common_sulten', | ||
sulten_page_book_table: 'sulten_page_book_table', | ||
sulten_page_kitchen: 'sulten_page_kitchen', | ||
sulten_page_see_menu: 'sulten_page_see_menu', | ||
sulten_page_about_us: 'sulten_page_about_us', | ||
sulten_page_more_about_us: 'sulten_page_more_about_us', | ||
admin_saksdokumenter_title: 'admin_saksdokumenter_title', | ||
back_to_samfundet: 'back_to_samfundet', | ||
no_file_selected: 'no_file_selected', | ||
category: 'category', | ||
choose_a_file: 'choose_a_file', | ||
control_panel_faq: 'control_panel_faq', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Så du ikke hvor fin filen var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Veldig tydelig mønster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Les docstring øverst om navn
frontend/src/i18n/translations.ts
Outdated
[KEY.duration]: 'Varighet', | ||
[KEY.publication]: 'Publisering', | ||
[KEY.closed_period]: 'Stengt periode', | ||
[KEY.saksdokument]: 'Saksdokument', | ||
[KEY.select_event]: 'Velg lokale', | ||
[KEY.all]: 'Alle', | ||
[KEY.search_all]: 'Søk på alle arrangemanger!', | ||
[KEY.archived_events]: 'Vis arkiverte arrangemanger', | ||
[KEY.event]: '', | ||
[KEY.event_category]: 'Velg type arrangemang', | ||
[KEY.choose_age]: 'Aldersgrense', | ||
[KEY.choose_status]: 'Status', | ||
[KEY.photos]: 'Foto', | ||
[KEY.nybygg]: 'Nybygg', | ||
[KEY.common_sulten]: 'Lyche', | ||
[KEY.sulten_page_book_table]: 'Bestill bord', | ||
[KEY.sulten_page_kitchen]: 'Kjøkken', | ||
[KEY.navbar_photos]: 'Foto', | ||
[KEY.navbar_nybygg]: 'Nybygg', | ||
[KEY.control_panel_faq]: 'Hjelp/spørsmål', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls rydd
No description provided.