Skip to content

[ADD] helpdesk_tickets_tickets: Added snippet for helpdesk tickets #755

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

Draft
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Draft
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
Empty file.
24 changes: 24 additions & 0 deletions website_helpdesk_tickets/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
'name': 'Website Helpdesk Tickets',
'version': '1.0',
'description': 'Display helpdesk tickets on the website via snippets.',
'license': 'LGPL-3',
'depends': [
'website_helpdesk', 'website', 'web_editor'
],
'data': [
'views/snippets/snippets.xml',
'views/snippets/s_helpdesk_tickets.xml',
],
'auto_install': False,
'application': False,
'assets': {
'web.assets_frontend': [
'website_helpdesk_tickets/static/**/*',
('remove', 'website_helpdesk_tickets/static/src/snippets/s_helpdesk_tickets/options.js'),
],
'website.assets_wysiwyg': [
'website_helpdesk_tickets/static/src/snippets/s_helpdesk_tickets/options.js',
]
}
}
18 changes: 18 additions & 0 deletions website_helpdesk_tickets/static/src/img/books.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/** @odoo-module */
import { renderToElement } from "@web/core/utils/render";
import publicWidget from "@web/legacy/js/public/public_widget";


publicWidget.registry.GetHelpdeskTickets = publicWidget.Widget.extend({
selector : ".s_helpdesk_tickets",
disabledInEditableMode: false,

init() {
this._super(...arguments);
this.orm = this.bindService("orm");
},

async willStart() {
const helpdesk_team_id = this.el.dataset.helpdeskTeamId
const domain = []
if(helpdesk_team_id && helpdesk_team_id != "")
domain.push(["team_id", "=", parseInt(helpdesk_team_id)])
this.result = await this.orm.searchRead(
"helpdesk.ticket",
domain,
["id", "name", "user_id", "partner_id", "priority"],
)
},
start() {
if(this.result){
this.el.innerHTML = "";
this.el.append(renderToElement(this.el.dataset.layout == "list"? "website_helpdesk_tickets.s_helpdesk_tickets_list": "website_helpdesk_tickets.s_helpdesk_tickets_card", {result: this.result}))
}
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>

<templates xml:space="preserve">
<t t-name="website_helpdesk_tickets.s_helpdesk_tickets_card">
<t class="s_helpdesk_tickets">
<div class="my-5 container">
<h2 class="text-center mb-4">Helpdesk Tickets</h2>
<div class="g-4 row">
<t t-if="result.length == 0">
<div class="container">
<p class="text-center">No tickets to display</p>
</div>
</t>
<t t-else="">
<p class="text-center mb-5">Here are the latest support tickets for your selected team.</p>
<t t-foreach="result" t-as="ticket" t-key="ticket.id">
<div class="col-md-4">
<div class="card h-100 shadow-lg border-1 rounded-4">
<div class="card-body d-flex flex-column p-4">
<h5 class="card-title mb-3 text-primary fw-semibold">
<t t-esc="ticket.name"/>
</h5>

<ul class="list-unstyled text-muted small mb-0">
<li class="mb-1">
<strong>Assigned To: </strong>
<t t-if="ticket.user_id">
<t t-out="ticket.user_id[1]"/>
</t>
<t t-else="">
<span class="fst-italic text-danger">Unassigned</span>
</t>
</li>
<li class="mb-1">
<strong>Customer: </strong>
<t t-if="ticket.partner_id">
<t t-out="ticket.partner_id[1]"/>
</t>
<t t-else="">
<span class="fst-italic text-muted">Not Set</span>
</t>
</li>
<li class="mb-1">
<strong>Priority: </strong>
<t t-if="ticket.priority">
<t t-esc="ticket.priority"/>
</t>
<t t-else="">
<span class="text-warning">Normal</span>
</t>
</li>
</ul>
</div>
</div>
</div>
</t>
</t>
</div>
</div>
</t>
</t>

<t t-name="website_helpdesk_tickets.s_helpdesk_tickets_list">
<t class="s_helpdesk_tickets">
<div class="my-5 container">
<h2 class="text-center mb-4">Helpdesk Tickets</h2>
<div>
<t t-if="result.length == 0">
<div class="container">
<p class="text-center">No tickets to display</p>
</div>
</t>
<t t-else="">
<p class="text-center mb-4">Here are the latest support tickets for your selected team.</p>
<ul class="list-group">
<t t-foreach="result" t-as="ticket" t-key="ticket.id">
<li class="list-group-item d-flex flex-column gap-2 py-3 px-4">
<h5 class="mb-1 text-primary fw-semibold">
<t t-esc="ticket.name"/>
</h5>
<div class="text-muted small">
<p class="mb-1">
<strong>Assigned To:</strong>
<t t-if="ticket.user_id">
<t t-out="ticket.user_id[1]"/>
</t>
<t t-else="">
<span class="fst-italic text-danger">Unassigned</span>
</t>
</p>
<p class="mb-1">
<strong>Customer:</strong>
<t t-if="ticket.partner_id">
<t t-out="ticket.partner_id[1]"/>
</t>
<t t-else="">
<span class="fst-italic text-muted">Not Set</span>
</t>
</p>
<p class="mb-0">
<strong>Priority:</strong>
<t t-if="ticket.priority">
<t t-esc="ticket.priority"/>
</t>
<t t-else="">
<span class="text-warning">Normal</span>
</t>
</p>
</div>
</li>
</t>
</ul>
</t>
</div>
</div>
</t>
</t>


</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/** @odoo-module **/

import options from "@web_editor/js/editor/snippets.options";

options.registry.HelpdeskTickets = options.Class.extend({

//----------------------------------------------------------------------
// Private methods
//----------------------------------------------------------------------

/**
* @override
*/
_computeWidgetState(methodName, params) {
if (methodName === "setHelpdeskTeamId") {
return this.$target[0].dataset.helpdeskTeamId || "";
}
if (methodName === "setLayout") {
return this.$target[0].dataset.layout || "card";
}
return this._super(...arguments);
},
});
28 changes: 28 additions & 0 deletions website_helpdesk_tickets/views/snippets/s_helpdesk_tickets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<!-- Define the custom snippet -->
<template id="s_helpdesk_tickets" name="Helpdesk Tic36kets">
<section class="s_helpdesk_tickets o_snippet" data-snippet="s_helpdesk_tickets" data-name="Help Tickets">
<div class="my-5 container">
<h2 class="text-center mb-4">Helpdesk Tickets</h2>
<p class="text-center mb-5">Choose which tickets to be shown from options menu.</p>
</div>
</section>
</template>

<template id="helpdesk_input_snippet_options" inherit_id="website.snippet_options">
<xpath expr="." position="inside">
<div data-js="HelpdeskTickets" data-selector=".s_helpdesk_tickets">
<we-row>
<we-many2one string="Helpdesk Team" data-model="helpdesk.team" data-name="helpdesk_team_opt" data-no-preview="true" data-default-message="All Teams" data-select-attribute="" data-attribute-name="data-helpdesk-team-id"/>
<we-button data-icon="fa-times" data-no-preview="true" data-select-attribute="" data-attribute-name="data-helpdesk-team-id"/>
</we-row>
<we-select string="Select layout" data-no-preview="true" data-attribute-default-value="card">
<we-button title="Card" data-select-data-attribute="card" data-attribute-name="layout" data-value="card">Card</we-button>
<we-button title="List" data-select-data-attribute="list" data-attribute-name="layout" data-value="list">List</we-button>
</we-select>
</div>
</xpath>
</template>
</odoo>
24 changes: 24 additions & 0 deletions website_helpdesk_tickets/views/snippets/snippets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="external_snippets" inherit_id="website.snippets" priority="15">
<xpath expr="//snippets[@id='snippet_structure']//t[@id='event_upcoming_snippet_hook']" position="after">
<t id="helpdesk_hook"/>
</xpath>
</template>
<template id="snippets" inherit_id="website.snippets">
<xpath expr="//t[@id='helpdesk_hook']" position="replace">
<t t-snippet="website_helpdesk_tickets.s_helpdesk_tickets"
string="Helpdesk" group="helpdesk"/>
</xpath>
<xpath expr="//t[@id='installed_snippets_hook']" position="after">
<t snippet-group="helpdesk" t-snippet="website.s_snippet_group" string="Helpdesk"
t-thumbnail="/website_enterprise/static/src/img/snippets_thumbs/s_appointments.svg"/>
</xpath>
</template>
<template id="helpdesk_ticket_snippet" inherit_id="website.snippets">
<xpath expr="//snippets[@id='snippet_content']//t[@t-snippet][last()]" position="after">
<t t-snippet="website_helpdesk_tickets.s_helpdesk_tickets" string="Helpdesk Tickets" t-thumbnail="/website_helpdesk_tickets/static/src/img/books.svg"/>
</xpath>
</template>

</odoo>