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

fix: update the fields shown in new customer portal #2013

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions desk/src/components/ColumnSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
</template>
</Draggable>
<div class="mt-1.5 flex flex-col gap-1 border-t pt-1.5">
<!-- Show Add Column Button only for Agent Side -->
<Autocomplete
v-if="!isCustomerPortal"
value=""
:options="fields"
@change="(e) => addColumn(e)"
Expand Down
8 changes: 5 additions & 3 deletions desk/src/pages/KnowledgeBaseArticle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<div class="overflow-auto">
<div class="mx-5 my-12">
<TextEditor
v-if="textEditorContentWithIDs"
:content="textEditorContentWithIDs"
:editable="editMode"
:placeholder="placeholder"
Expand All @@ -48,9 +47,12 @@
/>
</template>
</TextEditor>
<div v-else class="text-gray-500 text-2xl font-semibold mb-5">
<!-- <div
v-else-if="!article.data && !editMode"
class="text-gray-500 text-2xl font-semibold mb-5"
>
Article Not Found
</div>
</div> -->
<RouterLink
v-if="route.meta.public"
:to="{ name: CUSTOMER_PORTAL_NEW_TICKET }"
Expand Down
48 changes: 28 additions & 20 deletions helpdesk/api/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def get_filterable_fields(doctype: str, show_customer_portal_fields=False):
"Text Editor",
"Text",
]

visible_custom_fields = get_visible_custom_fields()
customer_portal_fields = [
"name",
"subject",
Expand All @@ -49,14 +51,6 @@ def get_filterable_fields(doctype: str, show_customer_portal_fields=False):
.where(Criterion.any([QBDocField.fieldtype == i for i in allowed_fieldtypes]))
)

# for customer portal show only fields present in customer_portal_fields
if show_customer_portal_fields:
from_doc_fields = from_doc_fields.where(
QBDocField.fieldname.isin(customer_portal_fields)
)

from_doc_fields = from_doc_fields.run(as_dict=True)

from_custom_fields = (
frappe.qb.from_(QBCustomField)
.select(
Expand All @@ -71,16 +65,28 @@ def get_filterable_fields(doctype: str, show_customer_portal_fields=False):
.where(
Criterion.any([QBCustomField.fieldtype == i for i in allowed_fieldtypes])
)
.run(as_dict=True)
)

# for customer portal show only fields present in customer_portal_fields

if show_customer_portal_fields:
from_doc_fields = from_doc_fields.where(
QBDocField.fieldname.isin(customer_portal_fields)
)
from_custom_fields = from_custom_fields.where(
QBCustomField.fieldname.isin(visible_custom_fields)
)

from_doc_fields = from_doc_fields.run(as_dict=True)
from_custom_fields = from_custom_fields.run(as_dict=True)

# from hd ticket template get children with fieldname and hidden_from_customer

res = []
res.extend(from_doc_fields)
# TODO: Ritvik => till a better way we have for custom fields, just show custom fields
res.extend(from_custom_fields)
if not show_customer_portal_fields:
# TODO: Ritvik => till a better way we have for custom fields, dont show custom fields in customer portal
res.extend(from_custom_fields)
res.append(
{
"fieldname": "_assign",
Expand Down Expand Up @@ -242,9 +248,7 @@ def sort_options(doctype: str, show_customer_portal_fields=False):


def get_customer_portal_fields(doctype, fields):
custom_fields = frappe.db.get_all(
"Custom Field", {"dt": doctype}, pluck="fieldname"
)
visible_custom_fields = get_visible_custom_fields()
customer_portal_fields = [
"name",
"subject",
Expand All @@ -253,11 +257,15 @@ def get_customer_portal_fields(doctype, fields):
"response_by",
"resolution_by",
"creation",
*visible_custom_fields,
]
fields = [
field
for field in fields
if field.get("value") not in custom_fields
and field.get("value") in customer_portal_fields
]
fields = [field for field in fields if field.get("value") in customer_portal_fields]
return fields


def get_visible_custom_fields():
return frappe.db.get_all(
"HD Ticket Template Field",
{"parent": "Default", "hide_from_customer": 0},
pluck="fieldname",
)
12 changes: 6 additions & 6 deletions helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,12 +845,12 @@ def default_list_data(show_customer_portal_fields=False):
"key": "agent_group",
"width": "10rem",
},
{
"label": "Assigned To",
"type": "Text",
"key": "_assign",
"width": "10rem",
},
# {
# "label": "Assigned To",
# "type": "Text",
# "key": "_assign",
# "width": "10rem",
# },
{
"label": "Created",
"type": "Datetime",
Expand Down
Loading