Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2076-item_tags_refactor
gitea/salix/2076-item_tags_refactor This commit has test failures
Details
gitea/salix/2076-item_tags_refactor This commit has test failures
Details
This commit is contained in:
commit
462cf46753
|
@ -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: 'problems',
|
||||
type: 'Boolean',
|
||||
description: `Whether to show only tickets with problems`
|
||||
}, {
|
||||
arg: 'mine',
|
||||
type: 'Boolean',
|
||||
|
@ -239,6 +243,38 @@ module.exports = Self => {
|
|||
FROM tmp.filter f
|
||||
LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id
|
||||
LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`);
|
||||
|
||||
|
||||
let condition;
|
||||
let hasProblem;
|
||||
let range;
|
||||
let hasWhere;
|
||||
switch (ctx.args.problems) {
|
||||
case true:
|
||||
condition = `or`;
|
||||
hasProblem = true;
|
||||
range = 0;
|
||||
hasWhere = true;
|
||||
break;
|
||||
|
||||
case false:
|
||||
condition = `and`;
|
||||
hasProblem = null;
|
||||
range = null;
|
||||
hasWhere = true;
|
||||
break;
|
||||
}
|
||||
|
||||
let problems = {[condition]: [
|
||||
{'tp.isFreezed': hasProblem},
|
||||
{'tp.risk': hasProblem},
|
||||
{'tp.hasTicketRequest': hasProblem},
|
||||
{'tp.isAvailable': range}
|
||||
]};
|
||||
|
||||
if (hasWhere)
|
||||
stmt.merge(conn.makeWhere(problems));
|
||||
|
||||
stmt.merge(conn.makeOrderBy(filter.order));
|
||||
let ticketsIndex = stmts.push(stmt);
|
||||
|
||||
|
|
|
@ -10,4 +10,31 @@ describe('ticket filter()', () => {
|
|||
|
||||
expect(ticketId).toEqual(24);
|
||||
});
|
||||
|
||||
it('should return the tickets matching the problems on true', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}, args: {problems: true}};
|
||||
|
||||
let filter = {};
|
||||
let result = await app.models.Ticket.filter(ctx, filter);
|
||||
|
||||
expect(result.length).toEqual(4);
|
||||
});
|
||||
|
||||
it('should return the tickets matching the problems on false', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}, args: {problems: false}};
|
||||
|
||||
let filter = {};
|
||||
let result = await app.models.Ticket.filter(ctx, filter);
|
||||
|
||||
expect(result.length).toEqual(20);
|
||||
});
|
||||
|
||||
it('should return the tickets matching the problems on null', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}};
|
||||
|
||||
let filter = {};
|
||||
let result = await app.models.Ticket.filter(ctx, filter);
|
||||
|
||||
expect(result.length).toEqual(24);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -91,12 +91,6 @@
|
|||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="My team"
|
||||
ng-model="filter.myTeam"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Warehouse"
|
||||
|
@ -110,6 +104,20 @@
|
|||
url="Provinces">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="My team"
|
||||
ng-model="filter.myTeam"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Problems"
|
||||
ng-model="filter.problems"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -23,11 +23,11 @@ module.exports = Self => {
|
|||
beginningYear.setHours(0, 0, 0, 0);
|
||||
|
||||
let holidays = await Self.rawSql(
|
||||
`SELECT lh.dated, lhl.description, lht.name, w.id
|
||||
`SELECT lh.dated, chn.name, cht.name, w.id
|
||||
FROM vn.holiday lh
|
||||
JOIN vn.workCenter w ON w.id = lh.workcenterFk
|
||||
LEFT JOIN vn.holidayDetail lhl ON lhl.id = lh.holidayDetailFk
|
||||
LEFT JOIN vn.holidayType lht ON lht.id = lh.holidayTypeFk
|
||||
LEFT JOIN vn.calendarHolidaysName chn ON chn.id = lh.holidayDetailFk
|
||||
LEFT JOIN vn.calendarHolidaysType cht ON cht.id = lh.holidayTypeFk
|
||||
WHERE w.warehouseFk = ? AND lh.dated >= ?`, [warehouseFk, beginningYear]);
|
||||
|
||||
return holidays.map(holiday => {
|
||||
|
|
Loading…
Reference in New Issue