Skip to content

Commit

Permalink
fixed some merge conflicts that gitkraken forgot about
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudo-Thijn committed Aug 14, 2024
1 parent ef56ca9 commit 8487bcd
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 50 deletions.
4 changes: 3 additions & 1 deletion src/sidebars/SideBars.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { navigationStore, searchStore } from '../store/store.js'
<template>
<div>
<!-- Placeholder div for all of the sidebars-->
<SearchSideBar v-if="navigationStore.selected === 'search'" :search="searchStore.search" />
<SearchSideBar v-if="navigationStore.selected === 'search'"
:search="searchStore.search"
:metadata="searchStore.metadata" />
<DashboardSideBar v-if="navigationStore.selected === 'dashboard'" />
<DirectorySideBar v-if="navigationStore.selected === 'directory'" />
</div>
Expand Down
16 changes: 15 additions & 1 deletion src/sidebars/search/SearchSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import { searchStore, directoryStore, metadataStore } from '../../store/store.js
<template #icon>
<FileTreeOutline :size="20" />
</template>
<NcCheckboxRadioSwitch v-for="(metaData, i) in metadataStore.metaDataList" :key="`${metaData}${i}`" type="switch">
{{ searchStore.metadata }}
<NcCheckboxRadioSwitch v-for="(metaData, i) in metadataStore.metaDataList"
:key="`${metaData}${i}`"
type="switch"
:checked.sync="searchStore.metadata[metaData.id]">
{{ metaData.title || 'Geen titel' }}
</NcCheckboxRadioSwitch>
</NcAppSidebarTab>
Expand Down Expand Up @@ -62,6 +66,10 @@ export default {
type: String,
required: true,
},
metadata: {
type: Object,
required: true,
},
},
data() {
return {
Expand All @@ -70,6 +78,12 @@ export default {
},
watch: {
search: 'debouncedSearch',
metadata: {
handler() {
this.debouncedSearch()
},
deep: true,
},
},
mounted() {
directoryStore.refreshListingList()
Expand Down
105 changes: 57 additions & 48 deletions src/store/modules/search.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,65 @@
/* eslint-disable no-console */
import { defineStore } from 'pinia'

export const useSearchStore = defineStore(
'search', {
state: () => ({
search: '',
searchResults: '',
searchError: '',
}),
actions: {
setSearch(search) {
this.search = search
console.log('Active search set to ' + search)
},
setSearchResults(searchResults) {
this.searchResults = searchResults
console.log('Active search set to ' + searchResults)
},
/* istanbul ignore next */ // ignore this for Jest until moved into a service
getSearchResults() {
fetch(
'/index.php/apps/opencatalogi/api/search?_search=' + this.search,
{
method: 'GET',
export const useSearchStore = defineStore('search', {
state: () => ({
search: '',
metadata: {},
searchResults: '',
searchError: '',
}),
actions: {
setSearch(search) {
this.search = search
console.log('Active search set to ' + search)
},
toggleMetadataSearch(metadataId, value = undefined) {
this.metadata[metadataId] = value || !this.metadata[metadataId] || false
},
setSearchResults(searchResults) {
this.searchResults = searchResults
console.log('Active search set to ' + searchResults)
},
/* istanbul ignore next */ // ignore this for Jest until moved into a service
getSearchResults() {
const enabledMetadataIds = Object.entries(this.metadata)
.filter(([key, value]) => value === true)
.map((metadata) => metadata[0])

console.log(enabledMetadataIds)

fetch(
'/index.php/apps/opencatalogi/api/search?_search=' + this.search,
{
method: 'GET',
},
)
.then(
(response) => {
response.json().then(
(data) => {

Check failure on line 40 in src/store/modules/search.js

View workflow job for this annotation

GitHub Actions / build

Multi-line function call not indented correctly; expected 20 spaces but found 24
if (data?.code === 403 && data?.message) {

Check failure on line 41 in src/store/modules/search.js

View workflow job for this annotation

GitHub Actions / build

Multi-line function call not indented correctly; expected 28 spaces but found 24
this.searchError = data.message

Check failure on line 42 in src/store/modules/search.js

View workflow job for this annotation

GitHub Actions / build

Multi-line function call not indented correctly; expected 28 spaces but found 32

Check failure on line 42 in src/store/modules/search.js

View workflow job for this annotation

GitHub Actions / build

Line indented incorrectly; expected 28 spaces, found 32
console.log(this.searchError)
} else {
this.searchError = '' // Clear any previous errors

Check failure on line 45 in src/store/modules/search.js

View workflow job for this annotation

GitHub Actions / build

Line indented incorrectly; expected 28 spaces, found 32
}

Check failure on line 46 in src/store/modules/search.js

View workflow job for this annotation

GitHub Actions / build

Multi-line function call not indented correctly; expected 28 spaces but found 36
this.searchResults = data
},
)
},
)
.catch(
(err) => {
this.searchError = err.message || 'An error occurred'
console.error(err.message ?? err)
},
)
.then(
(response) => {
response.json().then(
(data) => {
if (data?.code === 403 && data?.message) {
this.searchError = data.message
console.log(this.searchError)
} else {
this.searchError = '' // Clear any previous errors
}
this.searchResults = data
},
)
},
)
.catch(
(err) => {
this.searchError = err.message || 'An error occurred'
console.error(err.message ?? err)
},
)
},
clearSearch() {
this.search = ''
this.searchError = ''
},
},
clearSearch() {
this.search = ''
this.searchError = ''
},
},
},
)

0 comments on commit 8487bcd

Please sign in to comment.