Skip to content

Commit

Permalink
[projects] Allow to search in projects
Browse files Browse the repository at this point in the history
  • Loading branch information
frankrousseau committed Sep 27, 2023
1 parent 41bf509 commit 0014991
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions src/components/pages/OpenProductions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
class="open-productions-box"
v-if="!isOpenProductionsLoading && openProductions.length > 0"
>
<div class="flexrow search-area" v-if="openProductions.length > 6">
<search-field
ref="search-field"
class="search-field"
@change="onSearchChange"
/>
</div>

<div
:class="{
'open-productions-list': true,
Expand All @@ -34,7 +42,7 @@
<div
class="open-production has-text-centered"
:key="production.id"
v-for="production in openProductions"
v-for="production in filteredProductions"
>
<router-link :to="getPath(production)">
<div
Expand Down Expand Up @@ -94,20 +102,26 @@
<script>
import { mapGetters, mapActions } from 'vuex'
import colors from '@/lib/colors.js'
import { buildNameIndex } from '@/lib/indexing'
import colors from '@/lib/colors'
import EditProductionModal from '@/components/modals/EditProductionModal'
import SearchField from '@/components/widgets/SearchField'
import Spinner from '@/components/widgets/Spinner'
export default {
name: 'open-productions',
components: {
EditProductionModal,
SearchField,
Spinner
},
data() {
return {
filteredProductions: [],
search: '',
errors: {
edit: false
},
Expand All @@ -120,6 +134,12 @@ export default {
}
},
mounted() {
this.$refs['search-field'].focus()
this.filteredProductions = this.openProductions
this.productionIndex = buildNameIndex(this.openProductions)
},
computed: {
...mapGetters([
'isCurrentUserAdmin',
Expand Down Expand Up @@ -196,6 +216,15 @@ export default {
hideNewModal() {
this.modals.isNewDisplayed = false
},
onSearchChange(search) {
console.log(search)
if (search === '') {
this.filteredProductions = this.openProductions
} else {
this.filteredProductions = this.productionIndex[search]
}
}
},
Expand Down Expand Up @@ -385,6 +414,10 @@ a.secondary:hover {
}
}
.search-area {
justify-content: center;
}
@media screen and (max-width: 768px) {
.title {
margin-top: 1em;
Expand Down

0 comments on commit 0014991

Please sign in to comment.