Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
17c38c9b4b
|
@ -1,3 +1,6 @@
|
|||
let loopBackContext = require('loopback-context');
|
||||
let app = require('../../server/server');
|
||||
|
||||
module.exports = function(self) {
|
||||
|
||||
self.setup = function() {
|
||||
|
@ -28,14 +31,12 @@ module.exports = function(self) {
|
|||
};
|
||||
|
||||
self.getUser = function() {
|
||||
let loopBackContext = require('loopback-context');
|
||||
let currentUser = loopBackContext.getCurrentContext();
|
||||
let userId = currentUser.get('currentUser');
|
||||
return userId;
|
||||
};
|
||||
|
||||
self.getEmployee = function() {
|
||||
let app = require('../../server/server');
|
||||
let userId = self.getUser();
|
||||
let employee = app.models.Employee;
|
||||
return employee.findOne({where: {userFk: userId}});
|
||||
|
|
|
@ -28,12 +28,11 @@ module.exports = function(TicketState) {
|
|||
});
|
||||
|
||||
TicketState.changeState = function(tickets, state, cb) {
|
||||
TicketState.getEmployee().then(function(emp){
|
||||
icketState.getEmployee().then(function(emp){
|
||||
changeState(emp, tickets, state, cb);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var changeState = function(emp, tickets, state, cb){
|
||||
var inserts = [];
|
||||
|
||||
|
@ -47,4 +46,5 @@ module.exports = function(TicketState) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
module.exports = function(Warehouse) {
|
||||
Warehouse.remoteMethod('list', {
|
||||
description: 'List production warehouses',
|
||||
returns: {
|
||||
arg: 'warehouses',
|
||||
type: 'object'
|
||||
},
|
||||
http: {
|
||||
verb: 'get',
|
||||
path: '/list'
|
||||
}
|
||||
});
|
||||
|
||||
Warehouse.list = function(cb) {
|
||||
Warehouse.find(where(), function(err, warehouses){
|
||||
if(!err)
|
||||
cb(null, warehouses);
|
||||
});
|
||||
};
|
||||
|
||||
var where = function(){
|
||||
return {"where": {"tpv": {"neq": 0}}}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
let loopBackContext = require('loopback-context');
|
||||
let app = require('../../server/server');
|
||||
|
||||
module.exports = function(self) {
|
||||
|
||||
self.setup = function() {
|
||||
|
@ -28,14 +31,12 @@ module.exports = function(self) {
|
|||
};
|
||||
|
||||
self.getUser = function() {
|
||||
let loopBackContext = require('loopback-context');
|
||||
let currentUser = loopBackContext.getCurrentContext();
|
||||
let userId = currentUser.get('currentUser');
|
||||
return userId;
|
||||
};
|
||||
|
||||
self.getEmployee = function() {
|
||||
let app = require('../../server/server');
|
||||
let userId = self.getUser();
|
||||
let employee = app.models.Employee;
|
||||
return employee.findOne({where: {userFk: userId}});
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
var app = require('../../server/server');
|
||||
|
||||
module.exports = function(Warehouse) {
|
||||
var models = app.models;
|
||||
|
||||
// Methods
|
||||
|
||||
require('../methods/warehouse/list-warehouses.js')(Warehouse);
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "Warehouse",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "Number",
|
||||
"forceId": false
|
||||
},
|
||||
"name": {
|
||||
"type": "String"
|
||||
},
|
||||
"tpv": {
|
||||
"type": "Number"
|
||||
},
|
||||
"inventary": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "*",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "DENY"
|
||||
},
|
||||
{
|
||||
"accessType": "*",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "root",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -52,5 +52,9 @@
|
|||
"TicketState":{
|
||||
"dataSource": "vn",
|
||||
"public": true
|
||||
},
|
||||
"Warehouse":{
|
||||
"dataSource": "vn",
|
||||
"public": true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue