Merge pull request 'feat(Searchbar): You can now filter by a ticket collection' (#722) from 3068-ticket_colletion into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #722
Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2021-09-02 13:20:29 +00:00
commit 86553b5472
6 changed files with 47 additions and 3 deletions

View File

@ -6,6 +6,6 @@ describe('newCollection()', () => {
let response = await app.models.Collection.newCollection(ctx, 1, 1, 1);
expect(response.length).toBeGreaterThan(0);
expect(response[0].ticketFk).toEqual(1);
expect(response[0].ticketFk).toEqual(2);
});
});

View File

@ -1072,6 +1072,11 @@ INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`)
(1, 1106, 5),
(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`)
VALUES
('100', '01', 1, '100-01', 1);

View File

@ -107,7 +107,12 @@ module.exports = Self => {
arg: 'alertLevel',
type: 'number',
description: `The alert level of the tickets`
}
},
{
arg: 'collectionFk',
type: 'number',
description: `The collection id filter`
},
],
returns: {
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));
stmts.push(stmt);

View File

@ -202,4 +202,23 @@ describe('ticket filter()', () => {
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;
}
});
});

View File

@ -110,6 +110,11 @@
ng-model="filter.provinceFk"
url="Provinces">
</vn-autocomplete>
<vn-textfield
vn-one
label="Collection"
ng-model="filter.collectionFk">
</vn-textfield>
</vn-horizontal>
<vn-horizontal class="vn-px-lg">
<vn-check

View File

@ -18,4 +18,5 @@ DELIVERED: Servido
ON_PREPARATION: En preparacion
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
Or: O
Or: O
Collection: Colección