diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 16255bf82d..929ea92c90 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -63,6 +63,10 @@ module.exports = Self => { arg: 'myTeam', type: 'Boolean', description: `Whether to show only tickets for the current logged user team (For now it shows only the current user tickets)` + }, { + arg: 'mine', + type: 'Boolean', + description: `Whether to show only tickets for the current logged user` }, { arg: 'orderFk', type: 'Number', @@ -107,6 +111,10 @@ module.exports = Self => { teamIds = [worker && worker.id]; } + if (ctx.args && ctx.args.mine || ctx.args.myTeam) + ctx.args.teamIds = teamIds; + + let orderTickets = []; if (ctx.args && ctx.args.orderFk) { let ticketsToSearch = await Self.app.models.OrderTickets.find({where: {orderFk: filter.orderFk}}); @@ -134,6 +142,7 @@ module.exports = Self => { return {'a.provinceFk': value}; case 'stateFk': return {'ts.stateFk': value}; + case 'mine': case 'myTeam': return {'c.salesPersonFk': {inq: teamIds}}; case 'alertLevel': diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index ba0b6dc6cf..f52b2591be 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -19,9 +19,15 @@ export default class Controller { tomorrow.setHours(23, 59, 59, 999); tomorrow.setTime(tomorrow.getTime() - offset); - // FIXME: History loop - // let filter = {myTeam: true, from: today, to: tomorrow}; - // $state.go('.', {q: JSON.stringify(filter)}); + let sixDays = new Date(today); + sixDays.setDate(today.getDate() + 6); + sixDays.setHours(23, 59, 59, 999); + sixDays.setTime(sixDays.getTime() - offset); + this.filter = {mine: true, from: today, to: sixDays}; + } + + $postLink() { + this.onSearch(this.filter); } onSearch(params) {