-
Notifications
You must be signed in to change notification settings - Fork 25
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
Speak-32 Add search algorithm #195
Merged
ann-kilzer
merged 6 commits into
WomenInSoftwareEngineeringJP:master
from
tuul-wq:Speak-32
Dec 15, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
875e9c0
Speak-32 Add search algorithm
tuul-wq 88bbb9f
Speak-32 Fixed naming for i18n
89b8289
Merge branch 'master' into Speak-32
tuul-wq 854499f
Speak-32 Review fixes
49bf388
Merge branch 'Speak-32' of github.com:tuul-wq/speak-her-db into Speak-32
da0e95f
Merge branch 'master' into Speak-32
ann-kilzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div class="pa-9 text-center"> | ||
<span class="display-1">{{ $t('findSpeaker.noResults') }}</span> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
<contact-dialog | ||
:speaker="selectedSpeaker" | ||
:show="showDialog" | ||
@close="showDialog=false" | ||
@submit="showDialog= false; showSuccess = true" | ||
@close="showDialog = false" | ||
@submit="showDialog = false; showSuccess = true" | ||
/> | ||
<contact-result | ||
:show="showSuccess" | ||
|
@@ -16,30 +16,32 @@ | |
no-gutters | ||
> | ||
<v-col lg="10"> | ||
<v-row> | ||
<h2 class="mx-2 mb-2"> | ||
<v-row | ||
justify="space-between" | ||
align="center" | ||
> | ||
<h2 class="py-2"> | ||
{{ $t('findSpeaker.title') }} | ||
</h2> | ||
<pagination-row | ||
v-if="speakers.length" | ||
:first-entry="(page - 1) * pageSize + 1" | ||
:last-entry="lastEntry" | ||
:is-last-page="isLastPage" | ||
@onNextPage="getNextPage()" | ||
@onPrevPage="getPreviousPage()" | ||
/> | ||
</v-row> | ||
<pagination-row | ||
v-if="speakers.length" | ||
:first-entry="(page - 1) * pageSize + 1" | ||
:last-entry="lastEntry" | ||
:is-last-page="isLastPage" | ||
@onNextPage="getNextPage()" | ||
@onPrevPage="getPreviousPage()" | ||
/> | ||
<search v-if="false" /> | ||
<search /> | ||
<v-row | ||
v-if="isLoading" | ||
justify="space-around" | ||
class="my-10" | ||
> | ||
<v-col lg="1"> | ||
<v-progress-circular | ||
indeterminate | ||
color="primary" | ||
/> | ||
</v-col> | ||
<v-progress-circular | ||
indeterminate | ||
color="primary" | ||
/> | ||
</v-row> | ||
<div | ||
v-if="!isLoading" | ||
|
@@ -65,6 +67,7 @@ | |
@onNextPage="getNextPage()" | ||
@onPrevPage="getPreviousPage()" | ||
/> | ||
<no-results v-if="hasNoSpeakers" /> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
|
@@ -73,11 +76,12 @@ | |
<script> | ||
// @ is an alias to /src | ||
import api from '@/services/api'; | ||
import SpeakerCard from '@/components/speaker/SpeakerCard.vue'; | ||
import Search from '@/components/Search.vue'; | ||
import SpeakerCard from '@/components/speaker/SpeakerCard.vue'; | ||
import ContactDialog from '@/components/contact/ContactDialog.vue'; | ||
import ContactResult from '@/components/contact/ContactResult.vue'; | ||
import PaginationRow from '@/components/PaginationRow.vue'; | ||
import NoResults from '@/components/no-results/NoResults.vue'; | ||
|
||
export default { | ||
components: { | ||
|
@@ -86,6 +90,7 @@ export default { | |
Search, | ||
SpeakerCard, | ||
PaginationRow, | ||
NoResults, | ||
}, | ||
data: () => ({ | ||
speakers: [], | ||
|
@@ -103,13 +108,12 @@ export default { | |
}), | ||
computed: { | ||
selectedName() { | ||
if (this.selectedSpeaker) { | ||
if (this.$i18n.locale === 'ja') { | ||
return this.selectedSpeaker.get('name_ja') || this.selectedSpeaker.get('name_en') || ''; | ||
} | ||
return this.selectedSpeaker.get('name_en') || ''; | ||
if (!this.selectedSpeaker) return ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep this PR focused on search and avoid making other refactors? It gets confusing to follow the changes. |
||
|
||
if (this.$i18n.locale === 'ja') { | ||
return this.selectedSpeaker.get('name_ja') || this.selectedSpeaker.get('name_en') || ''; | ||
} | ||
return ''; | ||
return this.selectedSpeaker.get('name_en') || ''; | ||
}, | ||
getSpeakersForPage() { | ||
const offset = (this.page - 1) * this.pageSize; | ||
|
@@ -119,22 +123,32 @@ export default { | |
const lastPageEntry = this.page * this.pageSize; | ||
return lastPageEntry > this.speakers.length ? this.speakers.length : lastPageEntry; | ||
}, | ||
hasNoSpeakers() { | ||
return !this.speakers.length && !this.isLoading; | ||
}, | ||
}, | ||
mounted() { | ||
api.getLocations(this.setPrefectures, this.setError); | ||
api.getTopics(this.setTopics, this.setError); | ||
api.getLanguages(this.setLanguageList, this.setError); | ||
this.getSpeakers(); | ||
|
||
bus.$on('contact-speaker', (speaker) => { | ||
this.selectedSpeaker = speaker; | ||
this.showDialog = true; | ||
}); | ||
this.setupBusEvents(); | ||
}, | ||
beforeDestroy() { | ||
bus.$off('contact-speaker'); | ||
bus.$off('search-by-params'); | ||
}, | ||
methods: { | ||
setupBusEvents() { | ||
bus.$on('contact-speaker', (speaker) => { | ||
this.selectedSpeaker = speaker; | ||
this.showDialog = true; | ||
}); | ||
bus.$on('search-by-params', (params) => { | ||
this.resetPreSearchParams(); | ||
this.getSpeakers(params); | ||
}); | ||
}, | ||
setPrefectures(records) { | ||
this.prefectures = records; | ||
}, | ||
|
@@ -177,35 +191,45 @@ export default { | |
|
||
this.getNextPageInternal(); | ||
}, | ||
getSpeakers() { | ||
getSpeakers(params = { topic: '', location: '' }) { | ||
const filter = `AND(FIND("${params.topic}", topics), FIND("${params.location}", location_id))`; | ||
|
||
this.$db('People') | ||
.select({ | ||
view: 'Published', | ||
sort: [{ field: 'name_en', direction: 'asc' }], | ||
pageSize: this.pageSize, | ||
filterByFormula: filter, | ||
}) | ||
.eachPage( | ||
(records, next) => { | ||
this.speakers.push(...records); | ||
this.page += 1; | ||
this.airTableNextPage = next; | ||
this.isLoading = false; | ||
this.isLastPage = this.pageSize > records.length; | ||
}, | ||
(err) => { | ||
if (err) { | ||
this.error = err; | ||
} | ||
|
||
// if the error is null no new page exists | ||
this.isLastPage = true; | ||
this.isLoading = false; | ||
|
||
// set airTableNextPage to undefined to mark that we can not fetch any more pages | ||
// and have to switch to internal pagination logic | ||
this.airTableNextPage = undefined; | ||
}, | ||
); | ||
}, | ||
resetPreSearchParams() { | ||
this.speakers = []; | ||
this.page = 0; | ||
this.isLastPage = false; | ||
this.isLoading = true; | ||
this.airTableNextPage = undefined; | ||
this.selectedSpeaker = undefined; | ||
}, | ||
}, | ||
}; | ||
</script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🤔 I just noticed that the region column is in the DB, but there are no values. Probably best to add it later and fill out the DB.