Skip to content
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

feat: modify for frappe-search #269

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 24 additions & 30 deletions frontend/src/pages/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
v-if="$resources.search.params && $resources.search.data"
class="mt-4 text-base font-semibold text-gray-800"
>
About {{ $resources.search.data.total }} results for "{{
{{ $resources.search.data.total }} results for "{{
$resources.search.params?.query
}}" ({{ $resources.search.data.duration.toFixed(2) }}
}}" (in about {{ $resources.search.data.duration.toFixed(2) }}
ms)
</div>
<div
Expand All @@ -44,21 +44,18 @@
</div>
<router-link
v-for="item in group.items"
:key="item.name + item.via_comment"
:key="item.name"
:to="getRoute(item)"
class="block overflow-hidden rounded px-2.5 py-3 hover:bg-gray-100"
>
<div class="flex items-center">
<div class="text-base font-medium" v-html="item.title" />
<div class="text-base font-medium" v-html="item.highlighted_title || item.title" />
<span class="px-1 leading-none text-gray-600"> &middot; </span>
<div class="text-sm text-gray-600">
{{ timestamp(item) }}
</div>
</div>
<div
v-if="item.content"
v-if="item.highlighted_content"
class="mt-1 text-p-base text-gray-700"
v-html="trimContent(item.content)"
v-html="trimContent(item.highlighted_content.replaceAll('|||', '·'))"
></div>
</router-link>
</div>
Expand All @@ -83,7 +80,7 @@ export default {
resources: {
search: {
cache: 'Search',
url: 'gameplan.api.search',
url: 'frappe_search.core.search',
safwansamsudeen marked this conversation as resolved.
Show resolved Hide resolved
makeParams(query) {
return { query, start: this.start }
},
Expand All @@ -93,25 +90,22 @@ export default {
total: data.total,
duration: data.duration,
}
for (let doctype in data.results) {
let group = null
if (doctype === 'GP Discussion') {
group = 'Discussions'
} else if (doctype === 'GP Task') {
group = 'Tasks'
} else if (doctype === 'GP Page') {
group = 'Pages'
}
if (!group) {
continue
for (let group in data.results) {
safwansamsudeen marked this conversation as resolved.
Show resolved Hide resolved
let title
if (group === 'GP Discussion') {
title = 'Discussions'
} else if (group === 'GP Task') {
title = 'Tasks'
} else if (group === 'GP Page') {
title = 'Pages'
}
out.groups.push({
title: group,
items: data.results[doctype],
title,
items: data.results[group],
})
}
return out
},
}
},
},
methods: {
Expand Down Expand Up @@ -148,8 +142,8 @@ export default {
return {
name: 'ProjectDiscussion',
params: {
teamId: item.team,
projectId: item.project,
teamId: item.extras.team,
safwansamsudeen marked this conversation as resolved.
Show resolved Hide resolved
projectId: item.extras.project,
postId: item.name,
},
}
Expand All @@ -158,8 +152,8 @@ export default {
return {
name: item.project ? 'ProjectTaskDetail' : 'Task',
params: {
teamId: item.team,
projectId: item.project,
teamId: item.extras.team,
projectId: item.extras.project,
taskId: item.name,
},
}
Expand All @@ -168,8 +162,8 @@ export default {
return {
name: 'ProjectPage',
params: {
teamId: item.team,
projectId: item.project,
teamId: item.extras.team,
projectId: item.extras.project,
pageId: item.name,
},
}
Expand Down
21 changes: 21 additions & 0 deletions gameplan/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,24 @@
# Recommended only for DocTypes which have limited documents with untranslated names
# For example: Role, Gender, etc.
# translated_search_doctypes = []

frappe_search_doctypes = {
safwansamsudeen marked this conversation as resolved.
Show resolved Hide resolved
"GP Discussion": {
"title": "title",
"content": ["content"],
safwansamsudeen marked this conversation as resolved.
Show resolved Hide resolved
"extras": ["team", "project"],
},
"GP Task": {
"title": "title",
"content": ["description"],
"extras": ["team", "project"],
},
"GP Page": {
"title": "title",
"content": ["content"],
"extras": ["team", "project"],
},
"GP Comment": {
"content": ["content"],
},
}
Loading