diff --git a/Services/client/src/modules/01_user/components/AdvancedSearch.vue b/Services/client/src/modules/01_user/components/AdvancedSearch.vue index 0021992..6128d95 100644 --- a/Services/client/src/modules/01_user/components/AdvancedSearch.vue +++ b/Services/client/src/modules/01_user/components/AdvancedSearch.vue @@ -3,14 +3,8 @@ import { storeToRefs } from 'pinia' import { useSearchDataStore } from '@/stores/searched-data' -const { isAdvSearchCall, advSearchDataRow, advSearchDataField } = +const { isAdvSearchCall, advSearchDataRow, advSearchDataField, optionsField } = storeToRefs(useSearchDataStore()) -const optionsField = [ - { label: 'ชื่อเรื่อง (title)', value: 'title' }, - { label: 'คำสำคัญ (keyword)', value: 'keyword' }, - { label: 'หมวดหมู่ (category)', value: 'category' }, - { label: 'เนื้อหาในไฟล์ (content)', value: 'attachment.content' }, -] const optionsOp = [ { label: 'และ', value: 'AND' }, { label: 'หรือ', value: 'OR' }, diff --git a/Services/client/src/modules/01_user/components/SearchBar.vue b/Services/client/src/modules/01_user/components/SearchBar.vue index aa38ed7..694477e 100644 --- a/Services/client/src/modules/01_user/components/SearchBar.vue +++ b/Services/client/src/modules/01_user/components/SearchBar.vue @@ -22,16 +22,10 @@ const { isAdvSearchCall, searchData, advSearchDataField, + optionsField, advSearchDataRow, } = storeToRefs(useSearchDataStore()) const { getFoundFile } = useSearchDataStore() -const optionsField = [ - { label: 'ชื่อเรื่อง (title)', value: 'title' }, - { label: 'คำสำคัญ (keyword)', value: 'keyword' }, - { label: 'หมวดหมู่ (category)', value: 'category' }, - { label: 'เนื้อหาในไฟล์ (content)', value: 'attachment.content' }, - { label: 'เจ้าของผลงาน (author)', value: 'author' }, -] const submitSearchData = ref<{ AND: { field: string @@ -56,7 +50,7 @@ async function submitSearch() { if (searchData.value.value.trim() !== '') { submitSearchData.value = { AND: [], OR: [] } if (props.mode === 'admin') { - optionsField.forEach((option) => { + optionsField.value.forEach((option) => { submitSearchData.value.OR.push({ field: option.value, value: searchData.value.value, @@ -117,6 +111,20 @@ async function submitSearch() { (d: { field: string; value: string; op: string; exact: boolean }) => { if (d.field && d.value.trim() !== '') { const op = d.op === 'AND' ? 'AND' : 'OR' + if (d.field == 'title') { + submitSearchData.value[op].push({ + field: 'metadata.subject', + value: d.value, + exact: d.exact, + }) + } + if (d.field == 'author') { + submitSearchData.value[op].push({ + field: 'metadata.author', + value: d.value, + exact: d.exact, + }) + } submitSearchData.value[op].push({ field: d.field, value: d.value, diff --git a/Services/client/src/stores/searched-data.ts b/Services/client/src/stores/searched-data.ts index 125fb32..c62b330 100644 --- a/Services/client/src/stores/searched-data.ts +++ b/Services/client/src/stores/searched-data.ts @@ -36,6 +36,13 @@ export const useSearchDataStore = defineStore('searched', () => { exact: false, }, ]) + const optionsField = ref([ + { label: 'ชื่อเรื่อง (title)', value: 'title' }, + { label: 'คำสำคัญ (keyword)', value: 'keyword' }, + { label: 'หมวดหมู่ (category)', value: 'category' }, + { label: 'เนื้อหาในไฟล์ (content)', value: 'attachment.content' }, + { label: 'เจ้าของผลงาน (author)', value: 'author' }, + ]) const advSearchDataField = ref({ keyword: [], description: '', @@ -52,6 +59,7 @@ export const useSearchDataStore = defineStore('searched', () => { isAdvSearchCall, searchData, advSearchDataRow, + optionsField, advSearchDataField, getFoundFile, }