File tree Expand file tree Collapse file tree 5 files changed +68
-7
lines changed
helpdesk/doctype/hd_ticket Expand file tree Collapse file tree 5 files changed +68
-7
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div
3
+ class =" grid h-full place-items-center px-4 py-20 text-center text-lg text-gray-600"
4
+ >
5
+ <div class =" space-y-2" >
6
+ <div >Invalid page or not permitted to access</div >
7
+ <Button :route =" { name: 'TicketsAgent' }" >
8
+ <template #prefix ><TicketIcon class =" w-4" /></template >
9
+ Tickets
10
+ </Button >
11
+ </div >
12
+ </div >
13
+ </template >
14
+
15
+ <script setup>
16
+ import TicketIcon from " @/components/icons/TicketIcon.vue" ;
17
+ </script >
Original file line number Diff line number Diff line change 115
115
<span class =" block text-sm text-gray-700" >
116
116
{{ o.label }}
117
117
</span >
118
+ <FormControl
119
+ v-if =" o.type === 'select'"
120
+ :type =" o.type"
121
+ :value =" data[o.field]"
122
+ :options =" customers?.data"
123
+ @change =" update(o.field, $event.target.value)"
124
+ />
118
125
<Autocomplete
126
+ v-else
119
127
:options =" o.store.dropdown"
120
128
:placeholder =" `Select a ${o.label}`"
121
129
:value =" data[o.field]"
136
144
<script setup lang="ts">
137
145
import { computed , inject } from " vue" ;
138
146
import { Autocomplete } from " @/components" ;
139
- import { createResource , Tooltip } from " frappe-ui" ;
147
+ import { createResource , Tooltip , FormControl } from " frappe-ui" ;
140
148
import { dayjs } from " @/dayjs" ;
141
149
import { emitter } from " @/emitter" ;
142
150
import { createToast } from " @/utils" ;
@@ -167,8 +175,27 @@ const options = computed(() => [
167
175
label: " Team" ,
168
176
store: useTeamStore (),
169
177
},
178
+ {
179
+ field: " customer" ,
180
+ label: " Customer" ,
181
+ type: " select" ,
182
+ },
170
183
]);
171
184
185
+ const customers = createResource ({
186
+ url: " helpdesk.utils.get_customer" ,
187
+ params: {
188
+ contact: ticket ?.data ?.raised_by ,
189
+ },
190
+ auto: true ,
191
+ transform : (data ) => {
192
+ return data .map ((d ) => ({
193
+ label: d ,
194
+ value: d ,
195
+ }));
196
+ },
197
+ });
198
+
172
199
function update(fieldname : string , value : string ) {
173
200
createResource ({
174
201
url: " frappe.client.set_value" ,
Original file line number Diff line number Diff line change @@ -55,6 +55,11 @@ const routes = [
55
55
name : ONBOARDING_PAGE ,
56
56
component : ( ) => import ( "@/pages/onboarding/SimpleOnboarding.vue" ) ,
57
57
} ,
58
+ {
59
+ path : "/:invalidpath" ,
60
+ name : "Invalid Page" ,
61
+ component : ( ) => import ( "@/pages/InvalidPage.vue" ) ,
62
+ } ,
58
63
{
59
64
path : "" ,
60
65
name : "AgentRoot" ,
@@ -197,8 +202,16 @@ router.beforeEach(async (to) => {
197
202
await authStore . init ( ) ;
198
203
await usersStore . init ( ) ;
199
204
200
- if ( ( to . meta . agent && ! authStore . hasDeskAccess ) || isAuthRoute ) {
201
- router . replace ( { name : WEBSITE_ROOT } ) ;
205
+ if ( isAuthRoute && authStore . isLoggedIn ) {
206
+ if ( authStore . isAgent ) {
207
+ router . replace ( { name : AGENT_PORTAL_LANDING } ) ;
208
+ } else {
209
+ router . replace ( { name : CUSTOMER_PORTAL_LANDING } ) ;
210
+ }
211
+ } else if ( ! isAuthRoute && ! authStore . isLoggedIn ) {
212
+ router . replace ( { name : "Login" } ) ;
213
+ } else if ( to . matched . length === 0 ) {
214
+ router . replace ( { name : "Invalid Page" } ) ;
202
215
}
203
216
} catch {
204
217
if ( ! isAuthRoute ) {
Original file line number Diff line number Diff line change @@ -167,14 +167,16 @@ def before_validate(self):
167
167
self .check_update_perms ()
168
168
self .set_ticket_type ()
169
169
self .set_raised_by ()
170
- self .set_contact ()
171
- self .set_customer ()
172
170
self .set_priority ()
173
171
self .set_first_responded_on ()
174
172
self .set_feedback_values ()
175
173
self .apply_escalation_rule ()
176
174
self .set_sla ()
177
175
176
+ if self .via_customer_portal :
177
+ self .set_contact ()
178
+ self .set_customer ()
179
+
178
180
def validate (self ):
179
181
self .validate_feedback ()
180
182
self .validate_ticket_type ()
@@ -240,7 +242,9 @@ def set_customer(self):
240
242
if self .customer :
241
243
return
242
244
customer = get_customer (self .contact )
243
- if len (customer ) > 0 :
245
+
246
+ # let agent assign the customer when one contact has more than one customer
247
+ if len (customer ) == 1 :
244
248
self .customer = customer [0 ]
245
249
246
250
def set_priority (self ):
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def refetch_resource(key: str | List[str], user=None):
68
68
def capture_event (event : str ):
69
69
return _capture (event , "helpdesk" )
70
70
71
-
71
+ @ frappe . whitelist ()
72
72
def get_customer (contact : str ) -> tuple [str ]:
73
73
"""
74
74
Get `Customer` from `Contact`
You can’t perform that action at this time.
0 commit comments