fake production in table

This commit is contained in:
nelo 2017-06-21 12:11:38 +02:00
parent 8046c434fe
commit a7a4a211e2
10 changed files with 187 additions and 6 deletions

View File

@ -28,7 +28,7 @@ module.exports = function(self) {
}; };
self.defineScope = function(serverFilter) { self.defineScope = function(serverFilter) {
this.remoteMethod('list', { this.remoteMethodCtx('list', {
accepts: [ accepts: [
{ {
arg: 'filter', arg: 'filter',
@ -46,7 +46,7 @@ module.exports = function(self) {
} }
}); });
this.list = function(clientFilter, cb) { this.list = function(ctx, clientFilter, cb) {
var where = {"and": []}; var where = {"and": []};
(clientFilter) ? where.and.push(clientFilter.where) : undefined; (clientFilter) ? where.and.push(clientFilter.where) : undefined;
(serverFilter) ? where.and.push(serverFilter.where) : undefined; (serverFilter) ? where.and.push(serverFilter.where) : undefined;

View File

@ -0,0 +1,15 @@
module.exports = function(FakeProduction) {
FakeProduction.defineScope();
FakeProduction.list = function(ctx, filter, cb){
FakeProduction.connectToService(ctx, "client");
this.find(filter, function(err, tickets) {
(!err) ? cb(null, tickets) : cb(err, null);
});
FakeProduction.disconnectFromService("client");
}
}

View File

@ -0,0 +1,32 @@
{
"name": "Client",
"base": "MyModel",
"validateUpsert": true,
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string",
"required": true
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "root",
"permission": "ALLOW"
}
],
"validations": [],
"methods": {}
}

View File

@ -7,6 +7,9 @@
"type": "Number", "type": "Number",
"id": true, "id": true,
"description": "Identifier" "description": "Identifier"
},
"name":{
"type": "String"
} }
}, },
"acls": [] "acls": []

View File

@ -0,0 +1,8 @@
var app = require('../../server/server');
module.exports = function(FakeProduction) {
var models = app.models;
// Methods
require('../methods/fake-production/list.js')(FakeProduction);
};

View File

@ -0,0 +1,81 @@
{
"name": "FakeProduction",
"base": "MyModel",
"validateUpsert": true,
"properties": {
"id": {
"id": true,
"type": "Number",
"forceId": false
},
"hour":{
"type": "String"
},
"lines":{
"type": "Number"
},
"m3":{
"type": "Number"
},
"boxes":{
"type": "Number"
},
"city":{
"type": "String"
},
"problem":{
"type": "String"
}
},
"relations": {
"ticket": {
"type": "belongsTo",
"model": "Ticket",
"foreignKey": "ticketFk"
},
"state": {
"type": "belongsTo",
"model": "State",
"foreignKey": "stateFk"
},
"agency": {
"type": "belongsTo",
"model": "Agency",
"foreignKey": "agencyFk"
},
"province": {
"type": "belongsTo",
"model": "Province",
"foreignKey": "provinceFk"
},
"client": {
"type": "belongsTo",
"model": "Client",
"foreignKey": "clientFk"
},
"worker": {
"type": "belongsTo",
"model": "Employee",
"foreignKey": "workerFk"
},
"salePerson": {
"type": "belongsTo",
"model": "Employee",
"foreignKey": "salePersonFk"
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "root",
"permission": "ALLOW"
}
]
}

View File

@ -28,7 +28,7 @@ module.exports = function(self) {
}; };
self.defineScope = function(serverFilter) { self.defineScope = function(serverFilter) {
this.remoteMethod('list', { this.remoteMethodCtx('list', {
accepts: [ accepts: [
{ {
arg: 'filter', arg: 'filter',
@ -46,7 +46,7 @@ module.exports = function(self) {
} }
}); });
this.list = function(clientFilter, cb) { this.list = function(ctx, clientFilter, cb) {
var where = {"and": []}; var where = {"and": []};
(clientFilter) ? where.and.push(clientFilter.where) : undefined; (clientFilter) ? where.and.push(clientFilter.where) : undefined;
(serverFilter) ? where.and.push(serverFilter.where) : undefined; (serverFilter) ? where.and.push(serverFilter.where) : undefined;

View File

@ -0,0 +1,30 @@
{
"name": "Province",
"base": "MyModel",
"validateUpsert": true,
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string",
"required": true
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
}
]
}

View File

@ -61,8 +61,20 @@
"dataSource": "client", "dataSource": "client",
"public": true "public": true
}, },
"Client":{
"dataSource": "client",
"public": true
},
"Province":{
"dataSource": "client",
"public": true
},
"Agency": { "Agency": {
"dataSource": "vn", "dataSource": "vn",
"public": true "public": true
},
"FakeProduction": {
"dataSource": "vn",
"public": true
} }
} }

View File

@ -28,7 +28,7 @@ module.exports = function(self) {
}; };
self.defineScope = function(serverFilter) { self.defineScope = function(serverFilter) {
this.remoteMethod('list', { this.remoteMethodCtx('list', {
accepts: [ accepts: [
{ {
arg: 'filter', arg: 'filter',
@ -46,7 +46,7 @@ module.exports = function(self) {
} }
}); });
this.list = function(clientFilter, cb) { this.list = function(ctx, clientFilter, cb) {
var where = {"and": []}; var where = {"and": []};
(clientFilter) ? where.and.push(clientFilter.where) : undefined; (clientFilter) ? where.and.push(clientFilter.where) : undefined;
(serverFilter) ? where.and.push(serverFilter.where) : undefined; (serverFilter) ? where.and.push(serverFilter.where) : undefined;