feat(Searchbar): You can now filter by a ticket collection #722
|
@ -6,6 +6,6 @@ describe('newCollection()', () => {
|
||||||
let response = await app.models.Collection.newCollection(ctx, 1, 1, 1);
|
let response = await app.models.Collection.newCollection(ctx, 1, 1, 1);
|
||||||
|
|
||||||
expect(response.length).toBeGreaterThan(0);
|
expect(response.length).toBeGreaterThan(0);
|
||||||
expect(response[0].ticketFk).toEqual(1);
|
expect(response[0].ticketFk).toEqual(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1072,6 +1072,11 @@ INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`)
|
||||||
(1, 1106, 5),
|
(1, 1106, 5),
|
||||||
(2, 1106, 14);
|
(2, 1106, 14);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`ticketCollection`(`id`, `ticketFk`, `collectionFk`)
|
||||||
|
VALUES
|
||||||
|
(2, 2, 1),
|
||||||
|
(3, 3, 2);
|
||||||
|
|
||||||
INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`)
|
INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`)
|
||||||
VALUES
|
VALUES
|
||||||
('100', '01', 1, '100-01', 1);
|
('100', '01', 1, '100-01', 1);
|
||||||
|
|
|
@ -107,7 +107,12 @@ module.exports = Self => {
|
||||||
arg: 'alertLevel',
|
arg: 'alertLevel',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: `The alert level of the tickets`
|
description: `The alert level of the tickets`
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
arg: 'collectionFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The collection id filter`
|
||||||
|
},
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: ['object'],
|
||||||
|
@ -269,6 +274,15 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.collectionFk) {
|
||||||
|
stmt.merge({
|
||||||
|
sql: `
|
||||||
|
JOIN collection cll ON cll.id = ?
|
||||||
|
JOIN ticketCollection tc ON tc.collectionFk = cll.id AND tc.ticketFk = t.id`,
|
||||||
|
params: [args.collectionFk]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
|
|
@ -202,4 +202,23 @@ describe('ticket filter()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return the tickets belonging to the collection id 1', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 18}}, args: {collectionFk: 1}};
|
||||||
|
const filter = {};
|
||||||
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(2);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -110,6 +110,11 @@
|
||||||
ng-model="filter.provinceFk"
|
ng-model="filter.provinceFk"
|
||||||
url="Provinces">
|
url="Provinces">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Collection"
|
||||||
|
ng-model="filter.collectionFk">
|
||||||
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="vn-px-lg">
|
<vn-horizontal class="vn-px-lg">
|
||||||
<vn-check
|
<vn-check
|
||||||
|
|
|
@ -19,3 +19,4 @@ ON_PREPARATION: En preparacion
|
||||||
PACKED: Encajado
|
PACKED: Encajado
|
||||||
Cannot choose a range of dates and days onward at the same time: No se puede selecionar un rango de fechas y días en adelante a la vez
|
Cannot choose a range of dates and days onward at the same time: No se puede selecionar un rango de fechas y días en adelante a la vez
|
||||||
Or: O
|
Or: O
|
||||||
|
Collection: Colección
|
Loading…
Reference in New Issue