Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2145_e2e_linux_fix
gitea/salix/pipeline/head This commit has test failures
Details
gitea/salix/pipeline/head This commit has test failures
Details
This commit is contained in:
commit
2fe632f888
|
@ -24,8 +24,14 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.sendCheckingPresence = async(ctx, workerId, message) => {
|
Self.sendCheckingPresence = async(ctx, workerId, message) => {
|
||||||
|
if (!workerId) return false;
|
||||||
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const account = await models.Account.findById(workerId);
|
const account = await models.Account.findById(workerId);
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
|
||||||
|
if (!account)
|
||||||
|
throw new Error(`Could not send message "${message}" to worker id ${workerId} from user ${userId}`);
|
||||||
|
|
||||||
const query = `SELECT worker_isWorking(?) isWorking`;
|
const query = `SELECT worker_isWorking(?) isWorking`;
|
||||||
const [result] = await Self.rawSql(query, [workerId]);
|
const [result] = await Self.rawSql(query, [workerId]);
|
||||||
|
@ -37,7 +43,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const department = workerDepartment && workerDepartment.department();
|
const department = workerDepartment && workerDepartment.department();
|
||||||
const channelName = department.chatName;
|
const channelName = department && department.chatName;
|
||||||
|
|
||||||
if (channelName)
|
if (channelName)
|
||||||
return Self.send(ctx, `#${channelName}`, `@${account.name} => ${message}`);
|
return Self.send(ctx, `#${channelName}`, `@${account.name} => ${message}`);
|
||||||
|
|
|
@ -24,14 +24,15 @@ export default class Controller extends Component {
|
||||||
const filter = encodeURIComponent(JSON.stringify(filterObj));
|
const filter = encodeURIComponent(JSON.stringify(filterObj));
|
||||||
const query = `Clients/findOne?filter=${filter}`;
|
const query = `Clients/findOne?filter=${filter}`;
|
||||||
this.$http.get(query).then(res => {
|
this.$http.get(query).then(res => {
|
||||||
if (res.data.id) {
|
const params = {clientId: res.data.id};
|
||||||
const params = {clientId: res.data.id};
|
const question = $t('Found a client with this phone or email', params, null, null, 'sanitizeParameters');
|
||||||
const question = $t('Found a client with this phone or email', params, null, null, 'sanitizeParameters');
|
|
||||||
|
|
||||||
this.client.despiteOfClient = params.clientId;
|
this.client.despiteOfClient = params.clientId;
|
||||||
this.$.confirmDuplicatedClient.question = question;
|
this.$.confirmDuplicatedClient.question = question;
|
||||||
this.$.confirmDuplicatedClient.show();
|
this.$.confirmDuplicatedClient.show();
|
||||||
}
|
}).catch(error => {
|
||||||
|
if (error.status == 404)
|
||||||
|
this.save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,10 @@ module.exports = Self => {
|
||||||
type: 'Number',
|
type: 'Number',
|
||||||
description: 'The totalEntries filter',
|
description: 'The totalEntries filter',
|
||||||
http: {source: 'query'}
|
http: {source: 'query'}
|
||||||
|
}, {
|
||||||
|
arg: 'ref',
|
||||||
|
type: 'string',
|
||||||
|
description: 'The reference'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
@ -80,9 +84,11 @@ module.exports = Self => {
|
||||||
let where = buildFilter(ctx.args, (param, value) => {
|
let where = buildFilter(ctx.args, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'search':
|
case 'search':
|
||||||
return {'t.id': value};
|
return /^\d+$/.test(value)
|
||||||
|
? {'t.id': value}
|
||||||
|
: {'t.ref': {like: `%${value}%`}};
|
||||||
case 'ref':
|
case 'ref':
|
||||||
return {[param]: {regexp: value}};
|
return {'t.ref': {like: `%${value}%`}};
|
||||||
case 'shippedFrom':
|
case 'shippedFrom':
|
||||||
return {'t.shipped': {gte: value}};
|
return {'t.shipped': {gte: value}};
|
||||||
case 'shippedTo':
|
case 'shippedTo':
|
||||||
|
|
|
@ -2,38 +2,53 @@ const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('Travel filter()', () => {
|
describe('Travel filter()', () => {
|
||||||
it('should return the travel matching "search"', async() => {
|
it('should return the travel matching "search"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
search: 1
|
search: 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Travel.filter(ctx);
|
const result = await app.models.Travel.filter(ctx);
|
||||||
|
const firstRow = result[0];
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
expect(result[0].id).toEqual(1);
|
expect(firstRow.id).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the travel matching "search" by ref', async() => {
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
search: 'third'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await app.models.Travel.filter(ctx);
|
||||||
|
const firstRow = result[0];
|
||||||
|
|
||||||
|
expect(result.length).toEqual(1);
|
||||||
|
expect(firstRow.id).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the travel matching "warehouse out"', async() => {
|
it('should return the travel matching "warehouse out"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
warehouseOutFk: 2
|
warehouseOutFk: 2
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Travel.filter(ctx);
|
const result = await app.models.Travel.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(8);
|
expect(result.length).toEqual(8);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the travel matching "total entries"', async() => {
|
it('should return the travel matching "total entries"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
totalEntries: 1,
|
totalEntries: 1,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Travel.filter(ctx);
|
const result = await app.models.Travel.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(5);
|
expect(result.length).toEqual(5);
|
||||||
});
|
});
|
||||||
|
@ -44,14 +59,14 @@ describe('Travel filter()', () => {
|
||||||
from.setHours(0, 0, 0, 0);
|
from.setHours(0, 0, 0, 0);
|
||||||
to.setHours(23, 59, 59, 999);
|
to.setHours(23, 59, 59, 999);
|
||||||
to.setDate(to.getDate() + 1);
|
to.setDate(to.getDate() + 1);
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
shippedFrom: from,
|
shippedFrom: from,
|
||||||
shippedTo: to
|
shippedTo: to
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Travel.filter(ctx);
|
const result = await app.models.Travel.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"name": {
|
"name": {
|
||||||
"type": "String"
|
"type": "String"
|
||||||
},
|
},
|
||||||
"rgb": {
|
"hexColour": {
|
||||||
"type": "String"
|
"type": "String"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "Number",
|
"type": "Number"
|
||||||
"id": true
|
|
||||||
},
|
},
|
||||||
"dmsFk": {
|
"dmsFk": {
|
||||||
|
"id": true,
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
"required": true,
|
"required": true,
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
|
Loading…
Reference in New Issue