refs #6641 add button my team #2254

Merged
jcasado merged 7 commits from 6641-checkboxMyTeam into dev 2024-04-15 08:11:37 +00:00
3 changed files with 17 additions and 17 deletions
Showing only changes of commit 7d925bac87 - Show all commits

View File

@ -3747,6 +3747,6 @@ INSERT INTO `vn`.`supplierDms`(`supplierFk`, `dmsFk`, `editorFk`)
VALUES VALUES
(1, 10, 9); (1, 10, 9);
INSERT INTO vn.workerTeam INSERT INTO vn.workerTeam(id, team, workerFk)
(id, team, workerFk) VALUES
VALUES(8, 1, 19); (8, 1, 19);

View File

@ -4,15 +4,10 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters; const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('filter', { Self.remoteMethodCtx('filter', {
description: 'Find all instances of the model matched by filter from the data source.', description: 'Find all instances of the model matched by filter from the data source.',
accessType: 'READ', accessType: 'READ',
accepts: [ accepts: [
{
arg: 'ctx',
type: 'object',
http: {source: 'context'}
},
{ {
arg: 'filter', arg: 'filter',
type: 'object', type: 'object',

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('claim filter()', () => { fdescribe('claim filter()', () => {
let ctx; let ctx;
beforeEach(() => { beforeEach(() => {
ctx = { ctx = {
@ -18,7 +18,8 @@ describe('claim filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const result = await app.models.Claim.filter({...ctx, args: {filter: {}, search: 1}}, null, options); ctx.args = {search: 1};
const result = await app.models.Claim.filter(ctx, null, options);
expect(result.length).toEqual(1); expect(result.length).toEqual(1);
expect(result[0].id).toEqual(1); expect(result[0].id).toEqual(1);
@ -36,7 +37,8 @@ describe('claim filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const result = await app.models.Claim.filter({...ctx, args: {filter: {}, search: 'Tony Stark'}}, null, options); ctx.args = {search: 'Tony Stark'};
const result = await app.models.Claim.filter(ctx, null, options);
expect(result.length).toEqual(1); expect(result.length).toEqual(1);
expect(result[0].id).toEqual(4); expect(result[0].id).toEqual(4);
@ -54,7 +56,8 @@ describe('claim filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const result = await app.models.Claim.filter({...ctx, args: {filter: {}, workerFk: 18}}, null, options); ctx.args = {workerFk: 18};
const result = await app.models.Claim.filter(ctx, null, options);
expect(result.length).toEqual(4); expect(result.length).toEqual(4);
expect(result[0].id).toEqual(1); expect(result[0].id).toEqual(1);
@ -75,7 +78,8 @@ describe('claim filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const result = await app.models.Claim.filter({...ctx, args: {filter: {}, itemFk: 2}}, null, options); ctx.args = {itemFk: 2};
const result = await app.models.Claim.filter(ctx, null, options);
expect(result.length).toEqual(3); expect(result.length).toEqual(3);
expect(result[0].id).toEqual(1); expect(result[0].id).toEqual(1);
@ -95,7 +99,8 @@ describe('claim filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const result = await app.models.Claim.filter({...ctx, args: {filter: {}, claimResponsibleFk: 7}}, null, options); ctx.args = {claimResponsibleFk: 7};
const result = await app.models.Claim.filter(ctx, null, options);
expect(result.length).toEqual(3); expect(result.length).toEqual(3);
expect(result[0].id).toEqual(2); expect(result[0].id).toEqual(2);
@ -115,8 +120,8 @@ describe('claim filter()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const filter = {}; ctx.args = {itemFk: null, myTeam: true};
const result = await models.Claim.filter({...ctx, args: {filter: {}, itemFk: null, myTeam: true}}, filter, options); const result = await app.models.Claim.filter(ctx, null, options);
expect(result.length).toEqual(2); expect(result.length).toEqual(2);