Compare commits

..

No commits in common. "baghi/hadith/refactor" and "main" have entirely different histories.

5 changed files with 69 additions and 199 deletions

View File

@ -1,7 +1,7 @@
export default {
search: {
list: "repo/monir/search/@index_key/@search_type/@type_key/@listkey/@field_collapsed/@offset/@limit/@q=none",
show: "repo/public/get/byid/@index_key/@id/tbookmark",
show: "repo/public/get/byid/@index_key/@id",
synonym: "synonym/get/words",
prevNextHadith: "monir/next/@index_key/@vol_id/@parag_order/@step",
getDataTree: "@appname/book/tree/@offset/@limit/@vol_id/@q"

View File

@ -57,7 +57,7 @@ const search_type = ref("normal");
const type_key = ref("hadith");
const typeModelValue = ref("normal");
const typeModelValueFa = ref("");
// const showclearButton = ref(false);
const showclearButton = ref(false);
// If you want to share state across multiple components,
// you can use the same key in useState. Nuxt will ensure
@ -169,17 +169,17 @@ const clearSimilar = () => {
// const onUpdateModel = (newVal: boolean | InputMenuItem | any) => {
// console.info("onUpdateModel", newVal);
// };
// const searchButtonIcon = computed(() => {
// return showclearButton.value ? "i-lucide-x" : "i-haditha-search";
// });
const searchButtonIcon = computed(() => {
return showclearButton.value ? "i-lucide-x" : "i-haditha-search";
});
// const handleSearchClearButton = ()=>{
// showclearButton.value = true;
// sendQuery();
// }
const handleSearchClearButton = ()=>{
showclearButton.value = true;
sendQuery();
}
const onKeyDown = () => {
// showclearButton.value = false;
showclearButton.value = false;
// clearTimeout(typingTimer.value);
};
@ -235,12 +235,6 @@ const sendQuery = async (payload = {}) => {
return await httpService
.postRequest(url, payload)
.then((res) => {
emit("response-ready", {
res: res,
searchQuery: searchTerm.value,
disableAutoRedirect: true,
});
// pass res and search query to the parent.
loading.value = false;
@ -250,29 +244,31 @@ const sendQuery = async (payload = {}) => {
// close the history dropdown menu
open.value = false;
// show clear button
// if (showclearButton.value) {
// searchTerm.value = "";
if (showclearButton.value) {
searchTerm.value = "";
// emit("response-ready", {
// res: {
// hits:{
// total:0,
// hits:[]
// }
// },
// searchQuery: searchTerm.value,
// disableAutoRedirect: true,
// });
// } else {
// emit("response-ready", {
// res: res,
// searchQuery: searchTerm.value,
// disableAutoRedirect: true,
// });
// }
// showclearButton.value = !showclearButton.value;
emit("response-ready", {
res: {
hits:{
total:0,
hits:[]
}
},
searchQuery: searchTerm.value,
disableAutoRedirect: true,
});
} else {
emit("response-ready", {
res: res,
searchQuery: searchTerm.value,
disableAutoRedirect: true,
});
}
showclearButton.value = !showclearButton.value;
// store search phrase
useStorage("searchPhrase", searchTerm.value);
@ -449,10 +445,10 @@ onMounted(() => {
</div>
<UButton
class="my-trailing-button"
@click.prevent="sendQuery"
icon="i-haditha-search"
:class="{ 'close-mode': showclearButton }"
@click.prevent="handleSearchClearButton"
:icon="searchButtonIcon"
>
<!-- // @click.prevent="handleSearchClearButton" // :icon="searchButtonIcon" -->
<!-- <UIcon name="i-lucide-search" /> -->
</UButton>
<!-- </client-only> -->
@ -610,7 +606,7 @@ onMounted(() => {
{{ state.phrase.label }}
<UIcon
v-if="search_type == 'phrase'"
@click.self="setType('normal')"
@click.self="search_type = 'normal'"
name="i-haditha-close-bg-circle"
size="20px"
>

View File

@ -126,7 +126,7 @@ const leftItem = computed(() => [
const isMobile = ref(false);
const rerenderNavigation = ref(1);
const { isAuthenticatedGetter, isRealUserGetter } = useAuthStore();
const { isAuthenticatedGetter } = useAuthStore();
const setMenu = () => {
if (isAuthenticatedGetter) {
@ -152,9 +152,6 @@ const setMenu = () => {
setMenu();
// if(!(isAuthenticatedGetter && isRealUserGetter))
// items.value = items.value.filter((item) => item.to != "/haditha/favorites");
onMounted(() => {
if (window?.outerWidth < 991) {
isMobile.value = true;

View File

@ -1,6 +1,4 @@
<script setup>
import hadithaApi from "@haditha/apis/hadithaApi";
const httpService = useNuxtApp()["$http"];
const props = defineProps({
list: {
default() {
@ -18,7 +16,6 @@ const props = defineProps({
},
});
const router = useRouter();
const route = useRoute();
// const modal = useModal();
// const isModalOpen = ref(false);
@ -27,20 +24,17 @@ function openModal(selectedItem) {
// modal.open(SearchShow, { title: "Welcome" });
// isModalOpen.value = true;
const slug = selectedItem?._source?.content
.split(" ")
.filter((v, i) => i < 4)
.join("-");
const slug = selectedItem._source.content.split(' ').filter((v,i)=>i<4).join('-');
router.push({
name: "hadithaSearchShow",
params: {
id: selectedItem?._source?.id,
id: selectedItem._source.id,
slug: slug,
},
query: {
firstPage: 1,
page_count: props.total,
page_count:props.total
},
});
}
@ -58,20 +52,6 @@ function openModal(selectedItem) {
// const SearchShow = defineAsyncComponent(() =>
// import("@haditha/components/haditha/search-page/SearchShow.vue")
// );
const removeFromFavorites = async (item = {}, index = 0) => {
let url = repoUrl() + hadithaApi.favorite.deleteByRefid;
url = url.replace("{{data_type}}", "bookmark");
url = url.replace("{{index_key}}", "dhparag");
url = url.replace("{{ref_id}}", item._id);
const formData = {
ref_id: item._id,
title: item?._source?.title,
};
httpService.postRequest(url, formData).then((res) => {
// this.updateListAnswer(index, "tbookmark", 0);
});
};
</script>
<template>
@ -88,43 +68,20 @@ const removeFromFavorites = async (item = {}, index = 0) => {
v-for="(item, index) in props.list"
:key="index"
>
<div class="flex justify-between mt-4 mb-2">
<a
:href="`/haditha/search/${item?._source?.id}/${
item?._source?.meta?.hadith_masoum ??
item?._source?.meta?.hadith_sanad
}`"
@click.prevent="openModal(item)"
class="from-person block"
>
{{
item?._source?.meta?.hadith_masoum ??
item?._source?.meta?.hadith_sanad
}}
</a>
<UButton
v-if="route.name == 'hadithaFavorites'"
@click="removeFromFavorites(item)"
variant="ghost"
color="error"
class="copy-btn"
label="حذف"
/>
</div>
<a
@click.prevent="openModal(item)"
class="arabic-text block"
:href="`/haditha/search/${item?._source?.id}/${item?._source?.content_ar}`"
>
<p @click="openModal(item)" class="from-person">
{{
item?._source?.meta?.hadith_masoum ??
item?._source?.meta?.hadith_sanad ??
"بدون عنوان"
}}
</p>
<p @click="openModal(item)" class="arabic-text">
{{ item?._source?.content_ar }}
</a>
<a
@click.prevent="openModal(item)"
:href="`/haditha/search/${item?._source?.id}/${item?._source?.content}`"
class="persian-text block"
</p>
<p
class="persian-text"
v-html="item?.highlight?.['content.fa'] ?? item?._source?.content"
></a>
></p>
<div class="flex justify-end">
<p class="reference">
{{ item?._source?.address?.vol_title }}، صفحه
@ -245,7 +202,7 @@ const removeFromFavorites = async (item = {}, index = 0) => {
.reference {
height: 24px;
gap: 4px;
padding-top: 0.25em; /*4px*/
padding-top: 0.25em; /*4px*/
padding-right: 0.5em; /*8px*/
padding-bottom: 0.25em; /*4px*/
padding-left: 0.5em; /*8px*/
@ -274,7 +231,7 @@ const removeFromFavorites = async (item = {}, index = 0) => {
font-family: IRANSansX;
font-weight: 300;
font-size: 1rem;
line-height: 1.5rem; /*24px*/
line-height: 1.5rem; /*24px*/
letter-spacing: 0%;
text-align: center;
}
@ -291,7 +248,7 @@ const removeFromFavorites = async (item = {}, index = 0) => {
box-shadow: 0px 8px 20px 0px #0000001a;
background: #ffffff;
width: 100%;
max-width: 720px; /*18px*/
max-width: 720px; /*18px*/
border-radius: 16px; /*18px*/
gap: 8px;
border-width: 0.3px;
@ -354,28 +311,4 @@ const removeFromFavorites = async (item = {}, index = 0) => {
.modal-overlay {
background: #00000033;
}
.copy-btn {
padding: 0.2em 1em;
/* width: 44px; */
/* height: 24px; */
gap: 4px;
border-radius: 6px;
border-width: 0.5px;
padding-top: 4px;
padding-right: 12px;
padding-bottom: 4px;
padding-left: 12px;
/* background: #ffffff; */
/* border: 0.5px solid #d9d9d9; */
font-family: IRANSansX;
font-weight: 300;
font-size: 12px;
line-height: 18px;
letter-spacing: 0%;
text-align: right;
/* color: #a71111; */
}
</style>

View File

@ -132,7 +132,6 @@ const route = useRoute();
const router = useRouter();
const loading = ref(false);
const httpService = useNuxtApp()["$http"];
const toast = useToast();
const state = reactive({
selectedItem: {} as HadithResponseShowModel,
@ -175,13 +174,7 @@ const goToTheChatbot = () => {
};
const handleFavorite = async () => {
if (state.selectedItem?._source?.tbookmark) {
await removeFromFavorites(state.selectedItem);
state.selectedItem._source.tbookmark = false;
} else {
await addToFavorites(state.selectedItem);
state.selectedItem._source.tbookmark = true;
}
addToFavorites(state.selectedItem);
// // add
// if (!state.selectedItem._source.tbookmark) {
@ -203,21 +196,6 @@ const addToFavorites = async (item = {}) => {
};
httpService.postRequest(url, formData).then((res) => {
// this.updateListAnswer(index, "tbookmark", 1);
try {
toast.add({
title: "انجام شد.",
description: "به نشان شده ها افزوده شد",
color: "success",
});
} catch (err) {
console.log(err.message);
toast.add({
title: "انجام شد.",
description: "خطایی رخ داد.لطفا دوباره امتحان کنید.",
color: "error",
});
}
});
};
@ -233,21 +211,6 @@ const removeFromFavorites = async (item = {}, index = 0) => {
};
httpService.postRequest(url, formData).then((res) => {
// this.updateListAnswer(index, "tbookmark", 0);
try {
toast.add({
title: "انجام شد.",
description: "از لیست نشان شده ها حذف شد",
color: "success",
});
} catch (err) {
console.log(err.message);
toast.add({
title: "انجام شد.",
description: "خطایی رخ داد.لطفا دوباره امتحان کنید.",
color: "error",
});
}
});
};
@ -257,8 +220,8 @@ const handlePagination = (prevNextIndicator: string) => {
let url = repoUrl() + hadithaApi.search.prevNextHadith;
url = url.replace("@index_key", "dhparag");
url = url.replace("@vol_id", state.selectedItem?._source?.address?.vol_id);
url = url.replace("@parag_order", state.selectedItem?._source?.parag_order);
url = url.replace("@vol_id", state.selectedItem._source.address.vol_id);
url = url.replace("@parag_order", state.selectedItem._source.parag_order);
url = url.replace("@step", prevNextIndicator);
httpService
@ -342,19 +305,14 @@ const handlePagination = (prevNextIndicator: string) => {
<span class="section-title">
{{
state.selectedItem?._source?.meta?.hadith_masoum ??
state.selectedItem?._source?.meta?.hadith_sanad
"بدون عنوان"
}}
</span>
<UButton
v-if="
state.selectedItem?._source?.meta?.hadith_masoum
?.length ||
state.selectedItem?._source?.meta?.hadith_sanad
"
@click="
copyTextToClipboard(
state.selectedItem?._source?.content_ar ?? ''
state.selectedItem?._source?.meta?.hadith_masoum ?? ''
)
"
variant="ghost"
@ -362,13 +320,8 @@ const handlePagination = (prevNextIndicator: string) => {
label="کپی"
/>
</div>
<div
v-if="state.selectedItem?._source?.content_ar?.length"
class="arabic-text"
>
<p>
{{ state.selectedItem?._source?.content_ar ?? "" }}
</p>
<div class="arabic-text">
<p>بدون متن عربی</p>
</div>
</div>
@ -392,7 +345,7 @@ const handlePagination = (prevNextIndicator: string) => {
<p class="from">
{{
state.selectedItem?._source?.meta?.hadith_masoum ??
state.selectedItem?._source?.meta?.hadith_sanad
"بدون عنوان"
}}:
</p>
<p
@ -403,16 +356,13 @@ const handlePagination = (prevNextIndicator: string) => {
<div class="separator"></div>
<div
v-if="state.selectedItem?._source?.description?.length"
class="text-description-section"
>
<div class="text-description-section">
<div class="section-header">
<span class="section-title"> شرح </span>
<UButton
@click="
copyTextToClipboard(
state.selectedItem?._source?.description
state.selectedItem?._source?.content
)
"
variant="ghost"
@ -422,17 +372,14 @@ const handlePagination = (prevNextIndicator: string) => {
</div>
<p
class="description-item"
v-html="state.selectedItem?._source?.description"
v-html="state.selectedItem?._source?.content"
></p>
</div>
<div class="separator"></div>
<div class="text-description-section">
<div
v-if="state.selectedItem?._source?.ai_keywords?.length"
class="text-sm mb-1"
>
<div class="text-sm mb-1">
<span class=""> کلیدواژگان: </span>
<span
class="me-1 text-gray-400 font-light"
@ -445,10 +392,7 @@ const handlePagination = (prevNextIndicator: string) => {
</span>
</div>
<div
class="text-sm"
v-if="state.selectedItem?._source?.ai_classes?.length"
>
<div class="text-sm">
<span class=""> دسته بندی ها: </span>
<span
class="me-1 text-gray-400 font-light"